@carbonbox/domain 0.0.7 → 0.0.10

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.
Files changed (58) hide show
  1. package/build/carbonbox/shared/domain/value-objects/String.js +0 -3
  2. package/build/carbonbox/shared/domain/value-objects/Uuid.js +3 -0
  3. package/build/carbonbox/users/carbonBox/coordinator/domain/repository/ICoordinatorRepository.js +2 -0
  4. package/build/carbonbox/users/carbonBox/host/domain/repository/IHostRepository.js +2 -0
  5. package/build/carbonbox/users/carbonBox/host-manager/domain/repository/IHostManagerRepository.js +2 -0
  6. package/build/carbonbox/users/clients/company/domain/repository/ICompanyManagerRepository.js +2 -0
  7. package/build/carbonbox/users/clients/company/domain/repository/ICompanyRepository.js +2 -0
  8. package/build/carbonbox/users/clients/company-host-manager/domain/CompanyHostManager.js +126 -0
  9. package/build/carbonbox/users/clients/company-host-manager/domain/repository/ICompanyHostManagerRepository.js +2 -0
  10. package/build/carbonbox/users/clients/company-host-manager/domain/repository/IHostManagerRepository.js +2 -0
  11. package/build/carbonbox/users/shared/domain/exceptions/EmailAlreadyExistsError.js +19 -0
  12. package/build/carbonbox/users/shared/domain/services/EmailUniquenessValidatorDomainService.js +19 -0
  13. package/build/carbonbox/users/shared/domain/services/PasswordValueObjectCreationDomainService.js +20 -0
  14. package/build/carbonbox/users/shared/domain/services/SecurePasswordCreationDomainService.js +36 -0
  15. package/build/carbonbox/users/shared/domain/services/ports/IPasswordHashingDomainService.js +2 -0
  16. package/build/carbonbox/users/shared/domain/services/ports/IPasswordValueObjectCreationDomainService.js +2 -0
  17. package/build/carbonbox/users/shared/domain/value-objects/Password.js +2 -2
  18. package/build/main/index.js +256 -11
  19. package/build/types/carbonbox/shared/domain/value-objects/DateString.d.ts.map +1 -1
  20. package/build/types/carbonbox/shared/domain/value-objects/String.d.ts +0 -1
  21. package/build/types/carbonbox/shared/domain/value-objects/String.d.ts.map +1 -1
  22. package/build/types/carbonbox/shared/domain/value-objects/Uuid.d.ts +1 -0
  23. package/build/types/carbonbox/shared/domain/value-objects/Uuid.d.ts.map +1 -1
  24. package/build/types/carbonbox/users/carbonBox/coordinator/domain/repository/ICoordinatorRepository.d.ts +11 -0
  25. package/build/types/carbonbox/users/carbonBox/coordinator/domain/repository/ICoordinatorRepository.d.ts.map +1 -0
  26. package/build/types/carbonbox/users/carbonBox/host/domain/repository/IHostRepository.d.ts +11 -0
  27. package/build/types/carbonbox/users/carbonBox/host/domain/repository/IHostRepository.d.ts.map +1 -0
  28. package/build/types/carbonbox/users/carbonBox/host-manager/domain/repository/IHostManagerRepository.d.ts +11 -0
  29. package/build/types/carbonbox/users/carbonBox/host-manager/domain/repository/IHostManagerRepository.d.ts.map +1 -0
  30. package/build/types/carbonbox/users/clients/company/domain/repository/ICompanyManagerRepository.d.ts +11 -0
  31. package/build/types/carbonbox/users/clients/company/domain/repository/ICompanyManagerRepository.d.ts.map +1 -0
  32. package/build/types/carbonbox/users/clients/company/domain/repository/ICompanyRepository.d.ts +11 -0
  33. package/build/types/carbonbox/users/clients/company/domain/repository/ICompanyRepository.d.ts.map +1 -0
  34. package/build/types/carbonbox/users/clients/company-host-manager/domain/CompanyHostManager.d.ts +44 -0
  35. package/build/types/carbonbox/users/clients/company-host-manager/domain/CompanyHostManager.d.ts.map +1 -0
  36. package/build/types/carbonbox/users/clients/company-host-manager/domain/repository/ICompanyHostManagerRepository.d.ts +11 -0
  37. package/build/types/carbonbox/users/clients/company-host-manager/domain/repository/ICompanyHostManagerRepository.d.ts.map +1 -0
  38. package/build/types/carbonbox/users/clients/company-host-manager/domain/repository/IHostManagerRepository.d.ts +11 -0
  39. package/build/types/carbonbox/users/clients/company-host-manager/domain/repository/IHostManagerRepository.d.ts.map +1 -0
  40. package/build/types/carbonbox/users/shared/domain/AnySystemUserType.d.ts +1 -1
  41. package/build/types/carbonbox/users/shared/domain/AnySystemUserType.d.ts.map +1 -1
  42. package/build/types/carbonbox/users/shared/domain/exceptions/EmailAlreadyExistsError.d.ts +8 -0
  43. package/build/types/carbonbox/users/shared/domain/exceptions/EmailAlreadyExistsError.d.ts.map +1 -0
  44. package/build/types/carbonbox/users/shared/domain/services/EmailUniquenessValidatorDomainService.d.ts +18 -0
  45. package/build/types/carbonbox/users/shared/domain/services/EmailUniquenessValidatorDomainService.d.ts.map +1 -0
  46. package/build/types/carbonbox/users/shared/domain/services/PasswordValueObjectCreationDomainService.d.ts +14 -0
  47. package/build/types/carbonbox/users/shared/domain/services/PasswordValueObjectCreationDomainService.d.ts.map +1 -0
  48. package/build/types/carbonbox/users/shared/domain/services/SecurePasswordCreationDomainService.d.ts +16 -0
  49. package/build/types/carbonbox/users/shared/domain/services/SecurePasswordCreationDomainService.d.ts.map +1 -0
  50. package/build/types/carbonbox/users/shared/domain/services/ports/IPasswordHashingDomainService.d.ts +5 -0
  51. package/build/types/carbonbox/users/shared/domain/services/ports/IPasswordHashingDomainService.d.ts.map +1 -0
  52. package/build/types/carbonbox/users/shared/domain/services/ports/IPasswordValueObjectCreationDomainService.d.ts +5 -0
  53. package/build/types/carbonbox/users/shared/domain/services/ports/IPasswordValueObjectCreationDomainService.d.ts.map +1 -0
  54. package/build/types/carbonbox/users/shared/domain/value-objects/Password.d.ts +1 -1
  55. package/build/types/carbonbox/users/shared/domain/value-objects/Password.d.ts.map +1 -1
  56. package/build/types/main/index.d.ts +139 -5
  57. package/build/types/main/index.d.ts.map +1 -1
  58. package/package.json +1 -1
