@eliasrrosa/tutorhub-public-assets 0.0.18 → 0.0.20

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.
@@ -31,6 +31,7 @@ export declare class ISO8601Time implements ITime {
31
31
  static getNow(): string;
32
32
  getNowTimeString: typeof ISO8601Time.getNow;
33
33
  getTimezone: () => IISO8601Timezone;
34
+ getTimeInMinutes: () => number;
34
35
  addHours: (hours: number) => ITime;
35
36
  addMinutes: (minutes: number) => ITime;
36
37
  addTimezone: (timezone: string | number) => ITime;
@@ -25,6 +25,11 @@ class ISO8601Time {
25
25
  this.getTimezone = () => {
26
26
  return new ISO8601Timezone_1.ISO8601Timezone(this.originalTimeString);
27
27
  };
28
+ this.getTimeInMinutes = () => {
29
+ const hours = parseInt(this.getHoursString());
30
+ const minutes = parseInt(this.getMinutesString());
31
+ return hours * 60 + minutes;
32
+ };
28
33
  this.addHours = (hours) => {
29
34
  let targetHour = parseInt(this.getHoursString()) + hours;
30
35
  while (targetHour >= 24) {
@@ -50,7 +55,9 @@ class ISO8601Time {
50
55
  .selector.getTimezoneString(timeWithAddedHours.originalTimeString)}`);
51
56
  };
52
57
  this.addTimezone = (timezone) => {
53
- const newTimezone = typeof timezone == "number" ? this.timezoneParser.toString(timezone) : timezone;
58
+ const newTimezone = typeof timezone == "number"
59
+ ? this.timezoneParser.toString(timezone)
60
+ : timezone;
54
61
  return new ISO8601Time(`${this.getHoursString()}:${this.getMinutesString()}:${this.getSecondsString()}${newTimezone}`);
55
62
  };
56
63
  this.originalTimeString = value ? value : this.getNowTimeString();
@@ -211,4 +211,26 @@ describe("ISO8601Time", () => {
211
211
  expect(time.addTimezone("+03:00").getTimezoneString()).toEqual("+03:00");
212
212
  });
213
213
  });
214
+ describe("ISO8601Time.getTimeInMinutes()", () => {
215
+ it("Should return 60 for 01:00", () => {
216
+ const time = new ISO8601Time_1.ISO8601Time("01:00");
217
+ expect(time.getTimeInMinutes()).toEqual(60);
218
+ });
219
+ it("Should return 60 for 01:00:00", () => {
220
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00");
221
+ expect(time.getTimeInMinutes()).toEqual(60);
222
+ });
223
+ it("Should return 60 for 01:00:00+03:00", () => {
224
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00+03:00");
225
+ expect(time.getTimeInMinutes()).toEqual(60);
226
+ });
227
+ it("Should return 60 for 01:00:00Z", () => {
228
+ const time = new ISO8601Time_1.ISO8601Time("01:00:00Z");
229
+ expect(time.getTimeInMinutes()).toEqual(60);
230
+ });
231
+ it("Should return 90 for 01:30", () => {
232
+ const time = new ISO8601Time_1.ISO8601Time("01:30");
233
+ expect(time.getTimeInMinutes()).toEqual(90);
234
+ });
235
+ });
214
236
  });
@@ -30,4 +30,9 @@ export interface ITime {
30
30
  * and `(+|-)HH:MM` for others. */
31
31
  addTimezone: (timezone: string | number) => ITime;
32
32
  getTimezoneString: () => string;
33
+ /**
34
+ * Returns the quantity of minutes based on original time string.
35
+ * Eg:. `01:00 -> 60`, `02:00:00-03:00 -> 120`, `02:30 -> 150`
36
+ */
37
+ getTimeInMinutes: () => number;
33
38
  }
@@ -1 +1,3 @@
1
- export type ClassCreationRecurrenceRule = "daily" | "weekly" | "week days";
1
+ import { z } from "zod";
2
+ export declare const ClassCreationRecurrenceRuleSchema: z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"daily">, z.ZodLiteral<"weekly">]>, z.ZodLiteral<"week days">]>;
3
+ export type ClassCreationRecurrenceRule = z.infer<typeof ClassCreationRecurrenceRuleSchema>;
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassCreationRecurrenceRuleSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ClassCreationRecurrenceRuleSchema = zod_1.z
6
+ .literal("daily")
7
+ .or(zod_1.z.literal("weekly"))
8
+ .or(zod_1.z.literal("week days"));
@@ -1 +1,3 @@
1
- export type ClassStatus = "pending" | "done" | "canceled" | "to reschedule";
1
+ import { z } from "zod";
2
+ export declare const ClassStatusSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"pending">, z.ZodLiteral<"done">]>, z.ZodLiteral<"canceled">]>, z.ZodLiteral<"to reschedule">]>;
3
+ export type ClassStatus = z.infer<typeof ClassStatusSchema>;
@@ -1,2 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassStatusSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.ClassStatusSchema = zod_1.z
6
+ .literal("pending")
7
+ .or(zod_1.z.literal("done"))
8
+ .or(zod_1.z.literal("canceled"))
9
+ .or(zod_1.z.literal("to reschedule"));
package/dist/index.cjs CHANGED
@@ -22,6 +22,9 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  AsaasCustomer: () => AsaasCustomer,
24
24
  Class: () => Class,
25
+ ClassCreationFormSchema: () => ClassCreationFormSchema,
26
+ ClassCreationRecurrenceRuleSchema: () => ClassCreationRecurrenceRuleSchema,
27
+ ClassStatusSchema: () => ClassStatusSchema,
25
28
  FreeDateTimeSlot: () => FreeDateTimeSlot,
26
29
  ISO8601Date: () => ISO8601Date,
27
30
  ISO8601DateTime: () => ISO8601DateTime,
@@ -440,6 +443,11 @@ var ISO8601Time = class _ISO8601Time {
440
443
  this.getTimezone = () => {
441
444
  return new ISO8601Timezone(this.originalTimeString);
442
445
  };
446
+ this.getTimeInMinutes = () => {
447
+ const hours = parseInt(this.getHoursString());
448
+ const minutes = parseInt(this.getMinutesString());
449
+ return hours * 60 + minutes;
450
+ };
443
451
  this.addHours = (hours) => {
444
452
  let targetHour = parseInt(this.getHoursString()) + hours;
445
453
  while (targetHour >= 24) {
@@ -525,6 +533,29 @@ var ISO8601Time = class _ISO8601Time {
525
533
  }
526
534
  };
527
535
 
536
+ // src/infrastructure/restful/requests/forms/ClassCreationForm.ts
537
+ var import_zod2 = require("zod");
538
+
539
+ // src/domain/types/ClassStatus.ts
540
+ var import_zod = require("zod");
541
+ var ClassStatusSchema = import_zod.z.literal("pending").or(import_zod.z.literal("done")).or(import_zod.z.literal("canceled")).or(import_zod.z.literal("to reschedule"));
542
+
543
+ // src/infrastructure/restful/requests/forms/ClassCreationForm.ts
544
+ var ClassCreationFormSchema = import_zod2.z.object({
545
+ title: import_zod2.z.string().min(1).max(255),
546
+ date: import_zod2.z.string().date(),
547
+ startTime: import_zod2.z.string(),
548
+ endTime: import_zod2.z.string(),
549
+ courseId: import_zod2.z.string().uuid(),
550
+ description: import_zod2.z.string().max(255).optional(),
551
+ status: ClassStatusSchema.optional(),
552
+ meetingLink: import_zod2.z.string().url().optional()
553
+ });
554
+
555
+ // src/domain/types/ClassCreationRecurrenceRule.ts
556
+ var import_zod3 = require("zod");
557
+ var ClassCreationRecurrenceRuleSchema = import_zod3.z.literal("daily").or(import_zod3.z.literal("weekly")).or(import_zod3.z.literal("week days"));
558
+
528
559
  // src/domain/entities/UserUnavailableTime.ts
529
560
  var UserUnavailableTime = class {
530
561
  constructor(opts) {
@@ -568,6 +599,9 @@ var FreeDateTimeSlot = class {
568
599
  0 && (module.exports = {
569
600
  AsaasCustomer,
570
601
  Class,
602
+ ClassCreationFormSchema,
603
+ ClassCreationRecurrenceRuleSchema,
604
+ ClassStatusSchema,
571
605
  FreeDateTimeSlot,
572
606
  ISO8601Date,
573
607
  ISO8601DateTime,
package/dist/index.d.ts CHANGED
@@ -43,9 +43,9 @@ 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
45
  import { GetFixedAvailableTimeResponseBody } from "./infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.js";
46
- import { ClassCreationForm } from "./infrastructure/restful/requests/forms/ClassCreationForm.js";
47
- import { ClassStatus } from "./domain/types/ClassStatus.js";
48
- import { ClassCreationRecurrenceRule } from "./domain/types/ClassCreationRecurrenceRule.js";
46
+ import { ClassCreationForm, ClassCreationFormSchema } from "./infrastructure/restful/requests/forms/ClassCreationForm.js";
47
+ import { ClassStatus, ClassStatusSchema } from "./domain/types/ClassStatus.js";
48
+ import { ClassCreationRecurrenceRule, ClassCreationRecurrenceRuleSchema } from "./domain/types/ClassCreationRecurrenceRule.js";
49
49
  import { IUserUnavailableTime, UserUnavailableTime } from "./domain/entities/UserUnavailableTime.js";
50
50
  import { IFreeDateTimeSlot, FreeDateTimeSlot } from "./domain/entities/FreeTimeSlot.js";
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, ClassCreationForm, ClassCreationRecurrenceRule, ClassStatus };
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, ClassCreationForm, ClassCreationRecurrenceRule, ClassStatus, ClassCreationFormSchema, ClassCreationRecurrenceRuleSchema, ClassStatusSchema };
package/dist/index.js CHANGED
@@ -406,6 +406,11 @@ var ISO8601Time = class _ISO8601Time {
406
406
  this.getTimezone = () => {
407
407
  return new ISO8601Timezone(this.originalTimeString);
408
408
  };
409
+ this.getTimeInMinutes = () => {
410
+ const hours = parseInt(this.getHoursString());
411
+ const minutes = parseInt(this.getMinutesString());
412
+ return hours * 60 + minutes;
413
+ };
409
414
  this.addHours = (hours) => {
410
415
  let targetHour = parseInt(this.getHoursString()) + hours;
411
416
  while (targetHour >= 24) {
@@ -491,6 +496,29 @@ var ISO8601Time = class _ISO8601Time {
491
496
  }
492
497
  };
493
498
 
499
+ // src/infrastructure/restful/requests/forms/ClassCreationForm.ts
500
+ import { z as z2 } from "zod";
501
+
502
+ // src/domain/types/ClassStatus.ts
503
+ import { z } from "zod";
504
+ var ClassStatusSchema = z.literal("pending").or(z.literal("done")).or(z.literal("canceled")).or(z.literal("to reschedule"));
505
+
506
+ // src/infrastructure/restful/requests/forms/ClassCreationForm.ts
507
+ var ClassCreationFormSchema = z2.object({
508
+ title: z2.string().min(1).max(255),
509
+ date: z2.string().date(),
510
+ startTime: z2.string(),
511
+ endTime: z2.string(),
512
+ courseId: z2.string().uuid(),
513
+ description: z2.string().max(255).optional(),
514
+ status: ClassStatusSchema.optional(),
515
+ meetingLink: z2.string().url().optional()
516
+ });
517
+
518
+ // src/domain/types/ClassCreationRecurrenceRule.ts
519
+ import { z as z3 } from "zod";
520
+ var ClassCreationRecurrenceRuleSchema = z3.literal("daily").or(z3.literal("weekly")).or(z3.literal("week days"));
521
+
494
522
  // src/domain/entities/UserUnavailableTime.ts
495
523
  var UserUnavailableTime = class {
496
524
  constructor(opts) {
@@ -533,6 +561,9 @@ var FreeDateTimeSlot = class {
533
561
  export {
534
562
  AsaasCustomer,
535
563
  Class,
564
+ ClassCreationFormSchema,
565
+ ClassCreationRecurrenceRuleSchema,
566
+ ClassStatusSchema,
536
567
  FreeDateTimeSlot,
537
568
  ISO8601Date,
538
569
  ISO8601DateTime,
@@ -1,16 +1,30 @@
1
- import { ClassCreationRecurrenceRule } from "../../../../domain/types/ClassCreationRecurrenceRule";
2
- import { ClassStatus } from "../../../../domain/types/ClassStatus";
3
- export type ClassCreationForm = {
1
+ import { z } from "zod";
2
+ export declare const ClassCreationFormSchema: z.ZodObject<{
3
+ title: z.ZodString;
4
+ date: z.ZodString;
5
+ startTime: z.ZodString;
6
+ endTime: z.ZodString;
7
+ courseId: z.ZodString;
8
+ description: z.ZodOptional<z.ZodString>;
9
+ status: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"pending">, z.ZodLiteral<"done">]>, z.ZodLiteral<"canceled">]>, z.ZodLiteral<"to reschedule">]>>;
10
+ meetingLink: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ date: string;
4
13
  title: string;
14
+ startTime: string;
15
+ endTime: string;
16
+ courseId: string;
17
+ status?: "pending" | "done" | "canceled" | "to reschedule" | undefined;
18
+ description?: string | undefined;
19
+ meetingLink?: string | undefined;
20
+ }, {
5
21
  date: string;
6
- time: string;
22
+ title: string;
23
+ startTime: string;
7
24
  endTime: string;
8
25
  courseId: string;
9
- description?: string;
10
- id?: string;
11
- status?: ClassStatus;
12
- recurrenceRule?: ClassCreationRecurrenceRule;
13
- recurrenceEndDate?: string;
14
- groupId?: string;
15
- meetingLink?: string;
16
- };
26
+ status?: "pending" | "done" | "canceled" | "to reschedule" | undefined;
27
+ description?: string | undefined;
28
+ meetingLink?: string | undefined;
29
+ }>;
30
+ export type ClassCreationForm = z.infer<typeof ClassCreationFormSchema>;
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClassCreationFormSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const ClassStatus_1 = require("../../../../domain/types/ClassStatus");
6
+ exports.ClassCreationFormSchema = zod_1.z.object({
7
+ title: zod_1.z.string().min(1).max(255),
8
+ date: zod_1.z.string().date(),
9
+ startTime: zod_1.z.string(),
10
+ endTime: zod_1.z.string(),
11
+ courseId: zod_1.z.string().uuid(),
12
+ description: zod_1.z.string().max(255).optional(),
13
+ status: ClassStatus_1.ClassStatusSchema.optional(),
14
+ meetingLink: zod_1.z.string().url().optional(),
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliasrrosa/tutorhub-public-assets",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "Assets, mainly interfaces, to be shared among different Tutorhub apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -39,5 +39,8 @@
39
39
  "ts-jest": "^29.3.2",
40
40
  "tsup": "^8.4.0",
41
41
  "typescript": "^5.8.3"
42
+ },
43
+ "dependencies": {
44
+ "zod": "^3.25.67"
42
45
  }
43
46
  }