refactor: extract slots from libraries barrel file (#19895)

* refactor: extract slots fn from libraries barrel file

* bump platform libs

---------

Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
Rajiv SahalandMorgan Vernay authored and GitHub committed 2025-03-10 10:33:29 +00:00
1 parent 1848cd55b1
commit 277ce1c244
11 files changed
+45 -15

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@
"@axiomhq/winston": "^1.2.0",
"@calcom/platform-constants": "*",
"@calcom/platform-enums": "*",
"@calcom/platform-libraries": "npm:@calcom/[email protected]27",
"@calcom/platform-libraries": "npm:@calcom/[email protected]40",
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
"@calcom/platform-types": "*",
"@calcom/platform-utils": "*",
@@ -1,4 +1,5 @@
import { SlotsOutputService_2024_04_15 } from "@/modules/slots/slots-2024-04-15/services/slots-output.service";
import type { RangeSlots, TimeSlots } from "@/modules/slots/slots-2024-04-15/services/slots-output.service";
import { SlotsService_2024_04_15 } from "@/modules/slots/slots-2024-04-15/services/slots.service";
import { Query, Body, Controller, Get, Delete, Post, Req, Res } from "@nestjs/common";
import { ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
@@ -12,8 +13,7 @@ import {
VERSION_2024_06_11,
VERSION_2024_08_13,
} from "@calcom/platform-constants";
import { getAvailableSlots } from "@calcom/platform-libraries";
import type { AvailableSlotsType } from "@calcom/platform-libraries";
import { getAvailableSlots } from "@calcom/platform-libraries/slots";
import { RemoveSelectedSlotInput_2024_04_15, ReserveSlotInput_2024_04_15 } from "@calcom/platform-types";
import { ApiResponse, GetAvailableSlotsInput_2024_04_15 } from "@calcom/platform-types";
@@ -156,7 +156,7 @@ export class SlotsController_2024_04_15 {
async getAvailableSlots(
@Query() query: GetAvailableSlotsInput_2024_04_15,
@Req() req: ExpressRequest
): Promise<ApiResponse<AvailableSlotsType>> {
): Promise<ApiResponse<{ slots: TimeSlots["slots"] | RangeSlots["slots"] }>> {
const isTeamEvent = await this.slotsService.checkIfIsTeamEvent(query.eventTypeId);
const availableSlots = await getAvailableSlots({
input: {
@@ -7,7 +7,7 @@ import { SlotFormat } from "@calcom/platform-enums";
export type TimeSlots = {
slots: Record<string, { time: string; attendees?: number; bookingUid?: string }[]>;
};
type RangeSlots = {
export type RangeSlots = {
slots: Record<string, { startTime: string; endTime: string; attendees?: number; bookingUid?: string }[]>;
};
@@ -2,7 +2,7 @@ import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_20
import { OrganizationsRepository } from "@/modules/organizations/index/organizations.repository";
import { OrganizationsUsersRepository } from "@/modules/organizations/users/index/organizations-users.repository";
import { UsersRepository } from "@/modules/users/users.repository";
import { Injectable, NotFoundException } from "@nestjs/common";
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
import { DateTime } from "luxon";
import { dynamicEvent } from "@calcom/platform-libraries";
@@ -88,6 +88,11 @@ export class SlotsInputService_2024_09_04 {
dateTime = dateTime.set({ hour: 23, minute: 59, second: 59 });
}
return dateTime.toISO();
const ISOEndTime = dateTime.toISO();
if (ISOEndTime === null) {
throw new BadRequestException("Invalid end date");
}
return ISOEndTime;
}
}
@@ -17,7 +17,7 @@ import {
import { DateTime } from "luxon";
import { z } from "zod";
import { getAvailableSlots } from "@calcom/platform-libraries";
import { getAvailableSlots } from "@calcom/platform-libraries/slots";
import { GetSlotsInput_2024_09_04, ReserveSlotInput_2024_09_04 } from "@calcom/platform-types";
import { EventType } from "@calcom/prisma/client";
+2 -1
View File
@@ -18,7 +18,8 @@
"@calcom/platform-constants": ["../../../packages/platform/constants/index.ts"],
"@calcom/platform-types": ["../../../packages/platform/types/index.ts"],
"@calcom/platform-utils": ["../../../packages/platform/utils/index.ts"],
"@calcom/platform-enums": ["../../../packages/platform/enums/index.ts"]
"@calcom/platform-enums": ["../../../packages/platform/enums/index.ts"],
"@calcom/platform-libraries/slots": ["../../../packages/platform/libraries/slots.ts"]
},
"incremental": true,
"skipLibCheck": true,