@eliasrrosa/tutorhub-public-assets 0.7.6 → 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.
@@ -0,0 +1,11 @@
1
+ export interface IUserTimeSlotDTO {
2
+ id: string;
3
+ userId: string;
4
+ groupId: string;
5
+ dayOfTheWeek: number;
6
+ startDateTime: Date;
7
+ endDateTime: Date;
8
+ isAvailableTime: boolean;
9
+ courseId?: string;
10
+ rescheduleRequestIds?: string[];
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,2 @@
1
+ export declare function tryCatch<T, E>(callback: () => T, fallback: (error: unknown) => E): T | E;
2
+ export declare function tryCatchAsync<T, E>(callback: () => Promise<T>, fallback: (error: unknown) => Promise<E>): Promise<T | E>;
@@ -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
- }
@@ -1,2 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { ClassStatus as TClassStatus } from "../types/ClassStatus";
2
+ export interface IClassStatus {
3
+ value: TClassStatus;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
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() {
@@ -586,32 +573,6 @@ var ClassCreationFormSchema = import_zod2.z.object({
586
573
  var import_zod3 = require("zod");
587
574
  var ClassCreationRecurrenceRuleSchema = import_zod3.z.literal("daily").or(import_zod3.z.literal("weekly")).or(import_zod3.z.literal("week days"));
588
575
 
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
576
  // src/domain/entities/FreeTimeSlot.ts
616
577
  var FreeDateTimeSlot = class {
617
578
  constructor(opts) {
@@ -621,7 +582,7 @@ var FreeDateTimeSlot = class {
621
582
  }
622
583
  };
623
584
 
624
- // src/application/helpers/helpers/tryCatch.ts
585
+ // src/application/helpers/tryCatch.ts
625
586
  function tryCatch(callback, fallback) {
626
587
  try {
627
588
  return callback();
@@ -639,7 +600,7 @@ function tryCatchAsync(callback, fallback) {
639
600
  });
640
601
  }
641
602
 
642
- // src/application/helpers/helpers/filterAsync.ts
603
+ // src/application/helpers/filterAsync.ts
643
604
  function filterAsync(arr, predicate) {
644
605
  return __async(this, null, function* () {
645
606
  const results = yield Promise.all(arr.map(predicate));
@@ -648,7 +609,6 @@ function filterAsync(arr, predicate) {
648
609
  }
649
610
  // Annotate the CommonJS export names for ESM import in node:
650
611
  0 && (module.exports = {
651
- AsaasCustomer,
652
612
  ClassCreationFormSchema,
653
613
  ClassCreationRecurrenceRuleSchema,
654
614
  ClassStatusSchema,
@@ -658,7 +618,6 @@ function filterAsync(arr, predicate) {
658
618
  ISO8601DateValidator,
659
619
  ISO8601Time,
660
620
  ISO8601TimeValidator,
661
- UserTimeSlot,
662
621
  filterAsync,
663
622
  tryCatch,
664
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/helpers/tryCatch.js";
53
- import { filterAsync } from "./application/helpers/helpers/filterAsync.js";
54
- export { filterAsync, tryCatchAsync, tryCatch, ClassStatus, AsaasCustomer, IClass, IClassRequest, IContract, ICourse, ICourseToSchoolConnectionRequest, IDate, IDateTimeSlot, IFreeDateTimeSlot, FreeDateTimeSlot, IUserTimeSlot, UserTimeSlot, 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, ClassCreationForm, ClassCreationRecurrenceRule, ClassCreationFormSchema, ClassCreationRecurrenceRuleSchema, ClassStatusSchema, IClassStatus, };
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() {
@@ -548,32 +537,6 @@ var ClassCreationFormSchema = z2.object({
548
537
  import { z as z3 } from "zod";
549
538
  var ClassCreationRecurrenceRuleSchema = z3.literal("daily").or(z3.literal("weekly")).or(z3.literal("week days"));
550
539
 
551
- // src/domain/entities/UserTimeSlot.ts
552
- var UserTimeSlot = class {
553
- constructor(opts) {
554
- this.getDateTimeSlot = () => {
555
- return {
556
- endDateTime: this.endDateTime,
557
- startDateTime: this.startDateTime
558
- };
559
- };
560
- this.id = opts.id;
561
- this.userId = opts.userId;
562
- this.user = opts.user;
563
- this.groupId = opts.groupId;
564
- this.startDateTime = opts.startDateTime;
565
- this.endDateTime = opts.endDateTime;
566
- this.dayOfTheWeek = this.getDayOfTheWeek();
567
- this.isAvailableTime = opts.isAvailableTime;
568
- this.course = opts.course;
569
- this.courseId = opts.courseId;
570
- this.rescheduleRequests = opts.rescheduleRequests;
571
- }
572
- getDayOfTheWeek() {
573
- return this.startDateTime.getUTCDay();
574
- }
575
- };
576
-
577
540
  // src/domain/entities/FreeTimeSlot.ts
578
541
  var FreeDateTimeSlot = class {
579
542
  constructor(opts) {
@@ -583,7 +546,7 @@ var FreeDateTimeSlot = class {
583
546
  }
584
547
  };
585
548
 
586
- // src/application/helpers/helpers/tryCatch.ts
549
+ // src/application/helpers/tryCatch.ts
587
550
  function tryCatch(callback, fallback) {
588
551
  try {
589
552
  return callback();
@@ -601,7 +564,7 @@ function tryCatchAsync(callback, fallback) {
601
564
  });
602
565
  }
603
566
 
604
- // src/application/helpers/helpers/filterAsync.ts
567
+ // src/application/helpers/filterAsync.ts
605
568
  function filterAsync(arr, predicate) {
606
569
  return __async(this, null, function* () {
607
570
  const results = yield Promise.all(arr.map(predicate));
@@ -609,7 +572,6 @@ function filterAsync(arr, predicate) {
609
572
  });
610
573
  }
611
574
  export {
612
- AsaasCustomer,
613
575
  ClassCreationFormSchema,
614
576
  ClassCreationRecurrenceRuleSchema,
615
577
  ClassStatusSchema,
@@ -619,7 +581,6 @@ export {
619
581
  ISO8601DateValidator,
620
582
  ISO8601Time,
621
583
  ISO8601TimeValidator,
622
- UserTimeSlot,
623
584
  filterAsync,
624
585
  tryCatch,
625
586
  tryCatchAsync
@@ -1,5 +1,5 @@
1
- import { IUserTimeSlot } from "../../../domain/entities/UserTimeSlot";
1
+ import { IUserTimeSlotDTO } from "../../../application/dtos/UserTimeSlotDTO";
2
2
  export type GetFixedAvailableTimeResponseBody = {
3
- fixedAvailableTimes: IUserTimeSlot[];
3
+ fixedAvailableTimes: IUserTimeSlotDTO[];
4
4
  shareableText?: string;
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliasrrosa/tutorhub-public-assets",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
4
4
  "description": "Assets, mainly interfaces, to be shared among different Tutorhub apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",