@eliasrrosa/tutorhub-public-assets 0.0.3 → 0.0.5
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/dist/domain/entities/AsaasCustomer.js +5 -1
- package/dist/domain/entities/Class.js +5 -1
- package/dist/domain/entities/ClassRequest.js +2 -1
- package/dist/domain/entities/Contract.js +2 -1
- package/dist/domain/entities/Course.js +2 -1
- package/dist/domain/entities/CourseToSchoolConnectionRequest.js +2 -1
- package/dist/domain/entities/Date.js +2 -1
- package/dist/domain/entities/DateTimeSlot.js +2 -1
- package/dist/domain/entities/DateValidator.js +2 -1
- package/dist/domain/entities/File.js +2 -1
- package/dist/domain/entities/FreeTimeSlot.js +5 -1
- package/dist/domain/entities/GenericNotification.js +2 -1
- package/dist/domain/entities/GoogleAuth.js +2 -1
- package/dist/domain/entities/GoogleCalendar.js +2 -1
- package/dist/domain/entities/GoogleCalendarEvent.js +2 -1
- package/dist/domain/entities/ISO8601Date.js +7 -3
- package/dist/domain/entities/ISO8601Date.test.js +35 -33
- package/dist/domain/entities/ISO8601DateTime.js +5 -1
- package/dist/domain/entities/ISO8601DateTime.test.js +53 -51
- package/dist/domain/entities/ISO8601DateValidator.js +5 -1
- package/dist/domain/entities/ISO8601DateValidator.test.js +5 -3
- package/dist/domain/entities/ISO8601Time.js +7 -3
- package/dist/domain/entities/ISO8601Time.test.js +14 -12
- package/dist/domain/entities/ISO8601TimeValidator.js +5 -1
- package/dist/domain/entities/ISO8601TimeValidator.test.js +4 -2
- package/dist/domain/entities/PasswordRecovery.js +2 -1
- package/dist/domain/entities/Payment.js +2 -1
- package/dist/domain/entities/PaymentRecognitionRequest.js +2 -1
- package/dist/domain/entities/PreApprovedUser.js +2 -1
- package/dist/domain/entities/RescheduleRequest.js +2 -1
- package/dist/domain/entities/School.js +2 -1
- package/dist/domain/entities/SchoolConnection.js +2 -1
- package/dist/domain/entities/SchoolConnectionRequest.js +2 -1
- package/dist/domain/entities/SchoolStudent.js +2 -1
- package/dist/domain/entities/SchoolTeacher.js +2 -1
- package/dist/domain/entities/Time.js +2 -1
- package/dist/domain/entities/TimeSlot.js +2 -1
- package/dist/domain/entities/TimeValidator.js +2 -1
- package/dist/domain/entities/UnauthorizedUser.js +2 -1
- package/dist/domain/entities/UserAuth.js +2 -1
- package/dist/domain/entities/UserConnection.js +2 -1
- package/dist/domain/entities/UserConnectionRequest.js +2 -1
- package/dist/domain/entities/UserCredentials.js +5 -1
- package/dist/domain/entities/UserNavigation.js +2 -1
- package/dist/domain/entities/UserPreferences.js +2 -1
- package/dist/domain/entities/UserPremium.js +2 -1
- package/dist/domain/entities/UserProfile.js +2 -1
- package/dist/domain/entities/UserRoles.js +2 -1
- package/dist/domain/entities/UserSharedFileTimestamps.js +2 -1
- package/dist/domain/entities/UserUnavailableTime.js +5 -1
- package/dist/domain/entities/UserUnavailableTime.test.js +6 -4
- package/dist/domain/repositories/UnavailableTimeRepository.js +2 -1
- package/dist/index.cjs +341 -0
- package/dist/index.d.ts +47 -47
- package/dist/index.js +21 -10
- package/dist/restful/responses/GetFixedAvailableTimesResponseBody.js +2 -1
- package/package.json +9 -4
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ISO8601Time_1 = require("./ISO8601Time");
|
|
2
4
|
describe("ISO8601Time", () => {
|
|
3
5
|
beforeAll(() => {
|
|
4
6
|
jest.useFakeTimers({
|
|
@@ -11,50 +13,50 @@ describe("ISO8601Time", () => {
|
|
|
11
13
|
});
|
|
12
14
|
describe("ISO8601Time constructor", () => {
|
|
13
15
|
it("Should construct with no arguments.", () => {
|
|
14
|
-
const time = new ISO8601Time();
|
|
16
|
+
const time = new ISO8601Time_1.ISO8601Time();
|
|
15
17
|
expect(time).toBeDefined();
|
|
16
18
|
});
|
|
17
19
|
it("Should construct with now time when receiving no arguments.", () => {
|
|
18
|
-
const time = new ISO8601Time();
|
|
20
|
+
const time = new ISO8601Time_1.ISO8601Time();
|
|
19
21
|
expect(time.value).toBe("23:00:00");
|
|
20
22
|
});
|
|
21
23
|
});
|
|
22
24
|
describe("ISO8601Time.getNow()", () => {
|
|
23
25
|
it("Should get now time.", () => {
|
|
24
|
-
expect(ISO8601Time.getNow()).toBe("23:00:00");
|
|
26
|
+
expect(ISO8601Time_1.ISO8601Time.getNow()).toBe("23:00:00");
|
|
25
27
|
});
|
|
26
28
|
});
|
|
27
29
|
describe("ISO8601Time.getHours()", () => {
|
|
28
30
|
it("Should return hours when valid", () => {
|
|
29
|
-
const time = new ISO8601Time("00:01");
|
|
31
|
+
const time = new ISO8601Time_1.ISO8601Time("00:01");
|
|
30
32
|
expect(time.getHours()).toBe("00");
|
|
31
|
-
const time2 = new ISO8601Time("00:01:02");
|
|
33
|
+
const time2 = new ISO8601Time_1.ISO8601Time("00:01:02");
|
|
32
34
|
expect(time2.getHours()).toBe("00");
|
|
33
35
|
});
|
|
34
36
|
});
|
|
35
37
|
describe("ISO8601Time.getMinutes()", () => {
|
|
36
38
|
it("Should return minutes when valid", () => {
|
|
37
|
-
const time = new ISO8601Time("00:01");
|
|
39
|
+
const time = new ISO8601Time_1.ISO8601Time("00:01");
|
|
38
40
|
expect(time.getMinutes()).toBe("01");
|
|
39
|
-
const time2 = new ISO8601Time("00:01:02");
|
|
41
|
+
const time2 = new ISO8601Time_1.ISO8601Time("00:01:02");
|
|
40
42
|
expect(time2.getMinutes()).toBe("01");
|
|
41
43
|
});
|
|
42
44
|
});
|
|
43
45
|
describe("ISO8601Time.getSeconds()", () => {
|
|
44
46
|
it("Should return seconds when valid", () => {
|
|
45
|
-
const time2 = new ISO8601Time("00:01:02");
|
|
47
|
+
const time2 = new ISO8601Time_1.ISO8601Time("00:01:02");
|
|
46
48
|
expect(time2.getSeconds()).toBe("02");
|
|
47
49
|
});
|
|
48
50
|
it("Should return 00 when seconds are not present.", () => {
|
|
49
|
-
const time = new ISO8601Time("00:01");
|
|
51
|
+
const time = new ISO8601Time_1.ISO8601Time("00:01");
|
|
50
52
|
expect(time.getSeconds()).toBe("00");
|
|
51
53
|
});
|
|
52
54
|
});
|
|
53
55
|
describe("ISO8601Time.getTime()", () => {
|
|
54
56
|
it("Should return time when valid", () => {
|
|
55
|
-
const time = new ISO8601Time("00:01");
|
|
57
|
+
const time = new ISO8601Time_1.ISO8601Time("00:01");
|
|
56
58
|
expect(time.getTime()).toBe("00:01:00");
|
|
57
|
-
const time2 = new ISO8601Time("00:01:02");
|
|
59
|
+
const time2 = new ISO8601Time_1.ISO8601Time("00:01:02");
|
|
58
60
|
expect(time2.getTime()).toBe("00:01:02");
|
|
59
61
|
});
|
|
60
62
|
});
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ISO8601TimeValidator = void 0;
|
|
4
|
+
class ISO8601TimeValidator {
|
|
2
5
|
constructor() {
|
|
3
6
|
this.hhMMssPattern = new RegExp("^([0-1][0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9]$");
|
|
4
7
|
this.hhMMPattern = new RegExp("^([0-1][0-9]|[2][0-3]):[0-5][0-9]$");
|
|
@@ -13,3 +16,4 @@ export class ISO8601TimeValidator {
|
|
|
13
16
|
return this.hhMMPattern.test(time);
|
|
14
17
|
}
|
|
15
18
|
}
|
|
19
|
+
exports.ISO8601TimeValidator = ISO8601TimeValidator;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ISO8601TimeValidator_1 = require("./ISO8601TimeValidator");
|
|
2
4
|
describe("ISO8601TimeValidator", () => {
|
|
3
|
-
const validator = new ISO8601TimeValidator();
|
|
5
|
+
const validator = new ISO8601TimeValidator_1.ISO8601TimeValidator();
|
|
4
6
|
describe("ISO8601TimeValidator.formatIsValid()", () => {
|
|
5
7
|
it("Should not accept ISO8601 timestamp with offset.", () => {
|
|
6
8
|
const time = "00:00:00-03:00";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserCredentials = void 0;
|
|
4
|
+
class UserCredentials {
|
|
2
5
|
constructor(opts) {
|
|
3
6
|
this.email = opts.email;
|
|
4
7
|
this.password = opts.password;
|
|
5
8
|
this.user = opts.user;
|
|
6
9
|
}
|
|
7
10
|
}
|
|
11
|
+
exports.UserCredentials = UserCredentials;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserUnavailableTime = void 0;
|
|
4
|
+
class UserUnavailableTime {
|
|
2
5
|
constructor(opts) {
|
|
3
6
|
this.getDateTimeSlot = () => {
|
|
4
7
|
return {
|
|
@@ -26,3 +29,4 @@ export class UserUnavailableTime {
|
|
|
26
29
|
return this.date.getDayOfTheWeek();
|
|
27
30
|
}
|
|
28
31
|
}
|
|
32
|
+
exports.UserUnavailableTime = UserUnavailableTime;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ISO8601Date_1 = require("./ISO8601Date");
|
|
4
|
+
const UserUnavailableTime_1 = require("./UserUnavailableTime");
|
|
3
5
|
describe("UserUnavailableTime", () => {
|
|
4
|
-
const availableTime = new UserUnavailableTime({
|
|
6
|
+
const availableTime = new UserUnavailableTime_1.UserUnavailableTime({
|
|
5
7
|
courseId: "courseId",
|
|
6
|
-
date: new ISO8601Date("2025-01-01"),
|
|
8
|
+
date: new ISO8601Date_1.ISO8601Date("2025-01-01"),
|
|
7
9
|
endTime: "15:00",
|
|
8
10
|
startTime: "14:00",
|
|
9
11
|
groupId: "groupId",
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AsaasCustomer: () => AsaasCustomer,
|
|
24
|
+
Class: () => Class,
|
|
25
|
+
FreeDateTimeSlot: () => FreeDateTimeSlot,
|
|
26
|
+
ISO8601Date: () => ISO8601Date,
|
|
27
|
+
ISO8601DateTime: () => ISO8601DateTime,
|
|
28
|
+
ISO8601DateValidator: () => ISO8601DateValidator,
|
|
29
|
+
ISO8601Time: () => ISO8601Time,
|
|
30
|
+
ISO8601TimeValidator: () => ISO8601TimeValidator,
|
|
31
|
+
UserUnavailableTime: () => UserUnavailableTime
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/domain/entities/AsaasCustomer.ts
|
|
36
|
+
var AsaasCustomer = class {
|
|
37
|
+
constructor(opts) {
|
|
38
|
+
this.name = opts.name;
|
|
39
|
+
this.cpfCnpj = opts.cpfCnpj;
|
|
40
|
+
this.email = opts.email;
|
|
41
|
+
this.mobilePhone = opts.mobilePhone;
|
|
42
|
+
this.externalReference = opts.externalReference;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/domain/entities/Class.ts
|
|
47
|
+
var Class = class {
|
|
48
|
+
constructor(params) {
|
|
49
|
+
this.id = params.id;
|
|
50
|
+
this.groupId = params.groupId ? params.groupId : null;
|
|
51
|
+
this.title = params.title;
|
|
52
|
+
this.description = params.description ? params.description : null;
|
|
53
|
+
this.createdAt = params.createdAt ? params.createdAt : null;
|
|
54
|
+
this.updatedAt = params.updatedAt ? params.updatedAt : null;
|
|
55
|
+
this.date = params.date;
|
|
56
|
+
this.time = params.time;
|
|
57
|
+
this.endTime = params.endTime;
|
|
58
|
+
this.endDate = params.endDate ? params.endDate : null;
|
|
59
|
+
this.courseId = params.courseId;
|
|
60
|
+
this.paymentId = params.paymentId ? params.paymentId : null;
|
|
61
|
+
this.status = params.status ? params.status : null;
|
|
62
|
+
this.course = params.course;
|
|
63
|
+
this.payment = params.payment;
|
|
64
|
+
this.files = params.files;
|
|
65
|
+
this.rescheduleRequests = params.rescheduleRequests;
|
|
66
|
+
this.googleCalendarEvents = params.googleCalendarEvents;
|
|
67
|
+
this.meetingLink = params.meetingLink ? params.meetingLink : null;
|
|
68
|
+
this.contractId = params.contractId ? params.contractId : null;
|
|
69
|
+
this.contract = params.contract;
|
|
70
|
+
this.ownerId = params.ownerId;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/domain/entities/ISO8601DateValidator.ts
|
|
75
|
+
var ISO8601DateValidator = class {
|
|
76
|
+
constructor() {
|
|
77
|
+
this.YYYYmmDD = new RegExp(
|
|
78
|
+
"^[0-9]{4}-([0][1-9]|[1][0-2])-([0][1-9]|[1-2][0-9]|[3][0-1])$"
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Accepted format: YYYY-MM-DD
|
|
83
|
+
*/
|
|
84
|
+
formatIsValid(date) {
|
|
85
|
+
return this.YYYYmmDD.test(date);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/domain/entities/ISO8601Date.ts
|
|
90
|
+
var _ISO8601Date = class _ISO8601Date {
|
|
91
|
+
constructor(value) {
|
|
92
|
+
this.validator = new ISO8601DateValidator();
|
|
93
|
+
this.getDay = () => {
|
|
94
|
+
this.throwIfFormatIsNotValid();
|
|
95
|
+
return this.value.split("-")[2];
|
|
96
|
+
};
|
|
97
|
+
this.getMonth = () => {
|
|
98
|
+
this.throwIfFormatIsNotValid();
|
|
99
|
+
return this.value.split("-")[1];
|
|
100
|
+
};
|
|
101
|
+
this.getYear = () => {
|
|
102
|
+
this.throwIfFormatIsNotValid();
|
|
103
|
+
return this.value.split("-")[0];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* @returns today's date as a srting, in local time, formatted like YYYY-MM-DD.
|
|
107
|
+
*/
|
|
108
|
+
this.getToday = _ISO8601Date.getToday;
|
|
109
|
+
this.addDays = (x) => {
|
|
110
|
+
const now = new Date(
|
|
111
|
+
parseInt(this.getYear()),
|
|
112
|
+
parseInt(this.getMonth()) - 1,
|
|
113
|
+
parseInt(this.getDay())
|
|
114
|
+
);
|
|
115
|
+
const day = now.getDate() + x;
|
|
116
|
+
const newDate = new Date(now.getFullYear(), now.getMonth(), day);
|
|
117
|
+
return new _ISO8601Date(this.jsDateTimeToDate(newDate).value);
|
|
118
|
+
};
|
|
119
|
+
this.jsDateTimeToDate = _ISO8601Date.jsDateTimeToDate;
|
|
120
|
+
this.toLocalJsDateTime = (date) => {
|
|
121
|
+
const targetDate = date ? date : this;
|
|
122
|
+
return new Date(
|
|
123
|
+
parseInt(targetDate.getYear()),
|
|
124
|
+
parseInt(targetDate.getMonth()) - 1,
|
|
125
|
+
parseInt(targetDate.getDay())
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
this.getDaysSinceEpoch = (date) => {
|
|
129
|
+
const targetDate = date || this;
|
|
130
|
+
const differenceInDays = Math.floor(
|
|
131
|
+
targetDate.toLocalJsDateTime(targetDate).getTime() / 1e3 / 60 / 60 / 24
|
|
132
|
+
);
|
|
133
|
+
return differenceInDays;
|
|
134
|
+
};
|
|
135
|
+
this.toUtcJsDateTime = (date) => {
|
|
136
|
+
const targetDate = date ? date : this;
|
|
137
|
+
const year = targetDate.getYear();
|
|
138
|
+
const month = targetDate.getMonth();
|
|
139
|
+
const day = targetDate.getDay();
|
|
140
|
+
const dateString = `${year}-${month}-${day}T00:00:00.000Z`;
|
|
141
|
+
return new Date(dateString);
|
|
142
|
+
};
|
|
143
|
+
this.getDayOfTheWeek = (date) => {
|
|
144
|
+
const targetDate = date || this;
|
|
145
|
+
return targetDate.toUtcJsDateTime().getUTCDay();
|
|
146
|
+
};
|
|
147
|
+
this.value = value ? value : this.getToday();
|
|
148
|
+
this.throwIfFormatIsNotValid();
|
|
149
|
+
}
|
|
150
|
+
throwIfFormatIsNotValid() {
|
|
151
|
+
if (!this.validator.formatIsValid(this.value)) {
|
|
152
|
+
throw new Error("Date format must be YYYY-MM-DD.");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @returns today's date as a string, in local time, formatted like YYYY-MM-DD.
|
|
157
|
+
*/
|
|
158
|
+
static getToday() {
|
|
159
|
+
const now = /* @__PURE__ */ new Date();
|
|
160
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
161
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
162
|
+
const year = now.getFullYear().toString();
|
|
163
|
+
return `${year}-${month}-${day}`;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Converts a Javascript Date instance into an IDate instance. Uses local timezone as default.
|
|
168
|
+
* @param useUtc set to `true` to consider UTC when extracting year, month and date
|
|
169
|
+
* @returns a new `ISO8601Date` instance.
|
|
170
|
+
*/
|
|
171
|
+
_ISO8601Date.jsDateTimeToDate = (dateTime, opts) => {
|
|
172
|
+
const day = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCDate() : dateTime.getDate()).toString().padStart(2, "0");
|
|
173
|
+
const month = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCMonth() + 1 : dateTime.getMonth() + 1).toString().padStart(2, "0");
|
|
174
|
+
const year = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCFullYear() : dateTime.getFullYear()).toString();
|
|
175
|
+
return new _ISO8601Date(`${year}-${month}-${day}`);
|
|
176
|
+
};
|
|
177
|
+
var ISO8601Date = _ISO8601Date;
|
|
178
|
+
|
|
179
|
+
// src/domain/entities/ISO8601DateTime.ts
|
|
180
|
+
var ISO8601DateTime = class _ISO8601DateTime {
|
|
181
|
+
constructor(opts) {
|
|
182
|
+
this.getJSDateTime = () => {
|
|
183
|
+
return new Date(
|
|
184
|
+
parseInt(this.date.getYear()),
|
|
185
|
+
parseInt(this.date.getMonth()) - 1,
|
|
186
|
+
parseInt(this.date.getDay()),
|
|
187
|
+
parseInt(this.time.getHours()),
|
|
188
|
+
parseInt(this.time.getMinutes()),
|
|
189
|
+
parseInt(this.time.getSeconds())
|
|
190
|
+
);
|
|
191
|
+
};
|
|
192
|
+
this.getBrazilianIsoString = () => {
|
|
193
|
+
return this.getIsoString({
|
|
194
|
+
timezoneOffsetMinutes: -180
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
this.date = opts.date;
|
|
198
|
+
this.time = opts.time;
|
|
199
|
+
}
|
|
200
|
+
getIsoString(opts) {
|
|
201
|
+
const padLeft = (n) => String(n).padStart(2, "0");
|
|
202
|
+
const newDateTime = new _ISO8601DateTime({
|
|
203
|
+
date: (opts == null ? void 0 : opts.newDate) || this.date,
|
|
204
|
+
time: (opts == null ? void 0 : opts.newTime) || this.time
|
|
205
|
+
});
|
|
206
|
+
const jsDate = newDateTime.getJSDateTime();
|
|
207
|
+
const year = jsDate.getFullYear();
|
|
208
|
+
const month = padLeft(jsDate.getMonth() + 1);
|
|
209
|
+
const day = padLeft(jsDate.getDate());
|
|
210
|
+
const hour = padLeft(jsDate.getHours());
|
|
211
|
+
const minute = padLeft(jsDate.getMinutes());
|
|
212
|
+
const second = padLeft(jsDate.getSeconds());
|
|
213
|
+
const timezoneOffsetMinutes = (opts == null ? void 0 : opts.timezoneOffsetMinutes) ? opts.timezoneOffsetMinutes : 0;
|
|
214
|
+
const sign = timezoneOffsetMinutes == 0 ? void 0 : timezoneOffsetMinutes < 0 ? "-" : "+";
|
|
215
|
+
const offsetHours = padLeft(
|
|
216
|
+
Math.floor(Math.abs(timezoneOffsetMinutes) / 60)
|
|
217
|
+
);
|
|
218
|
+
const offsetMinutes = padLeft(Math.abs(timezoneOffsetMinutes) % 60);
|
|
219
|
+
const timezone = sign ? `${sign}${offsetHours}:${offsetMinutes}` : ".000Z";
|
|
220
|
+
return `${year}-${month}-${day}T${hour}:${minute}:${second}${timezone}`;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// src/domain/entities/ISO8601TimeValidator.ts
|
|
225
|
+
var ISO8601TimeValidator = class {
|
|
226
|
+
constructor() {
|
|
227
|
+
this.hhMMssPattern = new RegExp(
|
|
228
|
+
"^([0-1][0-9]|[2][0-3]):[0-5][0-9]:[0-5][0-9]$"
|
|
229
|
+
);
|
|
230
|
+
this.hhMMPattern = new RegExp(
|
|
231
|
+
"^([0-1][0-9]|[2][0-3]):[0-5][0-9]$"
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
formatIsValid(time) {
|
|
235
|
+
return this.isHHmm(time) || this.isHHmmSS(time);
|
|
236
|
+
}
|
|
237
|
+
isHHmmSS(time) {
|
|
238
|
+
return this.hhMMssPattern.test(time);
|
|
239
|
+
}
|
|
240
|
+
isHHmm(time) {
|
|
241
|
+
return this.hhMMPattern.test(time);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/domain/entities/ISO8601Time.ts
|
|
246
|
+
var ISO8601Time = class _ISO8601Time {
|
|
247
|
+
/**
|
|
248
|
+
* Throws if format is invalid.
|
|
249
|
+
* Accepted formats: HH:MM:SS and HH:MM.
|
|
250
|
+
*/
|
|
251
|
+
constructor(value) {
|
|
252
|
+
this.validator = new ISO8601TimeValidator();
|
|
253
|
+
this.getNow = _ISO8601Time.getNow;
|
|
254
|
+
this.value = value ? value : this.getNow();
|
|
255
|
+
this.validateFormatOrThrow();
|
|
256
|
+
}
|
|
257
|
+
validateFormatOrThrow() {
|
|
258
|
+
if (!this.validator.formatIsValid(this.value))
|
|
259
|
+
throw new Error("Time format must be ISO8601.");
|
|
260
|
+
}
|
|
261
|
+
getTime() {
|
|
262
|
+
this.validateFormatOrThrow();
|
|
263
|
+
if (this.validator.isHHmm(this.value)) {
|
|
264
|
+
return `${this.value}:00`;
|
|
265
|
+
}
|
|
266
|
+
return this.value;
|
|
267
|
+
}
|
|
268
|
+
getMinutes() {
|
|
269
|
+
this.validateFormatOrThrow();
|
|
270
|
+
return this.value.split(":")[1];
|
|
271
|
+
}
|
|
272
|
+
getHours() {
|
|
273
|
+
this.validateFormatOrThrow();
|
|
274
|
+
return this.value.split(":")[0];
|
|
275
|
+
}
|
|
276
|
+
getSeconds() {
|
|
277
|
+
this.validateFormatOrThrow();
|
|
278
|
+
const seconds = this.value.split(":")[2];
|
|
279
|
+
if (seconds) return seconds;
|
|
280
|
+
return "00";
|
|
281
|
+
}
|
|
282
|
+
static getNow() {
|
|
283
|
+
const nowDate = /* @__PURE__ */ new Date();
|
|
284
|
+
const hours = nowDate.getHours().toString().padStart(2, "0");
|
|
285
|
+
const minutes = nowDate.getMinutes().toString().padStart(2, "0");
|
|
286
|
+
const seconds = nowDate.getSeconds().toString().padStart(2, "0");
|
|
287
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// src/domain/entities/UserUnavailableTime.ts
|
|
292
|
+
var UserUnavailableTime = class {
|
|
293
|
+
constructor(opts) {
|
|
294
|
+
this.getDateTimeSlot = () => {
|
|
295
|
+
return {
|
|
296
|
+
date: this.date,
|
|
297
|
+
timeSlot: {
|
|
298
|
+
endTime: this.endTime,
|
|
299
|
+
startTime: this.startTime
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
this.id = opts.id;
|
|
304
|
+
this.userId = opts.userId;
|
|
305
|
+
this.user = opts.user;
|
|
306
|
+
this.groupId = opts.groupId;
|
|
307
|
+
this.date = opts.date;
|
|
308
|
+
this.dayOfTheWeek = this.getDayOfTheWeek();
|
|
309
|
+
this.startTime = opts.startTime;
|
|
310
|
+
this.endTime = opts.endTime;
|
|
311
|
+
this.isAvailableTime = opts.isAvailableTime;
|
|
312
|
+
this.course = opts.course;
|
|
313
|
+
this.courseId = opts.courseId;
|
|
314
|
+
this.rescheduleRequests = opts.rescheduleRequests;
|
|
315
|
+
}
|
|
316
|
+
getDayOfTheWeek() {
|
|
317
|
+
return this.date.getDayOfTheWeek();
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// src/domain/entities/FreeTimeSlot.ts
|
|
322
|
+
var FreeDateTimeSlot = class {
|
|
323
|
+
constructor(opts) {
|
|
324
|
+
this.date = opts.date;
|
|
325
|
+
this.startTime = opts.startTime;
|
|
326
|
+
this.endTime = opts.endTime;
|
|
327
|
+
this.userId = opts.userId;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
331
|
+
0 && (module.exports = {
|
|
332
|
+
AsaasCustomer,
|
|
333
|
+
Class,
|
|
334
|
+
FreeDateTimeSlot,
|
|
335
|
+
ISO8601Date,
|
|
336
|
+
ISO8601DateTime,
|
|
337
|
+
ISO8601DateValidator,
|
|
338
|
+
ISO8601Time,
|
|
339
|
+
ISO8601TimeValidator,
|
|
340
|
+
UserUnavailableTime
|
|
341
|
+
});
|