@carbonbox/domain 0.20.1 → 0.21.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/shared/domain/enums/IdentityDocumentType.js +10 -0
- package/build/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.js +18 -0
- package/build/carbonbox/shared/domain/types/IdentityDocument.js +2 -0
- package/build/carbonbox/shared/domain/types/IdentityDocumentPrimitives.js +2 -0
- package/build/carbonbox/shared/domain/value-objects/IdentityDocument.js +336 -0
- package/build/carbonbox/stakeholders/carbon-clients/domain/entity/CarbonClient.js +22 -5
- package/build/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.js +27 -0
- package/build/carbonbox/stakeholders/carbon-coordinators/domain/entity/CarbonCoordinator.js +22 -5
- package/build/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.js +27 -0
- package/build/carbonbox/stakeholders/carbon-host/domain/entity/CarbonHost.js +15 -5
- package/build/carbonbox/stakeholders/carbon-managers/domain/entity/CarbonManager.js +22 -5
- package/build/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.js +27 -0
- package/build/carbonbox/stakeholders/shared/domain/entity/Stakeholder.js +21 -4
- package/build/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.js +47 -0
- package/build/main/index.js +16 -1
- package/build/types/carbonbox/shared/domain/enums/IdentityDocumentType.d.ts +7 -0
- package/build/types/carbonbox/shared/domain/enums/IdentityDocumentType.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.d.ts +7 -0
- package/build/types/carbonbox/shared/domain/exceptions/InvalidIdentityDocumentTypeError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/types/IdentityDocument.d.ts +9 -0
- package/build/types/carbonbox/shared/domain/types/IdentityDocument.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/types/IdentityDocumentPrimitives.d.ts +9 -0
- package/build/types/carbonbox/shared/domain/types/IdentityDocumentPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/value-objects/IdentityDocument.d.ts +132 -0
- package/build/types/carbonbox/shared/domain/value-objects/IdentityDocument.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/carbon-clients/domain/entity/CarbonClient.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.d.ts +10 -0
- package/build/types/carbonbox/stakeholders/carbon-clients/domain/value-objects/CarbonClientIdentityDocument.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/entity/CarbonCoordinator.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.d.ts +10 -0
- package/build/types/carbonbox/stakeholders/carbon-coordinators/domain/value-objects/CarbonCoordinatorIdentityDocument.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/carbon-host/domain/entity/CarbonHost.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/carbon-managers/domain/entity/CarbonManager.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.d.ts +10 -0
- package/build/types/carbonbox/stakeholders/carbon-managers/domain/value-objects/CarbonManagerIdentityDocument.d.ts.map +1 -0
- package/build/types/carbonbox/stakeholders/shared/domain/entity/IStakeholder.d.ts +3 -1
- package/build/types/carbonbox/stakeholders/shared/domain/entity/IStakeholder.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/shared/domain/entity/Stakeholder.d.ts +3 -1
- package/build/types/carbonbox/stakeholders/shared/domain/entity/Stakeholder.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPrimitives.d.ts +3 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderProps.d.ts +3 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderProps.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPropsWithHashedPassword.d.ts +3 -1
- package/build/types/carbonbox/stakeholders/shared/domain/types/StakeholderPropsWithHashedPassword.d.ts.map +1 -1
- package/build/types/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.d.ts +22 -0
- package/build/types/carbonbox/stakeholders/shared/domain/value-objects/StakeholderIdentityDocument.d.ts.map +1 -0
- package/build/types/main/index.d.ts +9 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IdentityDocumentType = void 0;
|
|
4
|
+
var IdentityDocumentType;
|
|
5
|
+
(function (IdentityDocumentType) {
|
|
6
|
+
IdentityDocumentType["CC"] = "CC";
|
|
7
|
+
IdentityDocumentType["CE"] = "CE";
|
|
8
|
+
IdentityDocumentType["PASSPORT"] = "PASSPORT";
|
|
9
|
+
IdentityDocumentType["DNI"] = "DNI";
|
|
10
|
+
})(IdentityDocumentType || (exports.IdentityDocumentType = IdentityDocumentType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidIdentityDocumentTypeError = void 0;
|
|
4
|
+
const RootError_1 = require("./RootError");
|
|
5
|
+
class InvalidIdentityDocumentTypeError extends RootError_1.RootError {
|
|
6
|
+
constructor(invalidType, validTypes) {
|
|
7
|
+
const message = `Invalid identity document type: '${invalidType}'. Valid types: ${validTypes.join(', ')}.`;
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'InvalidIdentityDocumentTypeError';
|
|
10
|
+
}
|
|
11
|
+
static create(invalidType, validTypes) {
|
|
12
|
+
return new InvalidIdentityDocumentTypeError(invalidType, validTypes);
|
|
13
|
+
}
|
|
14
|
+
logError() {
|
|
15
|
+
return `${this.name}: ${this.message}`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.InvalidIdentityDocumentTypeError = InvalidIdentityDocumentTypeError;
|
|
@@ -0,0 +1,336 @@
|
|
|
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 _IdentityDocument_type, _IdentityDocument_number, _IdentityDocument_country, _IdentityDocument_issuedBy, _IdentityDocument_validFrom, _IdentityDocument_validUntil;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.IdentityDocument = void 0;
|
|
16
|
+
const InvalidPropertyTypeError_1 = require("../exceptions/InvalidPropertyTypeError");
|
|
17
|
+
const InvalidIdentityDocumentTypeError_1 = require("../exceptions/InvalidIdentityDocumentTypeError");
|
|
18
|
+
const InvalidCountryCodeError_1 = require("../exceptions/InvalidCountryCodeError");
|
|
19
|
+
const InvalidDateRangeError_1 = require("../exceptions/InvalidDateRangeError");
|
|
20
|
+
const ObjectValueObject_1 = require("./ObjectValueObject");
|
|
21
|
+
const String_1 = require("./String");
|
|
22
|
+
const NullableDate_1 = require("./NullableDate");
|
|
23
|
+
const CountryCode_1 = require("../enums/CountryCode");
|
|
24
|
+
const IdentityDocumentType_1 = require("../enums/IdentityDocumentType");
|
|
25
|
+
class IdentityDocument extends ObjectValueObject_1.ObjectValueObject {
|
|
26
|
+
/**
|
|
27
|
+
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
28
|
+
* Aplica todas las validaciones de dominio al momento de construcción.
|
|
29
|
+
*/
|
|
30
|
+
constructor(value, skipDomainValidation, propertyName = IdentityDocument.DEFAULT_PROPERTY_NAME) {
|
|
31
|
+
super(value, skipDomainValidation, propertyName, 'The provided value must be of type IdentityDocument from the domain layer', { allowNull: false, allowUndefined: false });
|
|
32
|
+
_IdentityDocument_type.set(this, void 0);
|
|
33
|
+
_IdentityDocument_number.set(this, void 0);
|
|
34
|
+
_IdentityDocument_country.set(this, void 0);
|
|
35
|
+
_IdentityDocument_issuedBy.set(this, void 0);
|
|
36
|
+
_IdentityDocument_validFrom.set(this, void 0);
|
|
37
|
+
_IdentityDocument_validUntil.set(this, void 0);
|
|
38
|
+
if (skipDomainValidation === false) {
|
|
39
|
+
IdentityDocument.validateIdentityDocument(value, propertyName);
|
|
40
|
+
}
|
|
41
|
+
__classPrivateFieldSet(this, _IdentityDocument_type, value.type.trim().toUpperCase(), "f");
|
|
42
|
+
__classPrivateFieldSet(this, _IdentityDocument_number, value.number.trim(), "f");
|
|
43
|
+
__classPrivateFieldSet(this, _IdentityDocument_country, value.country.trim().toUpperCase(), "f");
|
|
44
|
+
__classPrivateFieldSet(this, _IdentityDocument_issuedBy, value.issuedBy?.trim() || null, "f");
|
|
45
|
+
__classPrivateFieldSet(this, _IdentityDocument_validFrom, value.validFrom?.trim() || null, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _IdentityDocument_validUntil, value.validUntil?.trim() || null, "f");
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validación estática para reutilización en factory methods y constructores.
|
|
50
|
+
*/
|
|
51
|
+
static validateIdentityDocument(value, propertyName) {
|
|
52
|
+
this.guardAgainstInvalidType(value, propertyName);
|
|
53
|
+
this.guardAgainstInvalidDocumentType(value.type);
|
|
54
|
+
this.guardAgainstInvalidNumber(value.number);
|
|
55
|
+
this.guardAgainstInvalidCountryCode(value.country);
|
|
56
|
+
this.guardAgainstInvalidIssuedBy(value.issuedBy);
|
|
57
|
+
this.guardAgainstInvalidValidFrom(value.validFrom);
|
|
58
|
+
this.guardAgainstInvalidValidUntil(value.validUntil);
|
|
59
|
+
this.guardAgainstInvalidDateRange(value.validFrom, value.validUntil);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Valida que el objeto tenga la estructura correcta.
|
|
63
|
+
*/
|
|
64
|
+
static guardAgainstInvalidType(value, propertyName) {
|
|
65
|
+
if (!value || typeof value !== 'object') {
|
|
66
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'IdentityDocument object', typeof value);
|
|
67
|
+
}
|
|
68
|
+
if (typeof value.type !== 'string') {
|
|
69
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('type', 'string', typeof value.type);
|
|
70
|
+
}
|
|
71
|
+
if (typeof value.number !== 'string') {
|
|
72
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('number', 'string', typeof value.number);
|
|
73
|
+
}
|
|
74
|
+
if (typeof value.country !== 'string') {
|
|
75
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('country', 'string', typeof value.country);
|
|
76
|
+
}
|
|
77
|
+
if (value.issuedBy !== null && typeof value.issuedBy !== 'string') {
|
|
78
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('issuedBy', 'string | null', typeof value.issuedBy);
|
|
79
|
+
}
|
|
80
|
+
if (value.validFrom !== null && typeof value.validFrom !== 'string') {
|
|
81
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('validFrom', 'string | null', typeof value.validFrom);
|
|
82
|
+
}
|
|
83
|
+
if (value.validUntil !== null && typeof value.validUntil !== 'string') {
|
|
84
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('validUntil', 'string | null', typeof value.validUntil);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Valida que el tipo de documento de identidad sea válido.
|
|
89
|
+
*/
|
|
90
|
+
static guardAgainstInvalidDocumentType(type) {
|
|
91
|
+
const trimmedType = type.trim().toUpperCase();
|
|
92
|
+
if (trimmedType.length === 0) {
|
|
93
|
+
throw InvalidIdentityDocumentTypeError_1.InvalidIdentityDocumentTypeError.create('empty identity document type', this.VALID_TYPES);
|
|
94
|
+
}
|
|
95
|
+
if (!this.VALID_TYPES.includes(trimmedType)) {
|
|
96
|
+
throw InvalidIdentityDocumentTypeError_1.InvalidIdentityDocumentTypeError.create(trimmedType, this.VALID_TYPES);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Valida el número del documento de identidad (no vacío y dentro de los límites de longitud).
|
|
101
|
+
*/
|
|
102
|
+
static guardAgainstInvalidNumber(number) {
|
|
103
|
+
const trimmedNumber = number.trim();
|
|
104
|
+
if (trimmedNumber.length === 0) {
|
|
105
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('number', 'non-empty identity document number', 'empty string');
|
|
106
|
+
}
|
|
107
|
+
if (trimmedNumber.length < this.MIN_NUMBER_LENGTH || trimmedNumber.length > this.MAX_NUMBER_LENGTH) {
|
|
108
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('number', `identity document number with length between ${this.MIN_NUMBER_LENGTH} and ${this.MAX_NUMBER_LENGTH}`, `length ${trimmedNumber.length}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Valida el código de país según los valores permitidos en el enum CountryCode.
|
|
113
|
+
*/
|
|
114
|
+
static guardAgainstInvalidCountryCode(country) {
|
|
115
|
+
const trimmedCountry = country.trim().toUpperCase();
|
|
116
|
+
if (trimmedCountry.length === 0) {
|
|
117
|
+
throw InvalidCountryCodeError_1.InvalidCountryCodeError.create('empty country code');
|
|
118
|
+
}
|
|
119
|
+
if (!this.VALID_COUNTRY_CODES.includes(trimmedCountry)) {
|
|
120
|
+
throw InvalidCountryCodeError_1.InvalidCountryCodeError.create(trimmedCountry);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Valida la entidad emisora si está presente.
|
|
125
|
+
*/
|
|
126
|
+
static guardAgainstInvalidIssuedBy(issuedBy) {
|
|
127
|
+
if (issuedBy !== null) {
|
|
128
|
+
String_1.String.guardAgainstEmptyValue(issuedBy, 'issuedBy');
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Valida la fecha de inicio de validez si está presente.
|
|
133
|
+
*/
|
|
134
|
+
static guardAgainstInvalidValidFrom(validFrom) {
|
|
135
|
+
if (validFrom !== null) {
|
|
136
|
+
if (!NullableDate_1.NullableDate.isValidNullableDate(validFrom)) {
|
|
137
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('validFrom', 'valid date string (DD/MM/YYYY)', validFrom);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Valida la fecha de fin de validez si está presente.
|
|
143
|
+
*/
|
|
144
|
+
static guardAgainstInvalidValidUntil(validUntil) {
|
|
145
|
+
if (validUntil !== null) {
|
|
146
|
+
if (!NullableDate_1.NullableDate.isValidNullableDate(validUntil)) {
|
|
147
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('validUntil', 'valid date string (DD/MM/YYYY)', validUntil);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Valida que el rango de fechas sea consistente.
|
|
153
|
+
*/
|
|
154
|
+
static guardAgainstInvalidDateRange(validFrom, validUntil) {
|
|
155
|
+
if (validFrom && validUntil) {
|
|
156
|
+
const fromDate = this.parseDate(validFrom);
|
|
157
|
+
const untilDate = this.parseDate(validUntil);
|
|
158
|
+
if (fromDate >= untilDate) {
|
|
159
|
+
throw InvalidDateRangeError_1.InvalidDateRangeError.create(validFrom, validUntil);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Método auxiliar para parsear fechas en formato DD/MM/YYYY.
|
|
165
|
+
*/
|
|
166
|
+
static parseDate(dateString) {
|
|
167
|
+
const [day, month, year] = dateString.split('/').map(Number);
|
|
168
|
+
return new Date(year, month - 1, day);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Tipo de documento de identidad (CC, CE, PASSPORT, DNI).
|
|
172
|
+
*/
|
|
173
|
+
get type() {
|
|
174
|
+
return __classPrivateFieldGet(this, _IdentityDocument_type, "f");
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Número del documento de identidad.
|
|
178
|
+
*/
|
|
179
|
+
get number() {
|
|
180
|
+
return __classPrivateFieldGet(this, _IdentityDocument_number, "f");
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* País de emisión del documento.
|
|
184
|
+
*/
|
|
185
|
+
get country() {
|
|
186
|
+
return __classPrivateFieldGet(this, _IdentityDocument_country, "f");
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Entidad emisora del documento (opcional).
|
|
190
|
+
*/
|
|
191
|
+
get issuedBy() {
|
|
192
|
+
return __classPrivateFieldGet(this, _IdentityDocument_issuedBy, "f");
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Fecha de inicio de validez (opcional).
|
|
196
|
+
*/
|
|
197
|
+
get validFrom() {
|
|
198
|
+
return __classPrivateFieldGet(this, _IdentityDocument_validFrom, "f");
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Fecha de fin de validez (opcional).
|
|
202
|
+
*/
|
|
203
|
+
get validUntil() {
|
|
204
|
+
return __classPrivateFieldGet(this, _IdentityDocument_validUntil, "f");
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Verifica si el documento de identidad tiene entidad emisora.
|
|
208
|
+
*/
|
|
209
|
+
hasIssuedBy() {
|
|
210
|
+
return __classPrivateFieldGet(this, _IdentityDocument_issuedBy, "f") !== null;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Verifica si el documento de identidad tiene fechas de validez.
|
|
214
|
+
*/
|
|
215
|
+
hasValidityPeriod() {
|
|
216
|
+
return __classPrivateFieldGet(this, _IdentityDocument_validFrom, "f") !== null || __classPrivateFieldGet(this, _IdentityDocument_validUntil, "f") !== null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Verifica si el documento de identidad está actualmente válido.
|
|
220
|
+
*/
|
|
221
|
+
isCurrentlyValid() {
|
|
222
|
+
const now = new Date();
|
|
223
|
+
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
224
|
+
if (__classPrivateFieldGet(this, _IdentityDocument_validFrom, "f")) {
|
|
225
|
+
const fromDate = IdentityDocument.parseDate(__classPrivateFieldGet(this, _IdentityDocument_validFrom, "f"));
|
|
226
|
+
if (today < fromDate) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (__classPrivateFieldGet(this, _IdentityDocument_validUntil, "f")) {
|
|
231
|
+
const untilDate = IdentityDocument.parseDate(__classPrivateFieldGet(this, _IdentityDocument_validUntil, "f"));
|
|
232
|
+
if (today > untilDate) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Verifica si el documento de identidad será válido en una fecha específica.
|
|
240
|
+
*/
|
|
241
|
+
isValidOnDate(date) {
|
|
242
|
+
const checkDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
243
|
+
if (__classPrivateFieldGet(this, _IdentityDocument_validFrom, "f")) {
|
|
244
|
+
const fromDate = IdentityDocument.parseDate(__classPrivateFieldGet(this, _IdentityDocument_validFrom, "f"));
|
|
245
|
+
if (checkDate < fromDate) {
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (__classPrivateFieldGet(this, _IdentityDocument_validUntil, "f")) {
|
|
250
|
+
const untilDate = IdentityDocument.parseDate(__classPrivateFieldGet(this, _IdentityDocument_validUntil, "f"));
|
|
251
|
+
if (checkDate > untilDate) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Verifica si pertenece a un país específico.
|
|
259
|
+
*/
|
|
260
|
+
belongsToCountry(countryCode) {
|
|
261
|
+
return __classPrivateFieldGet(this, _IdentityDocument_country, "f") === countryCode.trim().toUpperCase();
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Verifica si es del mismo tipo que otro documento de identidad.
|
|
265
|
+
*/
|
|
266
|
+
isSameType(other) {
|
|
267
|
+
return __classPrivateFieldGet(this, _IdentityDocument_type, "f") === __classPrivateFieldGet(other, _IdentityDocument_type, "f");
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Compara la igualdad semántica con otro objeto IdentityDocument.
|
|
271
|
+
*/
|
|
272
|
+
equals(other) {
|
|
273
|
+
if (!(other instanceof IdentityDocument)) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
return (__classPrivateFieldGet(this, _IdentityDocument_type, "f") === __classPrivateFieldGet(other, _IdentityDocument_type, "f")
|
|
277
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_number, "f") === __classPrivateFieldGet(other, _IdentityDocument_number, "f")
|
|
278
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_country, "f") === __classPrivateFieldGet(other, _IdentityDocument_country, "f")
|
|
279
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_issuedBy, "f") === __classPrivateFieldGet(other, _IdentityDocument_issuedBy, "f")
|
|
280
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_validFrom, "f") === __classPrivateFieldGet(other, _IdentityDocument_validFrom, "f")
|
|
281
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_validUntil, "f") === __classPrivateFieldGet(other, _IdentityDocument_validUntil, "f"));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Compara si dos documentos de identidad representan el mismo número
|
|
285
|
+
* independientemente de fechas de validez y entidad emisora.
|
|
286
|
+
*/
|
|
287
|
+
hasSameIdentifier(other) {
|
|
288
|
+
if (!(other instanceof IdentityDocument)) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
return (__classPrivateFieldGet(this, _IdentityDocument_type, "f") === __classPrivateFieldGet(other, _IdentityDocument_type, "f")
|
|
292
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_number, "f") === __classPrivateFieldGet(other, _IdentityDocument_number, "f")
|
|
293
|
+
&& __classPrivateFieldGet(this, _IdentityDocument_country, "f") === __classPrivateFieldGet(other, _IdentityDocument_country, "f"));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Convierte a representación primitiva para persistencia.
|
|
297
|
+
*/
|
|
298
|
+
toPrimitives() {
|
|
299
|
+
return {
|
|
300
|
+
type: __classPrivateFieldGet(this, _IdentityDocument_type, "f"),
|
|
301
|
+
number: __classPrivateFieldGet(this, _IdentityDocument_number, "f"),
|
|
302
|
+
country: __classPrivateFieldGet(this, _IdentityDocument_country, "f"),
|
|
303
|
+
issuedBy: __classPrivateFieldGet(this, _IdentityDocument_issuedBy, "f"),
|
|
304
|
+
validFrom: __classPrivateFieldGet(this, _IdentityDocument_validFrom, "f"),
|
|
305
|
+
validUntil: __classPrivateFieldGet(this, _IdentityDocument_validUntil, "f"),
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Representación como string.
|
|
310
|
+
*/
|
|
311
|
+
toString() {
|
|
312
|
+
return `${__classPrivateFieldGet(this, _IdentityDocument_type, "f")}-${__classPrivateFieldGet(this, _IdentityDocument_number, "f")}-${__classPrivateFieldGet(this, _IdentityDocument_country, "f")}`;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Representación JSON para serialización.
|
|
316
|
+
*/
|
|
317
|
+
toJSON() {
|
|
318
|
+
return this.toPrimitives();
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Método de utilidad para validar completamente un IdentityDocument antes de crear la instancia.
|
|
322
|
+
*/
|
|
323
|
+
static validateCompletely(value, propertyName = this.DEFAULT_PROPERTY_NAME) {
|
|
324
|
+
this.validateIdentityDocument(value, propertyName);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.IdentityDocument = IdentityDocument;
|
|
328
|
+
_IdentityDocument_type = new WeakMap(), _IdentityDocument_number = new WeakMap(), _IdentityDocument_country = new WeakMap(), _IdentityDocument_issuedBy = new WeakMap(), _IdentityDocument_validFrom = new WeakMap(), _IdentityDocument_validUntil = new WeakMap();
|
|
329
|
+
IdentityDocument.DEFAULT_PROPERTY_NAME = 'identityDocument';
|
|
330
|
+
// Tipos de documento de identidad válidos
|
|
331
|
+
IdentityDocument.VALID_TYPES = Object.values(IdentityDocumentType_1.IdentityDocumentType);
|
|
332
|
+
// Códigos de país válidos
|
|
333
|
+
IdentityDocument.VALID_COUNTRY_CODES = Object.values(CountryCode_1.CountryCode);
|
|
334
|
+
// Límites de longitud del número de documento (cédula, pasaporte, DNI, etc.)
|
|
335
|
+
IdentityDocument.MIN_NUMBER_LENGTH = 3;
|
|
336
|
+
IdentityDocument.MAX_NUMBER_LENGTH = 20;
|
|
@@ -34,6 +34,7 @@ const CarbonClientPrimaryContactPhone_1 = require("../value-objects/CarbonClient
|
|
|
34
34
|
const CarbonClientRoleType_1 = require("../value-objects/CarbonClientRoleType");
|
|
35
35
|
const CarbonClientSupervisedByStakeholder_1 = require("../value-objects/CarbonClientSupervisedByStakeholder");
|
|
36
36
|
const CarbonClientTaxIdentification_1 = require("../value-objects/CarbonClientTaxIdentification");
|
|
37
|
+
const CarbonClientIdentityDocument_1 = require("../value-objects/CarbonClientIdentityDocument");
|
|
37
38
|
const CarbonClientUserType_1 = require("../value-objects/CarbonClientUserType");
|
|
38
39
|
const CarbonClientWebsiteUrl_1 = require("../value-objects/CarbonClientWebsiteUrl");
|
|
39
40
|
class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
@@ -56,9 +57,16 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
56
57
|
const lastAccessAt = skipDomainValidation
|
|
57
58
|
? CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
|
|
58
59
|
: CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
59
|
-
const taxIdentification =
|
|
60
|
-
?
|
|
61
|
-
:
|
|
60
|
+
const taxIdentification = props.taxIdentification === null
|
|
61
|
+
? null
|
|
62
|
+
: (skipDomainValidation
|
|
63
|
+
? CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
|
|
64
|
+
: CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives());
|
|
65
|
+
const identityDocument = props.identityDocument === null
|
|
66
|
+
? null
|
|
67
|
+
: (skipDomainValidation
|
|
68
|
+
? CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.fromPrimitives(props.identityDocument).toPrimitives()
|
|
69
|
+
: CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.create(props.identityDocument).toPrimitives());
|
|
62
70
|
const roleType = skipDomainValidation
|
|
63
71
|
? CarbonClientRoleType_1.CarbonClientRoleType.fromPrimitives(props.roleType).toEnum()
|
|
64
72
|
: CarbonClientRoleType_1.CarbonClientRoleType.create(props.roleType).toEnum();
|
|
@@ -79,6 +87,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
79
87
|
displayName,
|
|
80
88
|
lastAccessAt,
|
|
81
89
|
taxIdentification,
|
|
90
|
+
identityDocument,
|
|
82
91
|
roleType,
|
|
83
92
|
businessStatus,
|
|
84
93
|
userType,
|
|
@@ -134,6 +143,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
134
143
|
displayName: primitives.displayName,
|
|
135
144
|
lastAccessAt: primitives.lastAccessAt,
|
|
136
145
|
taxIdentification: primitives.taxIdentification,
|
|
146
|
+
identityDocument: primitives.identityDocument,
|
|
137
147
|
roleType: primitives.roleType,
|
|
138
148
|
businessStatus: primitives.businessStatus,
|
|
139
149
|
userType: primitives.userType,
|
|
@@ -159,7 +169,12 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
159
169
|
const email = CarbonClientEmail_1.CarbonClientEmail.create(props.email).toPrimitives();
|
|
160
170
|
const displayName = CarbonClientDisplayName_1.CarbonClientDisplayName.create(props.displayName).toPrimitives();
|
|
161
171
|
const lastAccessAt = CarbonClientLastAccessAt_1.CarbonClientLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
162
|
-
const taxIdentification =
|
|
172
|
+
const taxIdentification = props.taxIdentification === null
|
|
173
|
+
? null
|
|
174
|
+
: CarbonClientTaxIdentification_1.CarbonClientTaxIdentification.create(props.taxIdentification).toPrimitives();
|
|
175
|
+
const identityDocument = props.identityDocument === null
|
|
176
|
+
? null
|
|
177
|
+
: CarbonClientIdentityDocument_1.CarbonClientIdentityDocument.create(props.identityDocument).toPrimitives();
|
|
163
178
|
const roleType = CarbonClientRoleType_1.CarbonClientRoleType.create(props.roleType).toEnum();
|
|
164
179
|
const businessStatus = CarbonClientBusinessStatus_1.CarbonClientBusinessStatus.create(props.businessStatus).toEnum();
|
|
165
180
|
const userType = CarbonClientUserType_1.CarbonClientUserType.create(props.userType).toEnum();
|
|
@@ -182,6 +197,7 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
182
197
|
displayName,
|
|
183
198
|
lastAccessAt,
|
|
184
199
|
taxIdentification,
|
|
200
|
+
identityDocument,
|
|
185
201
|
roleType,
|
|
186
202
|
businessStatus,
|
|
187
203
|
userType,
|
|
@@ -212,7 +228,8 @@ class CarbonClient extends Stakeholder_1.Stakeholder {
|
|
|
212
228
|
businessStatus: this.businessStatus.toEnum(),
|
|
213
229
|
userType: this.userType.toEnum(),
|
|
214
230
|
legalBusinessName: this.legalBusinessName.toPrimitives(),
|
|
215
|
-
taxIdentification: this.taxIdentification
|
|
231
|
+
taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
|
|
232
|
+
identityDocument: this.identityDocument?.toPrimitives() ?? null,
|
|
216
233
|
industryType: this.industryType.toPrimitives(),
|
|
217
234
|
organizationSize: this.organizationSize.toEnum(),
|
|
218
235
|
physicalAddress: this.physicalAddress.toPrimitives(),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarbonClientIdentityDocument = void 0;
|
|
4
|
+
const StakeholderIdentityDocument_1 = require("../../../shared/domain/value-objects/StakeholderIdentityDocument");
|
|
5
|
+
class CarbonClientIdentityDocument extends StakeholderIdentityDocument_1.StakeholderIdentityDocument {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CarbonClientIdentityDocument(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitives) {
|
|
13
|
+
const value = {
|
|
14
|
+
country: primitives.country,
|
|
15
|
+
issuedBy: primitives.issuedBy,
|
|
16
|
+
number: primitives.number,
|
|
17
|
+
type: primitives.type,
|
|
18
|
+
validFrom: primitives.validFrom,
|
|
19
|
+
validUntil: primitives.validUntil,
|
|
20
|
+
};
|
|
21
|
+
return new CarbonClientIdentityDocument(value, true);
|
|
22
|
+
}
|
|
23
|
+
toPrimitives() {
|
|
24
|
+
return this.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.CarbonClientIdentityDocument = CarbonClientIdentityDocument;
|
|
@@ -30,6 +30,7 @@ const CarbonCoordinatorPermissions_1 = require("../value-objects/CarbonCoordinat
|
|
|
30
30
|
const CarbonCoordinatorReportsToStakeholder_1 = require("../value-objects/CarbonCoordinatorReportsToStakeholder");
|
|
31
31
|
const CarbonCoordinatorRoleType_1 = require("../value-objects/CarbonCoordinatorRoleType");
|
|
32
32
|
const CarbonCoordinatorTaxIdentification_1 = require("../value-objects/CarbonCoordinatorTaxIdentification");
|
|
33
|
+
const CarbonCoordinatorIdentityDocument_1 = require("../value-objects/CarbonCoordinatorIdentityDocument");
|
|
33
34
|
const CarbonCoordinatorUserType_1 = require("../value-objects/CarbonCoordinatorUserType");
|
|
34
35
|
const CarbonCoordinatorWeeklyWorkingSchedule_1 = require("../value-objects/CarbonCoordinatorWeeklyWorkingSchedule");
|
|
35
36
|
class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
@@ -52,9 +53,16 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
52
53
|
const lastAccessAt = skipDomainValidation
|
|
53
54
|
? CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
|
|
54
55
|
: CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
55
|
-
const taxIdentification =
|
|
56
|
-
?
|
|
57
|
-
:
|
|
56
|
+
const taxIdentification = props.taxIdentification === null
|
|
57
|
+
? null
|
|
58
|
+
: (skipDomainValidation
|
|
59
|
+
? CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
|
|
60
|
+
: CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives());
|
|
61
|
+
const identityDocument = props.identityDocument === null
|
|
62
|
+
? null
|
|
63
|
+
: (skipDomainValidation
|
|
64
|
+
? CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.fromPrimitives(props.identityDocument).toPrimitives()
|
|
65
|
+
: CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.create(props.identityDocument).toPrimitives());
|
|
58
66
|
const roleType = skipDomainValidation
|
|
59
67
|
? CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.fromPrimitives(props.roleType).toEnum()
|
|
60
68
|
: CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.create(props.roleType).toEnum();
|
|
@@ -75,6 +83,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
75
83
|
displayName,
|
|
76
84
|
lastAccessAt,
|
|
77
85
|
taxIdentification,
|
|
86
|
+
identityDocument,
|
|
78
87
|
roleType,
|
|
79
88
|
businessStatus,
|
|
80
89
|
userType,
|
|
@@ -118,6 +127,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
118
127
|
displayName: primitives.displayName,
|
|
119
128
|
lastAccessAt: primitives.lastAccessAt,
|
|
120
129
|
taxIdentification: primitives.taxIdentification,
|
|
130
|
+
identityDocument: primitives.identityDocument,
|
|
121
131
|
roleType: primitives.roleType,
|
|
122
132
|
businessStatus: primitives.businessStatus,
|
|
123
133
|
userType: primitives.userType,
|
|
@@ -139,7 +149,12 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
139
149
|
const email = CarbonCoordinatorEmail_1.CarbonCoordinatorEmail.create(props.email).toPrimitives();
|
|
140
150
|
const displayName = CarbonCoordinatorDisplayName_1.CarbonCoordinatorDisplayName.create(props.displayName).toPrimitives();
|
|
141
151
|
const lastAccessAt = CarbonCoordinatorLastAccessAt_1.CarbonCoordinatorLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
142
|
-
const taxIdentification =
|
|
152
|
+
const taxIdentification = props.taxIdentification === null
|
|
153
|
+
? null
|
|
154
|
+
: CarbonCoordinatorTaxIdentification_1.CarbonCoordinatorTaxIdentification.create(props.taxIdentification).toPrimitives();
|
|
155
|
+
const identityDocument = props.identityDocument === null
|
|
156
|
+
? null
|
|
157
|
+
: CarbonCoordinatorIdentityDocument_1.CarbonCoordinatorIdentityDocument.create(props.identityDocument).toPrimitives();
|
|
143
158
|
const roleType = CarbonCoordinatorRoleType_1.CarbonCoordinatorRoleType.create(props.roleType).toEnum();
|
|
144
159
|
const businessStatus = CarbonCoordinatorBusinessStatus_1.CarbonCoordinatorBusinessStatus.create(props.businessStatus).toEnum();
|
|
145
160
|
const userType = CarbonCoordinatorUserType_1.CarbonCoordinatorUserType.create(props.userType).toEnum();
|
|
@@ -158,6 +173,7 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
158
173
|
displayName,
|
|
159
174
|
lastAccessAt,
|
|
160
175
|
taxIdentification,
|
|
176
|
+
identityDocument,
|
|
161
177
|
roleType,
|
|
162
178
|
businessStatus,
|
|
163
179
|
userType,
|
|
@@ -183,7 +199,8 @@ class CarbonCoordinator extends Stakeholder_1.Stakeholder {
|
|
|
183
199
|
roleType: this.roleType.toEnum(),
|
|
184
200
|
businessStatus: this.businessStatus.toEnum(),
|
|
185
201
|
userType: this.userType.toEnum(),
|
|
186
|
-
taxIdentification: this.taxIdentification
|
|
202
|
+
taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
|
|
203
|
+
identityDocument: this.identityDocument?.toPrimitives() ?? null,
|
|
187
204
|
availabilityStatus: __classPrivateFieldGet(this, _CarbonCoordinator_availabilityStatus, "f").toEnum(),
|
|
188
205
|
weeklyWorkingSchedule: __classPrivateFieldGet(this, _CarbonCoordinator_weeklyWorkingSchedule, "f").toPrimitives(),
|
|
189
206
|
gender: __classPrivateFieldGet(this, _CarbonCoordinator_gender, "f").toEnum(),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarbonCoordinatorIdentityDocument = void 0;
|
|
4
|
+
const StakeholderIdentityDocument_1 = require("../../../shared/domain/value-objects/StakeholderIdentityDocument");
|
|
5
|
+
class CarbonCoordinatorIdentityDocument extends StakeholderIdentityDocument_1.StakeholderIdentityDocument {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CarbonCoordinatorIdentityDocument(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitives) {
|
|
13
|
+
const value = {
|
|
14
|
+
country: primitives.country,
|
|
15
|
+
issuedBy: primitives.issuedBy,
|
|
16
|
+
number: primitives.number,
|
|
17
|
+
type: primitives.type,
|
|
18
|
+
validFrom: primitives.validFrom,
|
|
19
|
+
validUntil: primitives.validUntil,
|
|
20
|
+
};
|
|
21
|
+
return new CarbonCoordinatorIdentityDocument(value, true);
|
|
22
|
+
}
|
|
23
|
+
toPrimitives() {
|
|
24
|
+
return this.value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.CarbonCoordinatorIdentityDocument = CarbonCoordinatorIdentityDocument;
|
|
@@ -34,9 +34,13 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
34
34
|
const lastAccessAt = skipDomainValidation
|
|
35
35
|
? CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.fromPrimitives(props.lastAccessAt).toPrimitives()
|
|
36
36
|
: CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
// USR-020: Host conserva taxIdentification (a nivel app sigue requerido); identityDocument
|
|
38
|
+
// no aplica al Host (siempre null). El tipo base es nullable, de ahí el manejo defensivo.
|
|
39
|
+
const taxIdentification = props.taxIdentification === null
|
|
40
|
+
? null
|
|
41
|
+
: (skipDomainValidation
|
|
42
|
+
? CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.fromPrimitives(props.taxIdentification).toPrimitives()
|
|
43
|
+
: CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives());
|
|
40
44
|
const roleType = skipDomainValidation
|
|
41
45
|
? CarbonHostRoleType_1.CarbonHostRoleType.fromPrimitives(props.roleType).toEnum()
|
|
42
46
|
: CarbonHostRoleType_1.CarbonHostRoleType.create(props.roleType).toEnum();
|
|
@@ -57,6 +61,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
57
61
|
displayName,
|
|
58
62
|
lastAccessAt,
|
|
59
63
|
taxIdentification,
|
|
64
|
+
identityDocument: null,
|
|
60
65
|
roleType,
|
|
61
66
|
businessStatus,
|
|
62
67
|
userType,
|
|
@@ -76,6 +81,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
76
81
|
displayName: primitives.displayName,
|
|
77
82
|
lastAccessAt: primitives.lastAccessAt,
|
|
78
83
|
taxIdentification: primitives.taxIdentification,
|
|
84
|
+
identityDocument: primitives.identityDocument,
|
|
79
85
|
roleType: primitives.roleType,
|
|
80
86
|
businessStatus: primitives.businessStatus,
|
|
81
87
|
userType: primitives.userType,
|
|
@@ -91,7 +97,9 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
91
97
|
const email = CarbonHostEmail_1.CarbonHostEmail.create(props.email).toPrimitives();
|
|
92
98
|
const displayName = CarbonHostDisplayName_1.CarbonHostDisplayName.create(props.displayName).toPrimitives();
|
|
93
99
|
const lastAccessAt = CarbonHostLastAccessAt_1.CarbonHostLastAccessAt.create(props.lastAccessAt).toPrimitives();
|
|
94
|
-
const taxIdentification =
|
|
100
|
+
const taxIdentification = props.taxIdentification === null
|
|
101
|
+
? null
|
|
102
|
+
: CarbonHostTaxIdentification_1.CarbonHostTaxIdentification.create(props.taxIdentification).toPrimitives();
|
|
95
103
|
const roleType = CarbonHostRoleType_1.CarbonHostRoleType.create(props.roleType).toEnum();
|
|
96
104
|
const businessStatus = CarbonHostBusinessStatus_1.CarbonHostBusinessStatus.create(props.businessStatus).toEnum();
|
|
97
105
|
const userType = CarbonHostUserType_1.CarbonHostUserType.create(props.userType).toEnum();
|
|
@@ -104,6 +112,7 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
104
112
|
displayName,
|
|
105
113
|
lastAccessAt,
|
|
106
114
|
taxIdentification,
|
|
115
|
+
identityDocument: null,
|
|
107
116
|
roleType,
|
|
108
117
|
businessStatus,
|
|
109
118
|
userType,
|
|
@@ -123,7 +132,8 @@ class CarbonHost extends Stakeholder_1.Stakeholder {
|
|
|
123
132
|
roleType: this.roleType.toEnum(),
|
|
124
133
|
businessStatus: this.businessStatus.toEnum(),
|
|
125
134
|
userType: this.userType.toEnum(),
|
|
126
|
-
taxIdentification: this.taxIdentification
|
|
135
|
+
taxIdentification: this.taxIdentification?.toPrimitives() ?? null,
|
|
136
|
+
identityDocument: this.identityDocument?.toPrimitives() ?? null,
|
|
127
137
|
permissions: this.permissions.toEnums(),
|
|
128
138
|
preferredLocale: this.preferredLocale.toEnum(),
|
|
129
139
|
};
|