@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.
- package/@tool-box/tests/{entity-builder.util.d.ts → builder.abstract.util.d.ts} +1 -1
- package/@tool-box/tests/{entity-builder.util.js → builder.abstract.util.js} +3 -6
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.d.ts +3 -0
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.js +3 -0
- package/@tool-box/tests/builders/failures/failure.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/failures/failure.edge.builder.js +18 -0
- package/@tool-box/tests/builders/user/email.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/email.edge.builder.js +11 -0
- package/@tool-box/tests/builders/user/person-name.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/person-name.edge.builder.js +11 -0
- package/@tool-box/tests/builders/user/username.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/username.edge.builder.js +11 -0
- package/@tool-box/tests/create-fake-command.d.ts +9 -0
- package/@tool-box/tests/create-fake-command.js +23 -0
- package/@tool-box/tests/faker/faker.js +7 -10
- package/@tool-box/utils/datatypes/boolean-utils.d.ts +1 -0
- package/@tool-box/utils/datatypes/boolean-utils.js +5 -2
- package/@tool-box/utils/datatypes/generic-types.d.ts +1 -1
- package/@tool-box/utils/datatypes/generic-types.js +1 -2
- package/@tool-box/utils/datatypes/string-utils.d.ts +1 -3
- package/@tool-box/utils/datatypes/string-utils.js +1 -10
- package/@tool-box/utils/ducts/common.js +7 -11
- package/@tool-box/utils/ducts/optional-type.d.ts +0 -1
- package/@tool-box/utils/ducts/optional-type.js +19 -22
- package/@tool-box/utils/ducts/return-type.d.ts +2 -2
- package/@tool-box/utils/ducts/return-type.js +21 -26
- package/@tool-box/utils/{arrays/extended-map.d.ts → map/map.abstract.d.ts} +1 -2
- package/@tool-box/utils/map/map.abstract.js +13 -0
- package/@tool-box/utils/random/random.d.ts +5 -0
- package/@tool-box/utils/{randoms/random-value.js → random/random.js} +4 -8
- package/@tool-box/utils/type-guard/guardian-exception.js +1 -5
- package/@tool-box/utils/type-guard/guardian.d.ts +11 -13
- package/@tool-box/utils/type-guard/guardian.js +19 -51
- package/@tool-box/utils/type-guard/guardian.type.js +1 -2
- package/README.md +0 -8
- package/index.d.ts +28 -37
- package/index.js +30 -81
- package/objects/@common/edges/email.edge.d.ts +6 -0
- package/{arch/modules/domain/entities/user/value-objects/email.js → objects/@common/edges/email.edge.js} +3 -6
- package/objects/@common/edges/person-name.edge.d.ts +7 -0
- package/objects/@common/edges/person-name.edge.js +14 -0
- package/objects/@common/edges/url.edge.d.ts +6 -0
- package/objects/@common/edges/url.edge.js +17 -0
- package/objects/@common/edges/username.edge.d.ts +3 -0
- package/objects/@common/edges/username.edge.js +3 -0
- package/{arch/modules/domain/entities/uuid.abstract.d.ts → objects/@common/edges/uuid.sketch.edge.d.ts} +2 -2
- package/objects/@common/edges/uuid.sketch.edge.js +18 -0
- package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.js +2 -5
- package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.js +2 -5
- package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.js +2 -5
- package/objects/datetime/edges/datetime.edge.d.ts +27 -0
- package/objects/datetime/edges/datetime.edge.js +133 -0
- package/objects/datetime/points/month-name.enum.d.ts +14 -0
- package/objects/datetime/points/month-name.enum.js +15 -0
- package/objects/datetime/points/week-day.enum.d.ts +9 -0
- package/objects/datetime/points/week-day.enum.js +10 -0
- package/objects/failure/edges/failure.sketch.edge.d.ts +8 -0
- package/objects/failure/edges/failure.sketch.edge.js +23 -0
- package/objects/failure/edges/failure.sketch.polygon.d.ts +9 -0
- package/objects/failure/edges/failure.sketch.polygon.js +1 -0
- package/objects/password/password.edge.d.ts +8 -0
- package/objects/password/password.edge.js +38 -0
- package/{arch/modules/domain/entities/user/password/password.abstract.type.d.ts → objects/password/password.polygon.d.ts} +1 -1
- package/objects/password/password.polygon.js +1 -0
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.js +3 -6
- package/objects/password/steps/not-allowing-these-chars-step.js +14 -0
- package/objects/password/steps/numeric-step.js +9 -0
- package/objects/password/steps/with-at-least-one-letter-step.js +10 -0
- package/objects/password/steps/with-at-least-one-number-digit-step.js +10 -0
- package/objects/password/steps/with-at-least-one-special-char-step.js +10 -0
- package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.js +3 -6
- package/objects/password/validation-step.js +5 -0
- package/objects/password/validation-step.type.js +1 -0
- package/objects/primitives/boolean.edge.sketch.d.ts +7 -0
- package/objects/primitives/boolean.edge.sketch.js +18 -0
- package/objects/primitives/datetime.edge.sketch.d.ts +3 -0
- package/objects/primitives/datetime.edge.sketch.js +3 -0
- package/objects/primitives/number.edge.sketch.d.ts +13 -0
- package/{arch/modules/domain/entities/$number.abstract.js → objects/primitives/number.edge.sketch.js} +12 -15
- package/{arch/modules/domain/entities/$string.abstract.d.ts → objects/primitives/string.edge.sketch.d.ts} +1 -1
- package/{arch/modules/domain/entities/$string.abstract.js → objects/primitives/string.edge.sketch.js} +2 -5
- package/package.json +6 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.d.ts +0 -3
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.js +0 -7
- package/@tool-box/tests/builders/failures/failure.builder.d.ts +0 -6
- package/@tool-box/tests/builders/failures/failure.builder.js +0 -21
- package/@tool-box/tests/builders/generic/dummies/uuid.dummy.d.ts +0 -3
- package/@tool-box/tests/builders/generic/dummies/uuid.dummy.js +0 -7
- package/@tool-box/tests/builders/generic/uuid.builder.d.ts +0 -6
- package/@tool-box/tests/builders/generic/uuid.builder.js +0 -14
- package/@tool-box/tests/builders/user/email.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/email.builder.js +0 -15
- package/@tool-box/tests/builders/user/person-name.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/person-name.builder.js +0 -15
- package/@tool-box/tests/builders/user/user-id.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/user-id.builder.js +0 -14
- package/@tool-box/tests/builders/user/username.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/username.builder.js +0 -15
- package/@tool-box/tests/create-fake-usecase.d.ts +0 -9
- package/@tool-box/tests/create-fake-usecase.js +0 -26
- package/@tool-box/utils/arrays/extended-map.js +0 -22
- package/@tool-box/utils/http-client/http-client-exception.d.ts +0 -3
- package/@tool-box/utils/http-client/http-client-exception.js +0 -12
- package/@tool-box/utils/http-client/http-client-request.d.ts +0 -9
- package/@tool-box/utils/http-client/http-client-request.js +0 -2
- package/@tool-box/utils/http-client/http-client-response.d.ts +0 -18
- package/@tool-box/utils/http-client/http-client-response.get-header.failure.d.ts +0 -4
- package/@tool-box/utils/http-client/http-client-response.get-header.failure.js +0 -14
- package/@tool-box/utils/http-client/http-client-response.js +0 -39
- package/@tool-box/utils/http-client/http-client.d.ts +0 -9
- package/@tool-box/utils/http-client/http-client.js +0 -21
- package/@tool-box/utils/randoms/random-value.d.ts +0 -5
- package/arch/@atlantjs.json +0 -3
- package/arch/biome.json +0 -47
- package/arch/modules/application/failures/failure.abstract.d.ts +0 -9
- package/arch/modules/application/failures/failure.abstract.js +0 -24
- package/arch/modules/application/failures/failure.abstract.type.d.ts +0 -9
- package/arch/modules/application/failures/failure.abstract.type.js +0 -2
- package/arch/modules/application/failures/unknown-failure.d.ts +0 -15
- package/arch/modules/application/failures/unknown-failure.js +0 -16
- package/arch/modules/domain/entities/$array.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$array.abstract.js +0 -6
- package/arch/modules/domain/entities/$boolean.abstract.d.ts +0 -7
- package/arch/modules/domain/entities/$boolean.abstract.js +0 -21
- package/arch/modules/domain/entities/$date.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$date.abstract.js +0 -6
- package/arch/modules/domain/entities/$number.abstract.d.ts +0 -13
- package/arch/modules/domain/entities/$object.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$object.abstract.js +0 -6
- package/arch/modules/domain/entities/entity-frontend.abstract.d.ts +0 -6
- package/arch/modules/domain/entities/entity-frontend.abstract.js +0 -11
- package/arch/modules/domain/entities/solid.abstract.d.ts +0 -4
- package/arch/modules/domain/entities/solid.abstract.js +0 -6
- package/arch/modules/domain/entities/url.abstract.d.ts +0 -3
- package/arch/modules/domain/entities/url.abstract.js +0 -7
- package/arch/modules/domain/entities/user/password/password.abstract.d.ts +0 -8
- package/arch/modules/domain/entities/user/password/password.abstract.js +0 -41
- package/arch/modules/domain/entities/user/password/password.abstract.type.js +0 -2
- package/arch/modules/domain/entities/user/password/steps/not-allowing-these-chars-step.js +0 -17
- package/arch/modules/domain/entities/user/password/steps/numeric-step.js +0 -13
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-letter-step.js +0 -14
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-number-digit-step.js +0 -14
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-special-char-step.js +0 -14
- package/arch/modules/domain/entities/user/password/validation-step.js +0 -9
- package/arch/modules/domain/entities/user/password/validation-step.type.js +0 -2
- package/arch/modules/domain/entities/user/value-objects/email.d.ts +0 -6
- package/arch/modules/domain/entities/user/value-objects/person-name.d.ts +0 -7
- package/arch/modules/domain/entities/user/value-objects/person-name.js +0 -17
- package/arch/modules/domain/entities/user/value-objects/user-id.d.ts +0 -3
- package/arch/modules/domain/entities/user/value-objects/user-id.js +0 -7
- package/arch/modules/domain/entities/user/value-objects/username.d.ts +0 -3
- package/arch/modules/domain/entities/user/value-objects/username.js +0 -7
- package/arch/modules/domain/entities/uuid.abstract.js +0 -23
- package/arch/modules/domain/entities/value-object.abstract.d.ts +0 -3
- package/arch/modules/domain/entities/value-object.abstract.js +0 -7
- package/arch/modules/infrastructure/services/http-client.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/http-client.abstract.js +0 -1
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.js +0 -1
- package/arch/modules/infrastructure/services/responses/service.response.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/responses/service.response.abstract.js +0 -1
- package/arch/tsconfig-backend.json +0 -3
- package/arch/tsconfig-default.json +0 -45
- package/arch/tsconfig-frontend.json +0 -3
- package/arch/tsconfig-lib.json +0 -6
- package/arch/tsconfig-mobile.json +0 -3
- /package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.d.ts +0 -0
- /package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.d.ts +0 -0
- /package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-these-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/numeric-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-letter-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-number-digit-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-special-char-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/validation-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/validation-step.type.d.ts +0 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Holidays from "date-holidays";
|
|
2
|
+
import moment from "moment";
|
|
3
|
+
import { _ } from "../../../index";
|
|
4
|
+
import { MonthNameEnum } from "../points/month-name.enum";
|
|
5
|
+
import { WeekDayEnum } from "../points/week-day.enum";
|
|
6
|
+
export class DatetimeEdge {
|
|
7
|
+
value;
|
|
8
|
+
date;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
let dateValue;
|
|
12
|
+
if (_.isUndefined(this.value)) {
|
|
13
|
+
dateValue = new Date(Date.now());
|
|
14
|
+
}
|
|
15
|
+
else if (_.isTypeOf(this.value, "string")) {
|
|
16
|
+
const parsedDate = new Date(this.value);
|
|
17
|
+
if (Number.isNaN(parsedDate.getTime())) {
|
|
18
|
+
throw new Error(`Invalid date string: ${this.value}`);
|
|
19
|
+
}
|
|
20
|
+
dateValue = parsedDate;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
dateValue = this.value;
|
|
24
|
+
}
|
|
25
|
+
this.date = moment(dateValue);
|
|
26
|
+
this.validate();
|
|
27
|
+
}
|
|
28
|
+
isAfter(other) {
|
|
29
|
+
return this.date.isAfter(other.toDatePoint());
|
|
30
|
+
}
|
|
31
|
+
diffFromNow() {
|
|
32
|
+
const now = moment();
|
|
33
|
+
const diffInSeconds = now.diff(this.date, "seconds");
|
|
34
|
+
const diffInMinutes = now.diff(this.date, "minutes");
|
|
35
|
+
const diffInHours = now.diff(this.date, "hours");
|
|
36
|
+
const diffInDays = now.diff(this.date, "days");
|
|
37
|
+
const diffInMonths = now.diff(this.date, "months");
|
|
38
|
+
const diffInYears = now.diff(this.date, "years");
|
|
39
|
+
if (diffInSeconds < 60) {
|
|
40
|
+
return `Há ${diffInSeconds} segundo${diffInSeconds === 1 ? "" : "s"}.`;
|
|
41
|
+
}
|
|
42
|
+
if (diffInMinutes < 60) {
|
|
43
|
+
return `Há ${diffInMinutes} minuto${diffInMinutes === 1 ? "" : "s"}.`;
|
|
44
|
+
}
|
|
45
|
+
if (diffInHours < 24) {
|
|
46
|
+
return `Há ${diffInHours} hora${diffInHours === 1 ? "" : "s"}.`;
|
|
47
|
+
}
|
|
48
|
+
if (diffInDays < 30) {
|
|
49
|
+
return `Há ${diffInDays} dia${diffInDays === 1 ? "" : "s"}.`;
|
|
50
|
+
}
|
|
51
|
+
if (diffInMonths < 12) {
|
|
52
|
+
return `Há ${diffInMonths} mês${diffInMonths === 1 ? "" : "es"}.`;
|
|
53
|
+
}
|
|
54
|
+
return `Há ${diffInYears} ano${diffInYears === 1 ? "" : "s"}.`;
|
|
55
|
+
}
|
|
56
|
+
isEquals(other) {
|
|
57
|
+
return this.date.isSame(other.toDatePoint());
|
|
58
|
+
}
|
|
59
|
+
isBefore(other) {
|
|
60
|
+
return this.date.isBefore(other.toDatePoint());
|
|
61
|
+
}
|
|
62
|
+
isBetween(initialDate, finalDate) {
|
|
63
|
+
return this.date.isBetween(initialDate.toDatePoint(), finalDate.toDatePoint());
|
|
64
|
+
}
|
|
65
|
+
isWeekend() {
|
|
66
|
+
return [WeekDayEnum.sunday, WeekDayEnum.monday].includes(this.getDayOfWeek());
|
|
67
|
+
}
|
|
68
|
+
isHoliday() {
|
|
69
|
+
const holidays = new Holidays("BR");
|
|
70
|
+
return holidays.isHoliday(this.date.toDate()) !== false;
|
|
71
|
+
}
|
|
72
|
+
isBusinessDay() {
|
|
73
|
+
return !this.isWeekend() && !this.isHoliday();
|
|
74
|
+
}
|
|
75
|
+
getDayOfWeek() {
|
|
76
|
+
const daysOfWeek = [
|
|
77
|
+
WeekDayEnum.sunday,
|
|
78
|
+
WeekDayEnum.monday,
|
|
79
|
+
WeekDayEnum.tuesday,
|
|
80
|
+
WeekDayEnum.wednesday,
|
|
81
|
+
WeekDayEnum.thursday,
|
|
82
|
+
WeekDayEnum.friday,
|
|
83
|
+
WeekDayEnum.saturday,
|
|
84
|
+
];
|
|
85
|
+
return daysOfWeek[this.date.days()];
|
|
86
|
+
}
|
|
87
|
+
getNameOfMonth() {
|
|
88
|
+
const months = [
|
|
89
|
+
MonthNameEnum.january,
|
|
90
|
+
MonthNameEnum.february,
|
|
91
|
+
MonthNameEnum.march,
|
|
92
|
+
MonthNameEnum.april,
|
|
93
|
+
MonthNameEnum.may,
|
|
94
|
+
MonthNameEnum.june,
|
|
95
|
+
MonthNameEnum.july,
|
|
96
|
+
MonthNameEnum.august,
|
|
97
|
+
MonthNameEnum.september,
|
|
98
|
+
MonthNameEnum.october,
|
|
99
|
+
MonthNameEnum.november,
|
|
100
|
+
MonthNameEnum.december,
|
|
101
|
+
];
|
|
102
|
+
return months[this.date.month()];
|
|
103
|
+
}
|
|
104
|
+
getDayOfMonth() {
|
|
105
|
+
return this.date.date();
|
|
106
|
+
}
|
|
107
|
+
getNumberOfMonth() {
|
|
108
|
+
return this.date.month();
|
|
109
|
+
}
|
|
110
|
+
getYear() {
|
|
111
|
+
return this.date.year();
|
|
112
|
+
}
|
|
113
|
+
toISOStringPoint() {
|
|
114
|
+
return this.date.toISOString();
|
|
115
|
+
}
|
|
116
|
+
timestamp() {
|
|
117
|
+
return this.date.valueOf();
|
|
118
|
+
}
|
|
119
|
+
unix() {
|
|
120
|
+
return this.date.unix();
|
|
121
|
+
}
|
|
122
|
+
toDatePoint() {
|
|
123
|
+
return this.date.toDate();
|
|
124
|
+
}
|
|
125
|
+
toYYYYMMDD() {
|
|
126
|
+
return this.date.format("YYYY-MM-DD");
|
|
127
|
+
}
|
|
128
|
+
validate() {
|
|
129
|
+
if (!moment(this.date).isValid()) {
|
|
130
|
+
throw new Error(`${this.constructor.name} should be valid.`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum MonthNameEnum {
|
|
2
|
+
january = "january",
|
|
3
|
+
february = "february",
|
|
4
|
+
march = "march",
|
|
5
|
+
april = "april",
|
|
6
|
+
may = "may",
|
|
7
|
+
june = "june",
|
|
8
|
+
july = "july",
|
|
9
|
+
august = "august",
|
|
10
|
+
september = "september",
|
|
11
|
+
october = "october",
|
|
12
|
+
november = "november",
|
|
13
|
+
december = "december"
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var MonthNameEnum;
|
|
2
|
+
(function (MonthNameEnum) {
|
|
3
|
+
MonthNameEnum["january"] = "january";
|
|
4
|
+
MonthNameEnum["february"] = "february";
|
|
5
|
+
MonthNameEnum["march"] = "march";
|
|
6
|
+
MonthNameEnum["april"] = "april";
|
|
7
|
+
MonthNameEnum["may"] = "may";
|
|
8
|
+
MonthNameEnum["june"] = "june";
|
|
9
|
+
MonthNameEnum["july"] = "july";
|
|
10
|
+
MonthNameEnum["august"] = "august";
|
|
11
|
+
MonthNameEnum["september"] = "september";
|
|
12
|
+
MonthNameEnum["october"] = "october";
|
|
13
|
+
MonthNameEnum["november"] = "november";
|
|
14
|
+
MonthNameEnum["december"] = "december";
|
|
15
|
+
})(MonthNameEnum || (MonthNameEnum = {}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var WeekDayEnum;
|
|
2
|
+
(function (WeekDayEnum) {
|
|
3
|
+
WeekDayEnum["sunday"] = "sunday";
|
|
4
|
+
WeekDayEnum["monday"] = "monday";
|
|
5
|
+
WeekDayEnum["tuesday"] = "tuesday";
|
|
6
|
+
WeekDayEnum["wednesday"] = "wednesday";
|
|
7
|
+
WeekDayEnum["thursday"] = "thursday";
|
|
8
|
+
WeekDayEnum["friday"] = "friday";
|
|
9
|
+
WeekDayEnum["saturday"] = "saturday";
|
|
10
|
+
})(WeekDayEnum || (WeekDayEnum = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FailureSketchEdgeProps, FailureSketchPolygon } from "./failure.sketch.polygon";
|
|
2
|
+
export declare abstract class FailureSketchEdge {
|
|
3
|
+
private readonly props;
|
|
4
|
+
protected readonly _code: string;
|
|
5
|
+
protected readonly _message: string;
|
|
6
|
+
constructor(props: FailureSketchEdgeProps);
|
|
7
|
+
toPolygon(): FailureSketchPolygon;
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { _ } from "../../../index";
|
|
2
|
+
import { NodeEnvs } from "../../@common/points/node-envs.enum";
|
|
3
|
+
export class FailureSketchEdge {
|
|
4
|
+
props;
|
|
5
|
+
_code;
|
|
6
|
+
_message;
|
|
7
|
+
constructor(props) {
|
|
8
|
+
this.props = props;
|
|
9
|
+
this._code = this.props.failureClass.name.toKebabCase();
|
|
10
|
+
if (_.and(_.isEqual(process.env.ENVIRONMENT, NodeEnvs.development), _.isNotNullOrUndefined(this.props.stackTrace))) {
|
|
11
|
+
this._message = `${this.props.message} - ${this.props.stackTrace.toString()}`;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
this._message = this.props.message;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
toPolygon() {
|
|
18
|
+
return {
|
|
19
|
+
code: this._code,
|
|
20
|
+
message: this._message,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PasswordPolicyResultPolygon } from "./password.polygon";
|
|
2
|
+
export declare class PasswordEdge {
|
|
3
|
+
private readonly password;
|
|
4
|
+
private readonly validationSteps;
|
|
5
|
+
constructor(password: string);
|
|
6
|
+
protected validate(password: string): PasswordPolicyResultPolygon;
|
|
7
|
+
toString(): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { _ } from "../../@tool-box/utils/type-guard/guardian";
|
|
2
|
+
import { WithAtLeastOneLetterStep } from "./steps/with-at-least-one-letter-step";
|
|
3
|
+
import { WithAtLeastOneNumberDigitStep } from "./steps/with-at-least-one-number-digit-step";
|
|
4
|
+
import { WithAtLeastOneSpecialCharStep } from "./steps/with-at-least-one-special-char-step";
|
|
5
|
+
import { WithLengthStep } from "./steps/with-length-step";
|
|
6
|
+
export class PasswordEdge {
|
|
7
|
+
password;
|
|
8
|
+
validationSteps = [
|
|
9
|
+
new WithAtLeastOneLetterStep(),
|
|
10
|
+
new WithAtLeastOneNumberDigitStep(),
|
|
11
|
+
new WithAtLeastOneSpecialCharStep(),
|
|
12
|
+
new WithLengthStep({ min: 6, max: 999 }),
|
|
13
|
+
];
|
|
14
|
+
constructor(password) {
|
|
15
|
+
this.password = password;
|
|
16
|
+
const { valid, validationStepsResults } = this.validate(this.password);
|
|
17
|
+
if (valid.falsy()) {
|
|
18
|
+
throw new TypeError(`Password is invalid: ${validationStepsResults.map((result) => result.name)}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
validate(password) {
|
|
22
|
+
if (_.isEqual(this.validationSteps.length, 0)) {
|
|
23
|
+
throw new TypeError("No validations found");
|
|
24
|
+
}
|
|
25
|
+
const validationStepsResults = [];
|
|
26
|
+
for (const step of this.validationSteps) {
|
|
27
|
+
validationStepsResults.push(step.validate(password));
|
|
28
|
+
}
|
|
29
|
+
const valid = validationStepsResults.every((result) => result.valid);
|
|
30
|
+
return {
|
|
31
|
+
valid,
|
|
32
|
+
validationStepsResults,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
toString() {
|
|
36
|
+
return this.password;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class NotAllowingConsecutiveCharsStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingConsecutiveCharsStep extends ValidationStep {
|
|
3
|
+
params;
|
|
6
4
|
constructor(params) {
|
|
7
5
|
super();
|
|
8
6
|
this.params = params;
|
|
@@ -31,4 +29,3 @@ class NotAllowingConsecutiveCharsStep extends validation_step_1.ValidationStep {
|
|
|
31
29
|
return Math.max(numberOfConsecutiveChars, maxNumberOfConsecutiveChars);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
exports.NotAllowingConsecutiveCharsStep = NotAllowingConsecutiveCharsStep;
|
package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.js
RENAMED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class NotAllowingDateStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingDateStep extends ValidationStep {
|
|
3
|
+
notAllowedDate;
|
|
6
4
|
constructor(notAllowedDate) {
|
|
7
5
|
super();
|
|
8
6
|
this.notAllowedDate = notAllowedDate;
|
|
@@ -58,4 +56,3 @@ class NotAllowingDateStep extends validation_step_1.ValidationStep {
|
|
|
58
56
|
];
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
exports.NotAllowingDateStep = NotAllowingDateStep;
|
package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.js
RENAMED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class NotAllowingPhoneStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingPhoneStep extends ValidationStep {
|
|
3
|
+
notAllowedPhone;
|
|
6
4
|
constructor(phone) {
|
|
7
5
|
super();
|
|
8
6
|
const matches = phone.match(/\d{4}\-?\d{4}$/);
|
|
@@ -24,4 +22,3 @@ class NotAllowingPhoneStep extends validation_step_1.ValidationStep {
|
|
|
24
22
|
};
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
|
-
exports.NotAllowingPhoneStep = NotAllowingPhoneStep;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class NotAllowingRepeatedCharsStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingRepeatedCharsStep extends ValidationStep {
|
|
3
|
+
options;
|
|
6
4
|
constructor(options) {
|
|
7
5
|
super();
|
|
8
6
|
this.options = options;
|
|
@@ -31,4 +29,3 @@ class NotAllowingRepeatedCharsStep extends validation_step_1.ValidationStep {
|
|
|
31
29
|
return Math.max(numberOfRepeatedChars, maxNumberOfRepeatedChars);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
exports.NotAllowingRepeatedCharsStep = NotAllowingRepeatedCharsStep;
|
package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.js
RENAMED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class NotAllowingStringStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingStringStep extends ValidationStep {
|
|
3
|
+
forbiddenString;
|
|
6
4
|
constructor(forbiddenString) {
|
|
7
5
|
super();
|
|
8
6
|
this.forbiddenString = forbiddenString;
|
|
@@ -16,4 +14,3 @@ class NotAllowingStringStep extends validation_step_1.ValidationStep {
|
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
16
|
}
|
|
19
|
-
exports.NotAllowingStringStep = NotAllowingStringStep;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class NotAllowingTheseCharsStep extends ValidationStep {
|
|
3
|
+
options;
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super();
|
|
6
|
+
this.options = options;
|
|
7
|
+
}
|
|
8
|
+
validate(password) {
|
|
9
|
+
return {
|
|
10
|
+
valid: this.options.notAllowedCharsList.every((char) => !password.toLowerCase().includes(char.toLowerCase())),
|
|
11
|
+
name: this.name,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class WithAtLeastOneSpecialCharStep extends ValidationStep {
|
|
3
|
+
validate(password) {
|
|
4
|
+
const regex = /[ `!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
|
|
5
|
+
return {
|
|
6
|
+
valid: regex.test(password),
|
|
7
|
+
name: this.name,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const validation_step_1 = require("../validation-step");
|
|
5
|
-
class WithLengthStep extends validation_step_1.ValidationStep {
|
|
1
|
+
import { ValidationStep } from "../validation-step";
|
|
2
|
+
export class WithLengthStep extends ValidationStep {
|
|
3
|
+
options;
|
|
6
4
|
constructor(options) {
|
|
7
5
|
super();
|
|
8
6
|
this.options = options;
|
|
@@ -15,4 +13,3 @@ class WithLengthStep extends validation_step_1.ValidationStep {
|
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
|
-
exports.WithLengthStep = WithLengthStep;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class BooleanEdgeSketch {
|
|
2
|
+
value;
|
|
3
|
+
constructor(value) {
|
|
4
|
+
this.value = value;
|
|
5
|
+
}
|
|
6
|
+
toPoint() {
|
|
7
|
+
return this.value;
|
|
8
|
+
}
|
|
9
|
+
isEqual(value) {
|
|
10
|
+
if (value instanceof BooleanEdgeSketch) {
|
|
11
|
+
return value.toPoint() === this.value;
|
|
12
|
+
}
|
|
13
|
+
return this.value === value;
|
|
14
|
+
}
|
|
15
|
+
isDifferent(value) {
|
|
16
|
+
return this.value !== value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare abstract class NumberEdgeSketch {
|
|
2
|
+
private value;
|
|
3
|
+
constructor(value: number);
|
|
4
|
+
toNumber(): number;
|
|
5
|
+
isEqual(value: number | NumberEdgeSketch): boolean;
|
|
6
|
+
isDifferent(value: number | NumberEdgeSketch): boolean;
|
|
7
|
+
isBiggerThan(value: number | NumberEdgeSketch): boolean;
|
|
8
|
+
isSmallerThan(value: number | NumberEdgeSketch): boolean;
|
|
9
|
+
isEqualOrBiggerThan(value: number | NumberEdgeSketch): boolean;
|
|
10
|
+
isEqualOrSmallerThan(value: number | NumberEdgeSketch): boolean;
|
|
11
|
+
isBetween(min: number | NumberEdgeSketch, max: number | NumberEdgeSketch): boolean;
|
|
12
|
+
private validate;
|
|
13
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const guardian_1 = require("../../../../@tool-box/utils/type-guard/guardian");
|
|
5
|
-
class $number {
|
|
1
|
+
import { _ } from "../../@tool-box/utils/type-guard/guardian";
|
|
2
|
+
export class NumberEdgeSketch {
|
|
3
|
+
value;
|
|
6
4
|
constructor(value) {
|
|
7
5
|
this.value = value;
|
|
8
6
|
this.validate(value);
|
|
@@ -11,45 +9,45 @@ class $number {
|
|
|
11
9
|
return this.value;
|
|
12
10
|
}
|
|
13
11
|
isEqual(value) {
|
|
14
|
-
if (value instanceof
|
|
12
|
+
if (value instanceof NumberEdgeSketch) {
|
|
15
13
|
return value.toNumber() === this.value;
|
|
16
14
|
}
|
|
17
15
|
return this.value === value;
|
|
18
16
|
}
|
|
19
17
|
isDifferent(value) {
|
|
20
|
-
if (value instanceof
|
|
18
|
+
if (value instanceof NumberEdgeSketch) {
|
|
21
19
|
return value.toNumber() !== this.value;
|
|
22
20
|
}
|
|
23
21
|
return this.value !== value;
|
|
24
22
|
}
|
|
25
23
|
isBiggerThan(value) {
|
|
26
|
-
if (value instanceof
|
|
24
|
+
if (value instanceof NumberEdgeSketch) {
|
|
27
25
|
return value.toNumber() > this.value;
|
|
28
26
|
}
|
|
29
27
|
return this.value > value;
|
|
30
28
|
}
|
|
31
29
|
isSmallerThan(value) {
|
|
32
|
-
if (value instanceof
|
|
30
|
+
if (value instanceof NumberEdgeSketch) {
|
|
33
31
|
return value.toNumber() < this.value;
|
|
34
32
|
}
|
|
35
33
|
return this.value < value;
|
|
36
34
|
}
|
|
37
35
|
isEqualOrBiggerThan(value) {
|
|
38
|
-
if (value instanceof
|
|
36
|
+
if (value instanceof NumberEdgeSketch) {
|
|
39
37
|
return value.toNumber() >= this.value;
|
|
40
38
|
}
|
|
41
39
|
return this.value >= value;
|
|
42
40
|
}
|
|
43
41
|
isEqualOrSmallerThan(value) {
|
|
44
|
-
if (value instanceof
|
|
42
|
+
if (value instanceof NumberEdgeSketch) {
|
|
45
43
|
return value.toNumber() <= this.value;
|
|
46
44
|
}
|
|
47
45
|
return this.value <= value;
|
|
48
46
|
}
|
|
49
47
|
isBetween(min, max) {
|
|
50
|
-
const minimus = min instanceof
|
|
51
|
-
const maximus = max instanceof
|
|
52
|
-
return
|
|
48
|
+
const minimus = min instanceof NumberEdgeSketch ? min.toNumber() : min;
|
|
49
|
+
const maximus = max instanceof NumberEdgeSketch ? max.toNumber() : max;
|
|
50
|
+
return _.isBetween(this.value, minimus, maximus);
|
|
53
51
|
}
|
|
54
52
|
validate(value) {
|
|
55
53
|
if (Number.isNaN(value)) {
|
|
@@ -57,4 +55,3 @@ class $number {
|
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
|
-
exports.$number = $number;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.$string = void 0;
|
|
4
|
-
class $string {
|
|
1
|
+
export class StringEdgeSketch {
|
|
2
|
+
value;
|
|
5
3
|
constructor(value) {
|
|
6
4
|
this.value = value;
|
|
7
5
|
this.sanitize();
|
|
@@ -31,4 +29,3 @@ class $string {
|
|
|
31
29
|
}
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
exports.$string = $string;
|