@atlantjs/arch 10.0.8 → 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.
- package/@tool-box/tests/builder.abstract.util.js +6 -3
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.d.ts +3 -0
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.js +7 -0
- package/@tool-box/tests/builders/failures/{failure.edge.builder.d.ts → failure.builder.d.ts} +1 -1
- package/@tool-box/tests/builders/failures/failure.builder.js +21 -0
- package/@tool-box/tests/builders/user/email.edge.builder.js +9 -5
- package/@tool-box/tests/builders/user/person-name.edge.builder.js +9 -5
- package/@tool-box/tests/builders/user/username.edge.builder.js +9 -5
- package/@tool-box/tests/create-fake-command.d.ts +2 -2
- package/@tool-box/tests/create-fake-command.js +12 -9
- package/@tool-box/tests/faker/faker.js +10 -7
- package/@tool-box/utils/datatypes/generic-types.js +2 -1
- package/@tool-box/utils/datetime/mappers/month.mapper.js +53 -49
- package/@tool-box/utils/datetime/mappers/points/month-abbreviation.enum.js +5 -2
- package/@tool-box/utils/datetime/mappers/points/month-number.enum.js +5 -2
- package/@tool-box/utils/ducts/common.js +11 -7
- package/@tool-box/utils/ducts/optional-type.js +21 -19
- package/@tool-box/utils/ducts/return-type.d.ts +2 -2
- package/@tool-box/utils/ducts/return-type.js +26 -21
- package/@tool-box/utils/map/map.abstract.js +7 -3
- package/@tool-box/utils/random/random.js +5 -1
- package/@tool-box/utils/type-guard/guardian-exception.js +5 -1
- package/@tool-box/utils/type-guard/guardian.js +10 -7
- package/@tool-box/utils/type-guard/guardian.type.js +2 -1
- package/index.d.ts +2 -2
- package/index.js +72 -34
- package/objects/@common/edges/email.edge.js +6 -3
- package/objects/@common/edges/person-name.edge.js +6 -3
- package/objects/@common/edges/url.edge.js +6 -3
- package/objects/@common/edges/username.edge.js +6 -2
- package/objects/@common/edges/uuid.sketch.edge.js +13 -7
- package/objects/@common/points/header-token-name.enum.js +5 -2
- package/objects/@common/points/http-status-codes.enum.js +5 -2
- package/objects/@common/points/node-envs.enum.js +5 -2
- package/objects/datetime/edges/datetime.edge.js +39 -34
- package/objects/datetime/points/month-name.enum.js +5 -2
- package/objects/datetime/points/week-day.enum.js +5 -2
- package/objects/failure/edges/failure.abstract.d.ts +8 -0
- package/objects/failure/edges/failure.abstract.js +24 -0
- package/objects/failure/edges/{failure.sketch.polygon.d.ts → failure.abstract.polygon.d.ts} +2 -2
- package/objects/failure/edges/failure.abstract.polygon.js +2 -0
- package/objects/password/password.edge.js +17 -14
- package/objects/password/password.polygon.js +2 -1
- package/objects/password/steps/not-allowing-consecutive-chars-step.js +6 -3
- package/objects/password/steps/not-allowing-date-step.js +6 -3
- package/objects/password/steps/not-allowing-phone-step.js +6 -3
- package/objects/password/steps/not-allowing-repeated-chars-step.js +6 -3
- package/objects/password/steps/not-allowing-string-step.js +6 -3
- package/objects/password/steps/not-allowing-these-chars-step.js +6 -3
- package/objects/password/steps/numeric-step.js +6 -2
- package/objects/password/steps/with-at-least-one-letter-step.js +6 -2
- package/objects/password/steps/with-at-least-one-number-digit-step.js +6 -2
- package/objects/password/steps/with-at-least-one-special-char-step.js +6 -2
- package/objects/password/steps/with-length-step.js +6 -3
- package/objects/password/validation-step.js +5 -1
- package/objects/password/validation-step.type.js +2 -1
- package/objects/primitives/boolean.edge.sketch.js +5 -2
- package/objects/primitives/datetime.edge.sketch.js +6 -2
- package/objects/primitives/number.edge.sketch.js +7 -4
- package/objects/primitives/string.edge.sketch.js +5 -2
- package/package.json +1 -1
- package/tsconfig-default.json +2 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/@tool-box/tests/builders/datetime.edge.builder.d.ts +0 -6
- package/@tool-box/tests/builders/datetime.edge.builder.js +0 -11
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.d.ts +0 -3
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.js +0 -3
- package/@tool-box/tests/builders/failures/failure.edge.builder.js +0 -18
- package/objects/failure/edges/failure.sketch.edge.d.ts +0 -8
- package/objects/failure/edges/failure.sketch.edge.js +0 -23
- package/objects/failure/edges/failure.sketch.polygon.js +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 {
|
|
6
|
+
}
|
|
7
|
+
exports.FailureDummy = FailureDummy;
|
package/@tool-box/tests/builders/failures/{failure.edge.builder.d.ts → failure.builder.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class FailureBuilder<T> extends BuilderAbstract<T, FailureBuilder<T>> {
|
|
3
3
|
private instance;
|
|
4
4
|
constructor(entityClass: new (...args: any[]) => T);
|
|
5
5
|
protected buildDefault(): T;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 {
|
|
8
|
+
constructor(entityClass) {
|
|
9
|
+
super(FailureBuilder);
|
|
10
|
+
this.instance = entityClass;
|
|
11
|
+
}
|
|
12
|
+
buildDefault() {
|
|
13
|
+
const dummy = new failure_dummy_1.FailureDummy({
|
|
14
|
+
failureClass: FailureBuilder,
|
|
15
|
+
message: faker_1.faker.lorem.words(),
|
|
16
|
+
});
|
|
17
|
+
Object.assign(dummy, this.instance);
|
|
18
|
+
return dummy;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.FailureBuilder = FailureBuilder;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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,9 +1,9 @@
|
|
|
1
1
|
import { Return } from "../utils/ducts/return-type";
|
|
2
|
-
import {
|
|
2
|
+
import { FailureAbstract } from "../../objects/failure/edges/failure.abstract";
|
|
3
3
|
export declare class CreateFakeCommand {
|
|
4
4
|
private _response;
|
|
5
5
|
static new<UsecaseStub>(): UsecaseStub & CreateFakeCommand;
|
|
6
6
|
protected execute(): Promise<Return<unknown, unknown>>;
|
|
7
7
|
withSuccess(response: unknown): this;
|
|
8
|
-
withFailure(response?:
|
|
8
|
+
withFailure(response?: FailureAbstract): this;
|
|
9
9
|
}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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
|
-
|
|
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,54 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { FalseyValues, IterType, SuccessReturn, ValueReturn } from "./common";
|
|
2
|
-
import {
|
|
2
|
+
import { FailureAbstract } from "../../../objects/failure/edges/failure.abstract";
|
|
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
|
|
21
|
+
export declare function Failure<FailureReturn extends FailureAbstract | null | undefined>(failureValue?: FailureReturn): Failure<FailureReturn>;
|
|
22
22
|
export {};
|
|
@@ -1,52 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
43
|
+
exports.ReturnType = ReturnType;
|
|
44
|
+
function Return(val) {
|
|
40
45
|
return from(val);
|
|
41
46
|
}
|
|
42
|
-
|
|
47
|
+
function Success(successValue) {
|
|
43
48
|
return new ReturnType(successValue, true);
|
|
44
49
|
}
|
|
45
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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;
|