@eliasrrosa/tutorhub-public-assets 0.8.1 → 0.9.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/domain/entities/ISO8601DateTime.d.ts +15 -0
- package/dist/domain/entities/ISO8601DateTime.js +12 -0
- package/dist/domain/entities/ISO8601DateTime.test.js +21 -3
- package/dist/index.cjs +22 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -6
- package/dist/infrastructure/restful/requests/forms/ClassSchedulingForm.d.ts +27 -0
- package/dist/infrastructure/restful/requests/forms/ClassSchedulingForm.js +14 -0
- package/package.json +1 -1
|
@@ -15,6 +15,17 @@ export interface IDateTime {
|
|
|
15
15
|
getMinutesString: () => string;
|
|
16
16
|
getSecondsString: () => string;
|
|
17
17
|
getMilisecondsString: () => string;
|
|
18
|
+
/**
|
|
19
|
+
* @returns only the date like YYYY-MM-DD
|
|
20
|
+
*/
|
|
21
|
+
getDateString: () => string;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @returns the day of the month like DD
|
|
25
|
+
*/
|
|
26
|
+
getDayString: () => string;
|
|
27
|
+
getMonthString: () => string;
|
|
28
|
+
getYearString: () => string;
|
|
18
29
|
}
|
|
19
30
|
export declare class ISO8601DateTime implements IDateTime {
|
|
20
31
|
private readonly timeFormatValidator;
|
|
@@ -41,4 +52,8 @@ export declare class ISO8601DateTime implements IDateTime {
|
|
|
41
52
|
timezone?: string | number;
|
|
42
53
|
}) => string;
|
|
43
54
|
toMidnight: () => IDateTime;
|
|
55
|
+
getDateString: () => string;
|
|
56
|
+
getDayString: () => string;
|
|
57
|
+
getMonthString: () => string;
|
|
58
|
+
getYearString: () => string;
|
|
44
59
|
}
|
|
@@ -65,6 +65,18 @@ class ISO8601DateTime {
|
|
|
65
65
|
const timezone = this.dateString.slice(matchedString.length + matches.index);
|
|
66
66
|
return new ISO8601DateTime(`${datePlusT}00:00:00${timezone}`);
|
|
67
67
|
};
|
|
68
|
+
this.getDateString = () => {
|
|
69
|
+
return `${this.getYearString()}-${this.getMonthString()}-${this.getDayString()}`;
|
|
70
|
+
};
|
|
71
|
+
this.getDayString = () => {
|
|
72
|
+
return this.dateString.split("T")[0].split("-")[2];
|
|
73
|
+
};
|
|
74
|
+
this.getMonthString = () => {
|
|
75
|
+
return this.dateString.split("T")[0].split("-")[1];
|
|
76
|
+
};
|
|
77
|
+
this.getYearString = () => {
|
|
78
|
+
return this.dateString.split("T")[0].split("-")[0];
|
|
79
|
+
};
|
|
68
80
|
const normalizedDateString = this.normalizeDateString(dateString);
|
|
69
81
|
if (!normalizedDateString)
|
|
70
82
|
throw new Error("Date time format invalid.");
|
|
@@ -56,9 +56,27 @@ describe("ISO8601DateTime", () => {
|
|
|
56
56
|
});
|
|
57
57
|
describe("ISO8601DateTime.toMidnight().getIsoString()", () => {
|
|
58
58
|
it("Must take UTC ISO string and return it midnight", () => {
|
|
59
|
-
expect(new ISO8601DateTime_1.ISO8601DateTime("2025-01-01T03:00:00Z")
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
expect(new ISO8601DateTime_1.ISO8601DateTime("2025-01-01T03:00:00Z").toMidnight().getIsoString()).toEqual("2025-01-01T00:00:00.000Z");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe("ISO8601DateTime.getDay()", () => {
|
|
63
|
+
it("Should return the day if format is valid.", () => {
|
|
64
|
+
const date = new ISO8601DateTime_1.ISO8601DateTime("2025-01-02");
|
|
65
|
+
expect(date.getDayString()).toBe("02");
|
|
66
|
+
const date2 = new ISO8601DateTime_1.ISO8601DateTime("2025-01-02T15:00:00-03:00");
|
|
67
|
+
expect(date2.getDayString()).toBe("02");
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe("ISO8601DateTime.getMonth()", () => {
|
|
71
|
+
it("Should return the month if format is valid.", () => {
|
|
72
|
+
const date = new ISO8601DateTime_1.ISO8601DateTime("2025-01-02");
|
|
73
|
+
expect(date.getMonthString()).toBe("01");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe("ISO8601DateTime.getYear()", () => {
|
|
77
|
+
it("Should return the year if format is valid.", () => {
|
|
78
|
+
const date = new ISO8601DateTime_1.ISO8601DateTime("2025-01-02");
|
|
79
|
+
expect(date.getYearString()).toBe("2025");
|
|
62
80
|
});
|
|
63
81
|
});
|
|
64
82
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -40,8 +40,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
40
40
|
// src/index.ts
|
|
41
41
|
var index_exports = {};
|
|
42
42
|
__export(index_exports, {
|
|
43
|
-
ClassCreationFormSchema: () => ClassCreationFormSchema,
|
|
44
43
|
ClassCreationRecurrenceRuleSchema: () => ClassCreationRecurrenceRuleSchema,
|
|
44
|
+
ClassSchedulingFormSchema: () => ClassSchedulingFormSchema,
|
|
45
45
|
ClassStatusSchema: () => ClassStatusSchema,
|
|
46
46
|
FreeDateTimeSlot: () => FreeDateTimeSlot,
|
|
47
47
|
ISO8601Date: () => ISO8601Date,
|
|
@@ -416,12 +416,27 @@ var ISO8601DateTime = class _ISO8601DateTime {
|
|
|
416
416
|
this.toMidnight = () => {
|
|
417
417
|
const currentTimeString = this.getTimeString();
|
|
418
418
|
const matches = new RegExp(currentTimeString).exec(this.dateString);
|
|
419
|
-
if (!matches || matches.length < 1)
|
|
419
|
+
if (!matches || matches.length < 1)
|
|
420
|
+
throw new Error("Error getting current time string.");
|
|
420
421
|
const datePlusT = this.dateString.slice(0, matches.index);
|
|
421
422
|
const matchedString = matches[0];
|
|
422
|
-
const timezone = this.dateString.slice(
|
|
423
|
+
const timezone = this.dateString.slice(
|
|
424
|
+
matchedString.length + matches.index
|
|
425
|
+
);
|
|
423
426
|
return new _ISO8601DateTime(`${datePlusT}00:00:00${timezone}`);
|
|
424
427
|
};
|
|
428
|
+
this.getDateString = () => {
|
|
429
|
+
return `${this.getYearString()}-${this.getMonthString()}-${this.getDayString()}`;
|
|
430
|
+
};
|
|
431
|
+
this.getDayString = () => {
|
|
432
|
+
return this.dateString.split("T")[0].split("-")[2];
|
|
433
|
+
};
|
|
434
|
+
this.getMonthString = () => {
|
|
435
|
+
return this.dateString.split("T")[0].split("-")[1];
|
|
436
|
+
};
|
|
437
|
+
this.getYearString = () => {
|
|
438
|
+
return this.dateString.split("T")[0].split("-")[0];
|
|
439
|
+
};
|
|
425
440
|
const normalizedDateString = this.normalizeDateString(dateString);
|
|
426
441
|
if (!normalizedDateString) throw new Error("Date time format invalid.");
|
|
427
442
|
this.dateString = normalizedDateString;
|
|
@@ -589,15 +604,15 @@ _ISO8601Time.fromJsDateTime = (dateTime, opts) => {
|
|
|
589
604
|
};
|
|
590
605
|
var ISO8601Time = _ISO8601Time;
|
|
591
606
|
|
|
592
|
-
// src/infrastructure/restful/requests/forms/
|
|
607
|
+
// src/infrastructure/restful/requests/forms/ClassSchedulingForm.ts
|
|
593
608
|
var import_zod2 = require("zod");
|
|
594
609
|
|
|
595
610
|
// src/domain/types/ClassStatus.ts
|
|
596
611
|
var import_zod = require("zod");
|
|
597
612
|
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"));
|
|
598
613
|
|
|
599
|
-
// src/infrastructure/restful/requests/forms/
|
|
600
|
-
var
|
|
614
|
+
// src/infrastructure/restful/requests/forms/ClassSchedulingForm.ts
|
|
615
|
+
var ClassSchedulingFormSchema = import_zod2.z.object({
|
|
601
616
|
title: import_zod2.z.string().min(1).max(255),
|
|
602
617
|
startDateTime: import_zod2.z.string().datetime(),
|
|
603
618
|
endDateTime: import_zod2.z.string().datetime(),
|
|
@@ -647,8 +662,8 @@ function filterAsync(arr, predicate) {
|
|
|
647
662
|
}
|
|
648
663
|
// Annotate the CommonJS export names for ESM import in node:
|
|
649
664
|
0 && (module.exports = {
|
|
650
|
-
ClassCreationFormSchema,
|
|
651
665
|
ClassCreationRecurrenceRuleSchema,
|
|
666
|
+
ClassSchedulingFormSchema,
|
|
652
667
|
ClassStatusSchema,
|
|
653
668
|
FreeDateTimeSlot,
|
|
654
669
|
ISO8601Date,
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ import { ITime } from "./domain/entities/Time.js";
|
|
|
10
10
|
import { ITimeSlot } from "./domain/entities/TimeSlot.js";
|
|
11
11
|
import { ITimeValidator } from "./domain/entities/TimeValidator.js";
|
|
12
12
|
import { GetFixedAvailableTimeResponseBody } from "./infrastructure/restful/responses/GetFixedAvailableTimesResponseBody.js";
|
|
13
|
-
import {
|
|
13
|
+
import { ClassSchedulingForm, ClassSchedulingFormSchema } from "./infrastructure/restful/requests/forms/ClassSchedulingForm.js";
|
|
14
14
|
import { ClassStatus, ClassStatusSchema } from "./domain/types/ClassStatus.js";
|
|
15
15
|
import { ClassCreationRecurrenceRule, ClassCreationRecurrenceRuleSchema } from "./domain/types/ClassCreationRecurrenceRule.js";
|
|
16
16
|
import { IFreeDateTimeSlot, FreeDateTimeSlot } from "./domain/entities/FreeTimeSlot.js";
|
|
17
17
|
import { tryCatch, tryCatchAsync } from "./application/helpers/tryCatch.js";
|
|
18
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,
|
|
19
|
+
export { filterAsync, tryCatchAsync, tryCatch, ClassStatus, IDate, IDateTimeSlot, IFreeDateTimeSlot, FreeDateTimeSlot, IDateValidator, ISO8601Date, IDateTime, ISO8601DateValidator, ISO8601Time, ISO8601TimeValidator, ITime, ITimeSlot, ITimeValidator, GetFixedAvailableTimeResponseBody, ISO8601DateTime, ClassSchedulingForm, ClassCreationRecurrenceRule, ClassSchedulingFormSchema, ClassCreationRecurrenceRuleSchema, ClassStatusSchema, };
|
package/dist/index.js
CHANGED
|
@@ -380,12 +380,27 @@ var ISO8601DateTime = class _ISO8601DateTime {
|
|
|
380
380
|
this.toMidnight = () => {
|
|
381
381
|
const currentTimeString = this.getTimeString();
|
|
382
382
|
const matches = new RegExp(currentTimeString).exec(this.dateString);
|
|
383
|
-
if (!matches || matches.length < 1)
|
|
383
|
+
if (!matches || matches.length < 1)
|
|
384
|
+
throw new Error("Error getting current time string.");
|
|
384
385
|
const datePlusT = this.dateString.slice(0, matches.index);
|
|
385
386
|
const matchedString = matches[0];
|
|
386
|
-
const timezone = this.dateString.slice(
|
|
387
|
+
const timezone = this.dateString.slice(
|
|
388
|
+
matchedString.length + matches.index
|
|
389
|
+
);
|
|
387
390
|
return new _ISO8601DateTime(`${datePlusT}00:00:00${timezone}`);
|
|
388
391
|
};
|
|
392
|
+
this.getDateString = () => {
|
|
393
|
+
return `${this.getYearString()}-${this.getMonthString()}-${this.getDayString()}`;
|
|
394
|
+
};
|
|
395
|
+
this.getDayString = () => {
|
|
396
|
+
return this.dateString.split("T")[0].split("-")[2];
|
|
397
|
+
};
|
|
398
|
+
this.getMonthString = () => {
|
|
399
|
+
return this.dateString.split("T")[0].split("-")[1];
|
|
400
|
+
};
|
|
401
|
+
this.getYearString = () => {
|
|
402
|
+
return this.dateString.split("T")[0].split("-")[0];
|
|
403
|
+
};
|
|
389
404
|
const normalizedDateString = this.normalizeDateString(dateString);
|
|
390
405
|
if (!normalizedDateString) throw new Error("Date time format invalid.");
|
|
391
406
|
this.dateString = normalizedDateString;
|
|
@@ -553,15 +568,15 @@ _ISO8601Time.fromJsDateTime = (dateTime, opts) => {
|
|
|
553
568
|
};
|
|
554
569
|
var ISO8601Time = _ISO8601Time;
|
|
555
570
|
|
|
556
|
-
// src/infrastructure/restful/requests/forms/
|
|
571
|
+
// src/infrastructure/restful/requests/forms/ClassSchedulingForm.ts
|
|
557
572
|
import { z as z2 } from "zod";
|
|
558
573
|
|
|
559
574
|
// src/domain/types/ClassStatus.ts
|
|
560
575
|
import { z } from "zod";
|
|
561
576
|
var ClassStatusSchema = z.literal("pending").or(z.literal("done")).or(z.literal("canceled")).or(z.literal("to reschedule"));
|
|
562
577
|
|
|
563
|
-
// src/infrastructure/restful/requests/forms/
|
|
564
|
-
var
|
|
578
|
+
// src/infrastructure/restful/requests/forms/ClassSchedulingForm.ts
|
|
579
|
+
var ClassSchedulingFormSchema = z2.object({
|
|
565
580
|
title: z2.string().min(1).max(255),
|
|
566
581
|
startDateTime: z2.string().datetime(),
|
|
567
582
|
endDateTime: z2.string().datetime(),
|
|
@@ -610,8 +625,8 @@ function filterAsync(arr, predicate) {
|
|
|
610
625
|
});
|
|
611
626
|
}
|
|
612
627
|
export {
|
|
613
|
-
ClassCreationFormSchema,
|
|
614
628
|
ClassCreationRecurrenceRuleSchema,
|
|
629
|
+
ClassSchedulingFormSchema,
|
|
615
630
|
ClassStatusSchema,
|
|
616
631
|
FreeDateTimeSlot,
|
|
617
632
|
ISO8601Date,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ClassSchedulingFormSchema: z.ZodObject<{
|
|
3
|
+
title: z.ZodString;
|
|
4
|
+
startDateTime: z.ZodString;
|
|
5
|
+
endDateTime: z.ZodString;
|
|
6
|
+
courseId: z.ZodString;
|
|
7
|
+
description: z.ZodOptional<z.ZodString>;
|
|
8
|
+
status: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<"pending">, z.ZodLiteral<"done">]>, z.ZodLiteral<"canceled">]>, z.ZodLiteral<"to reschedule">]>>;
|
|
9
|
+
meetingLink: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
title: string;
|
|
12
|
+
startDateTime: string;
|
|
13
|
+
endDateTime: string;
|
|
14
|
+
courseId: string;
|
|
15
|
+
status?: "pending" | "done" | "canceled" | "to reschedule" | undefined;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
meetingLink?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
title: string;
|
|
20
|
+
startDateTime: string;
|
|
21
|
+
endDateTime: string;
|
|
22
|
+
courseId: string;
|
|
23
|
+
status?: "pending" | "done" | "canceled" | "to reschedule" | undefined;
|
|
24
|
+
description?: string | undefined;
|
|
25
|
+
meetingLink?: string | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type ClassSchedulingForm = z.infer<typeof ClassSchedulingFormSchema>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClassSchedulingFormSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ClassStatus_1 = require("../../../../domain/types/ClassStatus");
|
|
6
|
+
exports.ClassSchedulingFormSchema = zod_1.z.object({
|
|
7
|
+
title: zod_1.z.string().min(1).max(255),
|
|
8
|
+
startDateTime: zod_1.z.string().datetime(),
|
|
9
|
+
endDateTime: zod_1.z.string().datetime(),
|
|
10
|
+
courseId: zod_1.z.string().uuid(),
|
|
11
|
+
description: zod_1.z.string().max(255).optional(),
|
|
12
|
+
status: ClassStatus_1.ClassStatusSchema.optional(),
|
|
13
|
+
meetingLink: zod_1.z.string().url().optional(),
|
|
14
|
+
});
|