@eliasrrosa/tutorhub-public-assets 0.0.14 → 0.0.15
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/types/ClassCreationRecurrenceRule.d.ts +1 -0
- package/dist/domain/types/ClassCreationRecurrenceRule.js +2 -0
- package/dist/domain/types/ClassStatus.d.ts +1 -0
- package/dist/domain/types/ClassStatus.js +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +543 -21
- package/dist/infrastructure/restful/requests/forms/CreateClassForm.d.ts +16 -0
- package/dist/infrastructure/restful/requests/forms/CreateClassForm.js +2 -0
- package/dist/infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.d.ts +5 -0
- package/dist/infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.js +2 -0
- package/package.json +3 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ClassCreationRecurrenceRule = "daily" | "weekly" | "week days";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ClassStatus = "pending" | "done" | "canceled" | "to reschedule";
|
package/dist/index.d.ts
CHANGED
|
@@ -42,7 +42,10 @@ import { IUserProfile } from "./domain/entities/UserProfile.js";
|
|
|
42
42
|
import { IUserRoles } from "./domain/entities/UserRoles.js";
|
|
43
43
|
import { IUserSharedFileTimestamps } from "./domain/entities/UserSharedFileTimestamps.js";
|
|
44
44
|
import { IUnavailableTimeRepository } from "./domain/repositories/UnavailableTimeRepository.js";
|
|
45
|
-
import { GetFixedAvailableTimeResponseBody } from "./restful/responses/GetFixedAvailableTimesResponseBody.js";
|
|
45
|
+
import { GetFixedAvailableTimeResponseBody } from "./infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.js";
|
|
46
|
+
import { CreateClassForm } from "./infrastructure/restful/requests/forms/CreateClassForm.js";
|
|
47
|
+
import { ClassStatus } from "./domain/types/ClassStatus.js";
|
|
48
|
+
import { ClassCreationRecurrenceRule } from "./domain/types/ClassCreationRecurrenceRule.js";
|
|
46
49
|
import { IUserUnavailableTime, UserUnavailableTime } from "./domain/entities/UserUnavailableTime.js";
|
|
47
50
|
import { IFreeDateTimeSlot, FreeDateTimeSlot } from "./domain/entities/FreeTimeSlot.js";
|
|
48
|
-
export { AsaasCustomer, Class, IClass, IClassRequest, IContract, ICourse, ICourseToSchoolConnectionRequest, IDate, IDateTimeSlot, IFreeDateTimeSlot, FreeDateTimeSlot, IUserUnavailableTime, UserUnavailableTime, IDateValidator, IFile, IGenericNotification, IGoogleAuth, IGoogleCalendar, IGoogleCalendarEvent, ISO8601Date, IDateTime, ISO8601DateValidator, ISO8601Time, ISO8601TimeValidator, IPasswordRecovery, IPayment, IPaymentRecognitionRequest, IPreApprovedUser, IRescheduleRequest, ISchool, ISchoolConnection, ISchoolConnectionRequest, ISchoolStudent, ISchoolTeacher, ITime, ITimeSlot, ITimeValidator, IUnauthorizedUser, IUserAuth, IUserConnection, IUserConnectionRequest, IUserCredentials, IUserNavigation, IUserPreferences, IUserPremium, IUserProfile, IUserRoles, IUserSharedFileTimestamps, IUnavailableTimeRepository, GetFixedAvailableTimeResponseBody, ISO8601DateTime };
|
|
51
|
+
export { AsaasCustomer, Class, IClass, IClassRequest, IContract, ICourse, ICourseToSchoolConnectionRequest, IDate, IDateTimeSlot, IFreeDateTimeSlot, FreeDateTimeSlot, IUserUnavailableTime, UserUnavailableTime, IDateValidator, IFile, IGenericNotification, IGoogleAuth, IGoogleCalendar, IGoogleCalendarEvent, ISO8601Date, IDateTime, ISO8601DateValidator, ISO8601Time, ISO8601TimeValidator, IPasswordRecovery, IPayment, IPaymentRecognitionRequest, IPreApprovedUser, IRescheduleRequest, ISchool, ISchoolConnection, ISchoolConnectionRequest, ISchoolStudent, ISchoolTeacher, ITime, ITimeSlot, ITimeValidator, IUnauthorizedUser, IUserAuth, IUserConnection, IUserConnectionRequest, IUserCredentials, IUserNavigation, IUserPreferences, IUserPremium, IUserProfile, IUserRoles, IUserSharedFileTimestamps, IUnavailableTimeRepository, GetFixedAvailableTimeResponseBody, ISO8601DateTime, CreateClassForm, ClassCreationRecurrenceRule, ClassStatus };
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,543 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
// src/domain/entities/AsaasCustomer.ts
|
|
2
|
+
var AsaasCustomer = class {
|
|
3
|
+
constructor(opts) {
|
|
4
|
+
this.name = opts.name;
|
|
5
|
+
this.cpfCnpj = opts.cpfCnpj;
|
|
6
|
+
this.email = opts.email;
|
|
7
|
+
this.mobilePhone = opts.mobilePhone;
|
|
8
|
+
this.externalReference = opts.externalReference;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/domain/entities/Class.ts
|
|
13
|
+
var Class = class {
|
|
14
|
+
constructor(params) {
|
|
15
|
+
this.id = params.id;
|
|
16
|
+
this.groupId = params.groupId ? params.groupId : null;
|
|
17
|
+
this.title = params.title;
|
|
18
|
+
this.description = params.description ? params.description : null;
|
|
19
|
+
this.createdAt = params.createdAt ? params.createdAt : null;
|
|
20
|
+
this.updatedAt = params.updatedAt ? params.updatedAt : null;
|
|
21
|
+
this.date = params.date;
|
|
22
|
+
this.time = params.time;
|
|
23
|
+
this.endTime = params.endTime;
|
|
24
|
+
this.endDate = params.endDate ? params.endDate : null;
|
|
25
|
+
this.courseId = params.courseId;
|
|
26
|
+
this.paymentId = params.paymentId ? params.paymentId : null;
|
|
27
|
+
this.status = params.status ? params.status : null;
|
|
28
|
+
this.course = params.course;
|
|
29
|
+
this.payment = params.payment;
|
|
30
|
+
this.files = params.files;
|
|
31
|
+
this.rescheduleRequests = params.rescheduleRequests;
|
|
32
|
+
this.googleCalendarEvents = params.googleCalendarEvents;
|
|
33
|
+
this.meetingLink = params.meetingLink ? params.meetingLink : null;
|
|
34
|
+
this.contractId = params.contractId ? params.contractId : null;
|
|
35
|
+
this.contract = params.contract;
|
|
36
|
+
this.ownerId = params.ownerId;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/domain/entities/ISO8601DateValidator.ts
|
|
41
|
+
var ISO8601DateValidator = class {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.YYYYmmDD = new RegExp(
|
|
44
|
+
"^[0-9]{4}-([0][1-9]|[1][0-2])-([0][1-9]|[1-2][0-9]|[3][0-1])$"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Accepted format: YYYY-MM-DD
|
|
49
|
+
*/
|
|
50
|
+
formatIsValid(date) {
|
|
51
|
+
return this.YYYYmmDD.test(date);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/domain/entities/ISO8601Date.ts
|
|
56
|
+
var _ISO8601Date = class _ISO8601Date {
|
|
57
|
+
constructor(value) {
|
|
58
|
+
this.validator = new ISO8601DateValidator();
|
|
59
|
+
this.getDay = () => {
|
|
60
|
+
this.throwIfFormatIsNotValid();
|
|
61
|
+
return this.value.split("-")[2];
|
|
62
|
+
};
|
|
63
|
+
this.getMonth = () => {
|
|
64
|
+
this.throwIfFormatIsNotValid();
|
|
65
|
+
return this.value.split("-")[1];
|
|
66
|
+
};
|
|
67
|
+
this.getYear = () => {
|
|
68
|
+
this.throwIfFormatIsNotValid();
|
|
69
|
+
return this.value.split("-")[0];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @returns today's date as a srting, in local time, formatted like YYYY-MM-DD.
|
|
73
|
+
*/
|
|
74
|
+
this.getToday = _ISO8601Date.getToday;
|
|
75
|
+
this.addDays = (x) => {
|
|
76
|
+
const now = new Date(
|
|
77
|
+
parseInt(this.getYear()),
|
|
78
|
+
parseInt(this.getMonth()) - 1,
|
|
79
|
+
parseInt(this.getDay())
|
|
80
|
+
);
|
|
81
|
+
const day = now.getDate() + x;
|
|
82
|
+
const newDate = new Date(now.getFullYear(), now.getMonth(), day);
|
|
83
|
+
return new _ISO8601Date(this.jsDateTimeToDate(newDate).value);
|
|
84
|
+
};
|
|
85
|
+
this.jsDateTimeToDate = _ISO8601Date.jsDateTimeToDate;
|
|
86
|
+
this.toLocalJsDateTime = (date) => {
|
|
87
|
+
const targetDate = date ? date : this;
|
|
88
|
+
return new Date(
|
|
89
|
+
parseInt(targetDate.getYear()),
|
|
90
|
+
parseInt(targetDate.getMonth()) - 1,
|
|
91
|
+
parseInt(targetDate.getDay())
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
this.getDaysSinceEpoch = (date) => {
|
|
95
|
+
const targetDate = date || this;
|
|
96
|
+
const differenceInDays = Math.floor(
|
|
97
|
+
targetDate.toLocalJsDateTime(targetDate).getTime() / 1e3 / 60 / 60 / 24
|
|
98
|
+
);
|
|
99
|
+
return differenceInDays;
|
|
100
|
+
};
|
|
101
|
+
this.toUtcJsDateTime = (date) => {
|
|
102
|
+
const targetDate = date ? date : this;
|
|
103
|
+
const year = targetDate.getYear();
|
|
104
|
+
const month = targetDate.getMonth();
|
|
105
|
+
const day = targetDate.getDay();
|
|
106
|
+
const dateString = `${year}-${month}-${day}T00:00:00.000Z`;
|
|
107
|
+
return new Date(dateString);
|
|
108
|
+
};
|
|
109
|
+
this.getDayOfTheWeek = (date) => {
|
|
110
|
+
const targetDate = date || this;
|
|
111
|
+
return targetDate.toUtcJsDateTime().getUTCDay();
|
|
112
|
+
};
|
|
113
|
+
this.value = value ? value : this.getToday();
|
|
114
|
+
this.throwIfFormatIsNotValid();
|
|
115
|
+
}
|
|
116
|
+
throwIfFormatIsNotValid() {
|
|
117
|
+
if (!this.validator.formatIsValid(this.value)) {
|
|
118
|
+
throw new Error("Date format must be YYYY-MM-DD.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @returns today's date as a string, in local time, formatted like YYYY-MM-DD.
|
|
123
|
+
*/
|
|
124
|
+
static getToday() {
|
|
125
|
+
const now = /* @__PURE__ */ new Date();
|
|
126
|
+
const day = now.getDate().toString().padStart(2, "0");
|
|
127
|
+
const month = (now.getMonth() + 1).toString().padStart(2, "0");
|
|
128
|
+
const year = now.getFullYear().toString();
|
|
129
|
+
return `${year}-${month}-${day}`;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Converts a Javascript Date instance into an IDate instance. Uses local timezone as default.
|
|
134
|
+
* @param useUtc set to `true` to consider UTC when extracting year, month and date
|
|
135
|
+
* @returns a new `ISO8601Date` instance.
|
|
136
|
+
*/
|
|
137
|
+
_ISO8601Date.jsDateTimeToDate = (dateTime, opts) => {
|
|
138
|
+
const day = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCDate() : dateTime.getDate()).toString().padStart(2, "0");
|
|
139
|
+
const month = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCMonth() + 1 : dateTime.getMonth() + 1).toString().padStart(2, "0");
|
|
140
|
+
const year = ((opts == null ? void 0 : opts.useUtc) ? dateTime.getUTCFullYear() : dateTime.getFullYear()).toString();
|
|
141
|
+
return new _ISO8601Date(`${year}-${month}-${day}`);
|
|
142
|
+
};
|
|
143
|
+
var ISO8601Date = _ISO8601Date;
|
|
144
|
+
|
|
145
|
+
// src/domain/entities/ISO8601DateTime.ts
|
|
146
|
+
var ISO8601DateTime = class _ISO8601DateTime {
|
|
147
|
+
constructor(opts) {
|
|
148
|
+
this.getJSDateTime = () => {
|
|
149
|
+
return new Date(
|
|
150
|
+
parseInt(this.date.getYear()),
|
|
151
|
+
parseInt(this.date.getMonth()) - 1,
|
|
152
|
+
parseInt(this.date.getDay()),
|
|
153
|
+
parseInt(this.time.getHoursString()),
|
|
154
|
+
parseInt(this.time.getMinutesString()),
|
|
155
|
+
parseInt(this.time.getSecondsString())
|
|
156
|
+
);
|
|
157
|
+
};
|
|
158
|
+
this.getBrazilianIsoString = () => {
|
|
159
|
+
return this.getIsoString({
|
|
160
|
+
timezoneOffsetMinutes: -180
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
this.date = opts.date;
|
|
164
|
+
this.time = opts.time;
|
|
165
|
+
}
|
|
166
|
+
getIsoString(opts) {
|
|
167
|
+
const padLeft = (n) => String(n).padStart(2, "0");
|
|
168
|
+
const newDateTime = new _ISO8601DateTime({
|
|
169
|
+
date: (opts == null ? void 0 : opts.newDate) || this.date,
|
|
170
|
+
time: (opts == null ? void 0 : opts.newTime) || this.time
|
|
171
|
+
});
|
|
172
|
+
const jsDate = newDateTime.getJSDateTime();
|
|
173
|
+
const year = jsDate.getFullYear();
|
|
174
|
+
const month = padLeft(jsDate.getMonth() + 1);
|
|
175
|
+
const day = padLeft(jsDate.getDate());
|
|
176
|
+
const hour = padLeft(jsDate.getHours());
|
|
177
|
+
const minute = padLeft(jsDate.getMinutes());
|
|
178
|
+
const second = padLeft(jsDate.getSeconds());
|
|
179
|
+
const timezoneOffsetMinutes = (opts == null ? void 0 : opts.timezoneOffsetMinutes) ? opts.timezoneOffsetMinutes : 0;
|
|
180
|
+
const sign = timezoneOffsetMinutes == 0 ? void 0 : timezoneOffsetMinutes < 0 ? "-" : "+";
|
|
181
|
+
const offsetHours = padLeft(
|
|
182
|
+
Math.floor(Math.abs(timezoneOffsetMinutes) / 60)
|
|
183
|
+
);
|
|
184
|
+
const offsetMinutes = padLeft(Math.abs(timezoneOffsetMinutes) % 60);
|
|
185
|
+
const timezone = sign ? `${sign}${offsetHours}:${offsetMinutes}` : ".000Z";
|
|
186
|
+
return `${year}-${month}-${day}T${hour}:${minute}:${second}${timezone}`;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// src/domain/entities/ISO8601TimeValidator.ts
|
|
191
|
+
var ISO8601TimeValidator = class {
|
|
192
|
+
constructor() {
|
|
193
|
+
this.upTo23 = "([0-1][0-9]|[2][0-3])";
|
|
194
|
+
this.upTo59 = "[0-5][0-9]";
|
|
195
|
+
this.upTo11 = "(0[0-9]|1[0-2])";
|
|
196
|
+
this.upTo13 = "(0[0-9]|1[0-4])";
|
|
197
|
+
this.numberedTimezonePatternString = `(\\+(${this.upTo11}:${this.upTo59}|12:00)|\\-(${this.upTo13}:${this.upTo59}|14:00))`;
|
|
198
|
+
this.numberedTimezonePattern = new RegExp(`^${this.numberedTimezonePatternString}$`);
|
|
199
|
+
this.zTimezonePatternString = "Z";
|
|
200
|
+
this.zAndMillisecondsPatternString = `.[0-9]{3}Z`;
|
|
201
|
+
this.hhMMssPattern = new RegExp(
|
|
202
|
+
`^${this.upTo23}:${this.upTo59}:${this.upTo59}$`
|
|
203
|
+
);
|
|
204
|
+
this.hhMMPattern = new RegExp(`^${this.upTo23}:${this.upTo59}$`);
|
|
205
|
+
this.hhMMssPlusNumberedTimezonePattern = new RegExp(
|
|
206
|
+
`^${this.upTo23}:${this.upTo59}:${this.upTo59}${this.numberedTimezonePatternString}$`
|
|
207
|
+
);
|
|
208
|
+
this.hhMMssZPattern = new RegExp(
|
|
209
|
+
`^${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zTimezonePatternString}$`
|
|
210
|
+
);
|
|
211
|
+
this.hhMMssSSSZPattern = new RegExp(
|
|
212
|
+
`^${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zAndMillisecondsPatternString}$`
|
|
213
|
+
);
|
|
214
|
+
this.isHHmmSSPlusNumberedTimezone = (time) => {
|
|
215
|
+
return this.hhMMssPlusNumberedTimezonePattern.test(time);
|
|
216
|
+
};
|
|
217
|
+
this.isHHmmSSZ = (time) => {
|
|
218
|
+
return this.hhMMssZPattern.test(time);
|
|
219
|
+
};
|
|
220
|
+
this.isHHmmSSsssZ = (time) => {
|
|
221
|
+
return this.hhMMssSSSZPattern.test(time);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
formatIsValid(time) {
|
|
225
|
+
return this.isHHmm(time) || this.isHHmmSS(time) || this.isHHmmSSPlusNumberedTimezone(time) || this.isHHmmSSZ(time) || this.isHHmmSSsssZ(time);
|
|
226
|
+
}
|
|
227
|
+
isHHmmSS(time) {
|
|
228
|
+
return this.hhMMssPattern.test(time);
|
|
229
|
+
}
|
|
230
|
+
isHHmm(time) {
|
|
231
|
+
return this.hhMMPattern.test(time);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/domain/entities/ISO8601TimezoneValidator.ts
|
|
236
|
+
var ISO8601TimezoneValidator = class {
|
|
237
|
+
constructor() {
|
|
238
|
+
this.upTo59 = "[0-5][0-9]";
|
|
239
|
+
this.upTo11 = "(0[0-9]|1[0-1])";
|
|
240
|
+
this.upTo13 = "(0[0-9]|1[0-4])";
|
|
241
|
+
this.zTimezonePatternString = "Z";
|
|
242
|
+
this.zTimezonePattern = new RegExp(`${this.zTimezonePatternString}$`);
|
|
243
|
+
this.zAndMillisecondsPatternString = `.[0-9]{3}Z`;
|
|
244
|
+
this.zAndMillisecondsPattern = new RegExp(
|
|
245
|
+
`${this.zAndMillisecondsPatternString}$`
|
|
246
|
+
);
|
|
247
|
+
this.numberedTimezonePatternString = `(\\+(${this.upTo11}:${this.upTo59}|12:00)|\\-(${this.upTo13}:${this.upTo59}|14:00))`;
|
|
248
|
+
this.numberedTimezonePattern = new RegExp(
|
|
249
|
+
`${this.numberedTimezonePatternString}$`
|
|
250
|
+
);
|
|
251
|
+
this.formatIsValid = (timezone) => {
|
|
252
|
+
if (typeof timezone == "number") {
|
|
253
|
+
return this.timezoneNumberIsValid(timezone);
|
|
254
|
+
}
|
|
255
|
+
return this.timezoneIsNumbered(timezone) || this.timezoneIsZ(timezone) || this.timezoneIsZandMilliseconds(timezone);
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
timezoneIsNumbered(timezone) {
|
|
259
|
+
return this.numberedTimezonePattern.test(timezone);
|
|
260
|
+
}
|
|
261
|
+
timezoneIsZ(timezone) {
|
|
262
|
+
return this.zTimezonePattern.test(timezone);
|
|
263
|
+
}
|
|
264
|
+
timezoneIsZandMilliseconds(timezone) {
|
|
265
|
+
return this.zAndMillisecondsPattern.test(timezone);
|
|
266
|
+
}
|
|
267
|
+
timezoneNumberIsValid(timezone) {
|
|
268
|
+
return timezone >= -840 && timezone <= 720;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// src/domain/entities/ISO8601TimezoneSelector.ts
|
|
273
|
+
var ISO8601TimezoneSelector = class {
|
|
274
|
+
constructor() {
|
|
275
|
+
this.timezoneValidator = new ISO8601TimezoneValidator();
|
|
276
|
+
this.getTimezoneString = (timezone) => {
|
|
277
|
+
const timezoneFormatIsValid = this.timezoneValidator.formatIsValid(timezone);
|
|
278
|
+
if (!timezoneFormatIsValid) {
|
|
279
|
+
return "Z";
|
|
280
|
+
}
|
|
281
|
+
if (typeof timezone == "string" && (this.timezoneValidator.timezoneIsZ(timezone) || this.timezoneValidator.timezoneIsZandMilliseconds(timezone))) {
|
|
282
|
+
return "Z";
|
|
283
|
+
}
|
|
284
|
+
if (typeof timezone == "string" && this.timezoneValidator.timezoneIsNumbered(timezone)) {
|
|
285
|
+
const match = timezone.match(
|
|
286
|
+
this.timezoneValidator.numberedTimezonePattern
|
|
287
|
+
);
|
|
288
|
+
if (!match) return "Z";
|
|
289
|
+
return match[0];
|
|
290
|
+
}
|
|
291
|
+
return "Z";
|
|
292
|
+
};
|
|
293
|
+
this.getHoursString = (timezone) => {
|
|
294
|
+
var _a;
|
|
295
|
+
if (this.timezoneValidator.timezoneIsNumbered(timezone)) {
|
|
296
|
+
const matches = timezone.match(
|
|
297
|
+
this.timezoneValidator.numberedTimezonePatternString
|
|
298
|
+
);
|
|
299
|
+
if (matches == null || matches.length < 1) return void 0;
|
|
300
|
+
return (_a = matches[0].split(":")) == null ? void 0 : _a[0].split("").slice(1).join("");
|
|
301
|
+
}
|
|
302
|
+
return void 0;
|
|
303
|
+
};
|
|
304
|
+
this.getMinutesString = (timezone) => {
|
|
305
|
+
var _a;
|
|
306
|
+
if (this.timezoneValidator.timezoneIsNumbered(timezone)) {
|
|
307
|
+
const matches = timezone.match(
|
|
308
|
+
this.timezoneValidator.numberedTimezonePatternString
|
|
309
|
+
);
|
|
310
|
+
if (matches == null || matches.length < 1) return void 0;
|
|
311
|
+
return (_a = matches[0].split(":")) == null ? void 0 : _a[1];
|
|
312
|
+
}
|
|
313
|
+
return void 0;
|
|
314
|
+
};
|
|
315
|
+
this.getTimezoneSign = (timezone) => {
|
|
316
|
+
if (this.timezoneValidator.timezoneIsNumbered(timezone)) {
|
|
317
|
+
const matches = timezone.match(
|
|
318
|
+
this.timezoneValidator.numberedTimezonePatternString
|
|
319
|
+
);
|
|
320
|
+
if (matches == null || matches.length < 1) return void 0;
|
|
321
|
+
if (matches[0].includes("+")) return "+";
|
|
322
|
+
if (matches[0].includes("-")) return "-";
|
|
323
|
+
}
|
|
324
|
+
return void 0;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// src/domain/entities/ISO8601TimezoneParser.ts
|
|
330
|
+
var ISO8601TimezoneParser = class {
|
|
331
|
+
constructor() {
|
|
332
|
+
this.timezoneValidator = new ISO8601TimezoneValidator();
|
|
333
|
+
this.timezoneSelector = new ISO8601TimezoneSelector();
|
|
334
|
+
this.toMinutes = (timezone) => {
|
|
335
|
+
if (this.timezoneValidator.timezoneIsZ(timezone) || this.timezoneValidator.timezoneIsZandMilliseconds(timezone)) {
|
|
336
|
+
return 0;
|
|
337
|
+
}
|
|
338
|
+
if (this.timezoneValidator.timezoneIsNumbered(timezone)) {
|
|
339
|
+
const minutesString = this.timezoneSelector.getMinutesString(timezone);
|
|
340
|
+
const hoursString = this.timezoneSelector.getHoursString(timezone);
|
|
341
|
+
if (minutesString == void 0 || hoursString == void 0) {
|
|
342
|
+
return 0;
|
|
343
|
+
}
|
|
344
|
+
const minutes = parseInt(minutesString);
|
|
345
|
+
const hours = parseInt(hoursString);
|
|
346
|
+
const sign = this.timezoneSelector.getTimezoneSign(timezone);
|
|
347
|
+
return sign == void 0 ? 0 : sign == "+" ? minutes + hours * 60 : -(minutes + hours * 60);
|
|
348
|
+
}
|
|
349
|
+
return 0;
|
|
350
|
+
};
|
|
351
|
+
this.toString = (timezoneInMinutes) => {
|
|
352
|
+
if (this.timezoneValidator.timezoneNumberIsValid(timezoneInMinutes)) {
|
|
353
|
+
if (timezoneInMinutes == 0) return "Z";
|
|
354
|
+
const hours = Math.floor(Math.abs(timezoneInMinutes / 60));
|
|
355
|
+
const minutes = Math.abs(Math.abs(timezoneInMinutes) - hours * 60);
|
|
356
|
+
const hoursString = hours.toString().padStart(2, "0");
|
|
357
|
+
const minutesString = minutes.toString().padStart(2, "0");
|
|
358
|
+
const symbol = timezoneInMinutes > 0 ? "+" : "-";
|
|
359
|
+
return `${symbol}${hoursString}:${minutesString}`;
|
|
360
|
+
}
|
|
361
|
+
return "Z";
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/domain/entities/ISO8601Timezone.ts
|
|
367
|
+
var ISO8601Timezone = class {
|
|
368
|
+
constructor(originalTimezoneString) {
|
|
369
|
+
this.selector = new ISO8601TimezoneSelector();
|
|
370
|
+
this.parser = new ISO8601TimezoneParser();
|
|
371
|
+
this.originalTimezoneString = originalTimezoneString || "Z";
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// src/domain/entities/ISO8601TimezoneConverter.ts
|
|
376
|
+
var ISO8601TimezoneConverter = class {
|
|
377
|
+
constructor() {
|
|
378
|
+
this.timezoneParser = new ISO8601TimezoneParser();
|
|
379
|
+
this.timezoneValidator = new ISO8601TimezoneValidator();
|
|
380
|
+
this.convertTo = (opts) => {
|
|
381
|
+
if (!this.timezoneValidator.formatIsValid(opts.targetTimezone)) {
|
|
382
|
+
throw new Error("Timezone format is invalid, could not convert.");
|
|
383
|
+
}
|
|
384
|
+
const originalTimezoneInMinutes = opts.time.getTimezone().parser.toMinutes(opts.time.originalTimeString);
|
|
385
|
+
const targetTimezoneInMinutes = typeof opts.targetTimezone == "number" ? opts.targetTimezone : this.timezoneParser.toMinutes(opts.targetTimezone);
|
|
386
|
+
const timezoneOffsetMinutes = targetTimezoneInMinutes - originalTimezoneInMinutes;
|
|
387
|
+
const hoursOffset = Math.floor(timezoneOffsetMinutes / 60);
|
|
388
|
+
const minutesOffset = timezoneOffsetMinutes - hoursOffset * 60;
|
|
389
|
+
const targetTime = opts.time.addHours(hoursOffset).addMinutes(minutesOffset).addTimezone(opts.targetTimezone);
|
|
390
|
+
return targetTime;
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
// src/domain/entities/ISO8601Time.ts
|
|
396
|
+
var ISO8601Time = class _ISO8601Time {
|
|
397
|
+
/**
|
|
398
|
+
* Throws if format is invalid.
|
|
399
|
+
* Accepted formats: HH:MM:SS, HH:MM, HH:MM:SS(+|-)HH:MM, HH:MM:SS.sssZ and HH:MM:SSZ.
|
|
400
|
+
*/
|
|
401
|
+
constructor(value) {
|
|
402
|
+
this.timeValidator = new ISO8601TimeValidator();
|
|
403
|
+
this.timezoneConverter = new ISO8601TimezoneConverter();
|
|
404
|
+
this.timezoneParser = new ISO8601TimezoneParser();
|
|
405
|
+
this.getNowTimeString = _ISO8601Time.getNow;
|
|
406
|
+
this.getTimezone = () => {
|
|
407
|
+
return new ISO8601Timezone(this.originalTimeString);
|
|
408
|
+
};
|
|
409
|
+
this.addHours = (hours) => {
|
|
410
|
+
let targetHour = parseInt(this.getHoursString()) + hours;
|
|
411
|
+
while (targetHour >= 24) {
|
|
412
|
+
targetHour = targetHour - 24;
|
|
413
|
+
}
|
|
414
|
+
while (targetHour < 0) {
|
|
415
|
+
targetHour = 24 + targetHour;
|
|
416
|
+
}
|
|
417
|
+
const targetHourString = targetHour >= 0 ? targetHour.toString().padStart(2, "0") : `-${Math.abs(targetHour).toString().padStart(2, "0")}`;
|
|
418
|
+
const targetTimeString = `${targetHourString}:${this.getMinutesString()}:${this.getSecondsString()}${this.getTimezone().selector.getTimezoneString(
|
|
419
|
+
this.originalTimeString
|
|
420
|
+
)}`;
|
|
421
|
+
return new _ISO8601Time(targetTimeString);
|
|
422
|
+
};
|
|
423
|
+
this.addMinutes = (minutes) => {
|
|
424
|
+
const minutesToAddFromZeroMinutes = minutes + parseInt(this.getMinutesString());
|
|
425
|
+
const hoursToAdd = Math.floor(minutesToAddFromZeroMinutes / 60);
|
|
426
|
+
const targetMinutes = minutesToAddFromZeroMinutes - hoursToAdd * 60;
|
|
427
|
+
const timeWithAddedHours = new _ISO8601Time(
|
|
428
|
+
this.originalTimeString
|
|
429
|
+
).addHours(hoursToAdd);
|
|
430
|
+
const targetMinutesString = targetMinutes.toString().padStart(2, "0");
|
|
431
|
+
return new _ISO8601Time(
|
|
432
|
+
`${timeWithAddedHours.getHoursString()}:${targetMinutesString}:${timeWithAddedHours.getSecondsString()}${timeWithAddedHours.getTimezone().selector.getTimezoneString(timeWithAddedHours.originalTimeString)}`
|
|
433
|
+
);
|
|
434
|
+
};
|
|
435
|
+
this.addTimezone = (timezone) => {
|
|
436
|
+
const newTimezone = typeof timezone == "number" ? this.timezoneParser.toString(timezone) : timezone;
|
|
437
|
+
return new _ISO8601Time(
|
|
438
|
+
`${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}${newTimezone}`
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
this.originalTimeString = value ? value : this.getNowTimeString();
|
|
442
|
+
this.validateFormatOrThrow();
|
|
443
|
+
}
|
|
444
|
+
validateFormatOrThrow() {
|
|
445
|
+
if (!this.timeValidator.formatIsValid(this.originalTimeString))
|
|
446
|
+
throw new Error("Time format must be ISO8601.");
|
|
447
|
+
}
|
|
448
|
+
getTimeString(opts) {
|
|
449
|
+
this.validateFormatOrThrow();
|
|
450
|
+
if ((opts == null ? void 0 : opts.format) == "HH:MM") {
|
|
451
|
+
return `${this.getHoursString()}:${this.getMinutesString()}`;
|
|
452
|
+
}
|
|
453
|
+
if ((opts == null ? void 0 : opts.format) == "HH:MM:SS") {
|
|
454
|
+
return `${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}`;
|
|
455
|
+
}
|
|
456
|
+
if ((opts == null ? void 0 : opts.format) == "HH:MM:SS(+|-)HH:MM") {
|
|
457
|
+
const timezone = new ISO8601Timezone(this.originalTimeString);
|
|
458
|
+
return `${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}${timezone.selector.getTimezoneString(
|
|
459
|
+
this.originalTimeString
|
|
460
|
+
)}`;
|
|
461
|
+
}
|
|
462
|
+
return `${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}`;
|
|
463
|
+
}
|
|
464
|
+
getMinutesString() {
|
|
465
|
+
this.validateFormatOrThrow();
|
|
466
|
+
return this.originalTimeString.split(":")[1];
|
|
467
|
+
}
|
|
468
|
+
getHoursString() {
|
|
469
|
+
this.validateFormatOrThrow();
|
|
470
|
+
return this.originalTimeString.split(":")[0];
|
|
471
|
+
}
|
|
472
|
+
getSecondsString() {
|
|
473
|
+
this.validateFormatOrThrow();
|
|
474
|
+
const seconds = this.originalTimeString.split(":")[2];
|
|
475
|
+
const secondsFirstDigit = seconds == null ? void 0 : seconds.split("")[0];
|
|
476
|
+
const secondsSecondDigit = seconds == null ? void 0 : seconds.split("")[1];
|
|
477
|
+
if (seconds) return `${secondsFirstDigit}${secondsSecondDigit}`;
|
|
478
|
+
return "00";
|
|
479
|
+
}
|
|
480
|
+
static getNow() {
|
|
481
|
+
const nowDate = /* @__PURE__ */ new Date();
|
|
482
|
+
const hours = nowDate.getHours().toString().padStart(2, "0");
|
|
483
|
+
const minutes = nowDate.getMinutes().toString().padStart(2, "0");
|
|
484
|
+
const seconds = nowDate.getSeconds().toString().padStart(2, "0");
|
|
485
|
+
return `${hours}:${minutes}:${seconds}`;
|
|
486
|
+
}
|
|
487
|
+
getTimezoneString() {
|
|
488
|
+
return this.getTimezone().selector.getTimezoneString(
|
|
489
|
+
this.originalTimeString
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
// src/domain/entities/UserUnavailableTime.ts
|
|
495
|
+
var UserUnavailableTime = class {
|
|
496
|
+
constructor(opts) {
|
|
497
|
+
this.getDateTimeSlot = () => {
|
|
498
|
+
return {
|
|
499
|
+
date: this.date,
|
|
500
|
+
timeSlot: {
|
|
501
|
+
endTime: this.endTime,
|
|
502
|
+
startTime: this.startTime
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
this.id = opts.id;
|
|
507
|
+
this.userId = opts.userId;
|
|
508
|
+
this.user = opts.user;
|
|
509
|
+
this.groupId = opts.groupId;
|
|
510
|
+
this.date = opts.date;
|
|
511
|
+
this.dayOfTheWeek = this.getDayOfTheWeek();
|
|
512
|
+
this.startTime = typeof opts.startTime == "string" ? new ISO8601Time(opts.startTime) : opts.startTime;
|
|
513
|
+
this.endTime = typeof opts.endTime == "string" ? new ISO8601Time(opts.endTime) : opts.endTime;
|
|
514
|
+
this.isAvailableTime = opts.isAvailableTime;
|
|
515
|
+
this.course = opts.course;
|
|
516
|
+
this.courseId = opts.courseId;
|
|
517
|
+
this.rescheduleRequests = opts.rescheduleRequests;
|
|
518
|
+
}
|
|
519
|
+
getDayOfTheWeek() {
|
|
520
|
+
return this.date.getDayOfTheWeek();
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
// src/domain/entities/FreeTimeSlot.ts
|
|
525
|
+
var FreeDateTimeSlot = class {
|
|
526
|
+
constructor(opts) {
|
|
527
|
+
this.date = opts.date;
|
|
528
|
+
this.startTime = opts.startTime;
|
|
529
|
+
this.endTime = opts.endTime;
|
|
530
|
+
this.userId = opts.userId;
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
export {
|
|
534
|
+
AsaasCustomer,
|
|
535
|
+
Class,
|
|
536
|
+
FreeDateTimeSlot,
|
|
537
|
+
ISO8601Date,
|
|
538
|
+
ISO8601DateTime,
|
|
539
|
+
ISO8601DateValidator,
|
|
540
|
+
ISO8601Time,
|
|
541
|
+
ISO8601TimeValidator,
|
|
542
|
+
UserUnavailableTime
|
|
543
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ClassCreationRecurrenceRule } from "../../../../domain/types/ClassCreationRecurrenceRule";
|
|
2
|
+
import { ClassStatus } from "../../../../domain/types/ClassStatus";
|
|
3
|
+
export type CreateClassForm = {
|
|
4
|
+
title: string;
|
|
5
|
+
date: string;
|
|
6
|
+
time: string;
|
|
7
|
+
endTime: string;
|
|
8
|
+
courseId: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
status?: ClassStatus;
|
|
12
|
+
recurrenceRule?: ClassCreationRecurrenceRule;
|
|
13
|
+
recurrenceEndDate?: string;
|
|
14
|
+
groupId?: string;
|
|
15
|
+
meetingLink?: string;
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliasrrosa/tutorhub-public-assets",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "Assets, mainly interfaces, to be shared among different Tutorhub apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
-
"require": "./dist/index.cjs"
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
14
|
-
"default": "./dist/index.cjs"
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
15
13
|
}
|
|
16
14
|
},
|
|
17
15
|
"files": [
|
|
@@ -19,7 +17,7 @@
|
|
|
19
17
|
],
|
|
20
18
|
"scripts": {
|
|
21
19
|
"test": "npx jest --watch --passWithNoTests ",
|
|
22
|
-
"build": "tsup src/index.ts --format esm,cjs
|
|
20
|
+
"build": "tsc && tsup src/index.ts --format esm,cjs"
|
|
23
21
|
},
|
|
24
22
|
"repository": {
|
|
25
23
|
"type": "git",
|