@atlantjs/arch 10.0.9 → 10.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 (56) hide show
  1. package/@tool-box/tests/builder.abstract.util.js +6 -3
  2. package/@tool-box/tests/builders/failures/dummies/failure.dummy.js +6 -2
  3. package/@tool-box/tests/builders/failures/failure.builder.js +10 -7
  4. package/@tool-box/tests/builders/user/email.edge.builder.js +9 -5
  5. package/@tool-box/tests/builders/user/person-name.edge.builder.js +9 -5
  6. package/@tool-box/tests/builders/user/username.edge.builder.js +9 -5
  7. package/@tool-box/tests/create-fake-command.js +12 -9
  8. package/@tool-box/tests/faker/faker.js +10 -7
  9. package/@tool-box/utils/datatypes/generic-types.js +2 -1
  10. package/@tool-box/utils/datetime/mappers/month.mapper.js +53 -49
  11. package/@tool-box/utils/datetime/mappers/points/month-abbreviation.enum.js +5 -2
  12. package/@tool-box/utils/datetime/mappers/points/month-number.enum.js +5 -2
  13. package/@tool-box/utils/ducts/common.js +11 -7
  14. package/@tool-box/utils/ducts/optional-type.js +21 -19
  15. package/@tool-box/utils/ducts/return-type.js +26 -21
  16. package/@tool-box/utils/map/map.abstract.js +7 -3
  17. package/@tool-box/utils/random/random.js +5 -1
  18. package/@tool-box/utils/type-guard/guardian-exception.js +5 -1
  19. package/@tool-box/utils/type-guard/guardian.js +10 -7
  20. package/@tool-box/utils/type-guard/guardian.type.js +2 -1
  21. package/index.js +72 -34
  22. package/objects/@common/edges/email.edge.js +6 -3
  23. package/objects/@common/edges/person-name.edge.js +6 -3
  24. package/objects/@common/edges/url.edge.js +6 -3
  25. package/objects/@common/edges/username.edge.js +6 -2
  26. package/objects/@common/edges/uuid.sketch.edge.js +13 -7
  27. package/objects/@common/points/header-token-name.enum.js +5 -2
  28. package/objects/@common/points/http-status-codes.enum.js +5 -2
  29. package/objects/@common/points/node-envs.enum.js +5 -2
  30. package/objects/datetime/edges/datetime.edge.js +39 -34
  31. package/objects/datetime/points/month-name.enum.js +5 -2
  32. package/objects/datetime/points/week-day.enum.js +5 -2
  33. package/objects/failure/edges/failure.abstract.js +8 -7
  34. package/objects/failure/edges/failure.abstract.polygon.js +2 -1
  35. package/objects/password/password.edge.js +17 -14
  36. package/objects/password/password.polygon.js +2 -1
  37. package/objects/password/steps/not-allowing-consecutive-chars-step.js +6 -3
  38. package/objects/password/steps/not-allowing-date-step.js +6 -3
  39. package/objects/password/steps/not-allowing-phone-step.js +6 -3
  40. package/objects/password/steps/not-allowing-repeated-chars-step.js +6 -3
  41. package/objects/password/steps/not-allowing-string-step.js +6 -3
  42. package/objects/password/steps/not-allowing-these-chars-step.js +6 -3
  43. package/objects/password/steps/numeric-step.js +6 -2
  44. package/objects/password/steps/with-at-least-one-letter-step.js +6 -2
  45. package/objects/password/steps/with-at-least-one-number-digit-step.js +6 -2
  46. package/objects/password/steps/with-at-least-one-special-char-step.js +6 -2
  47. package/objects/password/steps/with-length-step.js +6 -3
  48. package/objects/password/validation-step.js +5 -1
  49. package/objects/password/validation-step.type.js +2 -1
  50. package/objects/primitives/boolean.edge.sketch.js +5 -2
  51. package/objects/primitives/datetime.edge.sketch.js +6 -2
  52. package/objects/primitives/number.edge.sketch.js +7 -4
  53. package/objects/primitives/string.edge.sketch.js +5 -2
  54. package/package.json +1 -1
  55. package/tsconfig-default.json +2 -5
  56. package/tsconfig.tsbuildinfo +1 -1
