@carbonbox/domain 0.13.0 → 0.16.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/purchase-management-system/purchase-contracts/domain/events/PurchaseContractActivatedDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractCancelledDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractExpiredDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractRenewedDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceAddedDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceRemovedDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractSuspendedDomainEvent.js +38 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractActivatedPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractCancelledPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractExpiredPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractRenewedPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceAddedPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceRemovedPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractSuspendedPayload.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/entity/CompanyServiceEntitlement.js +171 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/entity/ICompanyServiceEntitlement.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/policies/ServiceCapabilityPolicy.js +167 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/repository/ICompanyServiceEntitlementRepository.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementPrimitives.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProjection.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProps.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputContract.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputServiceCatalog.js +2 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementActiveServiceCodes.js +25 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAdditionalUserRoles.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsDocumentReading.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsSectoralComparison.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementCarbonClientId.js +24 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementId.js +48 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesCarbonBoxAcademy.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesEsgIndicators.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForCorporate.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForEvent.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForProduct.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementMaxUsers.js +29 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementSourceContractIds.js +22 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidFrom.js +24 -0
- package/build/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidTo.js +21 -0
- package/build/carbonbox/shared/domain/enums/SemanticUuidPrefix.js +1 -0
- package/build/carbonbox/shared/domain/exceptions/RootError.js +1 -3
- package/build/carbonbox/shared/domain/value-objects/PositiveInteger.js +2 -8
- package/build/carbonbox/shared/domain/value-objects/ValueObject.js +2 -8
- package/build/main/index.js +80 -14
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractActivatedDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractActivatedDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractCancelledDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractCancelledDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractExpiredDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractExpiredDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractRenewedDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractRenewedDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceAddedDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceAddedDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceRemovedDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractServiceRemovedDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractSuspendedDomainEvent.d.ts +15 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/events/PurchaseContractSuspendedDomainEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractActivatedPayload.d.ts +23 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractActivatedPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractCancelledPayload.d.ts +16 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractCancelledPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractExpiredPayload.d.ts +17 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractExpiredPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractRenewedPayload.d.ts +18 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractRenewedPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceAddedPayload.d.ts +17 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceAddedPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceRemovedPayload.d.ts +18 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractServiceRemovedPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractSuspendedPayload.d.ts +18 -0
- package/build/types/carbonbox/purchase-management-system/purchase-contracts/domain/types/PurchaseContractSuspendedPayload.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/entity/CompanyServiceEntitlement.d.ts +40 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/entity/CompanyServiceEntitlement.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/entity/ICompanyServiceEntitlement.d.ts +32 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/entity/ICompanyServiceEntitlement.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/policies/ServiceCapabilityPolicy.d.ts +54 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/policies/ServiceCapabilityPolicy.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/repository/ICompanyServiceEntitlementRepository.d.ts +12 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/repository/ICompanyServiceEntitlementRepository.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementPrimitives.d.ts +18 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProjection.d.ts +30 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProjection.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProps.d.ts +18 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/CompanyServiceEntitlementProps.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputContract.d.ts +30 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputContract.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputServiceCatalog.d.ts +32 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/types/EntitlementInputServiceCatalog.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementActiveServiceCodes.d.ts +10 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementActiveServiceCodes.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAdditionalUserRoles.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAdditionalUserRoles.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsDocumentReading.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsDocumentReading.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsSectoralComparison.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementAllowsSectoralComparison.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementCarbonClientId.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementCarbonClientId.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementId.d.ts +11 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementId.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesCarbonBoxAcademy.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesCarbonBoxAcademy.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesEsgIndicators.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIncludesEsgIndicators.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForCorporate.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForCorporate.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForEvent.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForEvent.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForProduct.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementIsAvailableForProduct.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementMaxUsers.d.ts +10 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementMaxUsers.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementSourceContractIds.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementSourceContractIds.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidFrom.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidFrom.d.ts.map +1 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidTo.d.ts +9 -0
- package/build/types/carbonbox/purchase-management-system/service-entitlements/domain/value-objects/CompanyServiceEntitlementValidTo.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/SemanticUuidPrefix.d.ts +1 -0
- package/build/types/carbonbox/shared/domain/enums/SemanticUuidPrefix.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/RootError.d.ts +1 -1
- package/build/types/carbonbox/shared/domain/exceptions/RootError.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/PositiveInteger.d.ts +2 -2
- package/build/types/carbonbox/shared/domain/value-objects/PositiveInteger.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/ValueObject.d.ts +2 -2
- package/build/types/carbonbox/shared/domain/value-objects/ValueObject.d.ts.map +1 -1
- package/build/types/main/index.d.ts +47 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceCapabilityPolicy = void 0;
|
|
4
|
+
const ContractStatus_1 = require("../../../purchase-contracts/domain/enums/ContractStatus");
|
|
5
|
+
const ServiceCatalogType_1 = require("../../../service-catalog/domain/enums/ServiceCatalogType");
|
|
6
|
+
/**
|
|
7
|
+
* Pure domain service that decides what a `CarbonClient` is entitled
|
|
8
|
+
* to USE today, given its purchase contracts and the catalogs they
|
|
9
|
+
* reference.
|
|
10
|
+
*
|
|
11
|
+
* Why this exists: the truth of "what services has this client
|
|
12
|
+
* bought" is spread across `PurchaseContract` + `ServiceCatalog`. The
|
|
13
|
+
* functional modules (carbon footprint configurations,
|
|
14
|
+
* activity-data-collection, ...) need a single decoded answer they
|
|
15
|
+
* can gate on. This policy collapses N contracts × M services into
|
|
16
|
+
* a single `CompanyServiceEntitlementProjection` ready to persist as
|
|
17
|
+
* the `CompanyServiceEntitlement` read model.
|
|
18
|
+
*
|
|
19
|
+
* Rules enforced (matches DT-62 plan §Pieza 1 / §Política de mapeo):
|
|
20
|
+
* - Only contracts in `ACTIVE` status grant entitlements. Other
|
|
21
|
+
* statuses (`DRAFT`, `PENDING_SIGNATURE`, `FULLY_SIGNED`,
|
|
22
|
+
* `SUSPENDED`, `COMPLETED`, `CANCELLED`, `EXPIRED`) contribute
|
|
23
|
+
* nothing — even `FULLY_SIGNED` does not grant until activation.
|
|
24
|
+
* - A `DEPENDENT_SERVICE` only grants entitlement if its parent
|
|
25
|
+
* (`dependsOnServiceCode`) is granted by some other contract
|
|
26
|
+
* service in the same active set.
|
|
27
|
+
* - Capability flags are OR-merged across contracts: a single
|
|
28
|
+
* contract granting the capability is enough.
|
|
29
|
+
* - `maxUsers` is the MAX across catalogs that define it (the more
|
|
30
|
+
* generous contract wins). `null` everywhere → `null`.
|
|
31
|
+
* - `additionalUserRoles` is the de-duplicated union across catalogs.
|
|
32
|
+
* - `validFrom` is the EARLIEST `startDate` and `validTo` the LATEST
|
|
33
|
+
* `endDate` across entitling contracts. If any entitling contract
|
|
34
|
+
* has no end date the projection's `validTo` is `null`.
|
|
35
|
+
*
|
|
36
|
+
* The policy is intentionally a pure function — it does not load
|
|
37
|
+
* data, throw, or mutate. Errors of shape (e.g. inconsistent input)
|
|
38
|
+
* are surfaced by callers, not by this class.
|
|
39
|
+
*/
|
|
40
|
+
class ServiceCapabilityPolicy {
|
|
41
|
+
constructor() {
|
|
42
|
+
// Static-only — not instantiable.
|
|
43
|
+
}
|
|
44
|
+
static computeEntitlement(carbonClientId, contracts, catalogsByCode) {
|
|
45
|
+
const entitlingContracts = contracts.filter((contract) => ServiceCapabilityPolicy.ENTITLING_STATUSES.includes(contract.status));
|
|
46
|
+
if (entitlingContracts.length === 0) {
|
|
47
|
+
return ServiceCapabilityPolicy.emptyProjection(carbonClientId);
|
|
48
|
+
}
|
|
49
|
+
const grantedCatalogCodes = ServiceCapabilityPolicy.resolveGrantedCatalogCodes(entitlingContracts, catalogsByCode);
|
|
50
|
+
const grantedCatalogs = ServiceCapabilityPolicy.collectCatalogs(grantedCatalogCodes, catalogsByCode);
|
|
51
|
+
return {
|
|
52
|
+
carbonClientId,
|
|
53
|
+
activeServiceCodes: Array.from(grantedCatalogCodes).sort(),
|
|
54
|
+
sourceContractIds: ServiceCapabilityPolicy.collectSourceContractIds(entitlingContracts),
|
|
55
|
+
allowsDocumentReading: grantedCatalogs.some((catalog) => catalog.allowsDocumentReading),
|
|
56
|
+
allowsSectoralComparison: grantedCatalogs.some((catalog) => catalog.allowsSectoralComparison),
|
|
57
|
+
includesCarbonBoxAcademy: grantedCatalogs.some((catalog) => catalog.includesCarbonBoxAcademy),
|
|
58
|
+
includesEsgIndicators: grantedCatalogs.some((catalog) => catalog.includesEsgIndicators),
|
|
59
|
+
isAvailableForCorporate: grantedCatalogs.some((catalog) => catalog.isAvailableForCorporate),
|
|
60
|
+
isAvailableForProduct: grantedCatalogs.some((catalog) => catalog.isAvailableForProduct),
|
|
61
|
+
isAvailableForEvent: grantedCatalogs.some((catalog) => catalog.isAvailableForEvent),
|
|
62
|
+
maxUsers: ServiceCapabilityPolicy.computeMaxUsers(grantedCatalogs),
|
|
63
|
+
additionalUserRoles: ServiceCapabilityPolicy.computeAdditionalUserRoles(grantedCatalogs),
|
|
64
|
+
validFrom: ServiceCapabilityPolicy.computeValidFrom(entitlingContracts),
|
|
65
|
+
validTo: ServiceCapabilityPolicy.computeValidTo(entitlingContracts),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
static isCatalogTypeDependent(catalogType) {
|
|
69
|
+
return catalogType === ServiceCatalogType_1.ServiceCatalogType.DEPENDENT_SERVICE;
|
|
70
|
+
}
|
|
71
|
+
static resolveGrantedCatalogCodes(entitlingContracts, catalogsByCode) {
|
|
72
|
+
const candidateCodes = new Set();
|
|
73
|
+
for (const contract of entitlingContracts) {
|
|
74
|
+
for (const service of contract.services) {
|
|
75
|
+
candidateCodes.add(service.serviceCode);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const grantedCodes = new Set();
|
|
79
|
+
for (const code of candidateCodes) {
|
|
80
|
+
const catalog = catalogsByCode.get(code);
|
|
81
|
+
if (catalog !== undefined && ServiceCapabilityPolicy.isCatalogGranted(catalog, candidateCodes)) {
|
|
82
|
+
grantedCodes.add(code);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return grantedCodes;
|
|
86
|
+
}
|
|
87
|
+
static isCatalogGranted(catalog, candidateCodes) {
|
|
88
|
+
if (!ServiceCapabilityPolicy.isCatalogTypeDependent(catalog.type)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (catalog.dependsOnServiceCode === null) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
return candidateCodes.has(catalog.dependsOnServiceCode);
|
|
95
|
+
}
|
|
96
|
+
static collectCatalogs(grantedCatalogCodes, catalogsByCode) {
|
|
97
|
+
const collected = [];
|
|
98
|
+
for (const code of grantedCatalogCodes) {
|
|
99
|
+
const catalog = catalogsByCode.get(code);
|
|
100
|
+
if (catalog !== undefined) {
|
|
101
|
+
collected.push(catalog);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return collected;
|
|
105
|
+
}
|
|
106
|
+
static collectSourceContractIds(entitlingContracts) {
|
|
107
|
+
const ids = entitlingContracts.map((contract) => contract.contractId);
|
|
108
|
+
return Array.from(new Set(ids)).sort();
|
|
109
|
+
}
|
|
110
|
+
static computeMaxUsers(grantedCatalogs) {
|
|
111
|
+
let max = null;
|
|
112
|
+
for (const catalog of grantedCatalogs) {
|
|
113
|
+
if (catalog.maxUsers !== null && (max === null || catalog.maxUsers > max)) {
|
|
114
|
+
max = catalog.maxUsers;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return max;
|
|
118
|
+
}
|
|
119
|
+
static computeAdditionalUserRoles(grantedCatalogs) {
|
|
120
|
+
const roles = new Set();
|
|
121
|
+
for (const catalog of grantedCatalogs) {
|
|
122
|
+
for (const role of catalog.additionalUserRoles) {
|
|
123
|
+
roles.add(role);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return Array.from(roles).sort();
|
|
127
|
+
}
|
|
128
|
+
static computeValidFrom(entitlingContracts) {
|
|
129
|
+
const sorted = entitlingContracts
|
|
130
|
+
.map((contract) => contract.startDate)
|
|
131
|
+
.sort();
|
|
132
|
+
return sorted[0];
|
|
133
|
+
}
|
|
134
|
+
static computeValidTo(entitlingContracts) {
|
|
135
|
+
const endDates = entitlingContracts.map((contract) => contract.endDate);
|
|
136
|
+
if (endDates.some((endDate) => endDate === null || endDate === undefined || endDate === '')) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const sorted = [...endDates].sort();
|
|
140
|
+
return sorted[sorted.length - 1];
|
|
141
|
+
}
|
|
142
|
+
static emptyProjection(carbonClientId) {
|
|
143
|
+
return {
|
|
144
|
+
carbonClientId,
|
|
145
|
+
activeServiceCodes: [],
|
|
146
|
+
sourceContractIds: [],
|
|
147
|
+
allowsDocumentReading: false,
|
|
148
|
+
allowsSectoralComparison: false,
|
|
149
|
+
includesCarbonBoxAcademy: false,
|
|
150
|
+
includesEsgIndicators: false,
|
|
151
|
+
isAvailableForCorporate: false,
|
|
152
|
+
isAvailableForProduct: false,
|
|
153
|
+
isAvailableForEvent: false,
|
|
154
|
+
maxUsers: null,
|
|
155
|
+
additionalUserRoles: [],
|
|
156
|
+
validFrom: ServiceCapabilityPolicy.epochStartDate(),
|
|
157
|
+
validTo: null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
static epochStartDate() {
|
|
161
|
+
return '01/01/1970 00:00:00';
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.ServiceCapabilityPolicy = ServiceCapabilityPolicy;
|
|
165
|
+
ServiceCapabilityPolicy.ENTITLING_STATUSES = [
|
|
166
|
+
ContractStatus_1.ContractStatus.ACTIVE,
|
|
167
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementActiveServiceCodes = void 0;
|
|
4
|
+
const StringList_1 = require("../../../../shared/domain/value-objects/StringList");
|
|
5
|
+
class CompanyServiceEntitlementActiveServiceCodes extends StringList_1.StringList {
|
|
6
|
+
constructor(values, skipDomainValidation) {
|
|
7
|
+
super(values, skipDomainValidation, CompanyServiceEntitlementActiveServiceCodes.PROPERTY_NAME, { allowEmpty: true });
|
|
8
|
+
}
|
|
9
|
+
static create(values) {
|
|
10
|
+
StringList_1.StringList.guardAgainstInvalidStringList(values, CompanyServiceEntitlementActiveServiceCodes.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementActiveServiceCodes(values, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitives) {
|
|
14
|
+
const values = primitives.map((primitive) => primitive);
|
|
15
|
+
return new CompanyServiceEntitlementActiveServiceCodes(values, true);
|
|
16
|
+
}
|
|
17
|
+
includesServiceCode(serviceCode) {
|
|
18
|
+
return this.value.includes(serviceCode);
|
|
19
|
+
}
|
|
20
|
+
toPrimitives() {
|
|
21
|
+
return this.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.CompanyServiceEntitlementActiveServiceCodes = CompanyServiceEntitlementActiveServiceCodes;
|
|
25
|
+
CompanyServiceEntitlementActiveServiceCodes.PROPERTY_NAME = 'activeServiceCodes';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementAdditionalUserRoles = void 0;
|
|
4
|
+
const StringList_1 = require("../../../../shared/domain/value-objects/StringList");
|
|
5
|
+
class CompanyServiceEntitlementAdditionalUserRoles extends StringList_1.StringList {
|
|
6
|
+
constructor(values, skipDomainValidation) {
|
|
7
|
+
super(values, skipDomainValidation, CompanyServiceEntitlementAdditionalUserRoles.PROPERTY_NAME, { allowEmpty: true });
|
|
8
|
+
}
|
|
9
|
+
static create(values) {
|
|
10
|
+
StringList_1.StringList.guardAgainstInvalidStringList(values, CompanyServiceEntitlementAdditionalUserRoles.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementAdditionalUserRoles(values, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitives) {
|
|
14
|
+
const values = primitives.map((primitive) => primitive);
|
|
15
|
+
return new CompanyServiceEntitlementAdditionalUserRoles(values, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementAdditionalUserRoles = CompanyServiceEntitlementAdditionalUserRoles;
|
|
22
|
+
CompanyServiceEntitlementAdditionalUserRoles.PROPERTY_NAME = 'additionalUserRoles';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementAllowsDocumentReading = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementAllowsDocumentReading extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementAllowsDocumentReading.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementAllowsDocumentReading.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementAllowsDocumentReading(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementAllowsDocumentReading(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementAllowsDocumentReading = CompanyServiceEntitlementAllowsDocumentReading;
|
|
22
|
+
CompanyServiceEntitlementAllowsDocumentReading.PROPERTY_NAME = 'allowsDocumentReading';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementAllowsSectoralComparison = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementAllowsSectoralComparison extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementAllowsSectoralComparison.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementAllowsSectoralComparison.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementAllowsSectoralComparison(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementAllowsSectoralComparison(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementAllowsSectoralComparison = CompanyServiceEntitlementAllowsSectoralComparison;
|
|
22
|
+
CompanyServiceEntitlementAllowsSectoralComparison.PROPERTY_NAME = 'allowsSectoralComparison';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementCarbonClientId = void 0;
|
|
4
|
+
const AggregateId_1 = require("../../../../shared/domain/value-objects/AggregateId");
|
|
5
|
+
class CompanyServiceEntitlementCarbonClientId extends AggregateId_1.AggregateId {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementCarbonClientId.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
AggregateId_1.AggregateId.guardAgainstEmptyValue(value, CompanyServiceEntitlementCarbonClientId.PROPERTY_NAME);
|
|
11
|
+
AggregateId_1.AggregateId.guardAgainstInvalidType(value, CompanyServiceEntitlementCarbonClientId.PROPERTY_NAME);
|
|
12
|
+
AggregateId_1.AggregateId.guardAgainstInvalidId(value, CompanyServiceEntitlementCarbonClientId.PROPERTY_NAME);
|
|
13
|
+
return new CompanyServiceEntitlementCarbonClientId(value, false);
|
|
14
|
+
}
|
|
15
|
+
static fromPrimitives(primitive) {
|
|
16
|
+
const value = primitive;
|
|
17
|
+
return new CompanyServiceEntitlementCarbonClientId(value, true);
|
|
18
|
+
}
|
|
19
|
+
toPrimitives() {
|
|
20
|
+
return this.value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CompanyServiceEntitlementCarbonClientId = CompanyServiceEntitlementCarbonClientId;
|
|
24
|
+
CompanyServiceEntitlementCarbonClientId.PROPERTY_NAME = 'carbonClientId';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementId = 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 CompanyServiceEntitlementId extends AggregateId_1.AggregateId {
|
|
8
|
+
constructor(value, skipDomainValidation) {
|
|
9
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
10
|
+
}
|
|
11
|
+
static create(value) {
|
|
12
|
+
AggregateId_1.AggregateId.guardAgainstEmptyValue(value, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
13
|
+
AggregateId_1.AggregateId.guardAgainstInvalidType(value, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
14
|
+
AggregateId_1.AggregateId.guardAgainstInvalidId(value, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
15
|
+
CompanyServiceEntitlementId.guardAgainstInvalidPrefix(value);
|
|
16
|
+
return new CompanyServiceEntitlementId(value, false);
|
|
17
|
+
}
|
|
18
|
+
static guardAgainstInvalidPrefix(value) {
|
|
19
|
+
try {
|
|
20
|
+
const tempInstance = new CompanyServiceEntitlementId(value, true);
|
|
21
|
+
const prefix = tempInstance.extractPrefix();
|
|
22
|
+
if (CompanyServiceEntitlementId.VALID_PREFIXES.includes(prefix) === false) {
|
|
23
|
+
throw InvalidAggregatePrefixError_1.InvalidAggregatePrefixError.create(value, 'CompanyServiceEntitlement', prefix, CompanyServiceEntitlementId.VALID_PREFIXES, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof InvalidAggregatePrefixError_1.InvalidAggregatePrefixError) {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
if (error instanceof Error) {
|
|
31
|
+
throw InvalidAggregatePrefixError_1.InvalidAggregatePrefixError.create(value, 'CompanyServiceEntitlement', 'UNKNOWN', CompanyServiceEntitlementId.VALID_PREFIXES, CompanyServiceEntitlementId.PROPERTY_NAME);
|
|
32
|
+
}
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static fromPrimitives(primitive) {
|
|
37
|
+
const value = primitive;
|
|
38
|
+
return new CompanyServiceEntitlementId(value, true);
|
|
39
|
+
}
|
|
40
|
+
toPrimitives() {
|
|
41
|
+
return this.value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.CompanyServiceEntitlementId = CompanyServiceEntitlementId;
|
|
45
|
+
CompanyServiceEntitlementId.PROPERTY_NAME = 'id';
|
|
46
|
+
CompanyServiceEntitlementId.VALID_PREFIXES = [
|
|
47
|
+
SemanticUuidPrefix_1.SemanticUuidPrefix.PMS_SERVICE_ENTITLEMENT,
|
|
48
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementIncludesCarbonBoxAcademy = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementIncludesCarbonBoxAcademy extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementIncludesCarbonBoxAcademy.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementIncludesCarbonBoxAcademy.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementIncludesCarbonBoxAcademy(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementIncludesCarbonBoxAcademy(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementIncludesCarbonBoxAcademy = CompanyServiceEntitlementIncludesCarbonBoxAcademy;
|
|
22
|
+
CompanyServiceEntitlementIncludesCarbonBoxAcademy.PROPERTY_NAME = 'includesCarbonBoxAcademy';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementIncludesEsgIndicators = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementIncludesEsgIndicators extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementIncludesEsgIndicators.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementIncludesEsgIndicators.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementIncludesEsgIndicators(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementIncludesEsgIndicators(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementIncludesEsgIndicators = CompanyServiceEntitlementIncludesEsgIndicators;
|
|
22
|
+
CompanyServiceEntitlementIncludesEsgIndicators.PROPERTY_NAME = 'includesEsgIndicators';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementIsAvailableForCorporate = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementIsAvailableForCorporate extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementIsAvailableForCorporate.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementIsAvailableForCorporate.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementIsAvailableForCorporate(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementIsAvailableForCorporate(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementIsAvailableForCorporate = CompanyServiceEntitlementIsAvailableForCorporate;
|
|
22
|
+
CompanyServiceEntitlementIsAvailableForCorporate.PROPERTY_NAME = 'isAvailableForCorporate';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementIsAvailableForEvent = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementIsAvailableForEvent extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementIsAvailableForEvent.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementIsAvailableForEvent.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementIsAvailableForEvent(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementIsAvailableForEvent(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementIsAvailableForEvent = CompanyServiceEntitlementIsAvailableForEvent;
|
|
22
|
+
CompanyServiceEntitlementIsAvailableForEvent.PROPERTY_NAME = 'isAvailableForEvent';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementIsAvailableForProduct = void 0;
|
|
4
|
+
const Boolean_1 = require("../../../../shared/domain/value-objects/Boolean");
|
|
5
|
+
class CompanyServiceEntitlementIsAvailableForProduct extends Boolean_1.Boolean {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementIsAvailableForProduct.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
Boolean_1.Boolean.guardAgainstInvalidType(value, CompanyServiceEntitlementIsAvailableForProduct.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementIsAvailableForProduct(value, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitive) {
|
|
14
|
+
const value = primitive;
|
|
15
|
+
return new CompanyServiceEntitlementIsAvailableForProduct(value, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementIsAvailableForProduct = CompanyServiceEntitlementIsAvailableForProduct;
|
|
22
|
+
CompanyServiceEntitlementIsAvailableForProduct.PROPERTY_NAME = 'isAvailableForProduct';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementMaxUsers = void 0;
|
|
4
|
+
const NullableNumeric_1 = require("../../../../shared/domain/value-objects/NullableNumeric");
|
|
5
|
+
class CompanyServiceEntitlementMaxUsers extends NullableNumeric_1.NullableNumeric {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementMaxUsers.PROPERTY_NAME, CompanyServiceEntitlementMaxUsers.MAX_USERS_OPTIONS);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CompanyServiceEntitlementMaxUsers(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitive) {
|
|
13
|
+
const value = primitive;
|
|
14
|
+
return new CompanyServiceEntitlementMaxUsers(value, true);
|
|
15
|
+
}
|
|
16
|
+
toPrimitives() {
|
|
17
|
+
return this.value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CompanyServiceEntitlementMaxUsers = CompanyServiceEntitlementMaxUsers;
|
|
21
|
+
CompanyServiceEntitlementMaxUsers.PROPERTY_NAME = 'maxUsers';
|
|
22
|
+
CompanyServiceEntitlementMaxUsers.MAX_USERS_OPTIONS = {
|
|
23
|
+
allowNegative: false,
|
|
24
|
+
allowZero: true,
|
|
25
|
+
allowDecimals: false,
|
|
26
|
+
maxDecimalPlaces: 0,
|
|
27
|
+
minValue: 0,
|
|
28
|
+
maxValue: 1000000,
|
|
29
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementSourceContractIds = void 0;
|
|
4
|
+
const StringList_1 = require("../../../../shared/domain/value-objects/StringList");
|
|
5
|
+
class CompanyServiceEntitlementSourceContractIds extends StringList_1.StringList {
|
|
6
|
+
constructor(values, skipDomainValidation) {
|
|
7
|
+
super(values, skipDomainValidation, CompanyServiceEntitlementSourceContractIds.PROPERTY_NAME, { allowEmpty: true });
|
|
8
|
+
}
|
|
9
|
+
static create(values) {
|
|
10
|
+
StringList_1.StringList.guardAgainstInvalidStringList(values, CompanyServiceEntitlementSourceContractIds.PROPERTY_NAME);
|
|
11
|
+
return new CompanyServiceEntitlementSourceContractIds(values, false);
|
|
12
|
+
}
|
|
13
|
+
static fromPrimitives(primitives) {
|
|
14
|
+
const values = primitives.map((primitive) => primitive);
|
|
15
|
+
return new CompanyServiceEntitlementSourceContractIds(values, true);
|
|
16
|
+
}
|
|
17
|
+
toPrimitives() {
|
|
18
|
+
return this.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CompanyServiceEntitlementSourceContractIds = CompanyServiceEntitlementSourceContractIds;
|
|
22
|
+
CompanyServiceEntitlementSourceContractIds.PROPERTY_NAME = 'sourceContractIds';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementValidFrom = void 0;
|
|
4
|
+
const DateTimeString_1 = require("../../../../shared/domain/value-objects/DateTimeString");
|
|
5
|
+
class CompanyServiceEntitlementValidFrom extends DateTimeString_1.DateTimeString {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementValidFrom.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
DateTimeString_1.DateTimeString.guardAgainstEmptyValue(value, CompanyServiceEntitlementValidFrom.PROPERTY_NAME);
|
|
11
|
+
DateTimeString_1.DateTimeString.guardAgainstInvalidType(value, CompanyServiceEntitlementValidFrom.PROPERTY_NAME);
|
|
12
|
+
DateTimeString_1.DateTimeString.guardAgainstInvalidDateTimeFormat(value);
|
|
13
|
+
return new CompanyServiceEntitlementValidFrom(value, false);
|
|
14
|
+
}
|
|
15
|
+
static fromPrimitives(primitive) {
|
|
16
|
+
const value = primitive;
|
|
17
|
+
return new CompanyServiceEntitlementValidFrom(value, true);
|
|
18
|
+
}
|
|
19
|
+
toPrimitives() {
|
|
20
|
+
return this.value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CompanyServiceEntitlementValidFrom = CompanyServiceEntitlementValidFrom;
|
|
24
|
+
CompanyServiceEntitlementValidFrom.PROPERTY_NAME = 'validFrom';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompanyServiceEntitlementValidTo = void 0;
|
|
4
|
+
const NullableDateTimeString_1 = require("../../../../shared/domain/value-objects/NullableDateTimeString");
|
|
5
|
+
class CompanyServiceEntitlementValidTo extends NullableDateTimeString_1.NullableDateTimeString {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation, CompanyServiceEntitlementValidTo.PROPERTY_NAME);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CompanyServiceEntitlementValidTo(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitive) {
|
|
13
|
+
const value = primitive;
|
|
14
|
+
return new CompanyServiceEntitlementValidTo(value, true);
|
|
15
|
+
}
|
|
16
|
+
toPrimitives() {
|
|
17
|
+
return this.value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.CompanyServiceEntitlementValidTo = CompanyServiceEntitlementValidTo;
|
|
21
|
+
CompanyServiceEntitlementValidTo.PROPERTY_NAME = 'validTo';
|
|
@@ -72,6 +72,7 @@ var SemanticUuidPrefix;
|
|
|
72
72
|
SemanticUuidPrefix["PMS_SERVICE_PRICING"] = "PMS-SP";
|
|
73
73
|
SemanticUuidPrefix["PMS_PURCHASE_CONTRACT"] = "PMS-PC";
|
|
74
74
|
SemanticUuidPrefix["PMS_PURCHASE_ORDER"] = "PMS-PO";
|
|
75
|
+
SemanticUuidPrefix["PMS_SERVICE_ENTITLEMENT"] = "PMS-SE";
|
|
75
76
|
// Shared Domain
|
|
76
77
|
SemanticUuidPrefix["SHR_DOMAIN"] = "SHR-DOM";
|
|
77
78
|
SemanticUuidPrefix["SHR_EITHER"] = "SHR-ETH";
|
|
@@ -7,16 +7,10 @@ class PositiveInteger extends Numeric_1.Numeric {
|
|
|
7
7
|
constructor(value, skipDomainValidation, propertyName) {
|
|
8
8
|
super(value, skipDomainValidation, propertyName, PositiveInteger.POSITIVE_INTEGER_OPTIONS);
|
|
9
9
|
}
|
|
10
|
-
add(
|
|
11
|
-
const result = this.value + other.value;
|
|
12
|
-
const _ = { result, propertyName };
|
|
13
|
-
console.log(_, 'PositiveInteger.add');
|
|
10
|
+
add(_other, _propertyName) {
|
|
14
11
|
throw MethodNotImplementedError_1.MethodNotImplementedError.create('add');
|
|
15
12
|
}
|
|
16
|
-
subtract(
|
|
17
|
-
const result = this.value - other.value;
|
|
18
|
-
const _ = { result, propertyName };
|
|
19
|
-
console.log(_, 'PositiveInteger.subtract');
|
|
13
|
+
subtract(_other, _propertyName) {
|
|
20
14
|
throw MethodNotImplementedError_1.MethodNotImplementedError.create('subtract');
|
|
21
15
|
}
|
|
22
16
|
static isValidPositiveInteger(value) {
|
|
@@ -33,20 +33,14 @@ class ValueObject {
|
|
|
33
33
|
/**
|
|
34
34
|
* Método de fábrica abstracto que debe ser implementado por cada subclase.
|
|
35
35
|
*/
|
|
36
|
-
static create(...
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
-
const _ = args;
|
|
39
|
-
console.log(_, 'ValueObject.create');
|
|
36
|
+
static create(..._args) {
|
|
40
37
|
throw MethodNotImplementedError_1.MethodNotImplementedError.create('create');
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
43
40
|
* Método abstracto que obliga a las subclases a definir cómo se crean a partir de tipos primitivos.
|
|
44
41
|
* Útil para reconstruir el VO desde datos persistidos o API.
|
|
45
42
|
*/
|
|
46
|
-
static fromPrimitives(...
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
48
|
-
const _ = args;
|
|
49
|
-
console.log(_, 'ValueObject.fromPrimitives');
|
|
43
|
+
static fromPrimitives(..._args) {
|
|
50
44
|
throw MethodNotImplementedError_1.MethodNotImplementedError.create('fromPrimitives');
|
|
51
45
|
}
|
|
52
46
|
get value() {
|