@carbonbox/domain 0.48.1 → 0.49.0
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/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationActivationRequirement.js +61 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationCompletionRequirement.js +28 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationActivationPolicy.js +349 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationCompletionPolicy.js +151 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationActivationFacts.js +2 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationCompletionFacts.js +2 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationRequirementContext.js +2 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/CorporateCarbonFootprintConfigurationActivationFacts.js +2 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationActivationRequirement.js +2 -0
- package/build/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationCompletionRequirement.js +2 -0
- package/build/carbonbox/shared/domain/enums/ErrorCode.js +5 -1
- package/build/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyBlockingReason.js +104 -0
- package/build/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStep.js +52 -0
- package/build/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStepStatus.js +30 -0
- package/build/carbonbox/shared/domain/journeys/enums/PendingActionType.js +59 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/entity/IUserPreference.js +2 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/entity/UserPreference.js +122 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/exceptions/DuplicateUserPreferenceCodeError.js +31 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/exceptions/InvalidUserPreferenceCodeError.js +33 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/exceptions/UserPreferenceCodeLimitExceededError.js +31 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/repository/IUserPreferenceRepository.js +2 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/types/UserPreferencePrimitives.js +2 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/types/UserPreferenceProps.js +2 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceCodes.js +93 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceDismissedChecklistCodes.js +29 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceSeenOnboardingTourCodes.js +29 -0
- package/build/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceUserId.js +47 -0
- package/build/main/index.js +53 -16
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationActivationRequirement.d.ts +48 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationActivationRequirement.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationCompletionRequirement.d.ts +22 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/enums/CarbonFootprintConfigurationCompletionRequirement.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationActivationPolicy.d.ts +121 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationActivationPolicy.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationCompletionPolicy.d.ts +71 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/policies/CarbonFootprintConfigurationCompletionPolicy.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationActivationFacts.d.ts +16 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationActivationFacts.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationCompletionFacts.d.ts +29 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationCompletionFacts.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationRequirementContext.d.ts +34 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CarbonFootprintConfigurationRequirementContext.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CorporateCarbonFootprintConfigurationActivationFacts.d.ts +22 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/CorporateCarbonFootprintConfigurationActivationFacts.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationActivationRequirement.d.ts +11 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationActivationRequirement.d.ts.map +1 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationCompletionRequirement.d.ts +11 -0
- package/build/types/carbonbox/carbon-footprint-configurations/shared/domain/types/UnmetCarbonFootprintConfigurationCompletionRequirement.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts +4 -1
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyBlockingReason.d.ts +93 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyBlockingReason.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStep.d.ts +49 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStep.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStepStatus.d.ts +27 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/CarbonClientJourneyStepStatus.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/PendingActionType.d.ts +56 -0
- package/build/types/carbonbox/shared/domain/journeys/enums/PendingActionType.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/entity/IUserPreference.d.ts +10 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/entity/IUserPreference.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/entity/UserPreference.d.ts +45 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/entity/UserPreference.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/DuplicateUserPreferenceCodeError.d.ts +7 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/DuplicateUserPreferenceCodeError.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/InvalidUserPreferenceCodeError.d.ts +7 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/InvalidUserPreferenceCodeError.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/UserPreferenceCodeLimitExceededError.d.ts +7 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/exceptions/UserPreferenceCodeLimitExceededError.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/repository/IUserPreferenceRepository.d.ts +21 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/repository/IUserPreferenceRepository.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/types/UserPreferencePrimitives.d.ts +22 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/types/UserPreferencePrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/types/UserPreferenceProps.d.ts +18 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/types/UserPreferenceProps.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceCodes.d.ts +53 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceCodes.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceDismissedChecklistCodes.d.ts +16 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceDismissedChecklistCodes.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceSeenOnboardingTourCodes.d.ts +16 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceSeenOnboardingTourCodes.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceUserId.d.ts +18 -0
- package/build/types/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceUserId.d.ts.map +1 -0
- package/build/types/main/index.d.ts +26 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@ exports.ErrorCode = void 0;
|
|
|
17
17
|
* - RPT: Reporting
|
|
18
18
|
* - SHR: Shared/Common
|
|
19
19
|
*
|
|
20
|
-
* Total Codes:
|
|
20
|
+
* Total Codes: 177
|
|
21
21
|
* Total Exceptions Migrated: 171 (100%)
|
|
22
22
|
*
|
|
23
23
|
* @since 1.0.0
|
|
@@ -83,6 +83,10 @@ var ErrorCode;
|
|
|
83
83
|
ErrorCode["MANAGER_REQUIRED"] = "CBX-STK-006";
|
|
84
84
|
ErrorCode["INVALID_CARBON_CLIENT_ACCOUNT_TYPE"] = "CBX-STK-007";
|
|
85
85
|
ErrorCode["INVALID_CARBON_COORDINATOR_AVAILABILITY_STATUS"] = "CBX-STK-008";
|
|
86
|
+
// User Preferences Errors (CBX-STK-009 to CBX-STK-011)
|
|
87
|
+
ErrorCode["INVALID_USER_PREFERENCE_CODE"] = "CBX-STK-009";
|
|
88
|
+
ErrorCode["DUPLICATE_USER_PREFERENCE_CODE"] = "CBX-STK-010";
|
|
89
|
+
ErrorCode["USER_PREFERENCE_CODE_LIMIT_EXCEEDED"] = "CBX-STK-011";
|
|
86
90
|
// Carbon Footprint Configuration Errors (CBX-CFC-XXX)
|
|
87
91
|
ErrorCode["CONFIGURATION_NOT_FOUND"] = "CBX-CFC-001";
|
|
88
92
|
ErrorCode["INVALID_REPORTING_STANDARD"] = "CBX-CFC-002";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarbonClientJourneyBlockingReason = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Carbon client journey blocking reason enumeration
|
|
6
|
+
* Reason codes attached to a journey step that is not DONE, explaining what keeps it from advancing.
|
|
7
|
+
* Unmet activation and completion requirements are reported separately (their own enums), so each
|
|
8
|
+
* array of the step carries a single type of code.
|
|
9
|
+
*/
|
|
10
|
+
var CarbonClientJourneyBlockingReason;
|
|
11
|
+
(function (CarbonClientJourneyBlockingReason) {
|
|
12
|
+
// Step 1 - Active contract
|
|
13
|
+
/**
|
|
14
|
+
* A purchase contract is waiting for the carbon client signature
|
|
15
|
+
*/
|
|
16
|
+
CarbonClientJourneyBlockingReason["CONTRACT_PENDING_CLIENT_SIGNATURE"] = "CONTRACT_PENDING_CLIENT_SIGNATURE";
|
|
17
|
+
/**
|
|
18
|
+
* A purchase contract is waiting for the CarbonBox signature
|
|
19
|
+
*/
|
|
20
|
+
CarbonClientJourneyBlockingReason["CONTRACT_PENDING_CARBONBOX_SIGNATURE"] = "CONTRACT_PENDING_CARBONBOX_SIGNATURE";
|
|
21
|
+
/**
|
|
22
|
+
* A purchase contract is fully signed but not activated yet
|
|
23
|
+
*/
|
|
24
|
+
CarbonClientJourneyBlockingReason["CONTRACT_PENDING_ACTIVATION"] = "CONTRACT_PENDING_ACTIVATION";
|
|
25
|
+
/**
|
|
26
|
+
* The carbon client has no purchase contract
|
|
27
|
+
*/
|
|
28
|
+
CarbonClientJourneyBlockingReason["NO_CONTRACT"] = "NO_CONTRACT";
|
|
29
|
+
/**
|
|
30
|
+
* The validity window of the entitlement already ended
|
|
31
|
+
*/
|
|
32
|
+
CarbonClientJourneyBlockingReason["ENTITLEMENT_EXPIRED"] = "ENTITLEMENT_EXPIRED";
|
|
33
|
+
/**
|
|
34
|
+
* The validity window of the entitlement has not started yet
|
|
35
|
+
*/
|
|
36
|
+
CarbonClientJourneyBlockingReason["ENTITLEMENT_NOT_YET_ACTIVE"] = "ENTITLEMENT_NOT_YET_ACTIVE";
|
|
37
|
+
// Step 2 - Facilities
|
|
38
|
+
/**
|
|
39
|
+
* The carbon client has no facility
|
|
40
|
+
*/
|
|
41
|
+
CarbonClientJourneyBlockingReason["NO_FACILITY"] = "NO_FACILITY";
|
|
42
|
+
/**
|
|
43
|
+
* The carbon client has facilities but none (or more than one) is marked as primary
|
|
44
|
+
*/
|
|
45
|
+
CarbonClientJourneyBlockingReason["NO_PRIMARY_FACILITY"] = "NO_PRIMARY_FACILITY";
|
|
46
|
+
// Steps 3 to 10 - Carbon footprint configuration
|
|
47
|
+
/**
|
|
48
|
+
* The carbon client has no carbon footprint configuration for an entitled footprint type
|
|
49
|
+
*/
|
|
50
|
+
CarbonClientJourneyBlockingReason["NO_CARBON_FOOTPRINT_CONFIGURATION"] = "NO_CARBON_FOOTPRINT_CONFIGURATION";
|
|
51
|
+
/**
|
|
52
|
+
* The DRAFT carbon footprint configuration does not meet its activation requirements
|
|
53
|
+
*/
|
|
54
|
+
CarbonClientJourneyBlockingReason["ACTIVATION_REQUIREMENTS_UNMET"] = "ACTIVATION_REQUIREMENTS_UNMET";
|
|
55
|
+
// Step 6 - Activity data review
|
|
56
|
+
/**
|
|
57
|
+
* Submitted activity data records are waiting for review
|
|
58
|
+
*/
|
|
59
|
+
CarbonClientJourneyBlockingReason["SUBMISSIONS_AWAITING_REVIEW"] = "SUBMISSIONS_AWAITING_REVIEW";
|
|
60
|
+
/**
|
|
61
|
+
* Activity data records were rejected and must be corrected and submitted again
|
|
62
|
+
*/
|
|
63
|
+
CarbonClientJourneyBlockingReason["SUBMISSIONS_REJECTED"] = "SUBMISSIONS_REJECTED";
|
|
64
|
+
/**
|
|
65
|
+
* Activity data records are still in DRAFT and were not submitted
|
|
66
|
+
*/
|
|
67
|
+
CarbonClientJourneyBlockingReason["DRAFT_SUBMISSIONS_NOT_SUBMITTED"] = "DRAFT_SUBMISSIONS_NOT_SUBMITTED";
|
|
68
|
+
// Step 7 - Calculation
|
|
69
|
+
/**
|
|
70
|
+
* There is no ACTIVE calculation workflow for the carbon client and footprint type
|
|
71
|
+
*/
|
|
72
|
+
CarbonClientJourneyBlockingReason["NO_ACTIVE_CALCULATION_WORKFLOW"] = "NO_ACTIVE_CALCULATION_WORKFLOW";
|
|
73
|
+
/**
|
|
74
|
+
* A calculation process of the carbon footprint configuration is running
|
|
75
|
+
*/
|
|
76
|
+
CarbonClientJourneyBlockingReason["CALCULATION_RUNNING"] = "CALCULATION_RUNNING";
|
|
77
|
+
/**
|
|
78
|
+
* Approved activity data records were not included in a completed calculation yet
|
|
79
|
+
*/
|
|
80
|
+
CarbonClientJourneyBlockingReason["APPROVED_SUBMISSIONS_NOT_CALCULATED"] = "APPROVED_SUBMISSIONS_NOT_CALCULATED";
|
|
81
|
+
/**
|
|
82
|
+
* The calculation workflow exists but the caller is not one of its allowed executors
|
|
83
|
+
*/
|
|
84
|
+
CarbonClientJourneyBlockingReason["CALLER_NOT_ALLOWED_EXECUTOR"] = "CALLER_NOT_ALLOWED_EXECUTOR";
|
|
85
|
+
// Step 9 - Report
|
|
86
|
+
/**
|
|
87
|
+
* The report is waiting for the internal approval
|
|
88
|
+
*/
|
|
89
|
+
CarbonClientJourneyBlockingReason["REPORT_AWAITING_INTERNAL_APPROVAL"] = "REPORT_AWAITING_INTERNAL_APPROVAL";
|
|
90
|
+
/**
|
|
91
|
+
* The report is waiting for the carbon client approval
|
|
92
|
+
*/
|
|
93
|
+
CarbonClientJourneyBlockingReason["REPORT_AWAITING_CLIENT_APPROVAL"] = "REPORT_AWAITING_CLIENT_APPROVAL";
|
|
94
|
+
// Step 10 - Completion
|
|
95
|
+
/**
|
|
96
|
+
* The ACTIVE carbon footprint configuration does not meet its completion requirements
|
|
97
|
+
*/
|
|
98
|
+
CarbonClientJourneyBlockingReason["COMPLETION_REQUIREMENTS_UNMET"] = "COMPLETION_REQUIREMENTS_UNMET";
|
|
99
|
+
// Any step
|
|
100
|
+
/**
|
|
101
|
+
* The caller lacks the view permission of the step owner, so the step is reported as NOT_APPLICABLE
|
|
102
|
+
*/
|
|
103
|
+
CarbonClientJourneyBlockingReason["CALLER_LACKS_VIEW_PERMISSION"] = "CALLER_LACKS_VIEW_PERMISSION";
|
|
104
|
+
})(CarbonClientJourneyBlockingReason || (exports.CarbonClientJourneyBlockingReason = CarbonClientJourneyBlockingReason = {}));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarbonClientJourneyStep = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Carbon client journey step enumeration
|
|
6
|
+
* Ordered steps a carbon client goes through, from an active contract to a completed carbon footprint.
|
|
7
|
+
* ACTIVE_CONTRACT and FACILITIES are evaluated once per carbon client; the remaining steps are
|
|
8
|
+
* evaluated per carbon footprint configuration.
|
|
9
|
+
*/
|
|
10
|
+
var CarbonClientJourneyStep;
|
|
11
|
+
(function (CarbonClientJourneyStep) {
|
|
12
|
+
/**
|
|
13
|
+
* Step 1 - The carbon client has an entitlement whose validity window is active
|
|
14
|
+
*/
|
|
15
|
+
CarbonClientJourneyStep["ACTIVE_CONTRACT"] = "ACTIVE_CONTRACT";
|
|
16
|
+
/**
|
|
17
|
+
* Step 2 - The carbon client has at least one facility and exactly one primary facility
|
|
18
|
+
*/
|
|
19
|
+
CarbonClientJourneyStep["FACILITIES"] = "FACILITIES";
|
|
20
|
+
/**
|
|
21
|
+
* Step 3 - The carbon footprint configuration meets every activation requirement
|
|
22
|
+
*/
|
|
23
|
+
CarbonClientJourneyStep["FOOTPRINT_CONFIGURED"] = "FOOTPRINT_CONFIGURED";
|
|
24
|
+
/**
|
|
25
|
+
* Step 4 - The carbon footprint configuration is ACTIVE (or already COMPLETED)
|
|
26
|
+
*/
|
|
27
|
+
CarbonClientJourneyStep["FOOTPRINT_ACTIVE"] = "FOOTPRINT_ACTIVE";
|
|
28
|
+
/**
|
|
29
|
+
* Step 5 - Activity data was loaded for every expected emission source
|
|
30
|
+
*/
|
|
31
|
+
CarbonClientJourneyStep["ACTIVITY_DATA_LOADED"] = "ACTIVITY_DATA_LOADED";
|
|
32
|
+
/**
|
|
33
|
+
* Step 6 - Every submitted activity data record was reviewed (none awaiting review nor rejected)
|
|
34
|
+
*/
|
|
35
|
+
CarbonClientJourneyStep["ACTIVITY_DATA_REVIEWED"] = "ACTIVITY_DATA_REVIEWED";
|
|
36
|
+
/**
|
|
37
|
+
* Step 7 - Every approved activity data record was included in a completed calculation
|
|
38
|
+
*/
|
|
39
|
+
CarbonClientJourneyStep["FOOTPRINT_CALCULATED"] = "FOOTPRINT_CALCULATED";
|
|
40
|
+
/**
|
|
41
|
+
* Step 8 - The report preparation questionnaire for the footprint type is COMPLETED
|
|
42
|
+
*/
|
|
43
|
+
CarbonClientJourneyStep["REPORT_QUESTIONNAIRE_COMPLETED"] = "REPORT_QUESTIONNAIRE_COMPLETED";
|
|
44
|
+
/**
|
|
45
|
+
* Step 9 - The report for the footprint type (and period, for corporate footprints) is PUBLISHED
|
|
46
|
+
*/
|
|
47
|
+
CarbonClientJourneyStep["REPORT_PUBLISHED"] = "REPORT_PUBLISHED";
|
|
48
|
+
/**
|
|
49
|
+
* Step 10 - The carbon footprint configuration is COMPLETED
|
|
50
|
+
*/
|
|
51
|
+
CarbonClientJourneyStep["FOOTPRINT_COMPLETED"] = "FOOTPRINT_COMPLETED";
|
|
52
|
+
})(CarbonClientJourneyStep || (exports.CarbonClientJourneyStep = CarbonClientJourneyStep = {}));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarbonClientJourneyStepStatus = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Carbon client journey step status enumeration
|
|
6
|
+
* State of a single step of the carbon client journey, evaluated against the current facts
|
|
7
|
+
*/
|
|
8
|
+
var CarbonClientJourneyStepStatus;
|
|
9
|
+
(function (CarbonClientJourneyStepStatus) {
|
|
10
|
+
/**
|
|
11
|
+
* The step condition is met
|
|
12
|
+
*/
|
|
13
|
+
CarbonClientJourneyStepStatus["DONE"] = "DONE";
|
|
14
|
+
/**
|
|
15
|
+
* The step was started but its condition is only partially met
|
|
16
|
+
*/
|
|
17
|
+
CarbonClientJourneyStepStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
18
|
+
/**
|
|
19
|
+
* The step cannot advance until the reasons listed in its blocking reason codes are resolved
|
|
20
|
+
*/
|
|
21
|
+
CarbonClientJourneyStepStatus["BLOCKED"] = "BLOCKED";
|
|
22
|
+
/**
|
|
23
|
+
* The step can be performed now but has not been started
|
|
24
|
+
*/
|
|
25
|
+
CarbonClientJourneyStepStatus["PENDING"] = "PENDING";
|
|
26
|
+
/**
|
|
27
|
+
* The step does not apply (e.g. footprint type not entitled, or the caller cannot view its data)
|
|
28
|
+
*/
|
|
29
|
+
CarbonClientJourneyStepStatus["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
30
|
+
})(CarbonClientJourneyStepStatus || (exports.CarbonClientJourneyStepStatus = CarbonClientJourneyStepStatus = {}));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PendingActionType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Pending action type enumeration
|
|
6
|
+
* Kinds of work waiting for the caller, counted per carbon client in the pending actions inbox.
|
|
7
|
+
* Each type is only reported when the caller holds the permission that acts on it.
|
|
8
|
+
*/
|
|
9
|
+
var PendingActionType;
|
|
10
|
+
(function (PendingActionType) {
|
|
11
|
+
/**
|
|
12
|
+
* Activity data records in SUBMITTED status, waiting for review (approve or reject)
|
|
13
|
+
*/
|
|
14
|
+
PendingActionType["ACTIVITY_DATA_SUBMISSIONS_TO_REVIEW"] = "ACTIVITY_DATA_SUBMISSIONS_TO_REVIEW";
|
|
15
|
+
/**
|
|
16
|
+
* Activity data records in DRAFT status, waiting to be submitted
|
|
17
|
+
*/
|
|
18
|
+
PendingActionType["ACTIVITY_DATA_SUBMISSIONS_TO_SUBMIT"] = "ACTIVITY_DATA_SUBMISSIONS_TO_SUBMIT";
|
|
19
|
+
/**
|
|
20
|
+
* Activity data records in REJECTED status, waiting to be corrected and submitted again
|
|
21
|
+
*/
|
|
22
|
+
PendingActionType["ACTIVITY_DATA_SUBMISSIONS_TO_CORRECT"] = "ACTIVITY_DATA_SUBMISSIONS_TO_CORRECT";
|
|
23
|
+
/**
|
|
24
|
+
* Purchase contracts waiting for the carbon client signature
|
|
25
|
+
*/
|
|
26
|
+
PendingActionType["PURCHASE_CONTRACTS_TO_SIGN_BY_CLIENT"] = "PURCHASE_CONTRACTS_TO_SIGN_BY_CLIENT";
|
|
27
|
+
/**
|
|
28
|
+
* Purchase contracts waiting for the CarbonBox signature
|
|
29
|
+
*/
|
|
30
|
+
PendingActionType["PURCHASE_CONTRACTS_TO_SIGN_BY_CARBONBOX"] = "PURCHASE_CONTRACTS_TO_SIGN_BY_CARBONBOX";
|
|
31
|
+
/**
|
|
32
|
+
* Fully signed purchase contracts waiting to be activated
|
|
33
|
+
*/
|
|
34
|
+
PendingActionType["PURCHASE_CONTRACTS_TO_ACTIVATE"] = "PURCHASE_CONTRACTS_TO_ACTIVATE";
|
|
35
|
+
/**
|
|
36
|
+
* Reports in PENDING_INTERNAL status, waiting for the internal approval
|
|
37
|
+
*/
|
|
38
|
+
PendingActionType["REPORTS_TO_APPROVE_INTERNALLY"] = "REPORTS_TO_APPROVE_INTERNALLY";
|
|
39
|
+
/**
|
|
40
|
+
* Reports in PENDING_CLIENT status, waiting for the carbon client approval
|
|
41
|
+
*/
|
|
42
|
+
PendingActionType["REPORTS_TO_APPROVE_BY_CLIENT"] = "REPORTS_TO_APPROVE_BY_CLIENT";
|
|
43
|
+
/**
|
|
44
|
+
* Reports in APPROVED status, waiting to be published
|
|
45
|
+
*/
|
|
46
|
+
PendingActionType["REPORTS_TO_PUBLISH"] = "REPORTS_TO_PUBLISH";
|
|
47
|
+
/**
|
|
48
|
+
* Calculation processes in FAILED or TIMEOUT status with no later COMPLETED process for the same footprint
|
|
49
|
+
*/
|
|
50
|
+
PendingActionType["FAILED_CALCULATION_PROCESSES"] = "FAILED_CALCULATION_PROCESSES";
|
|
51
|
+
/**
|
|
52
|
+
* Approved activity data records not included in a completed calculation yet
|
|
53
|
+
*/
|
|
54
|
+
PendingActionType["APPROVED_SUBMISSIONS_PENDING_CALCULATION"] = "APPROVED_SUBMISSIONS_PENDING_CALCULATION";
|
|
55
|
+
/**
|
|
56
|
+
* Carbon clients with an ACTIVE carbon footprint configuration of a type that has no ACTIVE calculation workflow
|
|
57
|
+
*/
|
|
58
|
+
PendingActionType["CARBON_CLIENTS_WITHOUT_ACTIVE_CALCULATION_WORKFLOW"] = "CARBON_CLIENTS_WITHOUT_ACTIVE_CALCULATION_WORKFLOW";
|
|
59
|
+
})(PendingActionType || (exports.PendingActionType = PendingActionType = {}));
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _UserPreference_userId, _UserPreference_seenOnboardingTourCodes, _UserPreference_dismissedChecklistCodes;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.UserPreference = void 0;
|
|
16
|
+
const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
|
|
17
|
+
const UserPreferenceUserId_1 = require("../value-objects/UserPreferenceUserId");
|
|
18
|
+
const UserPreferenceSeenOnboardingTourCodes_1 = require("../value-objects/UserPreferenceSeenOnboardingTourCodes");
|
|
19
|
+
const UserPreferenceDismissedChecklistCodes_1 = require("../value-objects/UserPreferenceDismissedChecklistCodes");
|
|
20
|
+
/**
|
|
21
|
+
* UserPreference aggregate: user interface preferences of a stakeholder user
|
|
22
|
+
* (onboarding tours seen, checklists dismissed). Its identity is the owner user id.
|
|
23
|
+
*
|
|
24
|
+
* Changes return a new instance; adding codes is a union (idempotent), so two concurrent
|
|
25
|
+
* additions never remove each other's codes.
|
|
26
|
+
*/
|
|
27
|
+
class UserPreference extends AggregateRoot_1.AggregateRoot {
|
|
28
|
+
constructor(props, skipDomainValidation) {
|
|
29
|
+
const userId = skipDomainValidation
|
|
30
|
+
? UserPreferenceUserId_1.UserPreferenceUserId.fromPrimitives(props.id)
|
|
31
|
+
: UserPreferenceUserId_1.UserPreferenceUserId.create(props.id);
|
|
32
|
+
super({ id: userId.toPrimitives() }, skipDomainValidation);
|
|
33
|
+
_UserPreference_userId.set(this, void 0);
|
|
34
|
+
_UserPreference_seenOnboardingTourCodes.set(this, void 0);
|
|
35
|
+
_UserPreference_dismissedChecklistCodes.set(this, void 0);
|
|
36
|
+
__classPrivateFieldSet(this, _UserPreference_userId, userId, "f");
|
|
37
|
+
if (skipDomainValidation === false) {
|
|
38
|
+
// Initialize with domain validation
|
|
39
|
+
__classPrivateFieldSet(this, _UserPreference_seenOnboardingTourCodes, UserPreferenceSeenOnboardingTourCodes_1.UserPreferenceSeenOnboardingTourCodes.create(props.seenOnboardingTourCodes), "f");
|
|
40
|
+
__classPrivateFieldSet(this, _UserPreference_dismissedChecklistCodes, UserPreferenceDismissedChecklistCodes_1.UserPreferenceDismissedChecklistCodes.create(props.dismissedChecklistCodes), "f");
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// Initialize from primitives (no domain validation)
|
|
44
|
+
__classPrivateFieldSet(this, _UserPreference_seenOnboardingTourCodes, UserPreferenceSeenOnboardingTourCodes_1.UserPreferenceSeenOnboardingTourCodes.fromPrimitives(props.seenOnboardingTourCodes), "f");
|
|
45
|
+
__classPrivateFieldSet(this, _UserPreference_dismissedChecklistCodes, UserPreferenceDismissedChecklistCodes_1.UserPreferenceDismissedChecklistCodes.fromPrimitives(props.dismissedChecklistCodes), "f");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
static create(props) {
|
|
49
|
+
return new UserPreference(props, false);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Default preferences of a user who never saved any (empty lists). Not persisted by itself:
|
|
53
|
+
* reading preferences without a stored record returns this without writing.
|
|
54
|
+
*/
|
|
55
|
+
static createDefault(userId) {
|
|
56
|
+
const props = {
|
|
57
|
+
id: userId,
|
|
58
|
+
seenOnboardingTourCodes: [],
|
|
59
|
+
dismissedChecklistCodes: [],
|
|
60
|
+
};
|
|
61
|
+
return new UserPreference(props, false);
|
|
62
|
+
}
|
|
63
|
+
static fromPrimitives(primitives) {
|
|
64
|
+
const props = {
|
|
65
|
+
id: primitives.id,
|
|
66
|
+
seenOnboardingTourCodes: primitives.seenOnboardingTourCodes,
|
|
67
|
+
dismissedChecklistCodes: primitives.dismissedChecklistCodes,
|
|
68
|
+
};
|
|
69
|
+
return new UserPreference(props, true);
|
|
70
|
+
}
|
|
71
|
+
get toPrimitives() {
|
|
72
|
+
return {
|
|
73
|
+
id: __classPrivateFieldGet(this, _UserPreference_userId, "f").toPrimitives(),
|
|
74
|
+
seenOnboardingTourCodes: __classPrivateFieldGet(this, _UserPreference_seenOnboardingTourCodes, "f").toPrimitives(),
|
|
75
|
+
dismissedChecklistCodes: __classPrivateFieldGet(this, _UserPreference_dismissedChecklistCodes, "f").toPrimitives(),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
get userId() {
|
|
79
|
+
return __classPrivateFieldGet(this, _UserPreference_userId, "f");
|
|
80
|
+
}
|
|
81
|
+
get seenOnboardingTourCodes() {
|
|
82
|
+
return __classPrivateFieldGet(this, _UserPreference_seenOnboardingTourCodes, "f");
|
|
83
|
+
}
|
|
84
|
+
get dismissedChecklistCodes() {
|
|
85
|
+
return __classPrivateFieldGet(this, _UserPreference_dismissedChecklistCodes, "f");
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns a new preference whose seen onboarding tours are the union of the current and the added codes.
|
|
89
|
+
* Throws UserPreferenceCodeLimitExceededError when the union exceeds the maximum.
|
|
90
|
+
*/
|
|
91
|
+
withAddedSeenOnboardingTourCodes(addedCodes) {
|
|
92
|
+
return UserPreference.create({
|
|
93
|
+
id: __classPrivateFieldGet(this, _UserPreference_userId, "f").toPrimitives(),
|
|
94
|
+
seenOnboardingTourCodes: __classPrivateFieldGet(this, _UserPreference_seenOnboardingTourCodes, "f").withAddedCodes(addedCodes).toPrimitives(),
|
|
95
|
+
dismissedChecklistCodes: __classPrivateFieldGet(this, _UserPreference_dismissedChecklistCodes, "f").toPrimitives(),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns a new preference whose dismissed checklists are the union of the current and the added codes.
|
|
100
|
+
* Throws UserPreferenceCodeLimitExceededError when the union exceeds the maximum.
|
|
101
|
+
*/
|
|
102
|
+
withAddedDismissedChecklistCodes(addedCodes) {
|
|
103
|
+
return UserPreference.create({
|
|
104
|
+
id: __classPrivateFieldGet(this, _UserPreference_userId, "f").toPrimitives(),
|
|
105
|
+
seenOnboardingTourCodes: __classPrivateFieldGet(this, _UserPreference_seenOnboardingTourCodes, "f").toPrimitives(),
|
|
106
|
+
dismissedChecklistCodes: __classPrivateFieldGet(this, _UserPreference_dismissedChecklistCodes, "f").withAddedCodes(addedCodes).toPrimitives(),
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns a new preference with no seen onboarding tours ("show the tours again").
|
|
111
|
+
* Dismissed checklists are kept.
|
|
112
|
+
*/
|
|
113
|
+
withSeenOnboardingToursReset() {
|
|
114
|
+
return UserPreference.create({
|
|
115
|
+
id: __classPrivateFieldGet(this, _UserPreference_userId, "f").toPrimitives(),
|
|
116
|
+
seenOnboardingTourCodes: [],
|
|
117
|
+
dismissedChecklistCodes: __classPrivateFieldGet(this, _UserPreference_dismissedChecklistCodes, "f").toPrimitives(),
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.UserPreference = UserPreference;
|
|
122
|
+
_UserPreference_userId = new WeakMap(), _UserPreference_seenOnboardingTourCodes = new WeakMap(), _UserPreference_dismissedChecklistCodes = new WeakMap();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuplicateUserPreferenceCodeError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class DuplicateUserPreferenceCodeError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(propertyName, duplicatedCodes) {
|
|
8
|
+
const duplicatedCodesList = duplicatedCodes.join(', ');
|
|
9
|
+
const technicalMessage = `Duplicated user preference codes in '${propertyName}': ${duplicatedCodesList}. Each code can appear only once.`;
|
|
10
|
+
const context = {
|
|
11
|
+
propertyName,
|
|
12
|
+
duplicatedCodes,
|
|
13
|
+
duplicatedCodesCount: duplicatedCodes.length,
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
};
|
|
16
|
+
const suggestions = [
|
|
17
|
+
'Send each code only once',
|
|
18
|
+
'Remove the repeated codes before sending the request',
|
|
19
|
+
'Codes already stored are kept, so there is no need to send them again',
|
|
20
|
+
];
|
|
21
|
+
super(ErrorCode_1.ErrorCode.DUPLICATE_USER_PREFERENCE_CODE, technicalMessage, context, suggestions);
|
|
22
|
+
this.name = 'DuplicateUserPreferenceCodeError';
|
|
23
|
+
}
|
|
24
|
+
static create(propertyName, duplicatedCodes) {
|
|
25
|
+
return new DuplicateUserPreferenceCodeError(propertyName, duplicatedCodes);
|
|
26
|
+
}
|
|
27
|
+
logError() {
|
|
28
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DuplicateUserPreferenceCodeError = DuplicateUserPreferenceCodeError;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidUserPreferenceCodeError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class InvalidUserPreferenceCodeError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(propertyName, invalidCodes, expectedPattern) {
|
|
8
|
+
const invalidCodesList = invalidCodes.join(', ');
|
|
9
|
+
const technicalMessage = `Invalid user preference codes in '${propertyName}': ${invalidCodesList}. Each code must match the pattern ${expectedPattern} (uppercase letters, digits and underscores, 1 to 100 characters).`;
|
|
10
|
+
const context = {
|
|
11
|
+
propertyName,
|
|
12
|
+
invalidCodes,
|
|
13
|
+
invalidCodesCount: invalidCodes.length,
|
|
14
|
+
expectedPattern,
|
|
15
|
+
timestamp: new Date().toISOString(),
|
|
16
|
+
};
|
|
17
|
+
const suggestions = [
|
|
18
|
+
`Use codes that match the pattern ${expectedPattern}`,
|
|
19
|
+
'Use only uppercase letters, digits and underscores, without spaces',
|
|
20
|
+
'Keep every code between 1 and 100 characters long',
|
|
21
|
+
'Verify that the codes come from the user interface catalog of onboarding tours and checklists',
|
|
22
|
+
];
|
|
23
|
+
super(ErrorCode_1.ErrorCode.INVALID_USER_PREFERENCE_CODE, technicalMessage, context, suggestions);
|
|
24
|
+
this.name = 'InvalidUserPreferenceCodeError';
|
|
25
|
+
}
|
|
26
|
+
static create(propertyName, invalidCodes, expectedPattern) {
|
|
27
|
+
return new InvalidUserPreferenceCodeError(propertyName, invalidCodes, expectedPattern);
|
|
28
|
+
}
|
|
29
|
+
logError() {
|
|
30
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.InvalidUserPreferenceCodeError = InvalidUserPreferenceCodeError;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPreferenceCodeLimitExceededError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class UserPreferenceCodeLimitExceededError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(propertyName, receivedCount, maximumCount) {
|
|
8
|
+
const technicalMessage = `Too many user preference codes in '${propertyName}': ${receivedCount} codes received, the maximum is ${maximumCount}.`;
|
|
9
|
+
const context = {
|
|
10
|
+
propertyName,
|
|
11
|
+
receivedCount,
|
|
12
|
+
maximumCount,
|
|
13
|
+
excessCount: receivedCount - maximumCount,
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
};
|
|
16
|
+
const suggestions = [
|
|
17
|
+
`Keep at most ${maximumCount} codes in '${propertyName}'`,
|
|
18
|
+
'Reset the stored codes before adding new ones',
|
|
19
|
+
'Verify that the user interface is not generating a new code on every visit',
|
|
20
|
+
];
|
|
21
|
+
super(ErrorCode_1.ErrorCode.USER_PREFERENCE_CODE_LIMIT_EXCEEDED, technicalMessage, context, suggestions);
|
|
22
|
+
this.name = 'UserPreferenceCodeLimitExceededError';
|
|
23
|
+
}
|
|
24
|
+
static create(propertyName, receivedCount, maximumCount) {
|
|
25
|
+
return new UserPreferenceCodeLimitExceededError(propertyName, receivedCount, maximumCount);
|
|
26
|
+
}
|
|
27
|
+
logError() {
|
|
28
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.UserPreferenceCodeLimitExceededError = UserPreferenceCodeLimitExceededError;
|
package/build/carbonbox/stakeholders/user-preferences/domain/value-objects/UserPreferenceCodes.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPreferenceCodes = void 0;
|
|
4
|
+
const StringList_1 = require("../../../../shared/domain/value-objects/StringList");
|
|
5
|
+
const InvalidUserPreferenceCodeError_1 = require("../exceptions/InvalidUserPreferenceCodeError");
|
|
6
|
+
const DuplicateUserPreferenceCodeError_1 = require("../exceptions/DuplicateUserPreferenceCodeError");
|
|
7
|
+
const UserPreferenceCodeLimitExceededError_1 = require("../exceptions/UserPreferenceCodeLimitExceededError");
|
|
8
|
+
/**
|
|
9
|
+
* Abstract list of user interface codes stored as a user preference
|
|
10
|
+
* (e.g. onboarding tours already seen, checklist items dismissed).
|
|
11
|
+
*
|
|
12
|
+
* The codes belong to the user interface, so there is no enum: every code must match
|
|
13
|
+
* `^[A-Z0-9_]{1,100}$`, codes are unique (case-sensitive) and a list holds at most 200 codes.
|
|
14
|
+
* An empty list is valid (default preferences).
|
|
15
|
+
*/
|
|
16
|
+
class UserPreferenceCodes extends StringList_1.StringList {
|
|
17
|
+
/**
|
|
18
|
+
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
19
|
+
* Aplica todas las validaciones de dominio al momento de construcción.
|
|
20
|
+
*/
|
|
21
|
+
constructor(values, skipDomainValidation, propertyName) {
|
|
22
|
+
super(values, skipDomainValidation, propertyName, { allowEmpty: true });
|
|
23
|
+
if (skipDomainValidation === false) {
|
|
24
|
+
UserPreferenceCodes.validateUserPreferenceCodes(values, propertyName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Validación estática para reutilización en factory methods y constructores.
|
|
29
|
+
*/
|
|
30
|
+
static validateUserPreferenceCodes(values, propertyName) {
|
|
31
|
+
StringList_1.StringList.guardAgainstInvalidStringList(values, propertyName, { allowEmpty: true });
|
|
32
|
+
UserPreferenceCodes.guardAgainstInvalidCodes(values, propertyName);
|
|
33
|
+
UserPreferenceCodes.guardAgainstDuplicateCodes(values, propertyName);
|
|
34
|
+
UserPreferenceCodes.guardAgainstCodeLimitExceeded(values, propertyName);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Valida que todos los códigos cumplan el patrón `^[A-Z0-9_]{1,100}$`.
|
|
38
|
+
*/
|
|
39
|
+
static guardAgainstInvalidCodes(values, propertyName) {
|
|
40
|
+
const invalidCodes = values.filter((code) => UserPreferenceCodes.CODE_PATTERN.test(code) === false);
|
|
41
|
+
if (invalidCodes.length > 0) {
|
|
42
|
+
throw InvalidUserPreferenceCodeError_1.InvalidUserPreferenceCodeError.create(propertyName, invalidCodes, UserPreferenceCodes.CODE_PATTERN.source);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Valida que no haya códigos repetidos.
|
|
47
|
+
*/
|
|
48
|
+
static guardAgainstDuplicateCodes(values, propertyName) {
|
|
49
|
+
const duplicatedCodes = values.filter((code, index) => values.indexOf(code) !== index);
|
|
50
|
+
if (duplicatedCodes.length > 0) {
|
|
51
|
+
throw DuplicateUserPreferenceCodeError_1.DuplicateUserPreferenceCodeError.create(propertyName, Array.from(new Set(duplicatedCodes)));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Valida que la lista no supere el tope de códigos.
|
|
56
|
+
*/
|
|
57
|
+
static guardAgainstCodeLimitExceeded(values, propertyName) {
|
|
58
|
+
if (values.length > UserPreferenceCodes.MAXIMUM_CODE_COUNT) {
|
|
59
|
+
throw UserPreferenceCodeLimitExceededError_1.UserPreferenceCodeLimitExceededError.create(propertyName, values.length, UserPreferenceCodes.MAXIMUM_CODE_COUNT);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Unión de códigos: conserva el orden de los actuales y agrega al final los nuevos que no estaban.
|
|
64
|
+
* Idempotente: agregar códigos ya presentes no cambia la lista.
|
|
65
|
+
*/
|
|
66
|
+
static mergeCodes(currentCodes, addedCodes) {
|
|
67
|
+
return Array.from(new Set([...currentCodes, ...addedCodes]));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Verifica si la lista contiene un código (comparación exacta).
|
|
71
|
+
*/
|
|
72
|
+
includesCode(code) {
|
|
73
|
+
return this.value.includes(code);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Número de códigos en la lista.
|
|
77
|
+
*/
|
|
78
|
+
get length() {
|
|
79
|
+
return this.value.length;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Verifica si la lista está vacía.
|
|
83
|
+
*/
|
|
84
|
+
isEmpty() {
|
|
85
|
+
return this.value.length === 0;
|
|
86
|
+
}
|
|
87
|
+
toPrimitives() {
|
|
88
|
+
return [...this.value];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.UserPreferenceCodes = UserPreferenceCodes;
|
|
92
|
+
UserPreferenceCodes.CODE_PATTERN = /^[A-Z0-9_]{1,100}$/;
|
|
93
|
+
UserPreferenceCodes.MAXIMUM_CODE_COUNT = 200;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPreferenceDismissedChecklistCodes = void 0;
|
|
4
|
+
const UserPreferenceCodes_1 = require("./UserPreferenceCodes");
|
|
5
|
+
/**
|
|
6
|
+
* Codes of the checklists (or checklist items) the user dismissed (the user interface hides them).
|
|
7
|
+
*/
|
|
8
|
+
class UserPreferenceDismissedChecklistCodes extends UserPreferenceCodes_1.UserPreferenceCodes {
|
|
9
|
+
constructor(values, skipDomainValidation) {
|
|
10
|
+
super(values, skipDomainValidation, UserPreferenceDismissedChecklistCodes.PROPERTY_NAME);
|
|
11
|
+
}
|
|
12
|
+
static create(values) {
|
|
13
|
+
UserPreferenceCodes_1.UserPreferenceCodes.validateUserPreferenceCodes(values, UserPreferenceDismissedChecklistCodes.PROPERTY_NAME);
|
|
14
|
+
return new UserPreferenceDismissedChecklistCodes(values, false);
|
|
15
|
+
}
|
|
16
|
+
static fromPrimitives(primitives) {
|
|
17
|
+
const values = primitives.map((primitive) => primitive);
|
|
18
|
+
return new UserPreferenceDismissedChecklistCodes(values, true);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a new list with the union of the current codes and the added ones (idempotent).
|
|
22
|
+
* Throws UserPreferenceCodeLimitExceededError when the union exceeds the maximum.
|
|
23
|
+
*/
|
|
24
|
+
withAddedCodes(addedCodes) {
|
|
25
|
+
return UserPreferenceDismissedChecklistCodes.create(UserPreferenceCodes_1.UserPreferenceCodes.mergeCodes(this.toPrimitives(), addedCodes.toPrimitives()));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.UserPreferenceDismissedChecklistCodes = UserPreferenceDismissedChecklistCodes;
|
|
29
|
+
UserPreferenceDismissedChecklistCodes.PROPERTY_NAME = 'dismissedChecklistCodes';
|