@@ -1,8 +1,10 @@
1
- export class BuilderAbstract {
2
- innerType;
3
- modifiers = [];
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BuilderAbstract = void 0;
4
+ class BuilderAbstract {
4
5
  constructor(innerType) {
5
6
  this.innerType = innerType;
7
+ this.modifiers = [];
6
8
  }
7
9
  build() {
8
10
  const instance = this.buildDefault();
@@ -34,3 +36,4 @@ export class BuilderAbstract {
34
36
  return newBuilder;
35
37
  }
36
38
  }
39
+ exports.BuilderAbstract = BuilderAbstract;
@@ -1,3 +1,7 @@
1
- import { FailureAbstract } from "../../../../../objects/failure/edges/failure.abstract";
2
- export class FailureDummy extends FailureAbstract {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FailureDummy = void 0;
4
+ const failure_abstract_1 = require("../../../../../objects/failure/edges/failure.abstract");
5
+ class FailureDummy extends failure_abstract_1.FailureAbstract {
3
6
  }
7
+ exports.FailureDummy = FailureDummy;
@@ -1,18 +1,21 @@
1
- import { BuilderAbstract } from "../../builder.abstract.util";
2
- import { FailureDummy } from "./dummies/failure.dummy";
3
- import { faker } from "../../faker/faker";
4
- export class FailureBuilder extends BuilderAbstract {
5
- instance;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FailureBuilder = void 0;
4
+ const builder_abstract_util_1 = require("../../builder.abstract.util");
5
+ const failure_dummy_1 = require("./dummies/failure.dummy");
6
+ const faker_1 = require("../../faker/faker");
7
+ class FailureBuilder extends builder_abstract_util_1.BuilderAbstract {
6
8
  constructor(entityClass) {
7
9
  super(FailureBuilder);
8
10
  this.instance = entityClass;
9
11
  }
10
12
  buildDefault() {
11
- const dummy = new FailureDummy({
13
+ const dummy = new failure_dummy_1.FailureDummy({
12
14
  failureClass: FailureBuilder,
13
- message: faker.lorem.words(),
15
+ message: faker_1.faker.lorem.words(),
14
16
  });
15
17
  Object.assign(dummy, this.instance);
16
18
  return dummy;
17
19
  }
18
20
  }
21
+ exports.FailureBuilder = FailureBuilder;
@@ -1,11 +1,15 @@
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 {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmailEdgeBuilder = void 0;
4
+ const builder_abstract_util_1 = require("../../builder.abstract.util");
5
+ const faker_1 = require("../../faker/faker");
6
+ const email_edge_1 = require("../../../../objects/@common/edges/email.edge");
7
+ class EmailEdgeBuilder extends builder_abstract_util_1.BuilderAbstract {
5
8
  constructor() {
6
9
  super(EmailEdgeBuilder);
7
10
  }
8
11
  buildDefault() {
9
- return new EmailEdge(faker.internet.email());
12
+ return new email_edge_1.EmailEdge(faker_1.faker.internet.email());
10
13
  }
11
14
  }
15
+ exports.EmailEdgeBuilder = EmailEdgeBuilder;
@@ -1,11 +1,15 @@
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 {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PersonNameEdgeBuilder = void 0;
4
+ const builder_abstract_util_1 = require("../../builder.abstract.util");
5
+ const faker_1 = require("../../faker/faker");
6
+ const person_name_edge_1 = require("../../../../objects/@common/edges/person-name.edge");
7
+ class PersonNameEdgeBuilder extends builder_abstract_util_1.BuilderAbstract {
5
8
  constructor() {
6
9
  super(PersonNameEdgeBuilder);
7
10
  }
8
11
  buildDefault() {
9
- return new PersonNameEdge(faker.person.fullName());
12
+ return new person_name_edge_1.PersonNameEdge(faker_1.faker.person.fullName());
10
13
  }
11
14
  }
15
+ exports.PersonNameEdgeBuilder = PersonNameEdgeBuilder;
@@ -1,11 +1,15 @@
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 {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsernameEdgeBuilder = void 0;
4
+ const builder_abstract_util_1 = require("../../builder.abstract.util");
5
+ const faker_1 = require("../../faker/faker");
6
+ const username_edge_1 = require("../../../../objects/@common/edges/username.edge");
7
+ class UsernameEdgeBuilder extends builder_abstract_util_1.BuilderAbstract {
5
8
  constructor() {
6
9
  super(UsernameEdgeBuilder);
7
10
  }
8
11
  buildDefault() {
9
- return new UsernameEdge(faker.internet.username());
12
+ return new username_edge_1.UsernameEdge(faker_1.faker.internet.username());
10
13
  }
11
14
  }
15
+ exports.UsernameEdgeBuilder = UsernameEdgeBuilder;
@@ -1,23 +1,26 @@
1
- import { FailureDummy } from "./builders/failures/dummies/failure.dummy";
2
- import { FailureBuilder } from "./builders/failures/failure.builder";
3
- import { Failure, Success } from "../utils/ducts/return-type";
4
- export class CreateFakeCommand {
5
- _response;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateFakeCommand = void 0;
4
+ const failure_dummy_1 = require("./builders/failures/dummies/failure.dummy");
5
+ const failure_builder_1 = require("./builders/failures/failure.builder");
6
+ const return_type_1 = require("../utils/ducts/return-type");
7
+ class CreateFakeCommand {
6
8
  static new() {
7
9
  const instance = new CreateFakeCommand();
8
10
  return instance;
9
11
  }
10
12
  async execute() {
11
13
  if (this._response.hasFailure())
12
- return Failure(this._response.unwrapFail());
13
- return Success(this._response.unwrap());
14
+ return (0, return_type_1.Failure)(this._response.unwrapFail());
15
+ return (0, return_type_1.Success)(this._response.unwrap());
14
16
  }
15
17
  withSuccess(response) {
16
- this._response = Success(response);
18
+ this._response = (0, return_type_1.Success)(response);
17
19
  return this;
18
20
  }
19
21
  withFailure(response) {
20
- this._response = Failure(response ?? new FailureBuilder(FailureDummy).build());
22
+ this._response = (0, return_type_1.Failure)(response ?? new failure_builder_1.FailureBuilder(failure_dummy_1.FailureDummy).build());
21
23
  return this;
22
24
  }
23
25
  }
26
+ exports.CreateFakeCommand = CreateFakeCommand;
@@ -1,4 +1,7 @@
1
- export const faker = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.faker = void 0;
4
+ exports.faker = {
2
5
  date: {
3
6
  past: ({ yearsAgo = 1 } = {}) => {
4
7
  const date = new Date();
@@ -32,15 +35,15 @@ export const faker = {
32
35
  productDescription: ({ lines = 3 } = {}) => {
33
36
  const result = [];
34
37
  for (let i = 0; i < lines; i++) {
35
- result.push(faker.lorem.paragraph());
38
+ result.push(exports.faker.lorem.paragraph());
36
39
  }
37
40
  return result.join("\n");
38
41
  }
39
42
  },
40
43
  image: {
41
44
  url: () => {
42
- const width = faker.number.int({ min: 100, max: 1000 });
43
- const height = faker.number.int({ min: 100, max: 1000 });
45
+ const width = exports.faker.number.int({ min: 100, max: 1000 });
46
+ const height = exports.faker.number.int({ min: 100, max: 1000 });
44
47
  return `https://via.placeholder.com/${width}x${height}`;
45
48
  }
46
49
  },
@@ -78,7 +81,7 @@ export const faker = {
78
81
  return lastNames[Math.floor(Math.random() * lastNames.length)];
79
82
  },
80
83
  fullName: () => {
81
- return `${faker.person.firstName()} ${faker.person.lastName()}`;
84
+ return `${exports.faker.person.firstName()} ${exports.faker.person.lastName()}`;
82
85
  },
83
86
  },
84
87
  internet: {
@@ -88,7 +91,7 @@ export const faker = {
88
91
  },
89
92
  email: () => {
90
93
  const domains = ["example.com", "test.com", "demo.com", "sample.com"];
91
- return `${faker.internet.username()}@${domains[Math.floor(Math.random() * domains.length)]}`;
94
+ return `${exports.faker.internet.username()}@${domains[Math.floor(Math.random() * domains.length)]}`;
92
95
  },
93
96
  url: () => {
94
97
  const protocols = ["http", "https"];
@@ -114,7 +117,7 @@ export const faker = {
114
117
  paragraph: ({ sentences = 5 } = {}) => {
115
118
  const result = [];
116
119
  for (let i = 0; i < sentences; i++) {
117
- result.push(faker.lorem.words({ count: Math.floor(Math.random() * 10) + 5 }));
120
+ result.push(exports.faker.lorem.words({ count: Math.floor(Math.random() * 10) + 5 }));
118
121
  }
119
122
  return result.join(". ") + ".";
120
123
  }
@@ -1,2 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const emptyObject = {};
2
- export {};
@@ -1,54 +1,58 @@
1
- import { MonthAbbreviationEnum } from "./points/month-abbreviation.enum";
2
- import { MonthNumberEnum } from "./points/month-number.enum";
3
- export class MonthMapper {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MonthMapper = void 0;
4
+ const month_abbreviation_enum_1 = require("./points/month-abbreviation.enum");
5
+ const month_number_enum_1 = require("./points/month-number.enum");
6
+ class MonthMapper {
4
7
  static toNumber(monthAbbreviation) {
5
- if (monthAbbreviation === MonthAbbreviationEnum.january)
6
- return MonthNumberEnum.january;
7
- if (monthAbbreviation === MonthAbbreviationEnum.february)
8
- return MonthNumberEnum.february;
9
- if (monthAbbreviation === MonthAbbreviationEnum.march)
10
- return MonthNumberEnum.march;
11
- if (monthAbbreviation === MonthAbbreviationEnum.april)
12
- return MonthNumberEnum.april;
13
- if (monthAbbreviation === MonthAbbreviationEnum.may)
14
- return MonthNumberEnum.may;
15
- if (monthAbbreviation === MonthAbbreviationEnum.june)
16
- return MonthNumberEnum.june;
17
- if (monthAbbreviation === MonthAbbreviationEnum.july)
18
- return MonthNumberEnum.july;
19
- if (monthAbbreviation === MonthAbbreviationEnum.august)
20
- return MonthNumberEnum.august;
21
- if (monthAbbreviation === MonthAbbreviationEnum.september)
22
- return MonthNumberEnum.september;
23
- if (monthAbbreviation === MonthAbbreviationEnum.october)
24
- return MonthNumberEnum.october;
25
- if (monthAbbreviation === MonthAbbreviationEnum.november)
26
- return MonthNumberEnum.november;
27
- return MonthNumberEnum.december;
8
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.january)
9
+ return month_number_enum_1.MonthNumberEnum.january;
10
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.february)
11
+ return month_number_enum_1.MonthNumberEnum.february;
12
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.march)
13
+ return month_number_enum_1.MonthNumberEnum.march;
14
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.april)
15
+ return month_number_enum_1.MonthNumberEnum.april;
16
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.may)
17
+ return month_number_enum_1.MonthNumberEnum.may;
18
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.june)
19
+ return month_number_enum_1.MonthNumberEnum.june;
20
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.july)
21
+ return month_number_enum_1.MonthNumberEnum.july;
22
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.august)
23
+ return month_number_enum_1.MonthNumberEnum.august;
24
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.september)
25
+ return month_number_enum_1.MonthNumberEnum.september;
26
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.october)
27
+ return month_number_enum_1.MonthNumberEnum.october;
28
+ if (monthAbbreviation === month_abbreviation_enum_1.MonthAbbreviationEnum.november)
29
+ return month_number_enum_1.MonthNumberEnum.november;
30
+ return month_number_enum_1.MonthNumberEnum.december;
28
31
  }
29
32
  static toAbbreviation(monthNumber) {
30
- if (monthNumber === MonthNumberEnum.january)
31
- return MonthAbbreviationEnum.january;
32
- if (monthNumber === MonthNumberEnum.february)
33
- return MonthAbbreviationEnum.february;
34
- if (monthNumber === MonthNumberEnum.march)
35
- return MonthAbbreviationEnum.march;
36
- if (monthNumber === MonthNumberEnum.april)
37
- return MonthAbbreviationEnum.april;
38
- if (monthNumber === MonthNumberEnum.may)
39
- return MonthAbbreviationEnum.may;
40
- if (monthNumber === MonthNumberEnum.june)
41
- return MonthAbbreviationEnum.june;
42
- if (monthNumber === MonthNumberEnum.july)
43
- return MonthAbbreviationEnum.july;
44
- if (monthNumber === MonthNumberEnum.august)
45
- return MonthAbbreviationEnum.august;
46
- if (monthNumber === MonthNumberEnum.september)
47
- return MonthAbbreviationEnum.september;
48
- if (monthNumber === MonthNumberEnum.october)
49
- return MonthAbbreviationEnum.october;
50
- if (monthNumber === MonthNumberEnum.november)
51
- return MonthAbbreviationEnum.november;
52
- return MonthAbbreviationEnum.december;
33
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.january)
34
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.january;
35
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.february)
36
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.february;
37
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.march)
38
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.march;
39
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.april)
40
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.april;
41
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.may)
42
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.may;
43
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.june)
44
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.june;
45
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.july)
46
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.july;
47
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.august)
48
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.august;
49
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.september)
50
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.september;
51
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.october)
52
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.october;
53
+ if (monthNumber === month_number_enum_1.MonthNumberEnum.november)
54
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.november;
55
+ return month_abbreviation_enum_1.MonthAbbreviationEnum.december;
53
56
  }
