@atlantjs/arch 9.1.2 → 10.0.1

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 (187) hide show
  1. package/@tool-box/tests/{entity-builder.util.d.ts → builder.abstract.util.d.ts} +1 -1
  2. package/@tool-box/tests/{entity-builder.util.js → builder.abstract.util.js} +3 -6
  3. package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.d.ts +3 -0
  4. package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.js +3 -0
  5. package/@tool-box/tests/builders/failures/failure.edge.builder.d.ts +6 -0
  6. package/@tool-box/tests/builders/failures/failure.edge.builder.js +18 -0
  7. package/@tool-box/tests/builders/user/email.edge.builder.d.ts +6 -0
  8. package/@tool-box/tests/builders/user/email.edge.builder.js +11 -0
  9. package/@tool-box/tests/builders/user/person-name.edge.builder.d.ts +6 -0
  10. package/@tool-box/tests/builders/user/person-name.edge.builder.js +11 -0
  11. package/@tool-box/tests/builders/user/username.edge.builder.d.ts +6 -0
  12. package/@tool-box/tests/builders/user/username.edge.builder.js +11 -0
  13. package/@tool-box/tests/create-fake-command.d.ts +9 -0
  14. package/@tool-box/tests/create-fake-command.js +23 -0
  15. package/@tool-box/tests/faker/faker.js +7 -10
  16. package/@tool-box/utils/datatypes/boolean-utils.d.ts +1 -0
  17. package/@tool-box/utils/datatypes/boolean-utils.js +5 -2
  18. package/@tool-box/utils/datatypes/generic-types.d.ts +1 -1
  19. package/@tool-box/utils/datatypes/generic-types.js +1 -2
  20. package/@tool-box/utils/datatypes/string-utils.d.ts +1 -3
  21. package/@tool-box/utils/datatypes/string-utils.js +1 -10
  22. package/@tool-box/utils/ducts/common.js +7 -11
  23. package/@tool-box/utils/ducts/optional-type.d.ts +0 -1
  24. package/@tool-box/utils/ducts/optional-type.js +19 -22
  25. package/@tool-box/utils/ducts/return-type.d.ts +2 -2
  26. package/@tool-box/utils/ducts/return-type.js +21 -26
  27. package/@tool-box/utils/{arrays/extended-map.d.ts → map/map.abstract.d.ts} +1 -2
  28. package/@tool-box/utils/map/map.abstract.js +13 -0
  29. package/@tool-box/utils/random/random.d.ts +5 -0
  30. package/@tool-box/utils/{randoms/random-value.js → random/random.js} +4 -8
  31. package/@tool-box/utils/type-guard/guardian-exception.js +1 -5
  32. package/@tool-box/utils/type-guard/guardian.d.ts +11 -13
  33. package/@tool-box/utils/type-guard/guardian.js +19 -51
  34. package/@tool-box/utils/type-guard/guardian.type.js +1 -2
  35. package/README.md +0 -8
  36. package/index.d.ts +28 -37
  37. package/index.js +30 -81
  38. package/objects/@common/edges/email.edge.d.ts +6 -0
  39. package/{arch/modules/domain/entities/user/value-objects/email.js → objects/@common/edges/email.edge.js} +3 -6
  40. package/objects/@common/edges/person-name.edge.d.ts +7 -0
  41. package/objects/@common/edges/person-name.edge.js +14 -0
  42. package/objects/@common/edges/url.edge.d.ts +6 -0
  43. package/objects/@common/edges/url.edge.js +17 -0
  44. package/objects/@common/edges/username.edge.d.ts +3 -0
  45. package/objects/@common/edges/username.edge.js +3 -0
  46. package/{arch/modules/domain/entities/uuid.abstract.d.ts → objects/@common/edges/uuid.sketch.edge.d.ts} +2 -2
  47. package/objects/@common/edges/uuid.sketch.edge.js +18 -0
  48. package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.js +2 -5
  49. package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.js +2 -5
  50. package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.js +2 -5
  51. package/objects/datetime/edges/datetime.edge.d.ts +27 -0
  52. package/objects/datetime/edges/datetime.edge.js +133 -0
  53. package/objects/datetime/points/month-name.enum.d.ts +14 -0
  54. package/objects/datetime/points/month-name.enum.js +15 -0
  55. package/objects/datetime/points/week-day.enum.d.ts +9 -0
  56. package/objects/datetime/points/week-day.enum.js +10 -0
  57. package/objects/failure/edges/failure.sketch.edge.d.ts +8 -0
  58. package/objects/failure/edges/failure.sketch.edge.js +23 -0
  59. package/objects/failure/edges/failure.sketch.polygon.d.ts +9 -0
  60. package/objects/failure/edges/failure.sketch.polygon.js +1 -0
  61. package/objects/password/password.edge.d.ts +8 -0
  62. package/objects/password/password.edge.js +38 -0
  63. package/{arch/modules/domain/entities/user/password/password.abstract.type.d.ts → objects/password/password.polygon.d.ts} +1 -1
  64. package/objects/password/password.polygon.js +1 -0
  65. package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.js +3 -6
  66. package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.js +3 -6
  67. package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.js +3 -6
  68. package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.js +3 -6
  69. package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.js +3 -6
  70. package/objects/password/steps/not-allowing-these-chars-step.js +14 -0
  71. package/objects/password/steps/numeric-step.js +9 -0
  72. package/objects/password/steps/with-at-least-one-letter-step.js +10 -0
  73. package/objects/password/steps/with-at-least-one-number-digit-step.js +10 -0
  74. package/objects/password/steps/with-at-least-one-special-char-step.js +10 -0
  75. package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.js +3 -6
  76. package/objects/password/validation-step.js +5 -0
  77. package/objects/password/validation-step.type.js +1 -0
  78. package/objects/primitives/boolean.edge.sketch.d.ts +7 -0
  79. package/objects/primitives/boolean.edge.sketch.js +18 -0
  80. package/objects/primitives/datetime.edge.sketch.d.ts +3 -0
  81. package/objects/primitives/datetime.edge.sketch.js +3 -0
  82. package/objects/primitives/number.edge.sketch.d.ts +13 -0
  83. package/{arch/modules/domain/entities/$number.abstract.js → objects/primitives/number.edge.sketch.js} +12 -15
  84. package/{arch/modules/domain/entities/$string.abstract.d.ts → objects/primitives/string.edge.sketch.d.ts} +1 -1
  85. package/{arch/modules/domain/entities/$string.abstract.js → objects/primitives/string.edge.sketch.js} +2 -5
  86. package/package.json +6 -11
  87. package/tsconfig.tsbuildinfo +1 -1
  88. package/@tool-box/tests/builders/failures/dummies/failure.dummy.d.ts +0 -3
  89. package/@tool-box/tests/builders/failures/dummies/failure.dummy.js +0 -7
  90. package/@tool-box/tests/builders/failures/failure.builder.d.ts +0 -6
  91. package/@tool-box/tests/builders/failures/failure.builder.js +0 -21
  92. package/@tool-box/tests/builders/generic/dummies/uuid.dummy.d.ts +0 -3
  93. package/@tool-box/tests/builders/generic/dummies/uuid.dummy.js +0 -7
  94. package/@tool-box/tests/builders/generic/uuid.builder.d.ts +0 -6
  95. package/@tool-box/tests/builders/generic/uuid.builder.js +0 -14
  96. package/@tool-box/tests/builders/user/email.builder.d.ts +0 -6
  97. package/@tool-box/tests/builders/user/email.builder.js +0 -15
  98. package/@tool-box/tests/builders/user/person-name.builder.d.ts +0 -6
  99. package/@tool-box/tests/builders/user/person-name.builder.js +0 -15
  100. package/@tool-box/tests/builders/user/user-id.builder.d.ts +0 -6
  101. package/@tool-box/tests/builders/user/user-id.builder.js +0 -14
  102. package/@tool-box/tests/builders/user/username.builder.d.ts +0 -6
  103. package/@tool-box/tests/builders/user/username.builder.js +0 -15
  104. package/@tool-box/tests/create-fake-usecase.d.ts +0 -9
  105. package/@tool-box/tests/create-fake-usecase.js +0 -26
  106. package/@tool-box/utils/arrays/extended-map.js +0 -22
  107. package/@tool-box/utils/http-client/http-client-exception.d.ts +0 -3
  108. package/@tool-box/utils/http-client/http-client-exception.js +0 -12
  109. package/@tool-box/utils/http-client/http-client-request.d.ts +0 -9
  110. package/@tool-box/utils/http-client/http-client-request.js +0 -2
  111. package/@tool-box/utils/http-client/http-client-response.d.ts +0 -18
  112. package/@tool-box/utils/http-client/http-client-response.get-header.failure.d.ts +0 -4
  113. package/@tool-box/utils/http-client/http-client-response.get-header.failure.js +0 -14
  114. package/@tool-box/utils/http-client/http-client-response.js +0 -39
  115. package/@tool-box/utils/http-client/http-client.d.ts +0 -9
  116. package/@tool-box/utils/http-client/http-client.js +0 -21
  117. package/@tool-box/utils/randoms/random-value.d.ts +0 -5
  118. package/arch/@atlantjs.json +0 -3
  119. package/arch/biome.json +0 -47
  120. package/arch/modules/application/failures/failure.abstract.d.ts +0 -9
  121. package/arch/modules/application/failures/failure.abstract.js +0 -24
  122. package/arch/modules/application/failures/failure.abstract.type.d.ts +0 -9
  123. package/arch/modules/application/failures/failure.abstract.type.js +0 -2
  124. package/arch/modules/application/failures/unknown-failure.d.ts +0 -15
  125. package/arch/modules/application/failures/unknown-failure.js +0 -16
  126. package/arch/modules/domain/entities/$array.abstract.d.ts +0 -2
  127. package/arch/modules/domain/entities/$array.abstract.js +0 -6
  128. package/arch/modules/domain/entities/$boolean.abstract.d.ts +0 -7
  129. package/arch/modules/domain/entities/$boolean.abstract.js +0 -21
  130. package/arch/modules/domain/entities/$date.abstract.d.ts +0 -2
  131. package/arch/modules/domain/entities/$date.abstract.js +0 -6
  132. package/arch/modules/domain/entities/$number.abstract.d.ts +0 -13
  133. package/arch/modules/domain/entities/$object.abstract.d.ts +0 -2
  134. package/arch/modules/domain/entities/$object.abstract.js +0 -6
  135. package/arch/modules/domain/entities/entity-frontend.abstract.d.ts +0 -6
  136. package/arch/modules/domain/entities/entity-frontend.abstract.js +0 -11
  137. package/arch/modules/domain/entities/solid.abstract.d.ts +0 -4
  138. package/arch/modules/domain/entities/solid.abstract.js +0 -6
  139. package/arch/modules/domain/entities/url.abstract.d.ts +0 -3
  140. package/arch/modules/domain/entities/url.abstract.js +0 -7
  141. package/arch/modules/domain/entities/user/password/password.abstract.d.ts +0 -8
  142. package/arch/modules/domain/entities/user/password/password.abstract.js +0 -41
  143. package/arch/modules/domain/entities/user/password/password.abstract.type.js +0 -2
  144. package/arch/modules/domain/entities/user/password/steps/not-allowing-these-chars-step.js +0 -17
  145. package/arch/modules/domain/entities/user/password/steps/numeric-step.js +0 -13
  146. package/arch/modules/domain/entities/user/password/steps/with-at-least-one-letter-step.js +0 -14
  147. package/arch/modules/domain/entities/user/password/steps/with-at-least-one-number-digit-step.js +0 -14
  148. package/arch/modules/domain/entities/user/password/steps/with-at-least-one-special-char-step.js +0 -14
  149. package/arch/modules/domain/entities/user/password/validation-step.js +0 -9
  150. package/arch/modules/domain/entities/user/password/validation-step.type.js +0 -2
  151. package/arch/modules/domain/entities/user/value-objects/email.d.ts +0 -6
  152. package/arch/modules/domain/entities/user/value-objects/person-name.d.ts +0 -7
  153. package/arch/modules/domain/entities/user/value-objects/person-name.js +0 -17
  154. package/arch/modules/domain/entities/user/value-objects/user-id.d.ts +0 -3
  155. package/arch/modules/domain/entities/user/value-objects/user-id.js +0 -7
  156. package/arch/modules/domain/entities/user/value-objects/username.d.ts +0 -3
  157. package/arch/modules/domain/entities/user/value-objects/username.js +0 -7
  158. package/arch/modules/domain/entities/uuid.abstract.js +0 -23
  159. package/arch/modules/domain/entities/value-object.abstract.d.ts +0 -3
  160. package/arch/modules/domain/entities/value-object.abstract.js +0 -7
  161. package/arch/modules/infrastructure/services/http-client.abstract.d.ts +0 -0
  162. package/arch/modules/infrastructure/services/http-client.abstract.js +0 -1
  163. package/arch/modules/infrastructure/services/payloads/service.payload.abstract.d.ts +0 -0
  164. package/arch/modules/infrastructure/services/payloads/service.payload.abstract.js +0 -1
  165. package/arch/modules/infrastructure/services/responses/service.response.abstract.d.ts +0 -0
  166. package/arch/modules/infrastructure/services/responses/service.response.abstract.js +0 -1
  167. package/arch/tsconfig-backend.json +0 -3
  168. package/arch/tsconfig-default.json +0 -45
  169. package/arch/tsconfig-frontend.json +0 -3
  170. package/arch/tsconfig-lib.json +0 -6
  171. package/arch/tsconfig-mobile.json +0 -3
  172. /package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.d.ts +0 -0
  173. /package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.d.ts +0 -0
  174. /package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.d.ts +0 -0
  175. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.d.ts +0 -0
  176. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.d.ts +0 -0
  177. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.d.ts +0 -0
  178. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.d.ts +0 -0
  179. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.d.ts +0 -0
  180. /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-these-chars-step.d.ts +0 -0
  181. /package/{arch/modules/domain/entities/user → objects}/password/steps/numeric-step.d.ts +0 -0
  182. /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-letter-step.d.ts +0 -0
  183. /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-number-digit-step.d.ts +0 -0
  184. /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-special-char-step.d.ts +0 -0
  185. /package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.d.ts +0 -0
  186. /package/{arch/modules/domain/entities/user → objects}/password/validation-step.d.ts +0 -0
  187. /package/{arch/modules/domain/entities/user → objects}/password/validation-step.type.d.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  type ModifierCallback<T> = (dataToModify: T) => void;