@@ -8,9 +8,6 @@ class String extends PrimitiveValueObject_1.PrimitiveValueObject {
8
8
  super(value, propertyName, 'string');
9
9
  String.ensureValidType(value, propertyName);
10
10
  }
11
- static create(value, propertyName) {
12
- return new this(value, propertyName);
13
- }
14
11
  static ensureValidType(value, propertyName) {
15
12
  if (typeof value !== 'string') {
16
13
  throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'string', typeof value);
@@ -8,6 +8,9 @@ class Uuid extends String_1.String {
8
8
  super(value, propertyName);
9
9
  Uuid.ensureIsValidUuid(value);
10
10
  }
11
+ static create(value, propertyName) {
12
+ return new this(value, propertyName);
13
+ }
11
14
  static ensureIsValidUuid(id) {
12
15
  if (!Uuid.UUID_REGEX.test(id)) {
13
16
  throw InvalidDomainIdError_1.InvalidDomainIdError.create(id);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,126 @@
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 _CompanyHostManager__officialName, _CompanyHostManager__taxIdentificationNumber, _CompanyHostManager__activeCustomPlanId, _CompanyHostManager__phone, _CompanyHostManager__workLocation, _CompanyHostManager__avatar, _CompanyHostManager__biography;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CompanyHostManager = void 0;
16
+ const User_1 = require("../../../shared/domain/User");
17
+ const ActiveCustomPlanId_1 = require("./value-objects/ActiveCustomPlanId");
18
+ const Avatar_1 = require("./value-objects/Avatar");
19
+ const Biography_1 = require("./value-objects/Biography");
20
+ const CreatedAt_1 = require("./value-objects/CreatedAt");
21
+ const Email_1 = require("./value-objects/Email");
22
+ const Id_1 = require("./value-objects/Id");
23
+ const OfficialName_1 = require("./value-objects/OfficialName");
24
+ const Password_1 = require("./value-objects/Password");
25
+ const Phone_1 = require("./value-objects/Phone");
26
+ const Roles_1 = require("./value-objects/Roles");
27
+ const TaxIdentificationNumber_1 = require("./value-objects/TaxIdentificationNumber");
28
+ const UpdatedAt_1 = require("./value-objects/UpdatedAt");
29
+ const UserType_1 = require("./value-objects/UserType");
30
+ const WorkLocation_1 = require("./value-objects/WorkLocation");
31
+ class CompanyHostManager extends User_1.User {
32
+ constructor(props) {
33
+ const id = Id_1.Id.create(props.id);
34
+ const createdAt = CreatedAt_1.CreatedAt.create(props.createdAt);
35
+ const updatedAt = UpdatedAt_1.UpdatedAt.create(props.createdAt);
36
+ const email = Email_1.Email.create(props.email);
37
+ const userType = UserType_1.UserType.create(props.userType);
38
+ const roles = Roles_1.Roles.create(props.roles);
39
+ const password = Password_1.Password.create(props.password);
40
+ super({
41
+ id: id.value,
42
+ createdAt: createdAt.value,
43
+ updatedAt: updatedAt.value,
44
+ email: email.value,
45
+ userType: userType.value,
46
+ roles: roles.value,
47
+ password: password.value,
48
+ });
49
+ _CompanyHostManager__officialName.set(this, void 0);
50
+ _CompanyHostManager__taxIdentificationNumber.set(this, void 0);
51
+ _CompanyHostManager__activeCustomPlanId.set(this, void 0);
52
+ _CompanyHostManager__phone.set(this, void 0);
53
+ _CompanyHostManager__workLocation.set(this, void 0);
54
+ _CompanyHostManager__avatar.set(this, void 0);
55
+ _CompanyHostManager__biography.set(this, void 0);
56
+ __classPrivateFieldSet(this, _CompanyHostManager__officialName, OfficialName_1.OfficialName.create(props.officialName), "f");
57
+ __classPrivateFieldSet(this, _CompanyHostManager__taxIdentificationNumber, TaxIdentificationNumber_1.TaxIdentificationNumber.create(props.taxIdentificationNumber), "f");
58
+ __classPrivateFieldSet(this, _CompanyHostManager__activeCustomPlanId, ActiveCustomPlanId_1.ActiveCustomPlanId.create(props.activeCustomPlanId), "f");
59
+ __classPrivateFieldSet(this, _CompanyHostManager__phone, Phone_1.Phone.create(props.phone), "f");
60
+ __classPrivateFieldSet(this, _CompanyHostManager__workLocation, WorkLocation_1.WorkLocation.create(props.workLocation), "f");
61
+ __classPrivateFieldSet(this, _CompanyHostManager__avatar, Avatar_1.Avatar.create(props.avatar), "f");
62
+ __classPrivateFieldSet(this, _CompanyHostManager__biography, Biography_1.Biography.create(props.biography), "f");
63
+ }
64
+ static create(props) {
65
+ return new CompanyHostManager(props);
66
+ }
67
+ static fromPrimitives(primitives) {
68
+ return new CompanyHostManager({
69
+ id: primitives.id,
70
+ createdAt: primitives.createdAt,
71
+ updatedAt: primitives.updatedAt,
72
+ email: primitives.email,
73
+ password: primitives.password,
74
+ userType: primitives.userType,
75
+ roles: primitives.roles,
76
+ phone: primitives.phone,
77
+ workLocation: primitives.workLocation,
78
+ avatar: primitives.avatar,
79
+ biography: primitives.biography,
80
+ officialName: primitives.officialName,
81
+ taxIdentificationNumber: primitives.taxIdentificationNumber,
82
+ activeCustomPlanId: primitives.activeCustomPlanId,
83
+ });
84
+ }
85
+ get officialName() {
86
+ return __classPrivateFieldGet(this, _CompanyHostManager__officialName, "f");
87
+ }
88
+ get taxIdentificationNumber() {
89
+ return __classPrivateFieldGet(this, _CompanyHostManager__taxIdentificationNumber, "f");
90
+ }
91
+ get activeCustomPlanId() {
92
+ return __classPrivateFieldGet(this, _CompanyHostManager__activeCustomPlanId, "f");
93
+ }
94
+ get phone() {
95
+ return __classPrivateFieldGet(this, _CompanyHostManager__phone, "f");
96
+ }
97
+ get workLocation() {
98
+ return __classPrivateFieldGet(this, _CompanyHostManager__workLocation, "f");
99
+ }
100
+ get avatar() {
101
+ return __classPrivateFieldGet(this, _CompanyHostManager__avatar, "f");
102
+ }
103
+ get biography() {
104
+ return __classPrivateFieldGet(this, _CompanyHostManager__biography, "f");
105
+ }
106
+ get toPrimitives() {
107
+ return {
108
+ id: this.id.value,
109
+ createdAt: this.createdAt.value,
110
+ updatedAt: this.updatedAt.value,
111
+ email: this.email.value,
112
+ password: this.password.value,
113
+ userType: this.userType.value,
114
+ roles: this.roles.value,
115
+ phone: __classPrivateFieldGet(this, _CompanyHostManager__phone, "f").value,
116
+ workLocation: __classPrivateFieldGet(this, _CompanyHostManager__workLocation, "f").value,
117
+ avatar: __classPrivateFieldGet(this, _CompanyHostManager__avatar, "f").value,
118
+ biography: __classPrivateFieldGet(this, _CompanyHostManager__biography, "f").value,
119
+ officialName: __classPrivateFieldGet(this, _CompanyHostManager__officialName, "f").value,
120
+ taxIdentificationNumber: __classPrivateFieldGet(this, _CompanyHostManager__taxIdentificationNumber, "f").value,
121
+ activeCustomPlanId: __classPrivateFieldGet(this, _CompanyHostManager__activeCustomPlanId, "f").value,
122
+ };
123
+ }
124
+ }
125
+ exports.CompanyHostManager = CompanyHostManager;
126
+ _CompanyHostManager__officialName = new WeakMap(), _CompanyHostManager__taxIdentificationNumber = new WeakMap(), _CompanyHostManager__activeCustomPlanId = new WeakMap(), _CompanyHostManager__phone = new WeakMap(), _CompanyHostManager__workLocation = new WeakMap(), _CompanyHostManager__avatar = new WeakMap(), _CompanyHostManager__biography = new WeakMap();
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailAlreadyExistsError = void 0;
4
+ const RootError_1 = require("../../../../shared/domain/exceptions/RootError");
5
+ class EmailAlreadyExistsError extends RootError_1.RootError {
6
+ constructor(email) {
7
+ const { value } = email.value;
8
+ const message = `Uniqueness constraint violation: email '${value}' already exists in the system.`;
9
+ super(message);
10
+ this.name = 'EmailAlreadyExistsError';
11
+ }
12
+ static create(email) {
13
+ return new EmailAlreadyExistsError(email);
14
+ }
15
+ logError() {
16
+ return `${this.name}: ${this.message}`;
17
+ }
18
+ }
19
+ exports.EmailAlreadyExistsError = EmailAlreadyExistsError;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailUniquenessValidatorDomainService = void 0;
4
+ const EmailAlreadyExistsError_1 = require("../exceptions/EmailAlreadyExistsError");
5
+ class EmailUniquenessValidatorDomainService {
6
+ constructor(dependencies) {
7
+ this.dependencies = dependencies;
8
+ }
9
+ static create(dependencies) {
10
+ return new EmailUniquenessValidatorDomainService(dependencies);
11
+ }
12
+ async ensureUniqueEmail(emailValueObject) {
13
+ const itemFound = await this.dependencies.emailUniquenessValidatorDomainServiceRepository.findByEmail(emailValueObject);
14
+ if (itemFound) {
15
+ throw EmailAlreadyExistsError_1.EmailAlreadyExistsError.create(emailValueObject);
16
+ }
17
+ }
18
+ }
19
+ exports.EmailUniquenessValidatorDomainService = EmailUniquenessValidatorDomainService;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PasswordValueObjectCreationDomainService = void 0;
4
+ const Password_1 = require("../value-objects/Password");
5
+ /**
6
+ * DomainService for creating Password value objects from hashed password values.
7
+ */
8
+ class PasswordValueObjectCreationDomainService {
9
+ static create() {
10
+ return new PasswordValueObjectCreationDomainService();
11
+ }
12
+ /**
13
+ * Creates a Password value object from a hashed password value.
14
+ * @param hashedPassword The hashed password string.
15
+ */
16
+ createFromHashedValue(hashedPassword) {
17
+ return Password_1.Password.create(hashedPassword, true);
18
+ }
19
+ }
20
+ exports.PasswordValueObjectCreationDomainService = PasswordValueObjectCreationDomainService;
@@ -0,0 +1,36 @@
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 _SecurePasswordCreationDomainService_passwordHashingDomainService, _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SecurePasswordCreationDomainService = void 0;
16
+ class SecurePasswordCreationDomainService {
17
+ constructor(dependencies) {
18
+ _SecurePasswordCreationDomainService_passwordHashingDomainService.set(this, void 0);
19
+ _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService.set(this, void 0);
20
+ __classPrivateFieldSet(this, _SecurePasswordCreationDomainService_passwordHashingDomainService, dependencies.passwordHashingDomainService, "f");
21
+ __classPrivateFieldSet(this, _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService, dependencies.passwordValueObjectCreationDomainService, "f");
22
+ }
23
+ static create(dependencies) {
24
+ return new SecurePasswordCreationDomainService(dependencies);
25
+ }
26
+ async createFromPlainText(userPassword) {
27
+ const { value } = userPassword;
28
+ const hashedPassword = await __classPrivateFieldGet(this, _SecurePasswordCreationDomainService_passwordHashingDomainService, "f").hash(value);
29
+ return __classPrivateFieldGet(this, _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService, "f").createFromHashedValue(hashedPassword);
30
+ }
31
+ async createFromHashedText(hashedText) {
32
+ return __classPrivateFieldGet(this, _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService, "f").createFromHashedValue(hashedText);
33
+ }
34
+ }
35
+ exports.SecurePasswordCreationDomainService = SecurePasswordCreationDomainService;
36
+ _SecurePasswordCreationDomainService_passwordHashingDomainService = new WeakMap(), _SecurePasswordCreationDomainService_passwordValueObjectCreationDomainService = new WeakMap();
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -16,8 +16,8 @@ class Password extends String_1.String {
16
16
  _a.ensureIsValidPassword(value);
17
17
  }
18
18
  }
19
- static create(value) {
20
- return new this(value);
19
+ static create(value, skipRequirements = false) {
20
+ return new this(value, skipRequirements);
21
21
  }
22
22
  static get passwordRegExp() {
23
23
  return __classPrivateFieldGet(_a, _a, "f", _Password_PASSWORD_REG_EXP);