@eliasrrosa/tutorhub-public-assets 0.7.5 → 0.8.0
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/ISO8601Date.d.ts +9 -1
- package/dist/domain/entities/ISO8601Date.js +11 -4
- package/dist/domain/entities/ISO8601Date.test.js +7 -0
- package/dist/domain/types/ClassStatus copy.d.ts +4 -0
- package/dist/domain/types/ClassStatus copy.js +2 -0
- package/dist/index.cjs +9 -45
- package/dist/index.d.ts +3 -38
- package/dist/index.js +9 -43
- package/dist/infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function filterAsync<T>(arr: T[], predicate: (item: T) => Promise<boolean>): Promise<T[]>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.filterAsync = filterAsync;
|
|
13
|
+
function filterAsync(arr, predicate) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const results = yield Promise.all(arr.map(predicate));
|
|
16
|
+
return arr.filter((_v, index) => results[index]);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const filterAsync_1 = require("./filterAsync");
|
|
13
|
+
describe("filterAsync", () => {
|
|
14
|
+
it("Should filter accepting async operations.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const numbers = [1, 2, 3];
|
|
16
|
+
const filteredNumbers = yield (0, filterAsync_1.filterAsync)(numbers, (number) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
return number > 1;
|
|
18
|
+
}));
|
|
19
|
+
expect(filteredNumbers).toEqual([2, 3]);
|
|
20
|
+
}));
|
|
21
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.tryCatch = tryCatch;
|
|
13
|
+
exports.tryCatchAsync = tryCatchAsync;
|
|
14
|
+
function tryCatch(callback, fallback) {
|
|
15
|
+
try {
|
|
16
|
+
return callback();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return fallback(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function tryCatchAsync(callback, fallback) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
return yield callback();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return yield fallback(error);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const tryCatch_1 = require("./tryCatch");
|
|
13
|
+
describe("tryCatch", () => {
|
|
14
|
+
it("Should return try return value if success.", () => {
|
|
15
|
+
const a = (0, tryCatch_1.tryCatch)(() => {
|
|
16
|
+
return "abc";
|
|
17
|
+
}, () => {
|
|
18
|
+
return new Error("Trycatch failed.");
|
|
19
|
+
});
|
|
20
|
+
expect(a).toEqual("abc");
|
|
21
|
+
});
|
|
22
|
+
it("Should return catch return value if error.", () => {
|
|
23
|
+
const a = (0, tryCatch_1.tryCatch)(() => {
|
|
24
|
+
throw new Error("Error!");
|
|
25
|
+
}, () => {
|
|
26
|
+
return new Error("Trycatch failed.");
|
|
27
|
+
});
|
|
28
|
+
expect(a).toBeInstanceOf(Error);
|
|
29
|
+
expect(a.message).toEqual("Trycatch failed.");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("tryCatchAsync", () => {
|
|
33
|
+
it("Should return try return value if success.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const a = yield (0, tryCatch_1.tryCatchAsync)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
return "abc";
|
|
36
|
+
}), () => __awaiter(void 0, void 0, void 0, function* () { return new Error(); }));
|
|
37
|
+
expect(a).toEqual("abc");
|
|
38
|
+
}));
|
|
39
|
+
it("Should return catch return value if error.", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
const a = yield (0, tryCatch_1.tryCatchAsync)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
throw new Error("Error!");
|
|
42
|
+
}), () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
return new Error("Trycatch failed.");
|
|
44
|
+
}));
|
|
45
|
+
expect(a).toBeInstanceOf(Error);
|
|
46
|
+
expect(a.message).toEqual("Trycatch failed.");
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IClassStatus } from "./ClassStatus";
|
|
2
|
-
export interface IClass {
|
|
3
|
-
id: string;
|
|
4
|
-
title: string;
|
|
5
|
-
startDateTime: Date;
|
|
6
|
-
endDateTime: Date;
|
|
7
|
-
courseId: string;
|
|
8
|
-
ownerId: string;
|
|
9
|
-
status: IClassStatus;
|
|
10
|
-
groupId?: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
createdAt?: Date;
|
|
13
|
-
updatedAt?: Date;
|
|
14
|
-
paymentId?: string;
|
|
15
|
-
meetingLink?: string;
|
|
16
|
-
contractId?: string;
|
|
17
|
-
}
|
|
@@ -6,7 +6,15 @@ export declare class ISO8601Date implements IDate {
|
|
|
6
6
|
/**Accepts YYYY-MM-DD date format. All other characters after this will be disconsidered.
|
|
7
7
|
* Disconsiders timezones.
|
|
8
8
|
*/
|
|
9
|
-
constructor(value?: string
|
|
9
|
+
constructor(value?: string | Date, opts?: {
|
|
10
|
+
/**
|
|
11
|
+
* If `value` is of type `Date`, set this to `true`
|
|
12
|
+
* so that hours, minutes and seconds are extracted
|
|
13
|
+
* considering UTC.
|
|
14
|
+
*/
|
|
15
|
+
useUtc?: boolean;
|
|
16
|
+
});
|
|
17
|
+
private normalizeValue;
|
|
10
18
|
private throwIfFormatIsNotValid;
|
|
11
19
|
getDay: () => string;
|
|
12
20
|
getMonth: () => string;
|
|
@@ -6,7 +6,7 @@ class ISO8601Date {
|
|
|
6
6
|
/**Accepts YYYY-MM-DD date format. All other characters after this will be disconsidered.
|
|
7
7
|
* Disconsiders timezones.
|
|
8
8
|
*/
|
|
9
|
-
constructor(value) {
|
|
9
|
+
constructor(value, opts) {
|
|
10
10
|
this.validator = new ISO8601DateValidator_1.ISO8601DateValidator();
|
|
11
11
|
this.getDay = () => {
|
|
12
12
|
this.throwIfFormatIsNotValid();
|
|
@@ -52,14 +52,21 @@ class ISO8601Date {
|
|
|
52
52
|
const targetDate = date || this;
|
|
53
53
|
return targetDate.toUtcJsDateTime().getUTCDay();
|
|
54
54
|
};
|
|
55
|
-
const normalizedValue = value
|
|
56
|
-
? this.validator.match(value)
|
|
57
|
-
: this.getToday();
|
|
55
|
+
const normalizedValue = this.normalizeValue(value, opts === null || opts === void 0 ? void 0 : opts.useUtc);
|
|
58
56
|
if (!normalizedValue)
|
|
59
57
|
throw new Error("Date format is invalid.");
|
|
60
58
|
this.value = normalizedValue;
|
|
61
59
|
this.throwIfFormatIsNotValid();
|
|
62
60
|
}
|
|
61
|
+
normalizeValue(value, useUtc) {
|
|
62
|
+
return typeof value == "string"
|
|
63
|
+
? this.validator.match(value)
|
|
64
|
+
: value instanceof Date
|
|
65
|
+
? this.jsDateTimeToDate(value, {
|
|
66
|
+
useUtc: useUtc,
|
|
67
|
+
}).value
|
|
68
|
+
: this.getToday();
|
|
69
|
+
}
|
|
63
70
|
throwIfFormatIsNotValid() {
|
|
64
71
|
if (!this.validator.formatIsValid(this.value)) {
|
|
65
72
|
throw new Error("Date format must be YYYY-MM-DD.");
|
|
@@ -38,6 +38,13 @@ describe("ISO8601Date", () => {
|
|
|
38
38
|
};
|
|
39
39
|
expect(validateFormat).not.toThrow();
|
|
40
40
|
});
|
|
41
|
+
it("Should be able to be constructed using js Date", () => {
|
|
42
|
+
const jsDate = new Date("2025-01-01T00:00:00Z");
|
|
43
|
+
const date = new ISO8601Date_1.ISO8601Date(jsDate, {
|
|
44
|
+
useUtc: true
|
|
45
|
+
});
|
|
46
|
+
expect(date.value).toEqual("2025-01-01");
|
|
47
|
+
});
|
|
41
48
|
});
|
|
42
49
|
describe("ISO8601Date.getDay()", () => {
|
|
43
50
|
it("Should return the day if format is valid.", () => {
|
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,24 +49,12 @@ __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() {
|
|
@@ -95,7 +82,7 @@ var _ISO8601Date = class _ISO8601Date {
|
|
|
95
82
|
/**Accepts YYYY-MM-DD date format. All other characters after this will be disconsidered.
|
|
96
83
|
* Disconsiders timezones.
|
|
97
84
|
*/
|
|
98
|
-
constructor(value) {
|
|
85
|
+
constructor(value, opts) {
|
|
99
86
|
this.validator = new ISO8601DateValidator();
|
|
100
87
|
this.getDay = () => {
|
|
101
88
|
this.throwIfFormatIsNotValid();
|
|
@@ -151,11 +138,16 @@ var _ISO8601Date = class _ISO8601Date {
|
|
|
151
138
|
const targetDate = date || this;
|
|
152
139
|
return targetDate.toUtcJsDateTime().getUTCDay();
|
|
153
140
|
};
|
|
154
|
-
const normalizedValue =
|
|
141
|
+
const normalizedValue = this.normalizeValue(value, opts == null ? void 0 : opts.useUtc);
|
|
155
142
|
if (!normalizedValue) throw new Error("Date format is invalid.");
|
|
156
143
|
this.value = normalizedValue;
|
|
157
144
|
this.throwIfFormatIsNotValid();
|
|
158
145
|
}
|
|
146
|
+
normalizeValue(value, useUtc) {
|
|
147
|
+
return typeof value == "string" ? this.validator.match(value) : value instanceof Date ? this.jsDateTimeToDate(value, {
|
|
148
|
+
useUtc
|
|
149
|
+
}).value : this.getToday();
|
|
150
|
+
}
|
|
159
151
|
throwIfFormatIsNotValid() {
|
|
160
152
|
if (!this.validator.formatIsValid(this.value)) {
|
|
161
153
|
throw new Error("Date format must be YYYY-MM-DD.");
|
|
@@ -581,32 +573,6 @@ var ClassCreationFormSchema = import_zod2.z.object({
|
|
|
581
573
|
var import_zod3 = require("zod");
|
|
582
574
|
var ClassCreationRecurrenceRuleSchema = import_zod3.z.literal("daily").or(import_zod3.z.literal("weekly")).or(import_zod3.z.literal("week days"));
|
|
583
575
|
|
|
584
|
-
// src/domain/entities/UserTimeSlot.ts
|
|
585
|
-
var UserTimeSlot = class {
|
|
586
|
-
constructor(opts) {
|
|
587
|
-
this.getDateTimeSlot = () => {
|
|
588
|
-
return {
|
|
589
|
-
endDateTime: this.endDateTime,
|
|
590
|
-
startDateTime: this.startDateTime
|
|
591
|
-
};
|
|
592
|
-
};
|
|
593
|
-
this.id = opts.id;
|
|
594
|
-
this.userId = opts.userId;
|
|
595
|
-
this.user = opts.user;
|
|
596
|
-
this.groupId = opts.groupId;
|
|
597
|
-
this.startDateTime = opts.startDateTime;
|
|
598
|
-
this.endDateTime = opts.endDateTime;
|
|
599
|
-
this.dayOfTheWeek = this.getDayOfTheWeek();
|
|
600
|
-
this.isAvailableTime = opts.isAvailableTime;
|
|
601
|
-
this.course = opts.course;
|
|
602
|
-
this.courseId = opts.courseId;
|
|
603
|
-
this.rescheduleRequests = opts.rescheduleRequests;
|
|
604
|
-
}
|
|
605
|
-
getDayOfTheWeek() {
|
|
606
|
-
return this.startDateTime.getUTCDay();
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
|
|
610
576
|
// src/domain/entities/FreeTimeSlot.ts
|
|
611
577
|
var FreeDateTimeSlot = class {
|
|
612
578
|
constructor(opts) {
|
|
@@ -616,7 +582,7 @@ var FreeDateTimeSlot = class {
|
|
|
616
582
|
}
|
|
617
583
|
};
|
|
618
584
|
|
|
619
|
-
// src/application/helpers/
|
|
585
|
+
// src/application/helpers/tryCatch.ts
|
|
620
586
|
function tryCatch(callback, fallback) {
|
|
621
587
|
try {
|
|
622
588
|
return callback();
|
|
@@ -634,7 +600,7 @@ function tryCatchAsync(callback, fallback) {
|
|
|
634
600
|
});
|
|
635
601
|
}
|
|
636
602
|
|
|
637
|
-
// src/application/helpers/
|
|
603
|
+
// src/application/helpers/filterAsync.ts
|
|
638
604
|
function filterAsync(arr, predicate) {
|
|
639
605
|
return __async(this, null, function* () {
|
|
640
606
|
const results = yield Promise.all(arr.map(predicate));
|
|
@@ -643,7 +609,6 @@ function filterAsync(arr, predicate) {
|
|
|
643
609
|
}
|
|
644
610
|
// Annotate the CommonJS export names for ESM import in node:
|
|
645
611
|
0 && (module.exports = {
|
|
646
|
-
AsaasCustomer,
|
|
647
612
|
ClassCreationFormSchema,
|
|
648
613
|
ClassCreationRecurrenceRuleSchema,
|
|
649
614
|
ClassStatusSchema,
|
|
@@ -653,7 +618,6 @@ function filterAsync(arr, predicate) {
|
|
|
653
618
|
ISO8601DateValidator,
|
|
654
619
|
ISO8601Time,
|
|
655
620
|
ISO8601TimeValidator,
|
|
656
|
-
UserTimeSlot,
|
|
657
621
|
filterAsync,
|
|
658
622
|
tryCatch,
|
|
659
623
|
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, };
|
package/dist/index.js
CHANGED
|
@@ -19,17 +19,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
// src/domain/entities/AsaasCustomer.ts
|
|
23
|
-
var AsaasCustomer = class {
|
|
24
|
-
constructor(opts) {
|
|
25
|
-
this.name = opts.name;
|
|
26
|
-
this.cpfCnpj = opts.cpfCnpj;
|
|
27
|
-
this.email = opts.email;
|
|
28
|
-
this.mobilePhone = opts.mobilePhone;
|
|
29
|
-
this.externalReference = opts.externalReference;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
22
|
// src/domain/entities/ISO8601DateValidator.ts
|
|
34
23
|
var ISO8601DateValidator = class {
|
|
35
24
|
constructor() {
|
|
@@ -57,7 +46,7 @@ var _ISO8601Date = class _ISO8601Date {
|
|
|
57
46
|
/**Accepts YYYY-MM-DD date format. All other characters after this will be disconsidered.
|
|
58
47
|
* Disconsiders timezones.
|
|
59
48
|
*/
|
|
60
|
-
constructor(value) {
|
|
49
|
+
constructor(value, opts) {
|
|
61
50
|
this.validator = new ISO8601DateValidator();
|
|
62
51
|
this.getDay = () => {
|
|
63
52
|
this.throwIfFormatIsNotValid();
|
|
@@ -113,11 +102,16 @@ var _ISO8601Date = class _ISO8601Date {
|
|
|
113
102
|
const targetDate = date || this;
|
|
114
103
|
return targetDate.toUtcJsDateTime().getUTCDay();
|
|
115
104
|
};
|
|
116
|
-
const normalizedValue =
|
|
105
|
+
const normalizedValue = this.normalizeValue(value, opts == null ? void 0 : opts.useUtc);
|
|
117
106
|
if (!normalizedValue) throw new Error("Date format is invalid.");
|
|
118
107
|
this.value = normalizedValue;
|
|
119
108
|
this.throwIfFormatIsNotValid();
|
|
120
109
|
}
|
|
110
|
+
normalizeValue(value, useUtc) {
|
|
111
|
+
return typeof value == "string" ? this.validator.match(value) : value instanceof Date ? this.jsDateTimeToDate(value, {
|
|
112
|
+
useUtc
|
|
113
|
+
}).value : this.getToday();
|
|
114
|
+
}
|
|
121
115
|
throwIfFormatIsNotValid() {
|
|
122
116
|
if (!this.validator.formatIsValid(this.value)) {
|
|
123
117
|
throw new Error("Date format must be YYYY-MM-DD.");
|
|
@@ -543,32 +537,6 @@ var ClassCreationFormSchema = z2.object({
|
|
|
543
537
|
import { z as z3 } from "zod";
|
|
544
538
|
var ClassCreationRecurrenceRuleSchema = z3.literal("daily").or(z3.literal("weekly")).or(z3.literal("week days"));
|
|
545
539
|
|
|
546
|
-
// src/domain/entities/UserTimeSlot.ts
|
|
547
|
-
var UserTimeSlot = class {
|
|
548
|
-
constructor(opts) {
|
|
549
|
-
this.getDateTimeSlot = () => {
|
|
550
|
-
return {
|
|
551
|
-
endDateTime: this.endDateTime,
|
|
552
|
-
startDateTime: this.startDateTime
|
|
553
|
-
};
|
|
554
|
-
};
|
|
555
|
-
this.id = opts.id;
|
|
556
|
-
this.userId = opts.userId;
|
|
557
|
-
this.user = opts.user;
|
|
558
|
-
this.groupId = opts.groupId;
|
|
559
|
-
this.startDateTime = opts.startDateTime;
|
|
560
|
-
this.endDateTime = opts.endDateTime;
|
|
561
|
-
this.dayOfTheWeek = this.getDayOfTheWeek();
|
|
562
|
-
this.isAvailableTime = opts.isAvailableTime;
|
|
563
|
-
this.course = opts.course;
|
|
564
|
-
this.courseId = opts.courseId;
|
|
565
|
-
this.rescheduleRequests = opts.rescheduleRequests;
|
|
566
|
-
}
|
|
567
|
-
getDayOfTheWeek() {
|
|
568
|
-
return this.startDateTime.getUTCDay();
|
|
569
|
-
}
|
|
570
|
-
};
|
|
571
|
-
|
|
572
540
|
// src/domain/entities/FreeTimeSlot.ts
|
|
573
541
|
var FreeDateTimeSlot = class {
|
|
574
542
|
constructor(opts) {
|
|
@@ -578,7 +546,7 @@ var FreeDateTimeSlot = class {
|
|
|
578
546
|
}
|
|
579
547
|
};
|
|
580
548
|
|
|
581
|
-
// src/application/helpers/
|
|
549
|
+
// src/application/helpers/tryCatch.ts
|
|
582
550
|
function tryCatch(callback, fallback) {
|
|
583
551
|
try {
|
|
584
552
|
return callback();
|
|
@@ -596,7 +564,7 @@ function tryCatchAsync(callback, fallback) {
|
|
|
596
564
|
});
|
|
597
565
|
}
|
|
598
566
|
|
|
599
|
-
// src/application/helpers/
|
|
567
|
+
// src/application/helpers/filterAsync.ts
|
|
600
568
|
function filterAsync(arr, predicate) {
|
|
601
569
|
return __async(this, null, function* () {
|
|
602
570
|
const results = yield Promise.all(arr.map(predicate));
|
|
@@ -604,7 +572,6 @@ function filterAsync(arr, predicate) {
|
|
|
604
572
|
});
|
|
605
573
|
}
|
|
606
574
|
export {
|
|
607
|
-
AsaasCustomer,
|
|
608
575
|
ClassCreationFormSchema,
|
|
609
576
|
ClassCreationRecurrenceRuleSchema,
|
|
610
577
|
ClassStatusSchema,
|
|
@@ -614,7 +581,6 @@ export {
|
|
|
614
581
|
ISO8601DateValidator,
|
|
615
582
|
ISO8601Time,
|
|
616
583
|
ISO8601TimeValidator,
|
|
617
|
-
UserTimeSlot,
|
|
618
584
|
filterAsync,
|
|
619
585
|
tryCatch,
|
|
620
586
|
tryCatchAsync
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IUserTimeSlotDTO } from "../../../application/dtos/UserTimeSlotDTO";
|
|
2
2
|
export type GetFixedAvailableTimeResponseBody = {
|
|
3
|
-
fixedAvailableTimes:
|
|
3
|
+
fixedAvailableTimes: IUserTimeSlotDTO[];
|
|
4
4
|
shareableText?: string;
|
|
5
5
|
};
|