@atlantjs/arch 1.0.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.
Files changed (176) hide show
  1. package/README.md +8 -0
  2. package/configs/env/env-vars.d.ts +3 -0
  3. package/configs/env/env-vars.js +20 -0
  4. package/external-files/biome.json +47 -0
  5. package/external-files/typescript/tsconfig-backend.json +3 -0
  6. package/external-files/typescript/tsconfig-default.json +42 -0
  7. package/external-files/typescript/tsconfig-frontend.json +3 -0
  8. package/external-files/typescript/tsconfig-lib.json +6 -0
  9. package/external-files/typescript/tsconfig-mobile.json +3 -0
  10. package/index.d.ts +51 -0
  11. package/index.js +106 -0
  12. package/objects/arch/application/errors/application-error.abstract.d.ts +8 -0
  13. package/objects/arch/application/errors/application-error.abstract.js +25 -0
  14. package/objects/arch/application/errors/application-error.abstract.type.d.ts +9 -0
  15. package/objects/arch/application/errors/application-error.abstract.type.js +2 -0
  16. package/objects/arch/application/errors/unknown-application-error.d.ts +15 -0
  17. package/objects/arch/application/errors/unknown-application-error.js +16 -0
  18. package/objects/arch/domain/entity.abstract.d.ts +3 -0
  19. package/objects/arch/domain/entity.abstract.js +6 -0
  20. package/objects/arch/domain/usecase.abstract.d.ts +4 -0
  21. package/objects/arch/domain/usecase.abstract.js +6 -0
  22. package/objects/arch/infrastructure/controller.abstract.d.ts +6 -0
  23. package/objects/arch/infrastructure/controller.abstract.js +6 -0
  24. package/objects/auth/entities/client/client-credentials.abstract.d.ts +13 -0
  25. package/objects/auth/entities/client/client-credentials.abstract.js +27 -0
  26. package/objects/auth/entities/client/client-credentials.abstract.type.d.ts +7 -0
  27. package/objects/auth/entities/client/client-credentials.abstract.type.js +2 -0
  28. package/objects/auth/entities/client/realm-credentials.abstract.d.ts +13 -0
  29. package/objects/auth/entities/client/realm-credentials.abstract.js +20 -0
  30. package/objects/auth/entities/token/access-token-signature.d.ts +10 -0
  31. package/objects/auth/entities/token/access-token-signature.js +58 -0
  32. package/objects/auth/entities/token/access-token.abstract.d.ts +10 -0
  33. package/objects/auth/entities/token/access-token.abstract.has-role.error.d.ts +4 -0
  34. package/objects/auth/entities/token/access-token.abstract.has-role.error.js +14 -0
  35. package/objects/auth/entities/token/access-token.abstract.js +25 -0
  36. package/objects/auth/entities/token/access-token.abstract.signature-verify.error.d.ts +4 -0
  37. package/objects/auth/entities/token/access-token.abstract.signature-verify.error.js +10 -0
  38. package/objects/auth/entities/token/access-token.abstract.type.d.ts +44 -0
  39. package/objects/auth/entities/token/access-token.abstract.type.js +2 -0
  40. package/objects/auth/entities/token/rotation.d.ts +12 -0
  41. package/objects/auth/entities/token/rotation.js +108 -0
  42. package/objects/auth/entities/token/rotation.type.d.ts +5 -0
  43. package/objects/auth/entities/token/rotation.type.js +2 -0
  44. package/objects/auth/entities/token/token.d.ts +16 -0
  45. package/objects/auth/entities/token/token.js +50 -0
  46. package/objects/auth/entities/token/token.type.d.ts +5 -0
  47. package/objects/auth/entities/token/token.type.js +2 -0
  48. package/objects/auth/entities/user/enums/user-status.enum.d.ts +4 -0
  49. package/objects/auth/entities/user/enums/user-status.enum.js +8 -0
  50. package/objects/auth/entities/user/password/password.abstract.d.ts +8 -0
  51. package/objects/auth/entities/user/password/password.abstract.js +41 -0
  52. package/objects/auth/entities/user/password/password.abstract.type.d.ts +5 -0
  53. package/objects/auth/entities/user/password/password.abstract.type.js +2 -0
  54. package/objects/auth/entities/user/password/steps/not-allowing-consecutive-chars-step.d.ts +11 -0
  55. package/objects/auth/entities/user/password/steps/not-allowing-consecutive-chars-step.js +34 -0
  56. package/objects/auth/entities/user/password/steps/not-allowing-date-step.d.ts +11 -0
  57. package/objects/auth/entities/user/password/steps/not-allowing-date-step.js +61 -0
  58. package/objects/auth/entities/user/password/steps/not-allowing-phone-step.d.ts +7 -0
  59. package/objects/auth/entities/user/password/steps/not-allowing-phone-step.js +27 -0
  60. package/objects/auth/entities/user/password/steps/not-allowing-repeated-chars-step.d.ts +11 -0
  61. package/objects/auth/entities/user/password/steps/not-allowing-repeated-chars-step.js +34 -0
  62. package/objects/auth/entities/user/password/steps/not-allowing-string-step.d.ts +7 -0
  63. package/objects/auth/entities/user/password/steps/not-allowing-string-step.js +19 -0
  64. package/objects/auth/entities/user/password/steps/not-allowing-these-chars-step.d.ts +10 -0
  65. package/objects/auth/entities/user/password/steps/not-allowing-these-chars-step.js +17 -0
  66. package/objects/auth/entities/user/password/steps/numeric-step.d.ts +5 -0
  67. package/objects/auth/entities/user/password/steps/numeric-step.js +13 -0
  68. package/objects/auth/entities/user/password/steps/with-at-least-one-letter-step.d.ts +5 -0
  69. package/objects/auth/entities/user/password/steps/with-at-least-one-letter-step.js +14 -0
  70. package/objects/auth/entities/user/password/steps/with-at-least-one-number-digit-step.d.ts +5 -0
  71. package/objects/auth/entities/user/password/steps/with-at-least-one-number-digit-step.js +14 -0
  72. package/objects/auth/entities/user/password/steps/with-at-least-one-special-char-step.d.ts +5 -0
  73. package/objects/auth/entities/user/password/steps/with-at-least-one-special-char-step.js +14 -0
  74. package/objects/auth/entities/user/password/steps/with-length-step.d.ts +11 -0
  75. package/objects/auth/entities/user/password/steps/with-length-step.js +18 -0
  76. package/objects/auth/entities/user/password/validation-step.d.ts +5 -0
  77. package/objects/auth/entities/user/password/validation-step.js +9 -0
  78. package/objects/auth/entities/user/password/validation-step.type.d.ts +4 -0
  79. package/objects/auth/entities/user/password/validation-step.type.js +2 -0
  80. package/objects/auth/entities/user/user-credentials.abstract.d.ts +9 -0
  81. package/objects/auth/entities/user/user-credentials.abstract.js +6 -0
  82. package/objects/auth/entities/user/user-tokens.abstract.d.ts +13 -0
  83. package/objects/auth/entities/user/user-tokens.abstract.js +27 -0
  84. package/objects/auth/entities/user/user-tokens.abstract.type.d.ts +5 -0
  85. package/objects/auth/entities/user/user-tokens.abstract.type.js +2 -0
  86. package/objects/auth/entities/user/user.abstract.d.ts +21 -0
  87. package/objects/auth/entities/user/user.abstract.js +29 -0
  88. package/objects/auth/entities/user/value-objects/email.d.ts +6 -0
  89. package/objects/auth/entities/user/value-objects/email.js +17 -0
  90. package/objects/auth/entities/user/value-objects/person-name.d.ts +7 -0
  91. package/objects/auth/entities/user/value-objects/person-name.js +17 -0
  92. package/objects/auth/entities/user/value-objects/user-id.d.ts +3 -0
  93. package/objects/auth/entities/user/value-objects/user-id.js +7 -0
  94. package/objects/auth/entities/user/value-objects/username.d.ts +3 -0
  95. package/objects/auth/entities/user/value-objects/username.js +7 -0
  96. package/objects/auth/enums/client.enum.d.ts +3 -0
  97. package/objects/auth/enums/client.enum.js +7 -0
  98. package/objects/auth/enums/realm.enum.d.ts +3 -0
  99. package/objects/auth/enums/realm.enum.js +7 -0
  100. package/objects/auth/enums/role-group.enum.d.ts +4 -0
  101. package/objects/auth/enums/role-group.enum.js +8 -0
  102. package/objects/auth/enums/role.enum.d.ts +17 -0
  103. package/objects/auth/enums/role.enum.js +21 -0
  104. package/objects/auth/enums/token-name-header.enum.d.ts +4 -0
  105. package/objects/auth/enums/token-name-header.enum.js +8 -0
  106. package/objects/configs/enums/node-envs.enum.d.ts +6 -0
  107. package/objects/configs/enums/node-envs.enum.js +10 -0
  108. package/objects/datatypes/entities/$boolean.abstract.d.ts +7 -0
  109. package/objects/datatypes/entities/$boolean.abstract.js +21 -0
  110. package/objects/datatypes/entities/$number.abstract.d.ts +13 -0
  111. package/objects/datatypes/entities/$number.abstract.js +60 -0
  112. package/objects/datatypes/entities/$string.abstract.d.ts +10 -0
  113. package/objects/datatypes/entities/$string.abstract.js +34 -0
  114. package/objects/datatypes/entities/uuid.abstract.d.ts +7 -0
  115. package/objects/datatypes/entities/uuid.abstract.js +20 -0
  116. package/package.json +66 -0
  117. package/tests/builders/auth/access-token-signature.builder.d.ts +6 -0
  118. package/tests/builders/auth/access-token-signature.builder.js +19 -0
  119. package/tests/builders/auth/access-token.builder.d.ts +6 -0
  120. package/tests/builders/auth/access-token.builder.js +15 -0
  121. package/tests/builders/auth/rotation.builder.d.ts +6 -0
  122. package/tests/builders/auth/rotation.builder.js +19 -0
  123. package/tests/builders/auth/token.builder.d.ts +7 -0
  124. package/tests/builders/auth/token.builder.js +15 -0
  125. package/tests/builders/auth/value-objects/client-credentials.builder.d.ts +6 -0
  126. package/tests/builders/auth/value-objects/client-credentials.builder.js +18 -0
  127. package/tests/builders/auth/value-objects/dummies/access-token.dummy.d.ts +3 -0
  128. package/tests/builders/auth/value-objects/dummies/access-token.dummy.js +7 -0
  129. package/tests/builders/auth/value-objects/dummies/client-credentials.dummy.d.ts +3 -0
  130. package/tests/builders/auth/value-objects/dummies/client-credentials.dummy.js +7 -0
  131. package/tests/builders/auth/value-objects/dummies/realm-credentials.dummy.d.ts +6 -0
  132. package/tests/builders/auth/value-objects/dummies/realm-credentials.dummy.js +12 -0
  133. package/tests/builders/auth/value-objects/dummies/user-tokens.dummy.d.ts +3 -0
  134. package/tests/builders/auth/value-objects/dummies/user-tokens.dummy.js +7 -0
  135. package/tests/builders/auth/value-objects/realm-credentials.builder.d.ts +6 -0
  136. package/tests/builders/auth/value-objects/realm-credentials.builder.js +17 -0
  137. package/tests/builders/auth/value-objects/user-tokens.builder.d.ts +7 -0
  138. package/tests/builders/auth/value-objects/user-tokens.builder.js +18 -0
  139. package/tests/builders/errors/application-error.builder.d.ts +6 -0
  140. package/tests/builders/errors/application-error.builder.js +21 -0
  141. package/tests/builders/errors/dummies/application-error.dummy.d.ts +3 -0
  142. package/tests/builders/errors/dummies/application-error.dummy.js +7 -0
  143. package/tests/builders/generic/dummies/uuid.dummy.d.ts +3 -0
  144. package/tests/builders/generic/dummies/uuid.dummy.js +7 -0
  145. package/tests/builders/generic/uuid.builder.d.ts +6 -0
  146. package/tests/builders/generic/uuid.builder.js +14 -0
  147. package/tests/builders/user/user-id.builder.d.ts +6 -0
  148. package/tests/builders/user/user-id.builder.js +15 -0
  149. package/tests/create-fake-stub.d.ts +8 -0
  150. package/tests/create-fake-stub.js +37 -0
  151. package/tests/entity-builder.util.d.ts +13 -0
  152. package/tests/entity-builder.util.js +39 -0
  153. package/tests/faker/faker.d.ts +2 -0
  154. package/tests/faker/faker.js +6 -0
  155. package/utils/arrays/extended-map.d.ts +5 -0
  156. package/utils/arrays/extended-map.js +23 -0
  157. package/utils/datatypes/generic-types.d.ts +7 -0
  158. package/utils/datatypes/generic-types.js +3 -0
  159. package/utils/datatypes/string-utils.d.ts +3 -0
  160. package/utils/datatypes/string-utils.js +4 -0
  161. package/utils/ducts/common.d.ts +9 -0
  162. package/utils/ducts/common.js +14 -0
  163. package/utils/ducts/optional-type.d.ts +25 -0
  164. package/utils/ducts/optional-type.js +50 -0
  165. package/utils/ducts/return-type.d.ts +22 -0
  166. package/utils/ducts/return-type.js +60 -0
  167. package/utils/randoms/random-enum-value.d.ts +2 -0
  168. package/utils/randoms/random-enum-value.js +20 -0
  169. package/utils/randoms/random-number.d.ts +6 -0
  170. package/utils/randoms/random-number.js +6 -0
  171. package/utils/type-guard/guardian-exception.d.ts +2 -0
  172. package/utils/type-guard/guardian-exception.js +6 -0
  173. package/utils/type-guard/guardian.d.ts +29 -0
  174. package/utils/type-guard/guardian.js +132 -0
  175. package/utils/type-guard/guardian.type.d.ts +1 -0
  176. package/utils/type-guard/guardian.type.js +2 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NotAllowingTheseCharsStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class NotAllowingTheseCharsStep extends validation_step_1.ValidationStep {
6
+ constructor(options) {
7
+ super();
8
+ this.options = options;
9
+ }
10
+ validate(password) {
11
+ return {
12
+ valid: this.options.notAllowedCharsList.every((char) => !password.toLowerCase().includes(char.toLowerCase())),
13
+ name: this.name,
14
+ };
15
+ }
16
+ }
17
+ exports.NotAllowingTheseCharsStep = NotAllowingTheseCharsStep;
@@ -0,0 +1,5 @@
1
+ import { ValidationStep } from "../validation-step";
2
+ import { ValidationStepResult } from "../validation-step.type";
3
+ export declare class NumericStep extends ValidationStep {
4
+ validate(password: string): ValidationStepResult;
5
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumericStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class NumericStep extends validation_step_1.ValidationStep {
6
+ validate(password) {
7
+ return {
8
+ valid: /^\d+$/.test(password),
9
+ name: this.name,
10
+ };
11
+ }
12
+ }
13
+ exports.NumericStep = NumericStep;
@@ -0,0 +1,5 @@
1
+ import { ValidationStep } from "../validation-step";
2
+ import { ValidationStepResult } from "../validation-step.type";
3
+ export declare class WithAtLeastOneLetterStep extends ValidationStep {
4
+ validate(password: string): ValidationStepResult;
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithAtLeastOneLetterStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class WithAtLeastOneLetterStep extends validation_step_1.ValidationStep {
6
+ validate(password) {
7
+ const regex = /[a-zA-Z]/;
8
+ return {
9
+ valid: regex.test(password),
10
+ name: this.name,
11
+ };
12
+ }
13
+ }
14
+ exports.WithAtLeastOneLetterStep = WithAtLeastOneLetterStep;
@@ -0,0 +1,5 @@
1
+ import { ValidationStep } from "../validation-step";
2
+ import { ValidationStepResult } from "../validation-step.type";
3
+ export declare class WithAtLeastOneNumberDigitStep extends ValidationStep {
4
+ validate(password: string): ValidationStepResult;
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithAtLeastOneNumberDigitStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class WithAtLeastOneNumberDigitStep extends validation_step_1.ValidationStep {
6
+ validate(password) {
7
+ const regex = /\d/;
8
+ return {
9
+ valid: regex.test(password),
10
+ name: this.name,
11
+ };
12
+ }
13
+ }
14
+ exports.WithAtLeastOneNumberDigitStep = WithAtLeastOneNumberDigitStep;
@@ -0,0 +1,5 @@
1
+ import { ValidationStep } from "../validation-step";
2
+ import { ValidationStepResult } from "../validation-step.type";
3
+ export declare class WithAtLeastOneSpecialCharStep extends ValidationStep {
4
+ validate(password: string): ValidationStepResult;
5
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithAtLeastOneSpecialCharStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class WithAtLeastOneSpecialCharStep extends validation_step_1.ValidationStep {
6
+ validate(password) {
7
+ const regex = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
8
+ return {
9
+ valid: regex.test(password),
10
+ name: this.name,
11
+ };
12
+ }
13
+ }
14
+ exports.WithAtLeastOneSpecialCharStep = WithAtLeastOneSpecialCharStep;
@@ -0,0 +1,11 @@
1
+ import { ValidationStep } from "../validation-step";
2
+ import { ValidationStepResult } from "../validation-step.type";
3
+ export interface WithLengthStepOptions {
4
+ min: number;
5
+ max: number;
6
+ }
7
+ export declare class WithLengthStep extends ValidationStep {
8
+ private readonly options;
9
+ constructor(options: WithLengthStepOptions);
10
+ validate(password: string): ValidationStepResult;
11
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WithLengthStep = void 0;
4
+ const validation_step_1 = require("../validation-step");
5
+ class WithLengthStep extends validation_step_1.ValidationStep {
6
+ constructor(options) {
7
+ super();
8
+ this.options = options;
9
+ }
10
+ validate(password) {
11
+ return {
12
+ valid: password.length >= this.options.min &&
13
+ password.length <= this.options.max,
14
+ name: this.name,
15
+ };
16
+ }
17
+ }
18
+ exports.WithLengthStep = WithLengthStep;
@@ -0,0 +1,5 @@
1
+ import { ValidationStepResult } from "./validation-step.type";
2
+ export declare abstract class ValidationStep {
3
+ abstract validate(password: string): ValidationStepResult;
4
+ protected get name(): string;
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidationStep = void 0;
4
+ class ValidationStep {
5
+ get name() {
6
+ return this.constructor.name;
7
+ }
8
+ }
9
+ exports.ValidationStep = ValidationStep;
@@ -0,0 +1,4 @@
1
+ export interface ValidationStepResult {
2
+ valid: boolean;
3
+ name: string;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import { PasswordAbstract } from "./password/password.abstract";
2
+ import { Email } from "./value-objects/email";
3
+ import { Username } from "./value-objects/username";
4
+ import { Optional } from "../../../../utils/ducts/optional-type";
5
+ export declare abstract class UserCredentialsAbstract {
6
+ abstract usernameWrapped: Optional<Username>;
7
+ abstract emailWrapped: Optional<Email>;
8
+ abstract passwordWrapped: Optional<PasswordAbstract>;
9
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserCredentialsAbstract = void 0;
4
+ class UserCredentialsAbstract {
5
+ }
6
+ exports.UserCredentialsAbstract = UserCredentialsAbstract;
@@ -0,0 +1,13 @@
1
+ import { AccessTokenPayload, RefreshTokenPayload } from "../token/access-token.abstract.type";
2
+ import { Token } from "../token/token";
3
+ import { UserTokensPrimitive } from "./user-tokens.abstract.type";
4
+ export declare abstract class UserTokensAbstract {
5
+ protected readonly _accessToken: Token<AccessTokenPayload>;
6
+ protected readonly _refreshToken: Token<RefreshTokenPayload>;
7
+ protected readonly _accessTokenExpirationDate: Date;
8
+ constructor(_accessToken: Token<AccessTokenPayload>, _refreshToken: Token<RefreshTokenPayload>, _accessTokenExpirationDate: Date);
9
+ get accessToken(): Token<AccessTokenPayload>;
10
+ get refreshToken(): Token<RefreshTokenPayload>;
11
+ get accessTokenExpirationDate(): Date;
12
+ toPlain(): UserTokensPrimitive;
13
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserTokensAbstract = void 0;
4
+ class UserTokensAbstract {
5
+ constructor(_accessToken, _refreshToken, _accessTokenExpirationDate) {
6
+ this._accessToken = _accessToken;
7
+ this._refreshToken = _refreshToken;
8
+ this._accessTokenExpirationDate = _accessTokenExpirationDate;
9
+ }
10
+ get accessToken() {
11
+ return this._accessToken;
12
+ }
13
+ get refreshToken() {
14
+ return this._refreshToken;
15
+ }
16
+ get accessTokenExpirationDate() {
17
+ return this._accessTokenExpirationDate;
18
+ }
19
+ toPlain() {
20
+ return {
21
+ accessToken: this.accessToken.toString(),
22
+ refreshToken: this.refreshToken.toString(),
23
+ accessTokenExpirationDate: this.accessTokenExpirationDate,
24
+ };
25
+ }
26
+ }
27
+ exports.UserTokensAbstract = UserTokensAbstract;
@@ -0,0 +1,5 @@
1
+ export interface UserTokensPrimitive {
2
+ accessToken: string;
3
+ refreshToken: string;
4
+ accessTokenExpirationDate: Date;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,21 @@
1
+ import { UserStatusEnum } from "./enums/user-status.enum";
2
+ import { UserCredentialsAbstract } from "./user-credentials.abstract";
3
+ import { PersonName } from "./value-objects/person-name";
4
+ import { UserId } from "./value-objects/user-id";
5
+ import { RoleGroupEnum } from "../../enums/role-group.enum";
6
+ import { RoleEnum } from "../../enums/role.enum";
7
+ import { Optional } from "../../../../utils/ducts/optional-type";
8
+ export declare abstract class UserAbstract {
9
+ protected _id: UserId;
10
+ protected _personName: PersonName;
11
+ protected _status: UserStatusEnum;
12
+ protected _roleGroups: RoleGroupEnum[];
13
+ abstract rolesWrapped: Optional<RoleEnum[]>;
14
+ abstract credentialsWrapped: Optional<UserCredentialsAbstract>;
15
+ constructor(_id: UserId, _personName: PersonName, _status: UserStatusEnum, _roleGroups: RoleGroupEnum[]);
16
+ get id(): UserId;
17
+ get status(): UserStatusEnum;
18
+ get roleGroups(): RoleGroupEnum[];
19
+ get personName(): PersonName;
20
+ isActive(): boolean;
21
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserAbstract = void 0;
4
+ const user_status_enum_1 = require("./enums/user-status.enum");
5
+ const guardian_1 = require("../../../../utils/type-guard/guardian");
6
+ class UserAbstract {
7
+ constructor(_id, _personName, _status, _roleGroups) {
8
+ this._id = _id;
9
+ this._personName = _personName;
10
+ this._status = _status;
11
+ this._roleGroups = _roleGroups;
12
+ }
13
+ get id() {
14
+ return this._id;
15
+ }
16
+ get status() {
17
+ return this._status;
18
+ }
19
+ get roleGroups() {
20
+ return this._roleGroups;
21
+ }
22
+ get personName() {
23
+ return this._personName;
24
+ }
25
+ isActive() {
26
+ return guardian_1.Guardian.isEqual(this._status, user_status_enum_1.UserStatusEnum.active);
27
+ }
28
+ }
29
+ exports.UserAbstract = UserAbstract;
@@ -0,0 +1,6 @@
1
+ import { $string } from "../../../../datatypes/entities/$string.abstract";
2
+ export declare class Email extends $string {
3
+ private readonly email;
4
+ constructor(email: string);
5
+ protected validation(): void;
6
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Email = void 0;
4
+ const _string_abstract_1 = require("../../../../datatypes/entities/$string.abstract");
5
+ class Email extends _string_abstract_1.$string {
6
+ constructor(email) {
7
+ super(email);
8
+ this.email = email;
9
+ this.validation();
10
+ }
11
+ validation() {
12
+ if (!/^[\w-\\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(this.email)) {
13
+ throw new Error(`${this.constructor.name} should be valid.`);
14
+ }
15
+ }
16
+ }
17
+ exports.Email = Email;
@@ -0,0 +1,7 @@
1
+ import { $string } from "../../../../datatypes/entities/$string.abstract";
2
+ export declare class PersonName extends $string {
3
+ private readonly name;
4
+ constructor(name: string);
5
+ get firstName(): string;
6
+ get lastName(): string;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PersonName = void 0;
4
+ const _string_abstract_1 = require("../../../../datatypes/entities/$string.abstract");
5
+ class PersonName extends _string_abstract_1.$string {
6
+ constructor(name) {
7
+ super(name);
8
+ this.name = name;
9
+ }
10
+ get firstName() {
11
+ return this.name.split(" ")[0];
12
+ }
13
+ get lastName() {
14
+ return this.name.split(" ").slice(1).join(" ");
15
+ }
16
+ }
17
+ exports.PersonName = PersonName;
@@ -0,0 +1,3 @@
1
+ import { UuidAbstract } from "../../../../datatypes/entities/uuid.abstract";
2
+ export declare class UserId extends UuidAbstract {
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserId = void 0;
4
+ const uuid_abstract_1 = require("../../../../datatypes/entities/uuid.abstract");
5
+ class UserId extends uuid_abstract_1.UuidAbstract {
6
+ }
7
+ exports.UserId = UserId;
@@ -0,0 +1,3 @@
1
+ import { $string } from "../../../../datatypes/entities/$string.abstract";
2
+ export declare class Username extends $string {
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Username = void 0;
4
+ const _string_abstract_1 = require("../../../../datatypes/entities/$string.abstract");
5
+ class Username extends _string_abstract_1.$string {
6
+ }
7
+ exports.Username = Username;
@@ -0,0 +1,3 @@
1
+ export declare enum ClientEnum {
2
+ movindentity = "movindentity_client"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientEnum = void 0;
4
+ var ClientEnum;
5
+ (function (ClientEnum) {
6
+ ClientEnum["movindentity"] = "movindentity_client";
7
+ })(ClientEnum || (exports.ClientEnum = ClientEnum = {}));
@@ -0,0 +1,3 @@
1
+ export declare enum RealmEnum {
2
+ movingapp = "movingapp"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RealmEnum = void 0;
4
+ var RealmEnum;
5
+ (function (RealmEnum) {
6
+ RealmEnum["movingapp"] = "movingapp";
7
+ })(RealmEnum || (exports.RealmEnum = RealmEnum = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum RoleGroupEnum {
2
+ freeUser = "free-user",
3
+ premiumUser = "premium-user"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RoleGroupEnum = void 0;
4
+ var RoleGroupEnum;
5
+ (function (RoleGroupEnum) {
6
+ RoleGroupEnum["freeUser"] = "free-user";
7
+ RoleGroupEnum["premiumUser"] = "premium-user";
8
+ })(RoleGroupEnum || (exports.RoleGroupEnum = RoleGroupEnum = {}));
@@ -0,0 +1,17 @@
1
+ export declare enum RoleEnum {
2
+ readRecipe = "read-recipe",
3
+ writeRecipe = "write-recipe",
4
+ deleteRecipe = "delete-recipe",
5
+ manageRecipe = "manage-recipe",
6
+ readPremiumRecipe = "read-premium-recipe",
7
+ manageRecipePremium = "manage-recipe-premium",
8
+ readIngredient = "read-ingredient",
9
+ writeIngredient = "write-ingredient",
10
+ deleteIngredient = "delete-ingredient",
11
+ manageIngredient = "manage-ingredient",
12
+ readUtensil = "read-utensil",
13
+ writeUtensil = "write-utensil",
14
+ deleteUtensil = "delete-utensil",
15
+ manageUtensil = "manage-utensil",
16
+ umaAuthorization = "uma_authorization"
17
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RoleEnum = void 0;
4
+ var RoleEnum;
5
+ (function (RoleEnum) {
6
+ RoleEnum["readRecipe"] = "read-recipe";
7
+ RoleEnum["writeRecipe"] = "write-recipe";
8
+ RoleEnum["deleteRecipe"] = "delete-recipe";
9
+ RoleEnum["manageRecipe"] = "manage-recipe";
10
+ RoleEnum["readPremiumRecipe"] = "read-premium-recipe";
11
+ RoleEnum["manageRecipePremium"] = "manage-recipe-premium";
12
+ RoleEnum["readIngredient"] = "read-ingredient";
13
+ RoleEnum["writeIngredient"] = "write-ingredient";
14
+ RoleEnum["deleteIngredient"] = "delete-ingredient";
15
+ RoleEnum["manageIngredient"] = "manage-ingredient";
16
+ RoleEnum["readUtensil"] = "read-utensil";
17
+ RoleEnum["writeUtensil"] = "write-utensil";
18
+ RoleEnum["deleteUtensil"] = "delete-utensil";
19
+ RoleEnum["manageUtensil"] = "manage-utensil";
20
+ RoleEnum["umaAuthorization"] = "uma_authorization";
21
+ })(RoleEnum || (exports.RoleEnum = RoleEnum = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum TokenNameHeaderEnum {
2
+ authorizationClient = "authorization_client",
3
+ authorizationUser = "authorization_user"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenNameHeaderEnum = void 0;
4
+ var TokenNameHeaderEnum;
5
+ (function (TokenNameHeaderEnum) {
6
+ TokenNameHeaderEnum["authorizationClient"] = "authorization_client";
7
+ TokenNameHeaderEnum["authorizationUser"] = "authorization_user";
8
+ })(TokenNameHeaderEnum || (exports.TokenNameHeaderEnum = TokenNameHeaderEnum = {}));
@@ -0,0 +1,6 @@
1
+ export declare enum NodeEnvs {
2
+ production = "production",
3
+ homolog = "homolog",
4
+ development = "development",
5
+ test = "test"
6
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeEnvs = void 0;
4
+ var NodeEnvs;
5
+ (function (NodeEnvs) {
6
+ NodeEnvs["production"] = "production";
7
+ NodeEnvs["homolog"] = "homolog";
8
+ NodeEnvs["development"] = "development";
9
+ NodeEnvs["test"] = "test";
10
+ })(NodeEnvs || (exports.NodeEnvs = NodeEnvs = {}));
@@ -0,0 +1,7 @@
1
+ export declare abstract class $boolean {
2
+ private value;
3
+ constructor(value: boolean);
4
+ toBoolean(): boolean;
5
+ isEqual(value: $boolean | boolean): boolean;
6
+ isDifferent(value: boolean): boolean;
7
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.$boolean = void 0;
4
+ class $boolean {
5
+ constructor(value) {
6
+ this.value = value;
7
+ }
8
+ toBoolean() {
9
+ return this.value;
10
+ }
11
+ isEqual(value) {
12
+ if (value instanceof $boolean) {
13
+ return value.toBoolean() === this.value;
14
+ }
15
+ return this.value === value;
16
+ }
17
+ isDifferent(value) {
18
+ return this.value !== value;
19
+ }
20
+ }
21
+ exports.$boolean = $boolean;
@@ -0,0 +1,13 @@
1
+ export declare abstract class $number {
2
+ private value;
3
+ constructor(value: number);
4
+ toNumber(): number;
5
+ isEqual(value: number | $number): boolean;
6
+ isDifferent(value: number | $number): boolean;
7
+ isBiggerThan(value: number | $number): boolean;
8
+ isSmallerThan(value: number | $number): boolean;
9
+ isEqualOrBiggerThan(value: number | $number): boolean;
10
+ isEqualOrSmallerThan(value: number | $number): boolean;
11
+ isBetween(min: number | $number, max: number | $number): boolean;
12
+ private validate;
13
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.$number = void 0;
4
+ const guardian_1 = require("../../../utils/type-guard/guardian");
5
+ class $number {
6
+ constructor(value) {
7
+ this.value = value;
8
+ this.validate(value);
9
+ }
10
+ toNumber() {
11
+ return this.value;
12
+ }
13
+ isEqual(value) {
14
+ if (value instanceof $number) {
15
+ return value.toNumber() === this.value;
16
+ }
17
+ return this.value === value;
18
+ }
19
+ isDifferent(value) {
20
+ if (value instanceof $number) {
21
+ return value.toNumber() !== this.value;
22
+ }
23
+ return this.value !== value;
24
+ }
25
+ isBiggerThan(value) {
26
+ if (value instanceof $number) {
27
+ return value.toNumber() > this.value;
28
+ }
29
+ return this.value > value;
30
+ }
31
+ isSmallerThan(value) {
32
+ if (value instanceof $number) {
33
+ return value.toNumber() < this.value;
34
+ }
35
+ return this.value < value;
36
+ }
37
+ isEqualOrBiggerThan(value) {
38
+ if (value instanceof $number) {
39
+ return value.toNumber() >= this.value;
40
+ }
41
+ return this.value >= value;
42
+ }
43
+ isEqualOrSmallerThan(value) {
44
+ if (value instanceof $number) {
45
+ return value.toNumber() <= this.value;
46
+ }
47
+ return this.value <= value;
48
+ }
49
+ isBetween(min, max) {
50
+ const minimus = min instanceof $number ? min.toNumber() : min;
51
+ const maximus = max instanceof $number ? max.toNumber() : max;
52
+ return guardian_1.Guardian.isBetween(this.value, minimus, maximus);
53
+ }
54
+ validate(value) {
55
+ if (Number.isNaN(value)) {
56
+ throw new Error(`${this.constructor.name} should be valid.`);
57
+ }
58
+ }
59
+ }
60
+ exports.$number = $number;
@@ -0,0 +1,10 @@
1
+ export declare abstract class $string {
2
+ private value;
3
+ constructor(value: string);
4
+ toString(): string;
5
+ has(value: string): boolean;
6
+ extract(start: string, end: string): string;
7
+ remove(substrings: string[]): string;
8
+ private sanitize;
9
+ private validate;
10
+ }