@carbonbox/domain 0.28.2 → 0.29.1
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/build/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidContractStatusError.js +24 -7
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidPaymentTermsError.js +24 -7
- package/build/carbonbox/reporting/report-instances/domain/value-objects/ReportInstanceId.js +52 -0
- package/build/carbonbox/reporting/report-templates/domain/enums/ReportTemplateStatus.js +26 -0
- package/build/carbonbox/reporting/report-templates/domain/types/ReportTemplatePrimitives.js +2 -0
- package/build/carbonbox/reporting/report-templates/domain/types/ReportTemplateProps.js +2 -0
- package/build/carbonbox/reporting/report-templates/domain/value-objects/ReportTemplateId.js +52 -0
- package/build/carbonbox/reporting/shared/domain/enums/BlockNature.js +30 -0
- package/build/carbonbox/reporting/shared/domain/enums/DataBindingSource.js +91 -0
- package/build/carbonbox/reporting/shared/domain/enums/ReportStatus.js +42 -0
- package/build/carbonbox/reporting/shared/domain/enums/ReportType.js +30 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/EmptyReportSectionBlocksError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportInstanceIdError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionIdError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionOrderError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionTitleError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/exceptions/InvalidReportTemplateIdError.js +18 -0
- package/build/carbonbox/reporting/shared/domain/types/ReportBlockPrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/types/ReportSectionPrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/value-objects/ReportSection.js +67 -0
- package/build/carbonbox/reporting/text-banks/domain/value-objects/TextBankId.js +52 -0
- package/build/carbonbox/shared/domain/enums/ErrorCode.js +81 -0
- package/build/carbonbox/shared/domain/enums/SemanticUuidPrefix.js +6 -0
- package/build/carbonbox/shared/domain/exceptions/AccountLockedError.js +58 -0
- package/build/carbonbox/shared/domain/exceptions/CodedRootError.js +63 -0
- package/build/carbonbox/shared/domain/exceptions/ConfigurationNotFoundError.js +62 -0
- package/build/carbonbox/shared/domain/exceptions/ContractNotFoundError.js +58 -0
- package/build/carbonbox/shared/domain/exceptions/EmailNotVerifiedError.js +61 -0
- package/build/carbonbox/shared/domain/exceptions/InvalidBusinessStatusError.js +56 -0
- package/build/carbonbox/shared/domain/exceptions/InvalidCredentialsError.js +35 -0
- package/build/carbonbox/shared/domain/exceptions/InvalidCurrencyError.js +51 -6
- package/build/carbonbox/shared/domain/exceptions/InvalidDateFormatError.js +26 -6
- package/build/carbonbox/shared/domain/exceptions/InvalidEmailPolicyError.js +15 -7
- package/build/carbonbox/shared/domain/exceptions/MissingCredentialsError.js +53 -0
- package/build/carbonbox/shared/domain/exceptions/NullValueError.js +16 -7
- package/build/carbonbox/shared/domain/exceptions/OrderExceedsBudgetError.js +98 -0
- package/build/carbonbox/shared/domain/exceptions/ServiceCatalogNotFoundError.js +64 -0
- package/build/carbonbox/shared/domain/exceptions/StakeholderNotFoundError.js +49 -0
- package/build/carbonbox/shared/domain/exceptions/TokenExpiredError.js +48 -0
- package/build/carbonbox/shared/domain/interfaces/ICodedError.js +2 -0
- package/build/main/index.js +37 -7
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/repository/ICorporateCarbonFootprintConfigurationRepository.d.ts +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/repository/ICorporateCarbonFootprintConfigurationRepository.d.ts.map +1 -1
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidContractStatusError.d.ts +9 -3
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidContractStatusError.d.ts.map +1 -1
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidPaymentTermsError.d.ts +9 -3
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/exceptions/InvalidPaymentTermsError.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/report-instances/domain/value-objects/ReportInstanceId.d.ts +14 -0
- package/build/types/carbonbox/reporting/report-instances/domain/value-objects/ReportInstanceId.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/enums/ReportTemplateStatus.d.ts +23 -0
- package/build/types/carbonbox/reporting/report-templates/domain/enums/ReportTemplateStatus.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplatePrimitives.d.ts +21 -0
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplatePrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplateProps.d.ts +17 -0
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplateProps.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/value-objects/ReportTemplateId.d.ts +14 -0
- package/build/types/carbonbox/reporting/report-templates/domain/value-objects/ReportTemplateId.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/BlockNature.d.ts +27 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/BlockNature.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts +72 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/ReportStatus.d.ts +39 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/ReportStatus.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/ReportType.d.ts +27 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/ReportType.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/EmptyReportSectionBlocksError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/EmptyReportSectionBlocksError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportInstanceIdError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportInstanceIdError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionIdError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionIdError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionOrderError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionOrderError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionTitleError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportSectionTitleError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportTemplateIdError.d.ts +7 -0
- package/build/types/carbonbox/reporting/shared/domain/exceptions/InvalidReportTemplateIdError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportBlockPrimitives.d.ts +16 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportBlockPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportSectionPrimitives.d.ts +10 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportSectionPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/value-objects/ReportSection.d.ts +18 -0
- package/build/types/carbonbox/reporting/shared/domain/value-objects/ReportSection.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/value-objects/TextBankId.d.ts +14 -0
- package/build/types/carbonbox/reporting/text-banks/domain/value-objects/TextBankId.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts +71 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/SemanticUuidPrefix.d.ts +6 -1
- package/build/types/carbonbox/shared/domain/enums/SemanticUuidPrefix.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/AccountLockedError.d.ts +25 -0
- package/build/types/carbonbox/shared/domain/exceptions/AccountLockedError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/CodedRootError.d.ts +44 -0
- package/build/types/carbonbox/shared/domain/exceptions/CodedRootError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/ConfigurationNotFoundError.d.ts +29 -0
- package/build/types/carbonbox/shared/domain/exceptions/ConfigurationNotFoundError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/ContractNotFoundError.d.ts +25 -0
- package/build/types/carbonbox/shared/domain/exceptions/ContractNotFoundError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/EmailNotVerifiedError.d.ts +27 -0
- package/build/types/carbonbox/shared/domain/exceptions/EmailNotVerifiedError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidBusinessStatusError.d.ts +25 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidBusinessStatusError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidCredentialsError.d.ts +13 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidCredentialsError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidCurrencyError.d.ts +23 -3
- package/build/types/carbonbox/shared/domain/exceptions/InvalidCurrencyError.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/InvalidDateFormatError.d.ts +3 -3
- package/build/types/carbonbox/shared/domain/exceptions/InvalidDateFormatError.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/InvalidEmailPolicyError.d.ts +2 -3
- package/build/types/carbonbox/shared/domain/exceptions/InvalidEmailPolicyError.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/MissingCredentialsError.d.ts +25 -0
- package/build/types/carbonbox/shared/domain/exceptions/MissingCredentialsError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/NullValueError.d.ts +2 -3
- package/build/types/carbonbox/shared/domain/exceptions/NullValueError.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/OrderExceedsBudgetError.d.ts +42 -0
- package/build/types/carbonbox/shared/domain/exceptions/OrderExceedsBudgetError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/ServiceCatalogNotFoundError.d.ts +29 -0
- package/build/types/carbonbox/shared/domain/exceptions/ServiceCatalogNotFoundError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/StakeholderNotFoundError.d.ts +21 -0
- package/build/types/carbonbox/shared/domain/exceptions/StakeholderNotFoundError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/TokenExpiredError.d.ts +21 -0
- package/build/types/carbonbox/shared/domain/exceptions/TokenExpiredError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/interfaces/ICodedError.d.ts +38 -0
- package/build/types/carbonbox/shared/domain/interfaces/ICodedError.d.ts.map +1 -0
- package/build/types/main/index.d.ts +14 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextBankId = void 0;
|
|
4
|
+
const AggregateId_1 = require("../../../../shared/domain/value-objects/AggregateId");
|
|
5
|
+
const SemanticUuidPrefix_1 = require("../../../../shared/domain/enums/SemanticUuidPrefix");
|
|
6
|
+
const InvalidAggregatePrefixError_1 = require("../../../../shared/domain/exceptions/InvalidAggregatePrefixError");
|
|
7
|
+
class TextBankId extends AggregateId_1.AggregateId {
|
|
8
|
+
constructor(value, skipDomainValidation) {
|
|
9
|
+
super(value, skipDomainValidation, TextBankId.PROPERTY_NAME);
|
|
10
|
+
}
|
|
11
|
+
static create(value) {
|
|
12
|
+
AggregateId_1.AggregateId.guardAgainstEmptyValue(value, TextBankId.PROPERTY_NAME);
|
|
13
|
+
AggregateId_1.AggregateId.guardAgainstInvalidType(value, TextBankId.PROPERTY_NAME);
|
|
14
|
+
AggregateId_1.AggregateId.guardAgainstInvalidId(value, TextBankId.PROPERTY_NAME);
|
|
15
|
+
// Validate that the prefix is valid for TextBank
|
|
16
|
+
TextBankId.guardAgainstInvalidPrefix(value);
|
|
17
|
+
return new TextBankId(value, false);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validates that the UUID has a valid TextBank prefix
|
|
21
|
+
*/
|
|
22
|
+
static guardAgainstInvalidPrefix(value) {
|
|
23
|
+
try {
|
|
24
|
+
const tempInstance = new TextBankId(value, true);
|
|
25
|
+
const prefix = tempInstance.extractPrefix();
|
|
26
|
+
if (TextBankId.VALID_PREFIXES.includes(prefix) === false) {
|
|
27
|
+
throw InvalidAggregatePrefixError_1.InvalidAggregatePrefixError.create(value, 'TextBank', prefix, TextBankId.VALID_PREFIXES, TextBankId.PROPERTY_NAME);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof InvalidAggregatePrefixError_1.InvalidAggregatePrefixError) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
throw InvalidAggregatePrefixError_1.InvalidAggregatePrefixError.create(value, 'TextBank', 'UNKNOWN', TextBankId.VALID_PREFIXES, TextBankId.PROPERTY_NAME);
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static fromPrimitives(primitive) {
|
|
41
|
+
const value = primitive;
|
|
42
|
+
return new TextBankId(value, true);
|
|
43
|
+
}
|
|
44
|
+
toPrimitives() {
|
|
45
|
+
return this.value;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.TextBankId = TextBankId;
|
|
49
|
+
TextBankId.PROPERTY_NAME = 'id';
|
|
50
|
+
TextBankId.VALID_PREFIXES = [
|
|
51
|
+
SemanticUuidPrefix_1.SemanticUuidPrefix.RPT_TEXT_BANK,
|
|
52
|
+
];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Centralized error codes enum for the CarbonBox domain
|
|
6
|
+
* Format: CBX-[CONTEXT]-[NUMBER]
|
|
7
|
+
*
|
|
8
|
+
* Context Abbreviations:
|
|
9
|
+
* - AUTH: Authentication
|
|
10
|
+
* - PMS: Purchase Management System
|
|
11
|
+
* - STK: Stakeholders
|
|
12
|
+
* - CFC: Carbon Footprint Configurations
|
|
13
|
+
* - ADC: Activity Data Collection
|
|
14
|
+
* - EMC: Emission Calculations
|
|
15
|
+
* - SHR: Shared/Common
|
|
16
|
+
*
|
|
17
|
+
* @since 1.0.0
|
|
18
|
+
*/
|
|
19
|
+
var ErrorCode;
|
|
20
|
+
(function (ErrorCode) {
|
|
21
|
+
// Authentication Errors (CBX-AUTH-XXX)
|
|
22
|
+
ErrorCode["INVALID_CREDENTIALS"] = "CBX-AUTH-001";
|
|
23
|
+
ErrorCode["TOKEN_EXPIRED"] = "CBX-AUTH-002";
|
|
24
|
+
ErrorCode["TOKEN_INVALID"] = "CBX-AUTH-003";
|
|
25
|
+
ErrorCode["MISSING_CREDENTIALS"] = "CBX-AUTH-004";
|
|
26
|
+
ErrorCode["ACCOUNT_LOCKED"] = "CBX-AUTH-005";
|
|
27
|
+
ErrorCode["EMAIL_NOT_VERIFIED"] = "CBX-AUTH-006";
|
|
28
|
+
ErrorCode["PASSWORD_RESET_EXPIRED"] = "CBX-AUTH-007";
|
|
29
|
+
// Purchase Management System Errors (CBX-PMS-XXX)
|
|
30
|
+
ErrorCode["CONTRACT_NOT_FOUND"] = "CBX-PMS-001";
|
|
31
|
+
ErrorCode["INVALID_CONTRACT_STATUS"] = "CBX-PMS-002";
|
|
32
|
+
ErrorCode["INVALID_PAYMENT_TERMS"] = "CBX-PMS-003";
|
|
33
|
+
ErrorCode["ORDER_EXCEEDS_BUDGET"] = "CBX-PMS-004";
|
|
34
|
+
ErrorCode["DUPLICATE_ORDER"] = "CBX-PMS-005";
|
|
35
|
+
ErrorCode["INVALID_CURRENCY"] = "CBX-PMS-006";
|
|
36
|
+
ErrorCode["SERVICE_CATALOG_NOT_FOUND"] = "CBX-PMS-007";
|
|
37
|
+
// Stakeholder Errors (CBX-STK-XXX)
|
|
38
|
+
ErrorCode["STAKEHOLDER_EXISTS"] = "CBX-STK-001";
|
|
39
|
+
ErrorCode["INVALID_ROLE"] = "CBX-STK-002";
|
|
40
|
+
ErrorCode["STAKEHOLDER_NOT_FOUND"] = "CBX-STK-003";
|
|
41
|
+
ErrorCode["INSUFFICIENT_PERMISSIONS"] = "CBX-STK-004";
|
|
42
|
+
ErrorCode["INVALID_BUSINESS_STATUS"] = "CBX-STK-005";
|
|
43
|
+
ErrorCode["MANAGER_REQUIRED"] = "CBX-STK-006";
|
|
44
|
+
// Carbon Footprint Configuration Errors (CBX-CFC-XXX)
|
|
45
|
+
ErrorCode["CONFIGURATION_NOT_FOUND"] = "CBX-CFC-001";
|
|
46
|
+
ErrorCode["INVALID_REPORTING_STANDARD"] = "CBX-CFC-002";
|
|
47
|
+
ErrorCode["INVALID_COLLECTION_PERIOD"] = "CBX-CFC-003";
|
|
48
|
+
ErrorCode["CONFIGURATION_LOCKED"] = "CBX-CFC-004";
|
|
49
|
+
ErrorCode["DUPLICATE_CONFIGURATION"] = "CBX-CFC-005";
|
|
50
|
+
// Activity Data Collection Errors (CBX-ADC-XXX)
|
|
51
|
+
ErrorCode["FORM_NOT_FOUND"] = "CBX-ADC-001";
|
|
52
|
+
ErrorCode["INVALID_SUBMISSION"] = "CBX-ADC-002";
|
|
53
|
+
ErrorCode["SUBMISSION_LOCKED"] = "CBX-ADC-003";
|
|
54
|
+
ErrorCode["MISSING_REQUIRED_FIELDS"] = "CBX-ADC-004";
|
|
55
|
+
ErrorCode["INVALID_FIELD_TYPE"] = "CBX-ADC-005";
|
|
56
|
+
// Emission Calculation Errors (CBX-EMC-XXX)
|
|
57
|
+
ErrorCode["CALCULATION_FAILED"] = "CBX-EMC-001";
|
|
58
|
+
ErrorCode["MISSING_EMISSION_FACTOR"] = "CBX-EMC-002";
|
|
59
|
+
ErrorCode["INVALID_FORMULA"] = "CBX-EMC-003";
|
|
60
|
+
ErrorCode["JOB_NOT_FOUND"] = "CBX-EMC-004";
|
|
61
|
+
ErrorCode["JOB_ALREADY_RUNNING"] = "CBX-EMC-005";
|
|
62
|
+
// Shared/Common Errors (CBX-SHR-XXX)
|
|
63
|
+
ErrorCode["INVALID_EMAIL"] = "CBX-SHR-001";
|
|
64
|
+
ErrorCode["INVALID_DATE_FORMAT"] = "CBX-SHR-002";
|
|
65
|
+
ErrorCode["INVALID_COORDINATES"] = "CBX-SHR-003";
|
|
66
|
+
ErrorCode["INVALID_CURRENCY_CODE"] = "CBX-SHR-004";
|
|
67
|
+
ErrorCode["DATABASE_CONNECTION"] = "CBX-SHR-005";
|
|
68
|
+
ErrorCode["EXTERNAL_SERVICE"] = "CBX-SHR-006";
|
|
69
|
+
ErrorCode["INVALID_GENDER"] = "CBX-SHR-007";
|
|
70
|
+
ErrorCode["INVALID_PHONE_NUMBER"] = "CBX-SHR-008";
|
|
71
|
+
ErrorCode["INVALID_TAX_ID"] = "CBX-SHR-009";
|
|
72
|
+
ErrorCode["NULL_VALUE"] = "CBX-SHR-010";
|
|
73
|
+
ErrorCode["UNDEFINED_VALUE"] = "CBX-SHR-011";
|
|
74
|
+
ErrorCode["EMPTY_VALUE"] = "CBX-SHR-012";
|
|
75
|
+
ErrorCode["INVALID_PROPERTY_TYPE"] = "CBX-SHR-013";
|
|
76
|
+
ErrorCode["INVALID_PROPERTY_VALUE"] = "CBX-SHR-014";
|
|
77
|
+
ErrorCode["MINIMUM_VALUE_VIOLATION"] = "CBX-SHR-015";
|
|
78
|
+
ErrorCode["MAXIMUM_VALUE_VIOLATION"] = "CBX-SHR-016";
|
|
79
|
+
ErrorCode["INVALID_DATE_RANGE"] = "CBX-SHR-017";
|
|
80
|
+
ErrorCode["PASSWORD_POLICY_VIOLATION"] = "CBX-SHR-018";
|
|
81
|
+
})(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
|
|
@@ -77,6 +77,12 @@ var SemanticUuidPrefix;
|
|
|
77
77
|
// Shared Domain
|
|
78
78
|
SemanticUuidPrefix["SHR_DOMAIN"] = "SHR-DOM";
|
|
79
79
|
SemanticUuidPrefix["SHR_EITHER"] = "SHR-ETH";
|
|
80
|
+
// Reporting Module
|
|
81
|
+
SemanticUuidPrefix["RPT_TEMPLATE"] = "RPT-TPL";
|
|
82
|
+
SemanticUuidPrefix["RPT_INSTANCE"] = "RPT-INS";
|
|
83
|
+
SemanticUuidPrefix["RPT_TEXT_BANK"] = "RPT-TXB";
|
|
84
|
+
SemanticUuidPrefix["RPT_SECTION"] = "RPT-SEC";
|
|
85
|
+
SemanticUuidPrefix["RPT_BLOCK"] = "RPT-BLK";
|
|
80
86
|
// Future expansion examples (when system grows):
|
|
81
87
|
// ADC_SUB_FIELDS = 'ADC-SUB-FLD', // Activity Data Collection -> Submissions -> Fields
|
|
82
88
|
// USR_STH_CHO_MGT = 'USR-STH-CHO-MGT', // Users -> Stakeholders -> Carbon Host -> Management
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountLockedError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Exception thrown when a user account is locked
|
|
8
|
+
* This error occurs when too many failed login attempts or security violations
|
|
9
|
+
*
|
|
10
|
+
* Error code: CBX-AUTH-005
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
class AccountLockedError extends CodedRootError_1.CodedRootError {
|
|
14
|
+
constructor(email, reason, lockedUntil, attemptCount) {
|
|
15
|
+
const errorCode = ErrorCode_1.ErrorCode.ACCOUNT_LOCKED;
|
|
16
|
+
const lockedInfo = lockedUntil ? ` until ${lockedUntil.toISOString()}` : '';
|
|
17
|
+
const attemptInfo = attemptCount ? ` after ${attemptCount} failed attempts` : '';
|
|
18
|
+
const technicalMessage = `Account locked for ${email}: ${reason}${attemptInfo}${lockedInfo}`;
|
|
19
|
+
const context = {
|
|
20
|
+
email,
|
|
21
|
+
reason,
|
|
22
|
+
...(lockedUntil && { lockedUntil: lockedUntil.toISOString() }),
|
|
23
|
+
...(attemptCount !== undefined && { attemptCount }),
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
};
|
|
26
|
+
const suggestions = [
|
|
27
|
+
'Wait for the lockout period to expire',
|
|
28
|
+
'Contact support to unlock your account',
|
|
29
|
+
'Use the password reset option if available',
|
|
30
|
+
'Verify you are using the correct email address',
|
|
31
|
+
'Check with your administrator for account status',
|
|
32
|
+
];
|
|
33
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
34
|
+
this.name = 'AccountLockedError';
|
|
35
|
+
}
|
|
36
|
+
static create(email, reason, lockedUntil, attemptCount) {
|
|
37
|
+
return new AccountLockedError(email, reason, lockedUntil, attemptCount);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates an AccountLockedError for too many failed attempts
|
|
41
|
+
*/
|
|
42
|
+
static tooManyAttempts(email, attemptCount, lockedUntil) {
|
|
43
|
+
return new AccountLockedError(email, 'Too many failed login attempts', lockedUntil, attemptCount);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates an AccountLockedError for security violation
|
|
47
|
+
*/
|
|
48
|
+
static securityViolation(email, lockedUntil) {
|
|
49
|
+
return new AccountLockedError(email, 'Security violation detected', lockedUntil);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates an AccountLockedError for administrative lock
|
|
53
|
+
*/
|
|
54
|
+
static administrativeLock(email, reason) {
|
|
55
|
+
return new AccountLockedError(email, `Administrative lock: ${reason}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.AccountLockedError = AccountLockedError;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodedRootError = void 0;
|
|
4
|
+
const RootError_1 = require("./RootError");
|
|
5
|
+
/**
|
|
6
|
+
* Enhanced base class for all domain errors with error code support
|
|
7
|
+
* This extends the existing RootError to add error code functionality
|
|
8
|
+
* while maintaining backward compatibility
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
class CodedRootError extends RootError_1.RootError {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new CodedRootError instance
|
|
15
|
+
*
|
|
16
|
+
* @param errorCode - Unique error code (CBX-XXX-NNN)
|
|
17
|
+
* @param technicalMessage - Detailed technical message for debugging
|
|
18
|
+
* @param context - Optional context data safe to expose
|
|
19
|
+
* @param suggestions - Optional user action suggestions
|
|
20
|
+
*/
|
|
21
|
+
constructor(errorCode, technicalMessage, context, suggestions) {
|
|
22
|
+
// Call parent constructor with technical message
|
|
23
|
+
super(technicalMessage);
|
|
24
|
+
this.errorCode = errorCode;
|
|
25
|
+
this.technicalMessage = technicalMessage;
|
|
26
|
+
this.context = context;
|
|
27
|
+
this.suggestions = suggestions;
|
|
28
|
+
// Set the name to the constructor name for better logging
|
|
29
|
+
this.name = this.constructor.name;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns a log-friendly representation of the error
|
|
33
|
+
* Includes error code, name, technical message and context
|
|
34
|
+
*/
|
|
35
|
+
logError() {
|
|
36
|
+
const contextStr = this.context ? ` | Context: ${JSON.stringify(this.context)}` : '';
|
|
37
|
+
return `[${this.errorCode}] ${this.name}: ${this.technicalMessage}${contextStr}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns a safe representation of the error for external clients
|
|
41
|
+
* This excludes the technical message but includes code, context and suggestions
|
|
42
|
+
*/
|
|
43
|
+
toPublicError() {
|
|
44
|
+
return {
|
|
45
|
+
code: this.errorCode,
|
|
46
|
+
name: this.name,
|
|
47
|
+
...(this.context && { context: this.context }),
|
|
48
|
+
...(this.suggestions && { suggestions: this.suggestions }),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if an error implements the ICodedError interface
|
|
53
|
+
*/
|
|
54
|
+
static isCodedError(error) {
|
|
55
|
+
return (typeof error === 'object' &&
|
|
56
|
+
error !== null &&
|
|
57
|
+
'errorCode' in error &&
|
|
58
|
+
'technicalMessage' in error &&
|
|
59
|
+
typeof error.errorCode === 'string' &&
|
|
60
|
+
typeof error.technicalMessage === 'string');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.CodedRootError = CodedRootError;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigurationNotFoundError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Exception thrown when a carbon footprint configuration is not found
|
|
8
|
+
* This error occurs when searching for configurations by ID, type, or other criteria
|
|
9
|
+
*
|
|
10
|
+
* Error code: CBX-CFC-001
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
class ConfigurationNotFoundError extends CodedRootError_1.CodedRootError {
|
|
14
|
+
constructor(configurationType, searchCriteria, searchValue, clientId) {
|
|
15
|
+
const errorCode = ErrorCode_1.ErrorCode.CONFIGURATION_NOT_FOUND;
|
|
16
|
+
const clientInfo = clientId ? ` for client ${clientId}` : '';
|
|
17
|
+
const technicalMessage = `${configurationType} configuration not found: ${searchCriteria}='${searchValue}'${clientInfo}`;
|
|
18
|
+
const context = {
|
|
19
|
+
configurationType,
|
|
20
|
+
searchCriteria,
|
|
21
|
+
searchValue,
|
|
22
|
+
...(clientId && { clientId }),
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
};
|
|
25
|
+
const suggestions = [
|
|
26
|
+
`Verify the ${configurationType} configuration ID is correct`,
|
|
27
|
+
'Check if the configuration has been properly initialized',
|
|
28
|
+
'Ensure the configuration period is active',
|
|
29
|
+
'Contact an administrator to set up the required configuration',
|
|
30
|
+
];
|
|
31
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
32
|
+
this.name = 'ConfigurationNotFoundError';
|
|
33
|
+
}
|
|
34
|
+
static create(configurationType, searchCriteria, searchValue, clientId) {
|
|
35
|
+
return new ConfigurationNotFoundError(configurationType, searchCriteria, searchValue, clientId);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates an error for missing corporate configuration
|
|
39
|
+
*/
|
|
40
|
+
static corporate(id, clientId) {
|
|
41
|
+
return new ConfigurationNotFoundError('Corporate', 'id', id, clientId);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an error for missing product configuration
|
|
45
|
+
*/
|
|
46
|
+
static product(id, clientId) {
|
|
47
|
+
return new ConfigurationNotFoundError('Product', 'id', id, clientId);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error for missing event configuration
|
|
51
|
+
*/
|
|
52
|
+
static event(id, clientId) {
|
|
53
|
+
return new ConfigurationNotFoundError('Event', 'id', id, clientId);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates an error for missing configuration by period
|
|
57
|
+
*/
|
|
58
|
+
static byPeriod(configurationType, period, clientId) {
|
|
59
|
+
return new ConfigurationNotFoundError(configurationType, 'period', period, clientId);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ConfigurationNotFoundError = ConfigurationNotFoundError;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContractNotFoundError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Exception thrown when a purchase contract is not found in the system
|
|
8
|
+
* This error occurs when searching for contracts by ID, client, or other criteria
|
|
9
|
+
*
|
|
10
|
+
* Error code: CBX-PMS-001
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
class ContractNotFoundError extends CodedRootError_1.CodedRootError {
|
|
14
|
+
constructor(searchCriteria, searchValue, clientId, contractType) {
|
|
15
|
+
const errorCode = ErrorCode_1.ErrorCode.CONTRACT_NOT_FOUND;
|
|
16
|
+
const clientInfo = clientId ? ` for client ${clientId}` : '';
|
|
17
|
+
const typeInfo = contractType ? ` (type: ${contractType})` : '';
|
|
18
|
+
const technicalMessage = `Purchase contract not found: ${searchCriteria}='${searchValue}'${clientInfo}${typeInfo}`;
|
|
19
|
+
const context = {
|
|
20
|
+
searchCriteria,
|
|
21
|
+
searchValue,
|
|
22
|
+
...(clientId && { clientId }),
|
|
23
|
+
...(contractType && { contractType }),
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
};
|
|
26
|
+
const suggestions = [
|
|
27
|
+
'Verify the contract ID is correct',
|
|
28
|
+
'Check if the contract has been properly created',
|
|
29
|
+
'Ensure the contract has not been deleted or archived',
|
|
30
|
+
'Verify you have permission to access this contract',
|
|
31
|
+
'Contact the contract administrator for assistance',
|
|
32
|
+
];
|
|
33
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
34
|
+
this.name = 'ContractNotFoundError';
|
|
35
|
+
}
|
|
36
|
+
static create(searchCriteria, searchValue, clientId, contractType) {
|
|
37
|
+
return new ContractNotFoundError(searchCriteria, searchValue, clientId, contractType);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a ContractNotFoundError specifically for ID searches
|
|
41
|
+
*/
|
|
42
|
+
static byId(id, clientId) {
|
|
43
|
+
return new ContractNotFoundError('id', id, clientId);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Creates a ContractNotFoundError specifically for contract number searches
|
|
47
|
+
*/
|
|
48
|
+
static byContractNumber(contractNumber, clientId) {
|
|
49
|
+
return new ContractNotFoundError('contractNumber', contractNumber, clientId);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a ContractNotFoundError for active contracts
|
|
53
|
+
*/
|
|
54
|
+
static noActiveContract(clientId) {
|
|
55
|
+
return new ContractNotFoundError('status', 'ACTIVE', clientId);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.ContractNotFoundError = ContractNotFoundError;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmailNotVerifiedError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a user tries to perform an action that requires
|
|
8
|
+
* a verified email address, but their email has not been verified yet.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
class EmailNotVerifiedError extends CodedRootError_1.CodedRootError {
|
|
13
|
+
constructor(email, actionAttempted) {
|
|
14
|
+
const technicalMessage = actionAttempted
|
|
15
|
+
? `User with email ${email} attempted to ${actionAttempted} without verifying their email address`
|
|
16
|
+
: `User with email ${email} has not verified their email address`;
|
|
17
|
+
const context = {
|
|
18
|
+
email,
|
|
19
|
+
timestamp: new Date().toISOString(),
|
|
20
|
+
};
|
|
21
|
+
if (actionAttempted) {
|
|
22
|
+
context.actionAttempted = actionAttempted;
|
|
23
|
+
}
|
|
24
|
+
const suggestions = [
|
|
25
|
+
'Check your email inbox for a verification link',
|
|
26
|
+
'Request a new verification email if the previous one expired',
|
|
27
|
+
'Ensure you are checking the correct email account',
|
|
28
|
+
'Check your spam/junk folder for the verification email',
|
|
29
|
+
];
|
|
30
|
+
super(ErrorCode_1.ErrorCode.EMAIL_NOT_VERIFIED, technicalMessage, context, suggestions);
|
|
31
|
+
this.name = 'EmailNotVerifiedError';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Factory method to create a new EmailNotVerifiedError instance
|
|
35
|
+
*
|
|
36
|
+
* @param email - The unverified email address
|
|
37
|
+
* @param actionAttempted - Optional description of the action the user attempted
|
|
38
|
+
* @returns A new EmailNotVerifiedError instance
|
|
39
|
+
*/
|
|
40
|
+
static create(email, actionAttempted) {
|
|
41
|
+
return new EmailNotVerifiedError(email, actionAttempted);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns whether the error is related to accessing restricted features
|
|
45
|
+
*/
|
|
46
|
+
isAccessRestriction() {
|
|
47
|
+
return this.context?.actionAttempted !== undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns a user-friendly message based on the locale
|
|
51
|
+
*/
|
|
52
|
+
getUserMessage(locale = 'en') {
|
|
53
|
+
const messages = {
|
|
54
|
+
en: 'Please verify your email address to continue',
|
|
55
|
+
es: 'Por favor, verifica tu dirección de correo electrónico para continuar',
|
|
56
|
+
pt: 'Por favor, verifique seu endereço de e-mail para continuar',
|
|
57
|
+
};
|
|
58
|
+
return messages[locale] || messages.en;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.EmailNotVerifiedError = EmailNotVerifiedError;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidBusinessStatusError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Exception thrown when a business status transition is invalid
|
|
8
|
+
* This error occurs when attempting to change a stakeholder or entity status to an invalid state
|
|
9
|
+
*
|
|
10
|
+
* Error code: CBX-STK-005
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
class InvalidBusinessStatusError extends CodedRootError_1.CodedRootError {
|
|
14
|
+
constructor(currentStatus, attemptedStatus, entityType, entityId) {
|
|
15
|
+
const errorCode = ErrorCode_1.ErrorCode.INVALID_BUSINESS_STATUS;
|
|
16
|
+
const entityInfo = entityId ? ` (ID: ${entityId})` : '';
|
|
17
|
+
const technicalMessage = `Invalid business status transition for ${entityType}${entityInfo}: Cannot change from '${currentStatus}' to '${attemptedStatus}'`;
|
|
18
|
+
const context = {
|
|
19
|
+
currentStatus,
|
|
20
|
+
attemptedStatus,
|
|
21
|
+
entityType,
|
|
22
|
+
...(entityId && { entityId }),
|
|
23
|
+
timestamp: new Date().toISOString(),
|
|
24
|
+
};
|
|
25
|
+
const suggestions = [
|
|
26
|
+
`Current status '${currentStatus}' does not allow transition to '${attemptedStatus}'`,
|
|
27
|
+
'Review the allowed status transitions for this entity type',
|
|
28
|
+
'Ensure all required conditions are met for the status change',
|
|
29
|
+
'Contact an administrator if you believe this transition should be allowed',
|
|
30
|
+
];
|
|
31
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
32
|
+
this.name = 'InvalidBusinessStatusError';
|
|
33
|
+
}
|
|
34
|
+
static create(currentStatus, attemptedStatus, entityType, entityId) {
|
|
35
|
+
return new InvalidBusinessStatusError(currentStatus, attemptedStatus, entityType, entityId);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates an error for invalid activation attempts
|
|
39
|
+
*/
|
|
40
|
+
static cannotActivate(currentStatus, entityType, entityId) {
|
|
41
|
+
return new InvalidBusinessStatusError(currentStatus, 'ACTIVE', entityType, entityId);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an error for invalid deactivation attempts
|
|
45
|
+
*/
|
|
46
|
+
static cannotDeactivate(currentStatus, entityType, entityId) {
|
|
47
|
+
return new InvalidBusinessStatusError(currentStatus, 'INACTIVE', entityType, entityId);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error for invalid deletion attempts
|
|
51
|
+
*/
|
|
52
|
+
static cannotDelete(currentStatus, entityType, entityId) {
|
|
53
|
+
return new InvalidBusinessStatusError(currentStatus, 'DELETED', entityType, entityId);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.InvalidBusinessStatusError = InvalidBusinessStatusError;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidCredentialsError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Exception thrown when authentication credentials are invalid
|
|
8
|
+
* This error is used when the email/password combination is incorrect
|
|
9
|
+
*
|
|
10
|
+
* Error code: CBX-AUTH-001
|
|
11
|
+
* @since 1.0.0
|
|
12
|
+
*/
|
|
13
|
+
class InvalidCredentialsError extends CodedRootError_1.CodedRootError {
|
|
14
|
+
constructor(email, attemptNumber) {
|
|
15
|
+
const errorCode = ErrorCode_1.ErrorCode.INVALID_CREDENTIALS;
|
|
16
|
+
const technicalMessage = `Invalid credentials for user: ${email}${attemptNumber ? ` (attempt ${attemptNumber})` : ''}`;
|
|
17
|
+
const context = {
|
|
18
|
+
email,
|
|
19
|
+
...(attemptNumber !== undefined && { attemptNumber }),
|
|
20
|
+
timestamp: new Date().toISOString(),
|
|
21
|
+
};
|
|
22
|
+
const suggestions = [
|
|
23
|
+
'Verify your email and password are correct',
|
|
24
|
+
'Check if Caps Lock is enabled',
|
|
25
|
+
'Use "Forgot Password" if you cannot remember your credentials',
|
|
26
|
+
'Contact support if you continue having issues',
|
|
27
|
+
];
|
|
28
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
29
|
+
this.name = 'InvalidCredentialsError';
|
|
30
|
+
}
|
|
31
|
+
static create(email, attemptNumber) {
|
|
32
|
+
return new InvalidCredentialsError(email, attemptNumber);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.InvalidCredentialsError = InvalidCredentialsError;
|
|
@@ -1,19 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvalidCurrencyError = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when an invalid currency code is provided
|
|
8
|
+
* that does not match the accepted currency standards.
|
|
9
|
+
*
|
|
10
|
+
* @since 1.0.0
|
|
11
|
+
*/
|
|
12
|
+
class InvalidCurrencyError extends CodedRootError_1.CodedRootError {
|
|
6
13
|
constructor(currency, validCurrencies) {
|
|
7
14
|
const validCurrenciesText = validCurrencies.join(', ');
|
|
8
|
-
const
|
|
9
|
-
|
|
15
|
+
const technicalMessage = `Invalid currency '${currency}'. Valid currencies are: ${validCurrenciesText}`;
|
|
16
|
+
const context = {
|
|
17
|
+
providedCurrency: currency,
|
|
18
|
+
validCurrencies,
|
|
19
|
+
totalValidCurrencies: validCurrencies.length,
|
|
20
|
+
timestamp: new Date().toISOString(),
|
|
21
|
+
};
|
|
22
|
+
const suggestions = [
|
|
23
|
+
`Use one of the supported currency codes: ${validCurrencies.slice(0, 5).join(', ')}${validCurrencies.length > 5 ? '...' : ''}`,
|
|
24
|
+
'Currency codes should be in ISO 4217 format (e.g., USD, EUR, GBP)',
|
|
25
|
+
'Check for typos in the currency code',
|
|
26
|
+
'Ensure the currency code is in uppercase',
|
|
27
|
+
];
|
|
28
|
+
super(ErrorCode_1.ErrorCode.INVALID_CURRENCY, technicalMessage, context, suggestions);
|
|
10
29
|
this.name = 'InvalidCurrencyError';
|
|
11
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory method to create a new InvalidCurrencyError instance
|
|
33
|
+
*
|
|
34
|
+
* @param currency - The invalid currency code provided
|
|
35
|
+
* @param validCurrencies - List of valid currency codes
|
|
36
|
+
* @returns A new InvalidCurrencyError instance
|
|
37
|
+
*/
|
|
12
38
|
static create(currency, validCurrencies) {
|
|
13
39
|
return new InvalidCurrencyError(currency, validCurrencies);
|
|
14
40
|
}
|
|
15
|
-
|
|
16
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the provided currency might be a common typo
|
|
43
|
+
*/
|
|
44
|
+
isPossibleTypo() {
|
|
45
|
+
const currency = this.context?.providedCurrency;
|
|
46
|
+
const validCurrencies = this.context?.validCurrencies;
|
|
47
|
+
if (!currency || !validCurrencies)
|
|
48
|
+
return false;
|
|
49
|
+
// Check if it's just a case issue
|
|
50
|
+
return validCurrencies.some(valid => valid.toLowerCase() === currency.toLowerCase());
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns a user-friendly message based on the locale
|
|
54
|
+
*/
|
|
55
|
+
getUserMessage(locale = 'en') {
|
|
56
|
+
const messages = {
|
|
57
|
+
en: 'The currency code provided is not supported',
|
|
58
|
+
es: 'El código de moneda proporcionado no está soportado',
|
|
59
|
+
pt: 'O código de moeda fornecido não é suportado',
|
|
60
|
+
};
|
|
61
|
+
return messages[locale] || messages.en;
|
|
17
62
|
}
|
|
18
63
|
}
|
|
19
64
|
exports.InvalidCurrencyError = InvalidCurrencyError;
|
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InvalidDateFormatError = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const CodedRootError_1 = require("./CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../enums/ErrorCode");
|
|
6
|
+
class InvalidDateFormatError extends CodedRootError_1.CodedRootError {
|
|
6
7
|
constructor(value, expectedFormat) {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const errorCode = ErrorCode_1.ErrorCode.INVALID_DATE_FORMAT;
|
|
9
|
+
const technicalMessage = `Invalid date format: '${value}' does not match the required format '${expectedFormat}'.`;
|
|
10
|
+
const context = {
|
|
11
|
+
value,
|
|
12
|
+
expectedFormat,
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
const suggestions = [
|
|
16
|
+
`Use the format: ${expectedFormat}`,
|
|
17
|
+
`Example: ${InvalidDateFormatError.getFormatExample(expectedFormat)}`,
|
|
18
|
+
'Check the date separator characters',
|
|
19
|
+
'Verify the date components are in the correct order',
|
|
20
|
+
];
|
|
21
|
+
super(errorCode, technicalMessage, context, suggestions);
|
|
9
22
|
this.name = 'InvalidDateFormatError';
|
|
10
23
|
}
|
|
11
24
|
static create(value, expectedFormat) {
|
|
12
25
|
return new InvalidDateFormatError(value, expectedFormat);
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
static getFormatExample(format) {
|
|
28
|
+
const examples = {
|
|
29
|
+
'YYYY-MM-DD': '2024-03-15',
|
|
30
|
+
'DD/MM/YYYY': '15/03/2024',
|
|
31
|
+
'MM/DD/YYYY': '03/15/2024',
|
|
32
|
+
'ISO8601': '2024-03-15T10:30:00Z',
|
|
33
|
+
'YYYY-MM-DDTHH:mm:ss': '2024-03-15T10:30:00',
|
|
34
|
+
};
|
|
35
|
+
return examples[format] || '2024-03-15';
|
|
16
36
|
}
|
|
17
37
|
}
|
|
18
38
|
exports.InvalidDateFormatError = InvalidDateFormatError;
|