54
57
  }
58
+ exports.MonthMapper = MonthMapper;
@@ -1,4 +1,7 @@
1
- export var MonthAbbreviationEnum;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MonthAbbreviationEnum = void 0;
4
+ var MonthAbbreviationEnum;
2
5
  (function (MonthAbbreviationEnum) {
3
6
  MonthAbbreviationEnum["january"] = "jan";
4
7
  MonthAbbreviationEnum["february"] = "fev";
@@ -12,4 +15,4 @@ export var MonthAbbreviationEnum;
12
15
  MonthAbbreviationEnum["october"] = "out";
13
16
  MonthAbbreviationEnum["november"] = "nov";
14
17
  MonthAbbreviationEnum["december"] = "dez";
15
- })(MonthAbbreviationEnum || (MonthAbbreviationEnum = {}));
18
+ })(MonthAbbreviationEnum || (exports.MonthAbbreviationEnum = MonthAbbreviationEnum = {}));
@@ -1,4 +1,7 @@
1
- export var MonthNumberEnum;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MonthNumberEnum = void 0;
4
+ var MonthNumberEnum;
2
5
  (function (MonthNumberEnum) {
3
6
  MonthNumberEnum["january"] = "01";
4
7
  MonthNumberEnum["february"] = "02";
@@ -12,4 +15,4 @@ export var MonthNumberEnum;
12
15
  MonthNumberEnum["october"] = "10";
13
16
  MonthNumberEnum["november"] = "11";
14
17
  MonthNumberEnum["december"] = "12";
15
- })(MonthNumberEnum || (MonthNumberEnum = {}));
18
+ })(MonthNumberEnum || (exports.MonthNumberEnum = MonthNumberEnum = {}));
@@ -1,10 +1,14 @@
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) {
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) {
7
11
  return val instanceof Date
8
- ? _.isEqual(val.getTime(), val.getTime())
12
+ ? guardian_1._.isEqual(val.getTime(), val.getTime())
9
13
  : !!val;
10
14
  }
