wsp-ms-core 1.0.75 → 1.0.77
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 +330 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +55 -1
- package/dist/index.d.ts +55 -1
- package/dist/index.js +329 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -32,6 +32,7 @@ __export(src_exports, {
|
|
|
32
32
|
BaseObject: () => BaseObject,
|
|
33
33
|
BasicUnitOfWork: () => BasicUnitOfWork,
|
|
34
34
|
BasicUnitOfWorkFactory: () => BasicUnitOfWorkFactory,
|
|
35
|
+
Country: () => Country,
|
|
35
36
|
Currency: () => Currency,
|
|
36
37
|
DateTime: () => DateTime,
|
|
37
38
|
DomainEntity: () => DomainEntity,
|
|
@@ -168,6 +169,13 @@ var _DateTime = class _DateTime extends ValueObject {
|
|
|
168
169
|
getWeekdayName(locale = "en") {
|
|
169
170
|
return this._dt.setLocale(locale).toFormat("cccc");
|
|
170
171
|
}
|
|
172
|
+
format(format) {
|
|
173
|
+
if (!_DateTime.FORMATS.hasOwnProperty(format)) {
|
|
174
|
+
throw new Error(`Invalid format: ${format}`);
|
|
175
|
+
}
|
|
176
|
+
const formatString = _DateTime.FORMATS[format];
|
|
177
|
+
return this._dt.toFormat(formatString);
|
|
178
|
+
}
|
|
171
179
|
toPrimitives() {
|
|
172
180
|
return {
|
|
173
181
|
value: this.value
|
|
@@ -193,6 +201,35 @@ var _DateTime = class _DateTime extends ValueObject {
|
|
|
193
201
|
}
|
|
194
202
|
};
|
|
195
203
|
_DateTime.DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
|
204
|
+
_DateTime.FORMAT = "Y-M-D H:M:S";
|
|
205
|
+
_DateTime.FORMAT_Y_M = "Y-M";
|
|
206
|
+
_DateTime.FORMAT_Y_M_D = "Y-M-D";
|
|
207
|
+
_DateTime.FORMAT_Y_M_D_H_m_s = "Y-M-D H:M:S";
|
|
208
|
+
_DateTime.FORMAT_D_M_Y = "D-M-Y";
|
|
209
|
+
_DateTime.FORMATS = {
|
|
210
|
+
"Y-M": "yyyy-MM",
|
|
211
|
+
"Y-M-D": "yyyy-MM-dd",
|
|
212
|
+
"D/M/Y": "dd/MM/yyyy",
|
|
213
|
+
"Y/M/D": "yyyy/MM/dd",
|
|
214
|
+
"D-M-Y": "dd-MM-yyyy",
|
|
215
|
+
"Y.M.D": "yyyy.MM.dd",
|
|
216
|
+
"D.M.Y": "dd.MM.yyyy",
|
|
217
|
+
"Y-M-D H:M": "yyyy-MM-dd HH:mm",
|
|
218
|
+
"D/M/Y H:M": "dd/MM/yyyy HH:mm",
|
|
219
|
+
"Y/M/D H:M": "yyyy/MM/dd HH:mm",
|
|
220
|
+
"D-M-Y H:M": "dd-MM-yyyy HH:mm",
|
|
221
|
+
"Y.M.D H:M": "yyyy.MM.dd HH:mm",
|
|
222
|
+
"D.M.Y H:M": "dd.MM.yyyy HH:mm",
|
|
223
|
+
"Y-M-D H:M:S": "yyyy-MM-dd HH:mm:ss",
|
|
224
|
+
"Y-M-D H:M:S:SSS": "yyyy-MM-dd HH:mm:ss.SSS",
|
|
225
|
+
"D/M/Y H:M:S": "dd/MM/yyyy HH:mm:ss",
|
|
226
|
+
"Y/M/D H:M:S": "yyyy/MM/dd HH:mm:ss",
|
|
227
|
+
"D-M-Y H:M:S": "dd-MM-yyyy HH:mm:ss",
|
|
228
|
+
"Y.M.D H:M:S": "yyyy.MM.dd HH:mm:ss",
|
|
229
|
+
"D.M.Y H:M:S": "dd.MM.yyyy HH:mm:ss",
|
|
230
|
+
"H:M": "HH:mm",
|
|
231
|
+
"H:M:S": "HH:mm:ss"
|
|
232
|
+
};
|
|
196
233
|
var DateTime = _DateTime;
|
|
197
234
|
|
|
198
235
|
// src/domain/contracts/DomainEntity.ts
|
|
@@ -321,7 +358,7 @@ var DomainEvent = class _DomainEvent {
|
|
|
321
358
|
this._topic = topic;
|
|
322
359
|
this._payload = payload;
|
|
323
360
|
this._status = status;
|
|
324
|
-
this._attempts =
|
|
361
|
+
this._attempts = attempts;
|
|
325
362
|
this._errorMessage = errorMessage;
|
|
326
363
|
this._publishedAt = publishedAt;
|
|
327
364
|
this._lastAttempt = lastAttempt;
|
|
@@ -503,6 +540,297 @@ _Currency.ARS = new _Currency("ARS");
|
|
|
503
540
|
_Currency.BRL = new _Currency("BRL");
|
|
504
541
|
var Currency = _Currency;
|
|
505
542
|
|
|
543
|
+
// src/utils/StringVars.ts
|
|
544
|
+
var StringVars = class {
|
|
545
|
+
static parse(str, ob) {
|
|
546
|
+
const regex = /{{(.*?)}}/g;
|
|
547
|
+
return str.replace(regex, (match, variable) => {
|
|
548
|
+
if (ob.hasOwnProperty(variable.trim())) {
|
|
549
|
+
return ob[variable.trim()];
|
|
550
|
+
} else {
|
|
551
|
+
return match;
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
// src/infrastructure/errors/ErrorManager.ts
|
|
558
|
+
var _ErrorManager = class _ErrorManager {
|
|
559
|
+
constructor(logger = null) {
|
|
560
|
+
this.logger = logger;
|
|
561
|
+
}
|
|
562
|
+
getDefaultMessage(lang) {
|
|
563
|
+
return _ErrorManager.DEFAULT_MESSAGES[lang.value] || _ErrorManager.DEFAULT_MESSAGES[lang.base()] || "error";
|
|
564
|
+
}
|
|
565
|
+
onFatal(err, lang) {
|
|
566
|
+
this.logger?.fatal(err.type, err.message);
|
|
567
|
+
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
568
|
+
}
|
|
569
|
+
onInternal(err, lang) {
|
|
570
|
+
this.logger?.error(err.type, err.message);
|
|
571
|
+
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
572
|
+
}
|
|
573
|
+
onUsage(err, lang) {
|
|
574
|
+
const tmpl = _ErrorManager.TEMPLATES.get(err.type);
|
|
575
|
+
if (!tmpl) {
|
|
576
|
+
this.logger?.error("TEMPLATE_NOT_FOUND", `${err.type}`);
|
|
577
|
+
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
578
|
+
}
|
|
579
|
+
const code = lang.value;
|
|
580
|
+
const base = lang.base();
|
|
581
|
+
const rawMsg = tmpl.languages[code] ?? tmpl.languages[base] ?? this.getDefaultMessage(lang);
|
|
582
|
+
return {
|
|
583
|
+
status: 400,
|
|
584
|
+
message: StringVars.parse(rawMsg, err.vars)
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
onUnknown(err, lang) {
|
|
588
|
+
this.logger?.error("UNKNOWN_ERROR", err.message);
|
|
589
|
+
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
590
|
+
}
|
|
591
|
+
handle(err, lang) {
|
|
592
|
+
if (["local", "dev"].includes(process.env.ENVIRONMENT ?? "")) {
|
|
593
|
+
console.log(err);
|
|
594
|
+
}
|
|
595
|
+
if (err instanceof FatalError) {
|
|
596
|
+
return this.onFatal(err, lang);
|
|
597
|
+
}
|
|
598
|
+
if (err instanceof InternalError) {
|
|
599
|
+
return this.onInternal(err, lang);
|
|
600
|
+
}
|
|
601
|
+
if (err instanceof UsageError) {
|
|
602
|
+
return this.onUsage(err, lang);
|
|
603
|
+
}
|
|
604
|
+
return this.onUnknown(err, lang);
|
|
605
|
+
}
|
|
606
|
+
static addTemplate(template) {
|
|
607
|
+
_ErrorManager.TEMPLATES.set(template.type, template);
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
_ErrorManager.DEFAULT_MESSAGES = {
|
|
611
|
+
"es": "Ups, hemos encontrado un error. Nuestro equipo ya est\xE1 trabajando para solucionarlo",
|
|
612
|
+
"en": "Ups, we found an error. Our team is working on it.",
|
|
613
|
+
"pt": "Ops, encontramos um bug. Nossa equipe j\xE1 est\xE1 trabalhando para resolver isso."
|
|
614
|
+
};
|
|
615
|
+
_ErrorManager.APP_ERRORS = {
|
|
616
|
+
UNDEFINED: "UNDEFINED_ERROR",
|
|
617
|
+
PROCESS: "PROCESS_ERROR",
|
|
618
|
+
DATABASE: "DATABASE_ERROR"
|
|
619
|
+
};
|
|
620
|
+
_ErrorManager.TEMPLATES = /* @__PURE__ */ new Map();
|
|
621
|
+
var ErrorManager = _ErrorManager;
|
|
622
|
+
|
|
623
|
+
// src/domain/value-objects/Country.ts
|
|
624
|
+
ErrorManager.addTemplate({
|
|
625
|
+
type: "INVALID_COUNTRY",
|
|
626
|
+
languages: {
|
|
627
|
+
"es": "El pa\xEDs <{{country}}> no es v\xE1lido o no est\xE1 soportado",
|
|
628
|
+
"en": "Country <{{country}}> is not valid or not supported"
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
ErrorManager.addTemplate({
|
|
632
|
+
type: "COUNTRY_NOT_FOUND_BY_ALPHA2",
|
|
633
|
+
languages: {
|
|
634
|
+
"es": "No se encontr\xF3 pa\xEDs con c\xF3digo alpha2 <{{alpha2}}>",
|
|
635
|
+
"en": "Country not found with alpha2 code <{{alpha2}}>"
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
ErrorManager.addTemplate({
|
|
639
|
+
type: "COUNTRY_NOT_FOUND_BY_UUID",
|
|
640
|
+
languages: {
|
|
641
|
+
"es": "No se encontr\xF3 pa\xEDs con UUID <{{uuid}}>",
|
|
642
|
+
"en": "Country not found with UUID <{{uuid}}>"
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
var _Country = class _Country extends ValueObject {
|
|
646
|
+
constructor(country) {
|
|
647
|
+
const normalizedCountry = country.toUpperCase().trim();
|
|
648
|
+
super(normalizedCountry);
|
|
649
|
+
this._name = normalizedCountry;
|
|
650
|
+
this._alpha2 = _Country.COUNTRIES[normalizedCountry].alpha2;
|
|
651
|
+
this._alpha3 = _Country.COUNTRIES[normalizedCountry].alpha3;
|
|
652
|
+
this._numeric = _Country.COUNTRIES[normalizedCountry].numeric;
|
|
653
|
+
this._uuid = _Country.COUNTRIES[normalizedCountry].uuid;
|
|
654
|
+
this._phoneCode = _Country.COUNTRIES[normalizedCountry].phoneCode;
|
|
655
|
+
this._url = _Country.COUNTRIES[normalizedCountry].url;
|
|
656
|
+
}
|
|
657
|
+
validate(country) {
|
|
658
|
+
if (!_Country.NAMES.includes(country)) {
|
|
659
|
+
throw new UsageError("INVALID_COUNTRY", { country });
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
name() {
|
|
663
|
+
return this._name;
|
|
664
|
+
}
|
|
665
|
+
alpha2() {
|
|
666
|
+
return this._alpha2;
|
|
667
|
+
}
|
|
668
|
+
alpha3() {
|
|
669
|
+
return this._alpha3;
|
|
670
|
+
}
|
|
671
|
+
numeric() {
|
|
672
|
+
return this._numeric;
|
|
673
|
+
}
|
|
674
|
+
uuid() {
|
|
675
|
+
return this._uuid;
|
|
676
|
+
}
|
|
677
|
+
phoneCode() {
|
|
678
|
+
return this._phoneCode;
|
|
679
|
+
}
|
|
680
|
+
url() {
|
|
681
|
+
return this._url;
|
|
682
|
+
}
|
|
683
|
+
static findCountryByAlpha2(alpha2) {
|
|
684
|
+
for (const [country, codes] of Object.entries(_Country.COUNTRIES)) {
|
|
685
|
+
if (codes.alpha2 === alpha2.toUpperCase()) {
|
|
686
|
+
return new _Country(country);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
throw new UsageError("COUNTRY_NOT_FOUND_BY_ALPHA2", { alpha2 });
|
|
690
|
+
}
|
|
691
|
+
static findCountryByUUID(uuid) {
|
|
692
|
+
for (const [country, codes] of Object.entries(_Country.COUNTRIES)) {
|
|
693
|
+
if (codes.uuid === uuid) {
|
|
694
|
+
return new _Country(country);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
throw new UsageError("COUNTRY_NOT_FOUND_BY_UUID", { uuid });
|
|
698
|
+
}
|
|
699
|
+
static create(country) {
|
|
700
|
+
return new _Country(country);
|
|
701
|
+
}
|
|
702
|
+
static createOrDefault(country) {
|
|
703
|
+
try {
|
|
704
|
+
return new _Country(country);
|
|
705
|
+
} catch (error) {
|
|
706
|
+
return _Country.DEFAULT;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
toPrimitives() {
|
|
710
|
+
return {
|
|
711
|
+
value: this.value,
|
|
712
|
+
name: this._name,
|
|
713
|
+
alpha2: this._alpha2,
|
|
714
|
+
alpha3: this._alpha3,
|
|
715
|
+
numeric: this._numeric,
|
|
716
|
+
uuid: this._uuid,
|
|
717
|
+
phoneCode: this._phoneCode,
|
|
718
|
+
url: this._url
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
static isValid(country) {
|
|
722
|
+
try {
|
|
723
|
+
_Country.create(country);
|
|
724
|
+
return true;
|
|
725
|
+
} catch {
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
_Country.COUNTRIES = {
|
|
731
|
+
URUGUAY: {
|
|
732
|
+
alpha2: "UY",
|
|
733
|
+
alpha3: "URY",
|
|
734
|
+
numeric: "858",
|
|
735
|
+
phoneCode: "+598",
|
|
736
|
+
uuid: "5739ecc0-d12b-4db5-8897-e03a04a95c72",
|
|
737
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/uruguay.png"
|
|
738
|
+
},
|
|
739
|
+
ARGENTINA: {
|
|
740
|
+
alpha2: "AR",
|
|
741
|
+
alpha3: "ARG",
|
|
742
|
+
numeric: "032",
|
|
743
|
+
phoneCode: "+54",
|
|
744
|
+
uuid: "66663efe-ab7a-4166-b971-9f36fd0ea6b2",
|
|
745
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/argentina.png"
|
|
746
|
+
},
|
|
747
|
+
ECUADOR: {
|
|
748
|
+
alpha2: "EC",
|
|
749
|
+
alpha3: "ECU",
|
|
750
|
+
numeric: "218",
|
|
751
|
+
phoneCode: "+593",
|
|
752
|
+
uuid: "ee109239-0150-4e5f-9ff2-a85f270092b1",
|
|
753
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/ecuador.png"
|
|
754
|
+
},
|
|
755
|
+
PERU: {
|
|
756
|
+
alpha2: "PE",
|
|
757
|
+
alpha3: "PER",
|
|
758
|
+
numeric: "604",
|
|
759
|
+
phoneCode: "+51",
|
|
760
|
+
uuid: "e4d61ef5-b92d-4f9c-8ec1-23f4beb50abd",
|
|
761
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/peru.png"
|
|
762
|
+
},
|
|
763
|
+
BRASIL: {
|
|
764
|
+
alpha2: "BR",
|
|
765
|
+
alpha3: "BRA",
|
|
766
|
+
numeric: "076",
|
|
767
|
+
phoneCode: "+55",
|
|
768
|
+
uuid: "b7b91d72-deaf-4641-957c-a65003e33104",
|
|
769
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/brasil.png"
|
|
770
|
+
},
|
|
771
|
+
CHILE: {
|
|
772
|
+
alpha2: "CL",
|
|
773
|
+
alpha3: "CHL",
|
|
774
|
+
numeric: "152",
|
|
775
|
+
phoneCode: "+56",
|
|
776
|
+
uuid: "f69b35f4-d734-4c76-866c-29a18bf000fb",
|
|
777
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/chile.png"
|
|
778
|
+
},
|
|
779
|
+
VENEZUELA: {
|
|
780
|
+
alpha2: "VE",
|
|
781
|
+
alpha3: "VEN",
|
|
782
|
+
numeric: "862",
|
|
783
|
+
phoneCode: "+58",
|
|
784
|
+
uuid: "31b6c591-63f6-43db-8ea9-829bb03746c5",
|
|
785
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/venezuela.png"
|
|
786
|
+
},
|
|
787
|
+
COLOMBIA: {
|
|
788
|
+
alpha2: "CO",
|
|
789
|
+
alpha3: "COL",
|
|
790
|
+
numeric: "170",
|
|
791
|
+
phoneCode: "+57",
|
|
792
|
+
uuid: "6fdfe34b-6726-4604-96af-665ea5fc9239",
|
|
793
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/colombia.png"
|
|
794
|
+
},
|
|
795
|
+
BOLIVIA: {
|
|
796
|
+
alpha2: "BO",
|
|
797
|
+
alpha3: "BOL",
|
|
798
|
+
numeric: "068",
|
|
799
|
+
phoneCode: "+591",
|
|
800
|
+
uuid: "948886db-c280-4ba7-a777-a76c180b295b",
|
|
801
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/bolivia.png"
|
|
802
|
+
},
|
|
803
|
+
PARAGUAY: {
|
|
804
|
+
alpha2: "PY",
|
|
805
|
+
alpha3: "PRY",
|
|
806
|
+
numeric: "600",
|
|
807
|
+
phoneCode: "+595",
|
|
808
|
+
uuid: "d67b3472-e38d-4900-8ae3-02d99cd1d884",
|
|
809
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/paraguay.png"
|
|
810
|
+
},
|
|
811
|
+
USA: {
|
|
812
|
+
alpha2: "US",
|
|
813
|
+
alpha3: "USA",
|
|
814
|
+
numeric: "840",
|
|
815
|
+
phoneCode: "+1",
|
|
816
|
+
uuid: "16ac3b9b-8f7b-4c54-91d5-d62c7cd74ad4",
|
|
817
|
+
url: "https://dev-wonasports.s3.us-east-2.amazonaws.com/assets/usa.png"
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
_Country.NAMES = Object.keys(_Country.COUNTRIES);
|
|
821
|
+
_Country.DEFAULT = new _Country("URUGUAY");
|
|
822
|
+
_Country.ARGENTINA = new _Country("ARGENTINA");
|
|
823
|
+
_Country.ECUADOR = new _Country("ECUADOR");
|
|
824
|
+
_Country.PERU = new _Country("PERU");
|
|
825
|
+
_Country.BRASIL = new _Country("BRASIL");
|
|
826
|
+
_Country.CHILE = new _Country("CHILE");
|
|
827
|
+
_Country.VENEZUELA = new _Country("VENEZUELA");
|
|
828
|
+
_Country.COLOMBIA = new _Country("COLOMBIA");
|
|
829
|
+
_Country.BOLIVIA = new _Country("BOLIVIA");
|
|
830
|
+
_Country.PARAGUAY = new _Country("PARAGUAY");
|
|
831
|
+
_Country.USA = new _Country("USA");
|
|
832
|
+
var Country = _Country;
|
|
833
|
+
|
|
506
834
|
// src/domain/value-objects/Email.ts
|
|
507
835
|
var _Email = class _Email extends ValueObject {
|
|
508
836
|
constructor(email) {
|
|
@@ -626,86 +954,6 @@ _Language.SPANISH_NICARAGUA = new _Language("es-ni");
|
|
|
626
954
|
_Language.SPANISH_PUERTO_RICO = new _Language("es-pr");
|
|
627
955
|
var Language = _Language;
|
|
628
956
|
|
|
629
|
-
// src/utils/StringVars.ts
|
|
630
|
-
var StringVars = class {
|
|
631
|
-
static parse(str, ob) {
|
|
632
|
-
const regex = /{{(.*?)}}/g;
|
|
633
|
-
return str.replace(regex, (match, variable) => {
|
|
634
|
-
if (ob.hasOwnProperty(variable.trim())) {
|
|
635
|
-
return ob[variable.trim()];
|
|
636
|
-
} else {
|
|
637
|
-
return match;
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
}
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
// src/infrastructure/errors/ErrorManager.ts
|
|
644
|
-
var _ErrorManager = class _ErrorManager {
|
|
645
|
-
constructor(logger = null) {
|
|
646
|
-
this.logger = logger;
|
|
647
|
-
}
|
|
648
|
-
getDefaultMessage(lang) {
|
|
649
|
-
return _ErrorManager.DEFAULT_MESSAGES[lang.value] || _ErrorManager.DEFAULT_MESSAGES[lang.base()] || "error";
|
|
650
|
-
}
|
|
651
|
-
onFatal(err, lang) {
|
|
652
|
-
this.logger?.fatal(err.type, err.message);
|
|
653
|
-
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
654
|
-
}
|
|
655
|
-
onInternal(err, lang) {
|
|
656
|
-
this.logger?.error(err.type, err.message);
|
|
657
|
-
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
658
|
-
}
|
|
659
|
-
onUsage(err, lang) {
|
|
660
|
-
const tmpl = _ErrorManager.TEMPLATES.get(err.type);
|
|
661
|
-
if (!tmpl) {
|
|
662
|
-
this.logger?.error("TEMPLATE_NOT_FOUND", `${err.type}`);
|
|
663
|
-
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
664
|
-
}
|
|
665
|
-
const code = lang.value;
|
|
666
|
-
const base = lang.base();
|
|
667
|
-
const rawMsg = tmpl.languages[code] ?? tmpl.languages[base] ?? this.getDefaultMessage(lang);
|
|
668
|
-
return {
|
|
669
|
-
status: 400,
|
|
670
|
-
message: StringVars.parse(rawMsg, err.vars)
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
onUnknown(err, lang) {
|
|
674
|
-
this.logger?.error("UNKNOWN_ERROR", err.message);
|
|
675
|
-
return { status: "ERROR", message: this.getDefaultMessage(lang) };
|
|
676
|
-
}
|
|
677
|
-
handle(err, lang) {
|
|
678
|
-
if (["local", "dev"].includes(process.env.ENVIRONMENT ?? "")) {
|
|
679
|
-
console.log(err);
|
|
680
|
-
}
|
|
681
|
-
if (err instanceof FatalError) {
|
|
682
|
-
return this.onFatal(err, lang);
|
|
683
|
-
}
|
|
684
|
-
if (err instanceof InternalError) {
|
|
685
|
-
return this.onInternal(err, lang);
|
|
686
|
-
}
|
|
687
|
-
if (err instanceof UsageError) {
|
|
688
|
-
return this.onUsage(err, lang);
|
|
689
|
-
}
|
|
690
|
-
return this.onUnknown(err, lang);
|
|
691
|
-
}
|
|
692
|
-
static addTemplate(template) {
|
|
693
|
-
_ErrorManager.TEMPLATES.set(template.type, template);
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
_ErrorManager.DEFAULT_MESSAGES = {
|
|
697
|
-
"es": "Ups, hemos encontrado un error. Nuestro equipo ya est\xE1 trabajando para solucionarlo",
|
|
698
|
-
"en": "Ups, we found an error. Our team is working on it.",
|
|
699
|
-
"pt": "Ops, encontramos um bug. Nossa equipe j\xE1 est\xE1 trabalhando para resolver isso."
|
|
700
|
-
};
|
|
701
|
-
_ErrorManager.APP_ERRORS = {
|
|
702
|
-
UNDEFINED: "UNDEFINED_ERROR",
|
|
703
|
-
PROCESS: "PROCESS_ERROR",
|
|
704
|
-
DATABASE: "DATABASE_ERROR"
|
|
705
|
-
};
|
|
706
|
-
_ErrorManager.TEMPLATES = /* @__PURE__ */ new Map();
|
|
707
|
-
var ErrorManager = _ErrorManager;
|
|
708
|
-
|
|
709
957
|
// src/domain/value-objects/Price.ts
|
|
710
958
|
ErrorManager.addTemplate({
|
|
711
959
|
type: "INVALID_PRICE_AMOUNT",
|
|
@@ -1417,6 +1665,7 @@ var ExchangeRates = class _ExchangeRates extends BaseObject {
|
|
|
1417
1665
|
BaseObject,
|
|
1418
1666
|
BasicUnitOfWork,
|
|
1419
1667
|
BasicUnitOfWorkFactory,
|
|
1668
|
+
Country,
|
|
1420
1669
|
Currency,
|
|
1421
1670
|
DateTime,
|
|
1422
1671
|
DomainEntity,
|