2
- export declare abstract class EntityBuilder<T, TBuilder extends EntityBuilder<T, TBuilder>> {
2
+ export declare abstract class BuilderAbstract<T, TBuilder extends BuilderAbstract<T, TBuilder>> {
3
3
  private readonly innerType;
4
4
  protected modifiers: Array<ModifierCallback<T>>;
5
5
  protected constructor(innerType: new (...args: any[]) => TBuilder);
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EntityBuilder = void 0;
4
- class EntityBuilder {
1
+ export class BuilderAbstract {
2
+ innerType;
3
+ modifiers = [];
5
4
  constructor(innerType) {
6
5
  this.innerType = innerType;
7
- this.modifiers = [];
8
6
  }
9
7
  build() {
10
8
  const instance = this.buildDefault();
@@ -36,4 +34,3 @@ class EntityBuilder {
36
34
  return newBuilder;
37
35
  }
38
36
  }
39
- exports.EntityBuilder = EntityBuilder;
@@ -0,0 +1,3 @@
1
+ import { FailureSketchEdge } from "../../../../../objects/failure/edges/failure.sketch.edge";
2
+ export declare class FailureEdgeDummy extends FailureSketchEdge {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { FailureSketchEdge } from "../../../../../objects/failure/edges/failure.sketch.edge";
2
+ export class FailureEdgeDummy extends FailureSketchEdge {
3
+ }
@@ -0,0 +1,6 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ export declare class FailureEdgeBuilder<T> extends BuilderAbstract<T, FailureEdgeBuilder<T>> {
3
+ private instance;
4
+ constructor(entityClass: new (...args: any[]) => T);
5
+ protected buildDefault(): T;
6
+ }
@@ -0,0 +1,18 @@
1
+ import { FailureEdgeDummy } from "./dummies/failure.edge.dummy";
2
+ import { BuilderAbstract } from "../../builder.abstract.util";
3
+ import { faker } from "../../faker/faker";
4
+ export class FailureEdgeBuilder extends BuilderAbstract {
5
+ instance;
6
+ constructor(entityClass) {
7
+ super(FailureEdgeBuilder);
8
+ this.instance = entityClass;
9
+ }
10
+ buildDefault() {
11
+ const dummy = new FailureEdgeDummy({
12
+ failureClass: FailureEdgeBuilder,
13
+ message: faker.lorem.words(),
14
+ });
15
+ Object.assign(dummy, this.instance);
16
+ return dummy;
17
+ }
18
+ }
@@ -0,0 +1,6 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { EmailEdge } from "../../../../objects/@common/edges/email.edge";
3
+ export declare class EmailEdgeBuilder extends BuilderAbstract<EmailEdge, EmailEdgeBuilder> {
4
+ constructor();
5
+ protected buildDefault(): EmailEdge;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { faker } from "../../faker/faker";
3
+ import { EmailEdge } from "../../../../objects/@common/edges/email.edge";
4
+ export class EmailEdgeBuilder extends BuilderAbstract {
5
+ constructor() {
6
+ super(EmailEdgeBuilder);
7
+ }
8
+ buildDefault() {
9
+ return new EmailEdge(faker.internet.email());
10
+ }
11
+ }
@@ -0,0 +1,6 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { PersonNameEdge } from "../../../../objects/@common/edges/person-name.edge";
3
+ export declare class PersonNameEdgeBuilder extends BuilderAbstract<PersonNameEdge, PersonNameEdgeBuilder> {
4
+ constructor();
5
+ protected buildDefault(): PersonNameEdge;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { faker } from "../../faker/faker";
3
+ import { PersonNameEdge } from "../../../../objects/@common/edges/person-name.edge";
4
+ export class PersonNameEdgeBuilder extends BuilderAbstract {
5
+ constructor() {
6
+ super(PersonNameEdgeBuilder);
7
+ }
8
+ buildDefault() {
9
+ return new PersonNameEdge(faker.person.fullName());
10
+ }
11
+ }
@@ -0,0 +1,6 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { UsernameEdge } from "../../../../objects/@common/edges/username.edge";
3
+ export declare class UsernameEdgeBuilder extends BuilderAbstract<UsernameEdge, UsernameEdgeBuilder> {
4
+ constructor();
5
+ protected buildDefault(): UsernameEdge;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { BuilderAbstract } from "../../builder.abstract.util";
2
+ import { faker } from "../../faker/faker";
3
+ import { UsernameEdge } from "../../../../objects/@common/edges/username.edge";
4
+ export class UsernameEdgeBuilder extends BuilderAbstract {
5
+ constructor() {
6
+ super(UsernameEdgeBuilder);
7
+ }
8
+ buildDefault() {
9
+ return new UsernameEdge(faker.internet.username());
10
+ }
11
+ }
@@ -0,0 +1,9 @@
1
+ import { Return } from "../utils/ducts/return-type";
2
+ import { FailureSketchEdge } from "../../objects/failure/edges/failure.sketch.edge";
3
+ export declare class CreateFakeCommand {
4
+ private _response;
5
+ static new<UsecaseStub>(): UsecaseStub & CreateFakeCommand;
6
+ protected execute(): Promise<Return<unknown, unknown>>;
7
+ withSuccess(response: unknown): this;
8
+ withFailure(response?: FailureSketchEdge): this;
9
+ }
@@ -0,0 +1,23 @@
1
+ import { FailureEdgeDummy } from "./builders/failures/dummies/failure.edge.dummy";
2
+ import { FailureEdgeBuilder } from "./builders/failures/failure.edge.builder";
3
+ import { Failure, Success } from "../utils/ducts/return-type";
4
+ export class CreateFakeCommand {
5
+ _response;
6
+ static new() {
7
+ const instance = new CreateFakeCommand();
8
+ return instance;
9
+ }
10
+ async execute() {
11
+ if (this._response.hasFailure())
12
+ return Failure(this._response.unwrapFail());
13
+ return Success(this._response.unwrap());
14
+ }
15
+ withSuccess(response) {
16
+ this._response = Success(response);
17
+ return this;
18
+ }
19
+ withFailure(response) {
20
+ this._response = Failure(response ?? new FailureEdgeBuilder(FailureEdgeDummy).build());
21
+ return this;
22
+ }
23
+ }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.faker = void 0;
4
- exports.faker = {
1
+ export const faker = {
5
2
  date: {
6
3
  past: ({ yearsAgo = 1 } = {}) => {
7
4
  const date = new Date();
@@ -35,15 +32,15 @@ exports.faker = {
35
32
  productDescription: ({ lines = 3 } = {}) => {
36
33
  const result = [];
37
34
  for (let i = 0; i < lines; i++) {
38
- result.push(exports.faker.lorem.paragraph());
35
+ result.push(faker.lorem.paragraph());
39
36
  }
40
37
  return result.join("\n");
41
38
  }
42
39
  },
43
40
  image: {
44
41
  url: () => {
45
- const width = exports.faker.number.int({ min: 100, max: 1000 });
46
- const height = exports.faker.number.int({ min: 100, max: 1000 });
42
+ const width = faker.number.int({ min: 100, max: 1000 });
43
+ const height = faker.number.int({ min: 100, max: 1000 });
47
44
  return `https://via.placeholder.com/${width}x${height}`;
48
45
  }
49
46
  },
@@ -81,7 +78,7 @@ exports.faker = {
81
78
  return lastNames[Math.floor(Math.random() * lastNames.length)];
82
79
  },
83
80
  fullName: () => {
84
- return `${exports.faker.person.firstName()} ${exports.faker.person.lastName()}`;
81
+ return `${faker.person.firstName()} ${faker.person.lastName()}`;
85
82
  },
86
83
  },
87
84
  internet: {
@@ -91,7 +88,7 @@ exports.faker = {
91
88
  },
92
89
  email: () => {
93
90
  const domains = ["example.com", "test.com", "demo.com", "sample.com"];
94
- return `${exports.faker.internet.username()}@${domains[Math.floor(Math.random() * domains.length)]}`;
91
+ return `${faker.internet.username()}@${domains[Math.floor(Math.random() * domains.length)]}`;
95
92
  },
96
93
  url: () => {
97
94
  const protocols = ["http", "https"];
@@ -117,7 +114,7 @@ exports.faker = {
117
114
  paragraph: ({ sentences = 5 } = {}) => {
118
115
  const result = [];
119
116
  for (let i = 0; i < sentences; i++) {
120
- result.push(exports.faker.lorem.words({ count: Math.floor(Math.random() * 10) + 5 }));
117
+ result.push(faker.lorem.words({ count: Math.floor(Math.random() * 10) + 5 }));
121
118
  }
122
119
  return result.join(". ") + ".";
123
120
  }
@@ -2,6 +2,7 @@ interface Boolean {
2
2
  truthy(): boolean;
3
3
  falsy(): boolean;
4
4
  equal(value: boolean): boolean;
5
+ different(value: boolean): boolean;
5
6
  not(): boolean;
6
7
  and(value: boolean): boolean;
7
8
  or(value: boolean): boolean;
@@ -9,11 +9,14 @@ Boolean.prototype.not = function () {
9
9
  return !this.valueOf();
10
10
  };
11
11
  Boolean.prototype.and = function (value) {
12
- return this.valueOf() && value;
12
+ return this.valueOf() === true && value === true;
13
13
  };
14
14
  Boolean.prototype.or = function (value) {
15
- return this.valueOf() || value;
15
+ return this.valueOf() === true || value === true;
16
16
  };
17
17
  Boolean.prototype.equal = function (value) {
18
18
  return this === value;
19
19
  };
20
+ Boolean.prototype.different = function (value) {
21
+ return this !== value;
22
+ };
@@ -1,7 +1,7 @@
1
1
  declare const emptyObject: {};
2
2
  export type Newable<T> = new (...args: any[]) => T;
3
3
  export type ObjectType = typeof emptyObject;
4
- export interface Abstract<T> {
4
+ export interface Sketch<T> {
5
5
  prototype: T;
6
6
  }
7
7
  export {};
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const emptyObject = {};
2
+ export {};
@@ -2,14 +2,12 @@ interface String {
2
2
  toKebabCase(): string;
3
3
  toSnakeCase(): string;
4
4
  toPascalCase(): string;
5
- reverse(): string;
6
- trimSpaces(): string;
5
+ sanitize(): string;
7
6
  capitalize(): string;
8
7
  toTitleCase(): string;
9
8
  contains(substring: string): boolean;
10
9
  truncate(length: number): String;
11
10
  removeWhitespace(): string;
12
- toArray(): string[];
13
11
  isEmpty(): boolean;
14
12
  fromBase64(): string;
15
13
  }
@@ -8,10 +8,7 @@ String.prototype.toSnakeCase = function () {
8
8
  String.prototype.toPascalCase = function () {
9
9
  return this.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, (match) => match.toUpperCase()).replace(/\s+/g, "");
10
10
  };
11
- String.prototype.reverse = function () {
12
- return this.split("").reverse().join("");
13
- };
14
- String.prototype.trimSpaces = function () {
11
+ String.prototype.sanitize = function () {
15
12
  return this.replace(/\s+/g, " ").trim();
16
13
  };
17
14
  String.prototype.capitalize = function () {
@@ -19,9 +16,6 @@ String.prototype.capitalize = function () {
19
16
  .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
20
17
  .join(" ");
21
18
  };
22
- String.prototype.toTitleCase = function () {
23
- return this.replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase());
24
- };
25
19
  String.prototype.contains = function (substring) {
26
20
  return this.indexOf(substring) !== -1;
27
21
  };
@@ -33,9 +27,6 @@ String.prototype.truncate = function (length) {
33
27
  String.prototype.removeWhitespace = function () {
34
28
  return this.replace(/\s+/g, "");
35
29
  };
36
- String.prototype.toArray = function () {
37
- return this.split("");
38
- };
39
30
  String.prototype.isEmpty = function () {
40
31
  return this.length === 0;
41
32
  };
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyArray = exports.FnVal = exports.ValueReturn = exports.SuccessReturn = void 0;
4
- exports.isTruthy = isTruthy;
5
- const guardian_1 = require("../type-guard/guardian");
6
- exports.SuccessReturn = Symbol("SuccessReturn");
7
- exports.ValueReturn = Symbol("ValueReturn");
8
- exports.FnVal = Symbol("FnVal");
9
- exports.EmptyArray = Object.freeze([]);
10
- function isTruthy(val) {
1
+ import { _ } from "../type-guard/guardian";
2
+ export const SuccessReturn = Symbol("SuccessReturn");
3
+ export const ValueReturn = Symbol("ValueReturn");
4
+ export const FnVal = Symbol("FnVal");
5
+ export const EmptyArray = Object.freeze([]);
6
+ export function isTruthy(val) {
11
7
  return val instanceof Date
12
- ? guardian_1.Guardian.isEqual(val.getTime(), val.getTime())
8
+ ? _.isEqual(val.getTime(), val.getTime())
13
9
  : !!val;
14
10
  }
@@ -20,6 +20,5 @@ declare class OptionalType<T> {
20
20
  unpackOrElse(this: Optional<T>, f: () => T): T;
21
21
  }
22
22
  export declare function Optional<T>(val: T): Optional<From<T>>;
23
- export declare function Something<T>(val: T): Something<T>;
24
23
  export declare const Nothing: Readonly<OptionalType<never>>;
25
24
  export {};
@@ -1,50 +1,47 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Nothing = void 0;
4
- exports.Optional = Optional;
5
- exports.Something = Something;
6
- const common_1 = require("./common");
1
+ import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
7
2
  class OptionalType {
3
+ [SuccessReturn];
4
+ [ValueReturn];
8
5
  constructor(val, something) {
9
- this[common_1.SuccessReturn] = something;
10
- this[common_1.ValueReturn] = val;
6
+ this[SuccessReturn] = something;
7
+ this[ValueReturn] = val;
11
8
  }
12
9
  [Symbol.iterator]() {
13
- return this[common_1.SuccessReturn]
14
- ? this[common_1.ValueReturn][Symbol.iterator]()
15
- : common_1.EmptyArray[Symbol.iterator]();
10
+ return this[SuccessReturn]
11
+ ? this[ValueReturn][Symbol.iterator]()
12
+ : EmptyArray[Symbol.iterator]();
16
13
  }
17
14
  hasSomething() {
18
- return this[common_1.SuccessReturn];
15
+ return this[SuccessReturn];
19
16
  }
20
17
  hasNothing() {
21
- return !this[common_1.SuccessReturn];
18
+ return !this[SuccessReturn];
22
19
  }
23
20
  unpack() {
24
- if (this[common_1.SuccessReturn]) {
25
- return this[common_1.ValueReturn];
21
+ if (this[SuccessReturn]) {
22
+ return this[ValueReturn];
26
23
  }
27
24
  throw new Error("Failed to unpack optional value. There is nothing in here");
28
25
  }
29
26
  unpackAnyway() {
30
- return this[common_1.ValueReturn];
27
+ return this[ValueReturn];
31
28
  }
32
29
  unpackOr(def) {
33
- return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : def;
30
+ return this[SuccessReturn] ? this[ValueReturn] : def;
34
31
  }
35
32
  unpackOrElse(f) {
36
- return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : f();
33
+ return this[SuccessReturn] ? this[ValueReturn] : f();
37
34
  }
38
35
  }
39
- function Optional(val) {
36
+ export function Optional(val) {
40
37
  return from(val);
41
38
  }
42
39
  function Something(val) {
43
40
  return new OptionalType(val, true);
44
41
  }
45
- exports.Nothing = Object.freeze(new OptionalType(undefined, false));
42
+ export const Nothing = Object.freeze(new OptionalType(undefined, false));
46
43
  function from(val) {
47
- return (0, common_1.isTruthy)(val) && !(val instanceof Error)
44
+ return isTruthy(val) && !(val instanceof Error)
48
45
  ? Something(val)
49
- : exports.Nothing;
46
+ : Nothing;
50
47
  }
@@ -1,5 +1,5 @@
1
- import { FailureAbstract } from "../../../arch/modules/application/failures/failure.abstract";
2
1
  import { FalseyValues, IterType, SuccessReturn, ValueReturn } from "./common";
2
+ import { FailureSketchEdge } from "../../../objects/failure/edges/failure.sketch.edge";
3
3
  export type Success<SuccessReturn> = ReturnType<SuccessReturn, never>;
4
4
  export type Failure<FailureReturn> = ReturnType<never, FailureReturn>;
5
5
  export type Return<T, E> = ReturnType<T, E>;
@@ -18,5 +18,5 @@ export declare class ReturnType<SuccessReturn, FailureReturn> {
18
18
  }
19
19
  export declare function Return<T>(val: T): Return<From<T>, (T extends Error ? T : never) | (Extract<FalseyValues, T> extends never ? never : null)>;
20
20
  export declare function Success<SuccessReturn>(successValue?: SuccessReturn): Success<SuccessReturn>;
21
- export declare function Failure<FailureReturn extends FailureAbstract | null | undefined>(failureValue?: FailureReturn): Failure<FailureReturn>;
21
+ export declare function Failure<FailureReturn extends FailureSketchEdge | null | undefined>(failureValue?: FailureReturn): Failure<FailureReturn>;
22
22
  export {};
@@ -1,57 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReturnType = void 0;
4
- exports.Return = Return;
5
- exports.Success = Success;
6
- exports.Failure = Failure;
7
- const common_1 = require("./common");
8
- class ReturnType {
1
+ import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
2
+ export class ReturnType {
3
+ [SuccessReturn];
4
+ [ValueReturn];
9
5
  constructor(value, hasSuccess) {
10
- this[common_1.ValueReturn] = value;
11
- this[common_1.SuccessReturn] = hasSuccess;
6
+ this[ValueReturn] = value;
7
+ this[SuccessReturn] = hasSuccess;
12
8
  }
13
9
  [Symbol.iterator]() {
14
- return this[common_1.SuccessReturn]
15
- ? this[common_1.ValueReturn][Symbol.iterator]()
16
- : common_1.EmptyArray[Symbol.iterator]();
10
+ return this[SuccessReturn]
11
+ ? this[ValueReturn][Symbol.iterator]()
12
+ : EmptyArray[Symbol.iterator]();
17
13
  }
18
14
  hasSuccess() {
19
- return this[common_1.SuccessReturn];
15
+ return this[SuccessReturn];
20
16
  }
21
17
  hasFailure() {
22
- return !this[common_1.SuccessReturn];
18
+ return !this[SuccessReturn];
23
19
  }
24
20
  unwrap() {
25
- if (this[common_1.SuccessReturn]) {
26
- return this[common_1.ValueReturn];
21
+ if (this[SuccessReturn]) {
22
+ return this[ValueReturn];
27
23
  }
28
24
  throw new Error("Failed to unwrap Return. There is failure in here");
29
25
  }
30
26
  unwrapFail() {
31
- if (this[common_1.SuccessReturn]) {
27
+ if (this[SuccessReturn]) {
32
28
  throw new Error("Failed to unwrapFail Return. There is success in here");
33
29
  }
34
- return this[common_1.ValueReturn];
30
+ return this[ValueReturn];
35
31
  }
36
32
  unwrapOr(def) {
37
- return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : def;
33
+ return this[SuccessReturn] ? this[ValueReturn] : def;
38
34
  }
39
35
  unwrapAnyway() {
40
- return this[common_1.ValueReturn];
36
+ return this[ValueReturn];
41
37
  }
42
38
  }
43
- exports.ReturnType = ReturnType;
44
- function Return(val) {
39
+ export function Return(val) {
45
40
  return from(val);
46
41
  }
47
- function Success(successValue) {
42
+ export function Success(successValue) {
48
43
  return new ReturnType(successValue, true);
49
44
  }
50
- function Failure(failureValue) {
45
+ export function Failure(failureValue) {
51
46
  return new ReturnType(failureValue, false);
52
47
  }
53
48
  function from(val) {
54
- return (0, common_1.isTruthy)(val)
49
+ return isTruthy(val)
55
50
  ? new ReturnType(val, !(val instanceof Error))
56
51
  : Failure(null);
57
52
  }
@@ -1,5 +1,4 @@
1
- export declare class ExtendedMap<K, V> extends Map<K, V> {
1
+ export declare abstract class MapAbstract<K, V> extends Map<K, V> {
2
2
  getOrDefault(key: K, defaultValue: V): V;
3
3
  getOrThrow(key: K, errorMessage?: string): V;
4
- invert(): ExtendedMap<V, K>;
5
4
  }
@@ -0,0 +1,13 @@
1
+ import { _ } from "../type-guard/guardian";
2
+ export class MapAbstract extends Map {
3
+ getOrDefault(key, defaultValue) {
4
+ return this.get(key) ?? defaultValue;
5
+ }
6
+ getOrThrow(key, errorMessage = "Key not mapped") {
7
+ const value = this.get(key);
8
+ if (_.isUndefined(value)) {
9
+ throw Error(errorMessage);
10
+ }
11
+ return value;
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ export declare class Random {
2
+ static number(min: number, max: number): number;
3
+ static enum<T extends Record<string, unknown>>(anEnum: T): T[keyof T];
4
+ static enumExcluding<T extends Record<string, unknown>>(anEnum: T, excepts: Array<T[keyof T]>): T[keyof T];
5
+ }
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RandomValue = void 0;
4
- class RandomValue {
5
- static randomNumber(min, max) {
1
+ export class Random {
2
+ static number(min, max) {
6
3
  return Math.floor(Math.random() * (max - min + 1)) + min;
7
4
  }
8
- static randomEnumValue(anEnum) {
5
+ static enum(anEnum) {
9
6
  const keys = Object.keys(anEnum).filter((x) => Number.isNaN(Number(x)));
10
7
  const randomKeyIndex = Math.floor(Math.random() * keys.length);
11
8
  const randomKey = keys[randomKeyIndex];
12
9
  return anEnum[randomKey];
13
10
  }
14
- static randomEnumValueExcept(anEnum, excepts) {
11
+ static enumExcluding(anEnum, excepts) {
15
12
  const exceptKeys = excepts.map((value) => Object.keys(anEnum).find((key) => anEnum[key] === value));
16
13
  const validKeys = Object.keys(anEnum).filter((key) => Number.isNaN(Number(key)) && !exceptKeys.includes(key));
17
14
  if (validKeys.length === 0) {
@@ -22,4 +19,3 @@ class RandomValue {
22
19
  return anEnum[randomKey];
23
20
  }
24
21
  }
25
- exports.RandomValue = RandomValue;
@@ -1,6 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuardianException = void 0;
4
- class GuardianException extends Error {
1
+ export class GuardianException extends Error {
5
2
  }
6
- exports.GuardianException = GuardianException;
@@ -1,31 +1,29 @@
1
1
  import { PrimitiveType } from "./guardian.type";
2
- export declare class Guardian {
2
+ declare class Guardian {
3
3
  static and(...args: boolean[]): boolean;
4
4
  static or(...args: boolean[]): boolean;
5
5
  static greaterThan(value: number, reference: number): boolean;
6
6
  static lessThan(value: number, reference: number): boolean;
7
- static isArrayEmpty<T>(value: T[] | null | undefined): value is T[];
8
- static isArrayNotEmpty<T>(value: T[] | null | undefined): value is T[];
9
- static isEmpty<T>(value: unknown): value is null | undefined | T[];
10
- static isNotEmpty(value: unknown): boolean;
7
+ static isEmptyArray<T>(value: T[] | null | undefined): value is T[];
8
+ static isFilledArray<T>(value: T[] | null | undefined): value is T[];
9
+ static isLengthArray<T>(value: T[] | null | undefined, reference: number): value is T[];
10
+ private static isEmpty;
11
11
  static isUndefined(value: unknown): value is undefined;
12
12
  static isNotUndefined(value: unknown): value is boolean;
13
13
  static isNull(value: unknown): value is null;
14
14
  static isNotNull(value: unknown): value is boolean;
15
15
  static isEqual(valueA: unknown, valueB: unknown): boolean;
16
- static isAnyOf(reference: unknown, anyValues: unknown[]): boolean;
17
16
  static isDifferent(valueA: unknown, valueB: unknown): boolean;
18
- static isTruthy(value: boolean): boolean;
19
- static isFalsy(value: boolean | undefined): boolean;
17
+ static isAnyOf(reference: unknown, anyValues: unknown[]): boolean;
20
18
  static ternaryCondition<TTrue, TFalse>(condition: boolean, returnIfTrue: TTrue, returnIfFalse: TFalse): TTrue | TFalse;
21
19
  static isBetween(value: number | string, min: number, max: number): boolean;
22
- static isLengthEqual(value: unknown, length: number): boolean;
23
20
  static isNullOrUndefined(value: unknown): value is null | undefined;
24
21
  static isNotNullOrUndefined(value: unknown): value is boolean;
25
- static isNumber(value: unknown): value is number;
26
- static isString(value: unknown): value is string;
27
- static isArray(value: unknown): value is unknown[];
28
- static isObject(value: unknown): value is object;
22
+ private static isNumber;
23
+ private static isString;
24
+ private static isArray;
25
+ private static isObject;
29
26
  static isTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
30
27
  static isNotTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
31
28
  }
29
+ export { Guardian as _ };