@@ -1,47 +1,49 @@
1
- import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Nothing = void 0;
4
+ exports.Optional = Optional;
5
+ const common_1 = require("./common");
2
6
  class OptionalType {
3
- [SuccessReturn];
4
- [ValueReturn];
5
7
  constructor(val, something) {
6
- this[SuccessReturn] = something;
7
- this[ValueReturn] = val;
8
+ this[common_1.SuccessReturn] = something;
9
+ this[common_1.ValueReturn] = val;
8
10
  }
9
11
  [Symbol.iterator]() {
10
- return this[SuccessReturn]
11
- ? this[ValueReturn][Symbol.iterator]()
12
- : EmptyArray[Symbol.iterator]();
12
+ return this[common_1.SuccessReturn]
13
+ ? this[common_1.ValueReturn][Symbol.iterator]()
14
+ : common_1.EmptyArray[Symbol.iterator]();
13
15
  }
14
16
  hasSomething() {
15
- return this[SuccessReturn];
17
+ return this[common_1.SuccessReturn];
16
18
  }
17
19
  hasNothing() {
18
- return !this[SuccessReturn];
20
+ return !this[common_1.SuccessReturn];
19
21
  }
20
22
  unpack() {
21
- if (this[SuccessReturn]) {
22
- return this[ValueReturn];
23
+ if (this[common_1.SuccessReturn]) {
24
+ return this[common_1.ValueReturn];
23
25
  }
24
26
  throw new Error("Failed to unpack optional value. There is nothing in here");
25
27
  }
26
28
  unpackAnyway() {
27
- return this[ValueReturn];
29
+ return this[common_1.ValueReturn];
28
30
  }
29
31
  unpackOr(def) {
30
- return this[SuccessReturn] ? this[ValueReturn] : def;
32
+ return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : def;
31
33
  }
32
34
  unpackOrElse(f) {
33
- return this[SuccessReturn] ? this[ValueReturn] : f();
35
+ return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : f();
34
36
  }
35
37
  }
36
- export function Optional(val) {
38
+ function Optional(val) {
37
39
  return from(val);
38
40
  }
39
41
  function Something(val) {
40
42
  return new OptionalType(val, true);
41
43
  }
42
- export const Nothing = Object.freeze(new OptionalType(undefined, false));
44
+ exports.Nothing = Object.freeze(new OptionalType(undefined, false));
43
45
  function from(val) {
44
- return isTruthy(val) && !(val instanceof Error)
46
+ return (0, common_1.isTruthy)(val) && !(val instanceof Error)
45
47
  ? Something(val)
46
- : Nothing;
48
+ : exports.Nothing;
47
49
  }
@@ -1,52 +1,57 @@
1
- import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
2
- export class ReturnType {
3
- [SuccessReturn];
4
- [ValueReturn];
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 {
5
9
  constructor(value, hasSuccess) {
6
- this[ValueReturn] = value;
7
- this[SuccessReturn] = hasSuccess;
10
+ this[common_1.ValueReturn] = value;
11
+ this[common_1.SuccessReturn] = hasSuccess;
8
12
  }
9
13
  [Symbol.iterator]() {
10
- return this[SuccessReturn]
11
- ? this[ValueReturn][Symbol.iterator]()
12
- : EmptyArray[Symbol.iterator]();
14
+ return this[common_1.SuccessReturn]
15
+ ? this[common_1.ValueReturn][Symbol.iterator]()
16
+ : common_1.EmptyArray[Symbol.iterator]();
13
17
  }
14
18
  hasSuccess() {
15
- return this[SuccessReturn];
19
+ return this[common_1.SuccessReturn];
16
20
  }
17
21
  hasFailure() {
18
- return !this[SuccessReturn];
22
+ return !this[common_1.SuccessReturn];
19
23
  }
20
24
  unwrap() {
21
- if (this[SuccessReturn]) {
22
- return this[ValueReturn];
25
+ if (this[common_1.SuccessReturn]) {
26
+ return this[common_1.ValueReturn];
23
27
  }
24
28
  throw new Error("Failed to unwrap Return. There is failure in here");
25
29
  }
26
30
  unwrapFail() {
27
- if (this[SuccessReturn]) {
31
+ if (this[common_1.SuccessReturn]) {
28
32
  throw new Error("Failed to unwrapFail Return. There is success in here");
29
33
  }
30
- return this[ValueReturn];
34
+ return this[common_1.ValueReturn];
31
35
  }
32
36
  unwrapOr(def) {
33
- return this[SuccessReturn] ? this[ValueReturn] : def;
37
+ return this[common_1.SuccessReturn] ? this[common_1.ValueReturn] : def;
34
38
  }
35
39
  unwrapAnyway() {
36
- return this[ValueReturn];
40
+ return this[common_1.ValueReturn];
37
41
  }
38
42
  }
39
- export function Return(val) {
43
+ exports.ReturnType = ReturnType;
44
+ function Return(val) {
40
45
  return from(val);
41
46
  }
42
- export function Success(successValue) {
47
+ function Success(successValue) {
43
48
  return new ReturnType(successValue, true);
44
49
  }
45
- export function Failure(failureValue) {
50
+ function Failure(failureValue) {
46
51
  return new ReturnType(failureValue, false);
47
52
  }
48
53
  function from(val) {
49
- return isTruthy(val)
54
+ return (0, common_1.isTruthy)(val)
50
55
  ? new ReturnType(val, !(val instanceof Error))
51
56
  : Failure(null);
52
57
  }
@@ -1,13 +1,17 @@
1
- import { _ } from "../type-guard/guardian";
2
- export class MapAbstract extends Map {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapAbstract = void 0;
4
+ const guardian_1 = require("../type-guard/guardian");
5
+ class MapAbstract extends Map {
3
6
  getOrDefault(key, defaultValue) {
4
7
  return this.get(key) ?? defaultValue;
5
8
  }
6
9
  getOrThrow(key, errorMessage = "Key not mapped") {
7
10
  const value = this.get(key);
8
- if (_.isUndefined(value)) {
11
+ if (guardian_1._.isUndefined(value)) {
9
12
  throw Error(errorMessage);
10
13
  }
11
14
  return value;
12
15
  }
13
16
  }
17
+ exports.MapAbstract = MapAbstract;
@@ -1,4 +1,7 @@
1
- export class Random {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Random = void 0;
4
+ class Random {
2
5
  static number(min, max) {
3
6
  return Math.floor(Math.random() * (max - min + 1)) + min;
4
7
  }
@@ -19,3 +22,4 @@ export class Random {
19
22
  return anEnum[randomKey];
20
23
  }
21
24
  }
25
+ exports.Random = Random;
@@ -1,2 +1,6 @@
1
- export class GuardianException extends Error {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuardianException = void 0;
4
+ class GuardianException extends Error {
2
5
  }
6
+ exports.GuardianException = GuardianException;
@@ -1,4 +1,7 @@
1
- import { GuardianException } from "./guardian-exception";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._ = void 0;
4
+ const guardian_exception_1 = require("./guardian-exception");
2
5
  class Guardian {
3
6
  static and(...args) {
4
7
  return args.every((func) => func);
@@ -14,7 +17,7 @@ class Guardian {
14
17
  }
15
18
  static isEmptyArray(value) {
16
19
  if (Guardian.isArray(value).falsy()) {
17
- throw new GuardianException("The value is not an array");
20
+ throw new guardian_exception_1.GuardianException("The value is not an array");
18
21
  }
19
22
  if (Guardian.isNullOrUndefined(value)) {
20
23
  return true;
@@ -26,13 +29,13 @@ class Guardian {
26
29
  return false;
27
30
  }
28
31
  if (Guardian.isArray(value).falsy()) {
29
- throw new GuardianException("The value is not an array");
32
+ throw new guardian_exception_1.GuardianException("The value is not an array");
30
33
  }
31
34
  return value.length !== 0;
32
35
  }
33
36
  static isLengthArray(value, reference) {
34
37
  if (Guardian.isArray(value).falsy()) {
35
- throw new GuardianException("The value is not an array");
38
+ throw new guardian_exception_1.GuardianException("The value is not an array");
36
39
  }
37
40
  return value?.length === reference;
38
41
  }
@@ -79,9 +82,9 @@ class Guardian {
79
82
  }
80
83
  static isBetween(value, min, max) {
81
84
  if (min > max)
82
- throw new GuardianException(`Max ${max} should be greater than min ${min}.`);
85
+ throw new guardian_exception_1.GuardianException(`Max ${max} should be greater than min ${min}.`);
83
86
  if (Guardian.isEmpty(value)) {
84
- throw new GuardianException("Cannot check length of a value. Provided value is empty");
87
+ throw new guardian_exception_1.GuardianException("Cannot check length of a value. Provided value is empty");
85
88
  }
86
89
  const valueLength = Guardian.isNumber(value) ? value : Number(value);
87
90
  return valueLength >= min && valueLength <= max;
@@ -115,4 +118,4 @@ class Guardian {
115
118
  return Guardian.isDifferent(typeof value, type);
116
119
  }
117
120
  }
118
- export { Guardian as _ };
121
+ exports._ = Guardian;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });