@eliasrrosa/tutorhub-public-assets 0.7.6 → 0.8.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/dist/application/dtos/UserTimeSlotDTO.d.ts +11 -0
- package/dist/application/dtos/UserTimeSlotDTO.js +2 -0
- package/dist/application/helpers/filterAsync.d.ts +1 -0
- package/dist/application/helpers/filterAsync.js +18 -0
- package/dist/application/helpers/filterAsync.test.d.ts +1 -0
- package/dist/application/helpers/filterAsync.test.js +21 -0
- package/dist/application/helpers/tryCatch.d.ts +2 -0
- package/dist/application/helpers/tryCatch.js +31 -0
- package/dist/application/helpers/tryCatch.test.d.ts +1 -0
- package/dist/application/helpers/tryCatch.test.js +48 -0
- package/dist/domain/entities/Class.d.ts +0 -17
- package/dist/domain/entities/Class.js +0 -1
- package/dist/domain/entities/ISO8601DateTime.d.ts +36 -31
- package/dist/domain/entities/ISO8601DateTime.js +72 -34
- package/dist/domain/entities/ISO8601DateTime.test.js +51 -133
- package/dist/domain/entities/ISO8601DateValidator.d.ts +2 -1
- package/dist/domain/entities/ISO8601DateValidator.js +4 -3
- package/dist/domain/entities/ISO8601TimeValidator.d.ts +6 -3
- package/dist/domain/entities/ISO8601TimeValidator.js +6 -3
- package/dist/domain/entities/TimeUnitConverter.d.ts +20 -0
- package/dist/domain/entities/TimeUnitConverter.js +17 -0
- package/dist/domain/entities/TimeUnitConverter.test.d.ts +1 -0
- package/dist/domain/entities/TimeUnitConverter.test.js +110 -0
- package/dist/domain/types/ClassStatus copy.d.ts +4 -0
- package/dist/domain/types/ClassStatus copy.js +2 -0
- package/dist/index.cjs +98 -101
- package/dist/index.d.ts +3 -38
- package/dist/index.js +98 -99
- package/dist/infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ITimeUnitConverter {
|
|
2
|
+
msToSeconds: (n: number) => number;
|
|
3
|
+
msToMinutes: (n: number) => number;
|
|
4
|
+
msToHours: (n: number) => number;
|
|
5
|
+
msToDays: (n: number) => number;
|
|
6
|
+
daysToMs: (n: number) => number;
|
|
7
|
+
hoursToMs: (n: number) => number;
|
|
8
|
+
minutesToMs: (n: number) => number;
|
|
9
|
+
secondsToMs: (n: number) => number;
|
|
10
|
+
}
|
|
11
|
+
export declare class TimeUnitConverter implements ITimeUnitConverter {
|
|
12
|
+
msToSeconds: (n: number) => number;
|
|
13
|
+
msToMinutes: (n: number) => number;
|
|
14
|
+
msToHours: (n: number) => number;
|
|
15
|
+
msToDays: (n: number) => number;
|
|
16
|
+
daysToMs: (n: number) => number;
|
|
17
|
+
hoursToMs: (n: number) => number;
|
|
18
|
+
minutesToMs: (n: number) => number;
|
|
19
|
+
secondsToMs: (n: number) => number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimeUnitConverter = void 0;
|
|
4
|
+
class TimeUnitConverter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.msToSeconds = (n) => n / 1000;
|
|
7
|
+
this.msToMinutes = (n) => n / (1000 * 60);
|
|
8
|
+
this.msToHours = (n) => n / (1000 * 60 * 60);
|
|
9
|
+
this.msToDays = (n) => n / (1000 * 60 * 60 * 24);
|
|
10
|
+
this.daysToMs = (n) => n * 24 * 60 * 60 * 1000;
|
|
11
|
+
this.hoursToMs = (n) => n * 60 * 60 * 1000;
|
|
12
|
+
this.minutesToMs = (n) => n * 60 * 1000;
|
|
13
|
+
this.secondsToMs = (n) => n * 1000;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.TimeUnitConverter = TimeUnitConverter;
|
|
17
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const TimeUnitConverter_1 = require("./TimeUnitConverter");
|
|
4
|
+
describe("TimeUnitConverter", () => {
|
|
5
|
+
const converter = new TimeUnitConverter_1.TimeUnitConverter();
|
|
6
|
+
describe("msToSeconds", () => {
|
|
7
|
+
it("should convert ms to seconds", () => {
|
|
8
|
+
expect(converter.msToSeconds(2000)).toBe(2);
|
|
9
|
+
});
|
|
10
|
+
it("should convert ms to seconds and round up", () => {
|
|
11
|
+
const result = converter.msToSeconds(2500);
|
|
12
|
+
expect(Math.ceil(result)).toBe(3);
|
|
13
|
+
});
|
|
14
|
+
it("should convert ms to seconds and round down", () => {
|
|
15
|
+
expect(Math.floor(converter.msToSeconds(2500))).toBe(2);
|
|
16
|
+
expect(Math.floor(converter.msToSeconds(2999))).toBe(2);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe("msToMinutes", () => {
|
|
20
|
+
it("should convert ms to minutes", () => {
|
|
21
|
+
expect(converter.msToMinutes(120000)).toBe(2);
|
|
22
|
+
});
|
|
23
|
+
it("should convert ms to minutes and round up", () => {
|
|
24
|
+
const result = converter.msToMinutes(125000);
|
|
25
|
+
expect(Math.ceil(result)).toBe(3);
|
|
26
|
+
});
|
|
27
|
+
it("should convert ms to minutes and round down", () => {
|
|
28
|
+
const result = converter.msToMinutes(125000);
|
|
29
|
+
expect(Math.floor(result)).toBe(2);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("msToHours", () => {
|
|
33
|
+
it("should convert ms to hours", () => {
|
|
34
|
+
expect(converter.msToHours(7200000)).toBe(2);
|
|
35
|
+
});
|
|
36
|
+
it("should convert ms to hours and round up", () => {
|
|
37
|
+
const result = converter.msToHours(8100000);
|
|
38
|
+
expect(Math.ceil(result)).toBe(3);
|
|
39
|
+
});
|
|
40
|
+
it("should convert ms to hours and round down", () => {
|
|
41
|
+
const result = converter.msToHours(8100000);
|
|
42
|
+
expect(Math.floor(result)).toBe(2);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe("msToDays", () => {
|
|
46
|
+
it("should convert ms to days", () => {
|
|
47
|
+
expect(converter.msToDays(172800000)).toBe(2);
|
|
48
|
+
});
|
|
49
|
+
it("should convert ms to days and round up", () => {
|
|
50
|
+
const result = converter.msToDays(190000000);
|
|
51
|
+
expect(Math.ceil(result)).toBe(3);
|
|
52
|
+
});
|
|
53
|
+
it("should convert ms to days and round down", () => {
|
|
54
|
+
const result = converter.msToDays(190000000);
|
|
55
|
+
expect(Math.floor(result)).toBe(2);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe("daysToMs", () => {
|
|
59
|
+
it("should convert days to ms", () => {
|
|
60
|
+
expect(converter.daysToMs(2)).toBe(172800000);
|
|
61
|
+
});
|
|
62
|
+
it("should convert days to ms and round up", () => {
|
|
63
|
+
const result = converter.daysToMs(2.4);
|
|
64
|
+
expect(Math.ceil(result)).toBe(207360000);
|
|
65
|
+
});
|
|
66
|
+
it("should convert days to ms and round down", () => {
|
|
67
|
+
const result = converter.daysToMs(2.4);
|
|
68
|
+
expect(Math.floor(result)).toBe(207359999);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("hoursToMs", () => {
|
|
72
|
+
it("should convert hours to ms", () => {
|
|
73
|
+
expect(converter.hoursToMs(2)).toBe(7200000);
|
|
74
|
+
});
|
|
75
|
+
it("should convert hours to ms and round up", () => {
|
|
76
|
+
const result = converter.hoursToMs(2.5);
|
|
77
|
+
expect(Math.ceil(result)).toBe(9000000);
|
|
78
|
+
});
|
|
79
|
+
it("should convert hours to ms and round down", () => {
|
|
80
|
+
const result = converter.hoursToMs(2.5);
|
|
81
|
+
expect(Math.floor(result)).toBe(9000000);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
describe("minutesToMs", () => {
|
|
85
|
+
it("should convert minutes to ms", () => {
|
|
86
|
+
expect(converter.minutesToMs(2)).toBe(120000);
|
|
87
|
+
});
|
|
88
|
+
it("should convert minutes to ms and round up", () => {
|
|
89
|
+
const result = converter.minutesToMs(2.5);
|
|
90
|
+
expect(Math.ceil(result)).toBe(150000);
|
|
91
|
+
});
|
|
92
|
+
it("should convert minutes to ms and round down", () => {
|
|
93
|
+
const result = converter.minutesToMs(2.5);
|
|
94
|
+
expect(Math.floor(result)).toBe(150000);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe("secondsToMs", () => {
|
|
98
|
+
it("should convert seconds to ms", () => {
|
|
99
|
+
expect(converter.secondsToMs(2)).toBe(2000);
|
|
100
|
+
});
|
|
101
|
+
it("should convert seconds to ms and round up", () => {
|
|
102
|
+
const result = converter.secondsToMs(2.5);
|
|
103
|
+
expect(Math.ceil(result)).toBe(2500);
|
|
104
|
+
});
|
|
105
|
+
it("should convert seconds to ms and round down", () => {
|
|
106
|
+
const result = converter.secondsToMs(2.5);
|
|
107
|
+
expect(Math.floor(result)).toBe(2500);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
package/dist/index.cjs
CHANGED
|
@@ -40,7 +40,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
// src/index.ts
|
|
41
41
|
var index_exports = {};
|
|
42
42
|
__export(index_exports, {
|
|
43
|
-
AsaasCustomer: () => AsaasCustomer,
|
|
44
43
|
ClassCreationFormSchema: () => ClassCreationFormSchema,
|
|
45
44
|
ClassCreationRecurrenceRuleSchema: () => ClassCreationRecurrenceRuleSchema,
|
|
46
45
|
ClassStatusSchema: () => ClassStatusSchema,
|
|
@@ -50,39 +49,26 @@ __export(index_exports, {
|
|
|
50
49
|
ISO8601DateValidator: () => ISO8601DateValidator,
|
|
51
50
|
ISO8601Time: () => ISO8601Time,
|
|
52
51
|
ISO8601TimeValidator: () => ISO8601TimeValidator,
|
|
53
|
-
UserTimeSlot: () => UserTimeSlot,
|
|
54
52
|
filterAsync: () => filterAsync,
|
|
55
53
|
tryCatch: () => tryCatch,
|
|
56
54
|
tryCatchAsync: () => tryCatchAsync
|
|
57
55
|
});
|
|
58
56
|
module.exports = __toCommonJS(index_exports);
|
|
59
57
|
|
|
60
|
-
// src/domain/entities/AsaasCustomer.ts
|
|
61
|
-
var AsaasCustomer = class {
|
|
62
|
-
constructor(opts) {
|
|
63
|
-
this.name = opts.name;
|
|
64
|
-
this.cpfCnpj = opts.cpfCnpj;
|
|
65
|
-
this.email = opts.email;
|
|
66
|
-
this.mobilePhone = opts.mobilePhone;
|
|
67
|
-
this.externalReference = opts.externalReference;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
58
|
// src/domain/entities/ISO8601DateValidator.ts
|
|
72
59
|
var ISO8601DateValidator = class {
|
|
73
60
|
constructor() {
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
);
|
|
61
|
+
this.YYYYmmDDpatternString = "[0-9]{4}-([0][1-9]|[1][0-2])-([0][1-9]|[1-2][0-9]|[3][0-1])";
|
|
62
|
+
this.YYYYmmDDpattern = new RegExp(`^${this.YYYYmmDDpatternString}`);
|
|
77
63
|
}
|
|
78
64
|
/**
|
|
79
65
|
* Accepted format: YYYY-MM-DD
|
|
80
66
|
*/
|
|
81
67
|
formatIsValid(date) {
|
|
82
|
-
return this.
|
|
68
|
+
return this.YYYYmmDDpattern.test(date);
|
|
83
69
|
}
|
|
84
70
|
match(date) {
|
|
85
|
-
const matches = date.match(this.
|
|
71
|
+
const matches = date.match(this.YYYYmmDDpattern);
|
|
86
72
|
if (!matches || matches.length < 1) {
|
|
87
73
|
return void 0;
|
|
88
74
|
}
|
|
@@ -190,51 +176,6 @@ _ISO8601Date.jsDateTimeToDate = (dateTime, opts) => {
|
|
|
190
176
|
};
|
|
191
177
|
var ISO8601Date = _ISO8601Date;
|
|
192
178
|
|
|
193
|
-
// src/domain/entities/ISO8601DateTime.ts
|
|
194
|
-
var ISO8601DateTime = class _ISO8601DateTime {
|
|
195
|
-
constructor(opts) {
|
|
196
|
-
this.getJSDateTime = () => {
|
|
197
|
-
return new Date(
|
|
198
|
-
parseInt(this.date.getYear()),
|
|
199
|
-
parseInt(this.date.getMonth()) - 1,
|
|
200
|
-
parseInt(this.date.getDay()),
|
|
201
|
-
parseInt(this.time.getHoursString()),
|
|
202
|
-
parseInt(this.time.getMinutesString()),
|
|
203
|
-
parseInt(this.time.getSecondsString())
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
this.getBrazilianIsoString = () => {
|
|
207
|
-
return this.getIsoString({
|
|
208
|
-
timezoneOffsetMinutes: -180
|
|
209
|
-
});
|
|
210
|
-
};
|
|
211
|
-
this.date = opts.date;
|
|
212
|
-
this.time = opts.time;
|
|
213
|
-
}
|
|
214
|
-
getIsoString(opts) {
|
|
215
|
-
const padLeft = (n) => String(n).padStart(2, "0");
|
|
216
|
-
const newDateTime = new _ISO8601DateTime({
|
|
217
|
-
date: (opts == null ? void 0 : opts.newDate) || this.date,
|
|
218
|
-
time: (opts == null ? void 0 : opts.newTime) || this.time
|
|
219
|
-
});
|
|
220
|
-
const jsDate = newDateTime.getJSDateTime();
|
|
221
|
-
const year = jsDate.getFullYear();
|
|
222
|
-
const month = padLeft(jsDate.getMonth() + 1);
|
|
223
|
-
const day = padLeft(jsDate.getDate());
|
|
224
|
-
const hour = padLeft(jsDate.getHours());
|
|
225
|
-
const minute = padLeft(jsDate.getMinutes());
|
|
226
|
-
const second = padLeft(jsDate.getSeconds());
|
|
227
|
-
const timezoneOffsetMinutes = (opts == null ? void 0 : opts.timezoneOffsetMinutes) ? opts.timezoneOffsetMinutes : 0;
|
|
228
|
-
const sign = timezoneOffsetMinutes == 0 ? void 0 : timezoneOffsetMinutes < 0 ? "-" : "+";
|
|
229
|
-
const offsetHours = padLeft(
|
|
230
|
-
Math.floor(Math.abs(timezoneOffsetMinutes) / 60)
|
|
231
|
-
);
|
|
232
|
-
const offsetMinutes = padLeft(Math.abs(timezoneOffsetMinutes) % 60);
|
|
233
|
-
const timezone = sign ? `${sign}${offsetHours}:${offsetMinutes}` : ".000Z";
|
|
234
|
-
return `${year}-${month}-${day}T${hour}:${minute}:${second}${timezone}`;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
179
|
// src/domain/entities/ISO8601TimeValidator.ts
|
|
239
180
|
var ISO8601TimeValidator = class {
|
|
240
181
|
constructor() {
|
|
@@ -243,22 +184,23 @@ var ISO8601TimeValidator = class {
|
|
|
243
184
|
this.upTo11 = "(0[0-9]|1[0-2])";
|
|
244
185
|
this.upTo13 = "(0[0-9]|1[0-4])";
|
|
245
186
|
this.numberedTimezonePatternString = `(\\+(${this.upTo11}:${this.upTo59}|12:00)|\\-(${this.upTo13}:${this.upTo59}|14:00))`;
|
|
246
|
-
this.numberedTimezonePattern = new RegExp(
|
|
187
|
+
this.numberedTimezonePattern = new RegExp(
|
|
188
|
+
`^${this.numberedTimezonePatternString}$`
|
|
189
|
+
);
|
|
247
190
|
this.zTimezonePatternString = "Z";
|
|
248
191
|
this.zAndMillisecondsPatternString = `.[0-9]{3}Z`;
|
|
249
192
|
this.hhMMssPattern = new RegExp(
|
|
250
193
|
`^${this.upTo23}:${this.upTo59}:${this.upTo59}$`
|
|
251
194
|
);
|
|
252
195
|
this.hhMMPattern = new RegExp(`^${this.upTo23}:${this.upTo59}$`);
|
|
196
|
+
this.hhMMssPlusNumberedTimezonePatternString = `${this.upTo23}:${this.upTo59}:${this.upTo59}${this.numberedTimezonePatternString}`;
|
|
253
197
|
this.hhMMssPlusNumberedTimezonePattern = new RegExp(
|
|
254
|
-
`^${this.
|
|
255
|
-
);
|
|
256
|
-
this.hhMMssZPattern = new RegExp(
|
|
257
|
-
`^${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zTimezonePatternString}$`
|
|
258
|
-
);
|
|
259
|
-
this.hhMMssSSSZPattern = new RegExp(
|
|
260
|
-
`^${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zAndMillisecondsPatternString}$`
|
|
198
|
+
`^${this.hhMMssPlusNumberedTimezonePatternString}$`
|
|
261
199
|
);
|
|
200
|
+
this.hhMMssZPatternString = `${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zTimezonePatternString}`;
|
|
201
|
+
this.hhMMssZPattern = new RegExp(`^${this.hhMMssZPatternString}$`);
|
|
202
|
+
this.hhMMssSSSZPatternString = `${this.upTo23}:${this.upTo59}:${this.upTo59}${this.zAndMillisecondsPatternString}`;
|
|
203
|
+
this.hhMMssSSSZPattern = new RegExp(`^${this.hhMMssSSSZPatternString}$`);
|
|
262
204
|
this.isHHmmSSPlusNumberedTimezone = (time) => {
|
|
263
205
|
return this.hhMMssPlusNumberedTimezonePattern.test(time);
|
|
264
206
|
};
|
|
@@ -411,6 +353,89 @@ var ISO8601TimezoneParser = class {
|
|
|
411
353
|
}
|
|
412
354
|
};
|
|
413
355
|
|
|
356
|
+
// src/domain/entities/TimeUnitConverter.ts
|
|
357
|
+
var TimeUnitConverter = class {
|
|
358
|
+
constructor() {
|
|
359
|
+
this.msToSeconds = (n) => n / 1e3;
|
|
360
|
+
this.msToMinutes = (n) => n / (1e3 * 60);
|
|
361
|
+
this.msToHours = (n) => n / (1e3 * 60 * 60);
|
|
362
|
+
this.msToDays = (n) => n / (1e3 * 60 * 60 * 24);
|
|
363
|
+
this.daysToMs = (n) => n * 24 * 60 * 60 * 1e3;
|
|
364
|
+
this.hoursToMs = (n) => n * 60 * 60 * 1e3;
|
|
365
|
+
this.minutesToMs = (n) => n * 60 * 1e3;
|
|
366
|
+
this.secondsToMs = (n) => n * 1e3;
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/domain/entities/ISO8601DateTime.ts
|
|
371
|
+
var ISO8601DateTime = class _ISO8601DateTime {
|
|
372
|
+
constructor(dateString) {
|
|
373
|
+
this.timeFormatValidator = new ISO8601TimeValidator();
|
|
374
|
+
this.dateFormatValidator = new ISO8601DateValidator();
|
|
375
|
+
this.timeUnitConverter = new TimeUnitConverter();
|
|
376
|
+
this.dateTimePattern = new RegExp(
|
|
377
|
+
`^${this.dateFormatValidator.YYYYmmDDpatternString}T(${this.timeFormatValidator.hhMMssPlusNumberedTimezonePatternString}|${this.timeFormatValidator.hhMMssSSSZPatternString}|${this.timeFormatValidator.hhMMssZPatternString})$`
|
|
378
|
+
);
|
|
379
|
+
this.onlyDatePattern = new RegExp(
|
|
380
|
+
`^${this.dateFormatValidator.YYYYmmDDpatternString}$`
|
|
381
|
+
);
|
|
382
|
+
this.getTimeString = () => {
|
|
383
|
+
return `${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}`;
|
|
384
|
+
};
|
|
385
|
+
this.getHoursString = () => {
|
|
386
|
+
return this.dateString.split("T")[1].slice(0, 8).split(":")[0];
|
|
387
|
+
};
|
|
388
|
+
this.getMinutesString = () => {
|
|
389
|
+
return this.dateString.split("T")[1].slice(0, 8).split(":")[1];
|
|
390
|
+
};
|
|
391
|
+
this.getSecondsString = () => {
|
|
392
|
+
return this.dateString.split("T")[1].slice(0, 8).split(":")[2];
|
|
393
|
+
};
|
|
394
|
+
this.getMilisecondsString = () => {
|
|
395
|
+
return this.dateString.split("T")[1].slice(0, 8).split(":")[3];
|
|
396
|
+
};
|
|
397
|
+
this.getJsDateTime = () => {
|
|
398
|
+
return new Date(this.dateString);
|
|
399
|
+
};
|
|
400
|
+
this.getIsoString = (opts) => {
|
|
401
|
+
if (!opts || !(opts == null ? void 0 : opts.timezone)) return this.getJsDateTime().toISOString();
|
|
402
|
+
const parser = new ISO8601TimezoneParser();
|
|
403
|
+
const validator = new ISO8601TimezoneValidator();
|
|
404
|
+
const timezoneInMinutes = typeof opts.timezone == "string" ? parser.toMinutes(opts.timezone) : opts.timezone;
|
|
405
|
+
const isValid = validator.formatIsValid(timezoneInMinutes);
|
|
406
|
+
if (!isValid) throw new Error("Invalid timezone format.");
|
|
407
|
+
const timezoneInMs = this.timeUnitConverter.minutesToMs(timezoneInMinutes);
|
|
408
|
+
const newDateUtcString = new Date(
|
|
409
|
+
this.getJsDateTime().getTime() + timezoneInMs
|
|
410
|
+
).toISOString();
|
|
411
|
+
const newDateUtcStringWithoutTimezone = newDateUtcString.split(".")[0];
|
|
412
|
+
const timezoneString = parser.toString(timezoneInMinutes);
|
|
413
|
+
const newDateWithTimezoneString = `${newDateUtcStringWithoutTimezone}${timezoneString}`;
|
|
414
|
+
return newDateWithTimezoneString;
|
|
415
|
+
};
|
|
416
|
+
this.toMidnight = () => {
|
|
417
|
+
const currentTimeString = this.getTimeString();
|
|
418
|
+
const matches = new RegExp(currentTimeString).exec(this.dateString);
|
|
419
|
+
if (!matches || matches.length < 1) throw new Error("Error getting current time string.");
|
|
420
|
+
const datePlusT = this.dateString.slice(0, matches.index);
|
|
421
|
+
const matchedString = matches[0];
|
|
422
|
+
const timezone = this.dateString.slice(matchedString.length + matches.index);
|
|
423
|
+
return new _ISO8601DateTime(`${datePlusT}00:00:00${timezone}`);
|
|
424
|
+
};
|
|
425
|
+
const normalizedDateString = this.normalizeDateString(dateString);
|
|
426
|
+
if (!normalizedDateString) throw new Error("Date time format invalid.");
|
|
427
|
+
this.dateString = normalizedDateString;
|
|
428
|
+
}
|
|
429
|
+
normalizeDateString(dateString) {
|
|
430
|
+
if (this.onlyDatePattern.test(dateString)) {
|
|
431
|
+
return `${dateString}T00:00:00Z`;
|
|
432
|
+
}
|
|
433
|
+
if (this.dateTimePattern.test(dateString)) {
|
|
434
|
+
return dateString;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
414
439
|
// src/domain/entities/ISO8601Timezone.ts
|
|
415
440
|
var ISO8601Timezone = class {
|
|
416
441
|
constructor(originalTimezoneString) {
|
|
@@ -586,32 +611,6 @@ var ClassCreationFormSchema = import_zod2.z.object({
|
|
|
586
611
|
var import_zod3 = require("zod");
|
|
587
612
|
var ClassCreationRecurrenceRuleSchema = import_zod3.z.literal("daily").or(import_zod3.z.literal("weekly")).or(import_zod3.z.literal("week days"));
|
|
588
613
|
|
|
589
|
-
// src/domain/entities/UserTimeSlot.ts
|
|
590
|
-
var UserTimeSlot = class {
|
|
591
|
-
constructor(opts) {
|
|
592
|
-
this.getDateTimeSlot = () => {
|
|
593
|
-
return {
|
|
594
|
-
endDateTime: this.endDateTime,
|
|
595
|
-
startDateTime: this.startDateTime
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
this.id = opts.id;
|
|
599
|
-
this.userId = opts.userId;
|
|
600
|
-
this.user = opts.user;
|
|
601
|
-
this.groupId = opts.groupId;
|
|
602
|
-
this.startDateTime = opts.startDateTime;
|
|
603
|
-
this.endDateTime = opts.endDateTime;
|
|
604
|
-
this.dayOfTheWeek = this.getDayOfTheWeek();
|
|
605
|
-
this.isAvailableTime = opts.isAvailableTime;
|
|
606
|
-
this.course = opts.course;
|
|
607
|
-
this.courseId = opts.courseId;
|
|
608
|
-
this.rescheduleRequests = opts.rescheduleRequests;
|
|
609
|
-
}
|
|
610
|
-
getDayOfTheWeek() {
|
|
611
|
-
return this.startDateTime.getUTCDay();
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
|
|
615
614
|
// src/domain/entities/FreeTimeSlot.ts
|
|
616
615
|
var FreeDateTimeSlot = class {
|
|
617
616
|
constructor(opts) {
|
|
@@ -621,7 +620,7 @@ var FreeDateTimeSlot = class {
|
|
|
621
620
|
}
|
|
622
621
|
};
|
|
623
622
|
|
|
624
|
-
// src/application/helpers/
|
|
623
|
+
// src/application/helpers/tryCatch.ts
|
|
625
624
|
function tryCatch(callback, fallback) {
|
|
626
625
|
try {
|
|
627
626
|
return callback();
|
|
@@ -639,7 +638,7 @@ function tryCatchAsync(callback, fallback) {
|
|
|
639
638
|
});
|
|
640
639
|
}
|
|
641
640
|
|
|
642
|
-
// src/application/helpers/
|
|
641
|
+
// src/application/helpers/filterAsync.ts
|
|
643
642
|
function filterAsync(arr, predicate) {
|
|
644
643
|
return __async(this, null, function* () {
|
|
645
644
|
const results = yield Promise.all(arr.map(predicate));
|
|
@@ -648,7 +647,6 @@ function filterAsync(arr, predicate) {
|
|
|
648
647
|
}
|
|
649
648
|
// Annotate the CommonJS export names for ESM import in node:
|
|
650
649
|
0 && (module.exports = {
|
|
651
|
-
AsaasCustomer,
|
|
652
650
|
ClassCreationFormSchema,
|
|
653
651
|
ClassCreationRecurrenceRuleSchema,
|
|
654
652
|
ClassStatusSchema,
|
|
@@ -658,7 +656,6 @@ function filterAsync(arr, predicate) {
|
|
|
658
656
|
ISO8601DateValidator,
|
|
659
657
|
ISO8601Time,
|
|
660
658
|
ISO8601TimeValidator,
|
|
661
|
-
UserTimeSlot,
|
|
662
659
|
filterAsync,
|
|
663
660
|
tryCatch,
|
|
664
661
|
tryCatchAsync
|
package/dist/index.d.ts
CHANGED
|
@@ -1,54 +1,19 @@
|
|
|
1
|
-
import { AsaasCustomer } from "./domain/entities/AsaasCustomer.js";
|
|
2
|
-
import { IClass } from "./domain/entities/Class.js";
|
|
3
|
-
import { IClassRequest } from "./domain/entities/ClassRequest.js";
|
|
4
|
-
import { IContract } from "./domain/entities/Contract.js";
|
|
5
|
-
import { ICourse } from "./domain/entities/Course.js";
|
|
6
|
-
import { ICourseToSchoolConnectionRequest } from "./domain/entities/CourseToSchoolConnectionRequest.js";
|
|
7
1
|
import { IDate } from "./domain/entities/Date.js";
|
|
8
2
|
import { IDateTimeSlot } from "./domain/entities/DateTimeSlot.js";
|
|
9
3
|
import { IDateValidator } from "./domain/entities/DateValidator.js";
|
|
10
|
-
import { IFile } from "./domain/entities/File.js";
|
|
11
|
-
import { IGenericNotification } from "./domain/entities/GenericNotification.js";
|
|
12
|
-
import { IGoogleAuth } from "./domain/entities/GoogleAuth.js";
|
|
13
|
-
import { IGoogleCalendar } from "./domain/entities/GoogleCalendar.js";
|
|
14
|
-
import { IGoogleCalendarEvent } from "./domain/entities/GoogleCalendarEvent.js";
|
|
15
4
|
import { ISO8601Date } from "./domain/entities/ISO8601Date.js";
|
|
16
5
|
import { IDateTime, ISO8601DateTime } from "./domain/entities/ISO8601DateTime.js";
|
|
17
6
|
import { ISO8601DateValidator } from "./domain/entities/ISO8601DateValidator.js";
|
|
18
7
|
import { ISO8601Time } from "./domain/entities/ISO8601Time.js";
|
|
19
8
|
import { ISO8601TimeValidator } from "./domain/entities/ISO8601TimeValidator.js";
|
|
20
|
-
import { IPasswordRecovery } from "./domain/entities/PasswordRecovery.js";
|
|
21
|
-
import { IPayment } from "./domain/entities/Payment.js";
|
|
22
|
-
import { IPaymentRecognitionRequest } from "./domain/entities/PaymentRecognitionRequest.js";
|
|
23
|
-
import { IPreApprovedUser } from "./domain/entities/PreApprovedUser.js";
|
|
24
|
-
import { IRescheduleRequest } from "./domain/entities/RescheduleRequest.js";
|
|
25
|
-
import { ISchool } from "./domain/entities/School.js";
|
|
26
|
-
import { ISchoolConnection } from "./domain/entities/SchoolConnection.js";
|
|
27
|
-
import { ISchoolConnectionRequest } from "./domain/entities/SchoolConnectionRequest.js";
|
|
28
|
-
import { ISchoolStudent } from "./domain/entities/SchoolStudent.js";
|
|
29
|
-
import { ISchoolTeacher } from "./domain/entities/SchoolTeacher.js";
|
|
30
9
|
import { ITime } from "./domain/entities/Time.js";
|
|
31
10
|
import { ITimeSlot } from "./domain/entities/TimeSlot.js";
|
|
32
11
|
import { ITimeValidator } from "./domain/entities/TimeValidator.js";
|
|
33
|
-
import { IUnauthorizedUser } from "./domain/entities/UnauthorizedUser.js";
|
|
34
|
-
import { IUserAuth } from "./domain/entities/UserAuth.js";
|
|
35
|
-
import { IUserConnection } from "./domain/entities/UserConnection.js";
|
|
36
|
-
import { IUserConnectionRequest } from "./domain/entities/UserConnectionRequest.js";
|
|
37
|
-
import { IUserCredentials } from "./domain/entities/UserCredentials.js";
|
|
38
|
-
import { IUserNavigation } from "./domain/entities/UserNavigation.js";
|
|
39
|
-
import { IUserPreferences } from "./domain/entities/UserPreferences.js";
|
|
40
|
-
import { IUserPremium } from "./domain/entities/UserPremium.js";
|
|
41
|
-
import { IUserProfile } from "./domain/entities/UserProfile.js";
|
|
42
|
-
import { IUserRoles } from "./domain/entities/UserRoles.js";
|
|
43
|
-
import { IUserSharedFileTimestamps } from "./domain/entities/UserSharedFileTimestamps.js";
|
|
44
|
-
import { IUnavailableTimeRepository } from "./domain/repositories/UnavailableTimeRepository.js";
|
|
45
12
|
import { GetFixedAvailableTimeResponseBody } from "./infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.js";
|
|
46
13
|
import { ClassCreationForm, ClassCreationFormSchema } from "./infrastructure/restful/requests/forms/ClassCreationForm.js";
|
|
47
14
|
import { ClassStatus, ClassStatusSchema } from "./domain/types/ClassStatus.js";
|
|
48
15
|
import { ClassCreationRecurrenceRule, ClassCreationRecurrenceRuleSchema } from "./domain/types/ClassCreationRecurrenceRule.js";
|
|
49
|
-
import { IClassStatus } from "./domain/entities/ClassStatus.js";
|
|
50
|
-
import { IUserTimeSlot, UserTimeSlot } from "./domain/entities/UserTimeSlot.js";
|
|
51
16
|
import { IFreeDateTimeSlot, FreeDateTimeSlot } from "./domain/entities/FreeTimeSlot.js";
|
|
52
|
-
import { tryCatch, tryCatchAsync } from "./application/helpers/
|
|
53
|
-
import { filterAsync } from "./application/helpers/
|
|
54
|
-
export { filterAsync, tryCatchAsync, tryCatch, ClassStatus,
|
|
17
|
+
import { tryCatch, tryCatchAsync } from "./application/helpers/tryCatch.js";
|
|
18
|
+
import { filterAsync } from "./application/helpers/filterAsync.js";
|
|
19
|
+
export { filterAsync, tryCatchAsync, tryCatch, ClassStatus, IDate, IDateTimeSlot, IFreeDateTimeSlot, FreeDateTimeSlot, IDateValidator, ISO8601Date, IDateTime, ISO8601DateValidator, ISO8601Time, ISO8601TimeValidator, ITime, ITimeSlot, ITimeValidator, GetFixedAvailableTimeResponseBody, ISO8601DateTime, ClassCreationForm, ClassCreationRecurrenceRule, ClassCreationFormSchema, ClassCreationRecurrenceRuleSchema, ClassStatusSchema, };
|