feat: calendar-links API (#19777)
* refactor: Remove intervalLimits from @calcom/lib and export directly (#19710) * refactor: Remove intervalLimits from @calcom/lib and export directly * Tackle other places that use parseBookingLimit/parseDurationLimit * More type fixups that were hidden by previous fails * Fixed up booking-limits file * Remove server-only ## What does this PR do? <!-- Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. --> - Fixes #XXXX (GitHub issue number) - Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description) ## Visual Demo (For contributors especially) A visual demonstration is strongly recommended, for both the original and new change **(video / image - any one)**. #### Video Demo (if applicable): - Show screen recordings of the issue or feature. - Demonstrate how to reproduce the issue, the behavior before and after the change. #### Image Demo (if applicable): - Add side-by-side screenshots of the original and updated change. - Highlight any significant change(s). ## Mandatory Tasks (DO NOT REMOVE) - [ ] I have self-reviewed the code (A decent size PR without self-review might be rejected). - [ ] I have updated the developer docs in /docs if this PR makes changes that would require a [documentation change](https://cal.com/docs). If N/A, write N/A here and check the checkbox. - [ ] I confirm automated tests are in place that prove my fix is effective or that my feature works. ## How should this be tested? <!-- Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration. Write details that help to start the tests --> - Are there environment variables that should be set? - What are the minimal test data to have? - What is expected (happy path) to have (input and output)? - Any other important info that could help to test that PR ## Checklist <!-- Remove bullet points below that don't apply to you --> - I haven't read the [contributing guide](https://github.com/calcom/cal.com/blob/main/CONTRIBUTING.md) - My code doesn't follow the style guidelines of this project - I haven't commented my code, particularly in hard-to-understand areas - I haven't checked if my changes generate no new warnings * Add unit tests and e2e * fix ts errors * Add comment * bump platform libs * fix: yarn-lock * fix yarn.lock * doc update * Add isString --------- Co-authored-by: Morgan Vernay <[email protected]>
This commit is contained in:
1 parent
19e1714794
commit
b1bcbe9dfb
19 files changed
+3613
-764
No files matched your search
@@ -0,0 +1,9 @@
|
||||
- [x] Refactor individual calendar links functions to create the variables and just use the variables in the string literal instead of functions being called in the string literal
|
||||
- [x] Must ensure during review that logically there is no change in the functionality of booking-single-view.tsx
|
||||
|
||||
|
||||
- Testing
|
||||
- [x] Verify Google Calendar, Ics, Office 365 - Compare with Production
|
||||
- [x] Event Description, Booking title, Booking location, Start time, End time - All correct
|
||||
- [x] Recurring event?
|
||||
- [x] Dynamic Group booking?
|
||||
+30
-1
@@ -54,9 +54,29 @@ CALCOM_LICENSE_KEY=c4234812-12ab-42s6-a1e3-55bedd4a5bb
|
||||
|
||||
## Running the app
|
||||
|
||||
# Development
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ yarn run start
|
||||
```
|
||||
|
||||
OR if you don't want to use docker, you can run following command.
|
||||
|
||||
```bash
|
||||
$ yarn dev:no-docker
|
||||
```
|
||||
|
||||
Additionally you can run following command(in different terminal) to ensure that any change in any of the dependencies is rebuilt and detected. It watches platform-libraries, platform-constants, platform-enums, platform-utils, platform-types.
|
||||
|
||||
```bash
|
||||
$ yarn run dev:build:watch
|
||||
```
|
||||
|
||||
If you are making changes in packages/platform/libraries, you should run the following command too that would connect your local packages/platform/libraries to the api/v2
|
||||
|
||||
```bash
|
||||
$ yarn local
|
||||
```
|
||||
|
||||
# watch mode
|
||||
$ yarn run start:dev
|
||||
@@ -65,6 +85,9 @@ $ yarn run start:dev
|
||||
$ yarn run start:prod
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
@@ -74,6 +97,12 @@ $ yarn run test
|
||||
# e2e tests
|
||||
$ yarn run test:e2e
|
||||
|
||||
# e2e tests in watch mode
|
||||
$ yarn test:e2e:watch
|
||||
|
||||
# run specific e2e test file in watch mode
|
||||
$ yarn test:e2e:watch --testPathPattern=filePath
|
||||
|
||||
# test coverage
|
||||
$ yarn run test:cov
|
||||
```
|
||||
|
||||
@@ -9,8 +9,14 @@
|
||||
"build": "yarn dev:build && nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"dev:build:watch": "yarn workspace @calcom/platform-constants build:watch & yarn workspace @calcom/platform-utils build:watch & yarn workspace @calcom/platform-types build:watch",
|
||||
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-enums build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build ",
|
||||
"dev:build:watch": "concurrently --names \"libraries,lru-fix,constants,enums,utils,types\" \"yarn _dev:build:watch:libraries\" \"yarn _dev:build:watch:libraries:lru-fix\" \"yarn _dev:build:watch:constants\" \"yarn _dev:build:watch:enums\" \"yarn _dev:build:watch:utils\" \"yarn _dev:build:watch:types\"",
|
||||
"_dev:build:watch:libraries": "yarn workspace @calcom/platform-libraries build:watch",
|
||||
"_dev:build:watch:libraries:lru-fix": "yarn workspace @calcom/platform-libraries watch-lru-fix",
|
||||
"_dev:build:watch:constants": "yarn workspace @calcom/platform-constants build:watch",
|
||||
"_dev:build:watch:enums": "yarn workspace @calcom/platform-enums build:watch",
|
||||
"_dev:build:watch:utils": "yarn workspace @calcom/platform-utils build:watch",
|
||||
"_dev:build:watch:types": "yarn workspace @calcom/platform-types build:watch",
|
||||
"dev:build": "yarn workspace @calcom/platform-constants build && yarn workspace @calcom/platform-enums build && yarn workspace @calcom/platform-utils build && yarn workspace @calcom/platform-types build",
|
||||
"dev": "yarn dev:build && ts-node scripts/docker-start.ts && yarn copy-swagger-module && yarn start --watch",
|
||||
"dev:no-docker": "yarn dev:build && yarn copy-swagger-module && yarn start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
@@ -32,7 +38,7 @@
|
||||
"@axiomhq/winston": "^1.2.0",
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]4",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]5",
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
@@ -57,6 +63,7 @@
|
||||
"bull": "^4.12.4",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"concurrently": "^9.1.2",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"dotenv": "^16.3.1",
|
||||
"fs-extra": "^11.2.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import type { Prisma } from "@prisma/client";
|
||||
@Injectable()
|
||||
export class BookingsRepository_2024_08_13 {
|
||||
constructor(private readonly dbRead: PrismaReadService, private readonly dbWrite: PrismaWriteService) {}
|
||||
@@ -98,7 +98,7 @@ export class BookingsRepository_2024_08_13 {
|
||||
}
|
||||
|
||||
async getByUidWithAttendeesAndUserAndEvent(uid: string) {
|
||||
return this.dbRead.prisma.booking.findUnique({
|
||||
const booking = await this.dbRead.prisma.booking.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
},
|
||||
@@ -108,6 +108,15 @@ export class BookingsRepository_2024_08_13 {
|
||||
eventType: true,
|
||||
},
|
||||
});
|
||||
if (!booking) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
...booking,
|
||||
responses: booking.responses as Prisma.JsonObject,
|
||||
metadata: booking.metadata as Prisma.JsonObject | null,
|
||||
};
|
||||
}
|
||||
|
||||
async getByUidWithAttendeesWithBookingSeatAndUserAndEvent(uid: string) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BookingUidGuard } from "@/ee/bookings/2024-08-13/guards/booking-uid.guard";
|
||||
import { CalendarLinksOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/calendar-links.output";
|
||||
import { CancelBookingOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/cancel-booking.output";
|
||||
import { CreateBookingOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/create-booking.output";
|
||||
import { MarkAbsentBookingOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/mark-absent.output";
|
||||
@@ -335,4 +336,22 @@ export class BookingsController_2024_08_13 {
|
||||
data: booking,
|
||||
};
|
||||
}
|
||||
|
||||
@Get("/:bookingUid/calendar-links")
|
||||
@UseGuards(ApiAuthGuard, BookingUidGuard)
|
||||
@Permissions([BOOKING_READ])
|
||||
@ApiOperation({
|
||||
summary: "Get 'Add to Calendar' links for a booking",
|
||||
description:
|
||||
"Retrieve calendar links for a booking that can be used to add the event to various calendar services. Returns links for Google Calendar, Microsoft Office, Microsoft Outlook, and a downloadable ICS file.",
|
||||
})
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async getCalendarLinks(@Param("bookingUid") bookingUid: string): Promise<CalendarLinksOutput_2024_08_13> {
|
||||
const calendarLinks = await this.bookingsService.getCalendarLinks(bookingUid);
|
||||
|
||||
return {
|
||||
status: SUCCESS_STATUS,
|
||||
data: calendarLinks,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import { bootstrap } from "@/app";
|
||||
import { AppModule } from "@/app.module";
|
||||
import { CreateScheduleInput_2024_04_15 } from "@/ee/schedules/schedules_2024_04_15/inputs/create-schedule.input";
|
||||
import { SchedulesModule_2024_04_15 } from "@/ee/schedules/schedules_2024_04_15/schedules.module";
|
||||
import { SchedulesService_2024_04_15 } from "@/ee/schedules/schedules_2024_04_15/services/schedules.service";
|
||||
import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard";
|
||||
import { PrismaModule } from "@/modules/prisma/prisma.module";
|
||||
import { UsersModule } from "@/modules/users/users.module";
|
||||
import { INestApplication } from "@nestjs/common";
|
||||
import { NestExpressApplication } from "@nestjs/platform-express";
|
||||
import { Test } from "@nestjs/testing";
|
||||
import { User } from "@prisma/client";
|
||||
import * as request from "supertest";
|
||||
import { BookingsRepositoryFixture } from "test/fixtures/repository/bookings.repository.fixture";
|
||||
import { EventTypesRepositoryFixture } from "test/fixtures/repository/event-types.repository.fixture";
|
||||
import { OAuthClientRepositoryFixture } from "test/fixtures/repository/oauth-client.repository.fixture";
|
||||
import { TeamRepositoryFixture } from "test/fixtures/repository/team.repository.fixture";
|
||||
import { UserRepositoryFixture } from "test/fixtures/repository/users.repository.fixture";
|
||||
import { randomString } from "test/utils/randomString";
|
||||
import { withApiAuth } from "test/utils/withApiAuth";
|
||||
|
||||
import { CAL_API_VERSION_HEADER, SUCCESS_STATUS, VERSION_2024_08_13 } from "@calcom/platform-constants";
|
||||
import { Booking, PlatformOAuthClient, Team } from "@calcom/prisma/client";
|
||||
|
||||
describe("Bookings Endpoints 2024-08-13", () => {
|
||||
describe("Calendar Links", () => {
|
||||
let app: INestApplication;
|
||||
let organization: Team;
|
||||
|
||||
let userRepositoryFixture: UserRepositoryFixture;
|
||||
let bookingsRepositoryFixture: BookingsRepositoryFixture;
|
||||
let schedulesService: SchedulesService_2024_04_15;
|
||||
let eventTypesRepositoryFixture: EventTypesRepositoryFixture;
|
||||
let oauthClientRepositoryFixture: OAuthClientRepositoryFixture;
|
||||
let oAuthClient: PlatformOAuthClient;
|
||||
let teamRepositoryFixture: TeamRepositoryFixture;
|
||||
|
||||
const userEmail = `calendar-links-2024-08-13-user-${randomString()}@api.com`;
|
||||
let user: User;
|
||||
let booking: Booking;
|
||||
|
||||
beforeAll(async () => {
|
||||
const moduleRef = await withApiAuth(
|
||||
userEmail,
|
||||
Test.createTestingModule({
|
||||
imports: [AppModule, PrismaModule, UsersModule, SchedulesModule_2024_04_15],
|
||||
})
|
||||
)
|
||||
.overrideGuard(PermissionsGuard)
|
||||
.useValue({
|
||||
canActivate: () => true,
|
||||
})
|
||||
.compile();
|
||||
|
||||
userRepositoryFixture = new UserRepositoryFixture(moduleRef);
|
||||
bookingsRepositoryFixture = new BookingsRepositoryFixture(moduleRef);
|
||||
eventTypesRepositoryFixture = new EventTypesRepositoryFixture(moduleRef);
|
||||
oauthClientRepositoryFixture = new OAuthClientRepositoryFixture(moduleRef);
|
||||
teamRepositoryFixture = new TeamRepositoryFixture(moduleRef);
|
||||
schedulesService = moduleRef.get<SchedulesService_2024_04_15>(SchedulesService_2024_04_15);
|
||||
|
||||
organization = await teamRepositoryFixture.create({
|
||||
name: `confirm-bookings-2024-08-13-organization-${randomString()}`,
|
||||
});
|
||||
oAuthClient = await createOAuthClient(organization.id);
|
||||
|
||||
user = await userRepositoryFixture.create({
|
||||
email: userEmail,
|
||||
platformOAuthClients: {
|
||||
connect: {
|
||||
id: oAuthClient.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const userSchedule: CreateScheduleInput_2024_04_15 = {
|
||||
name: `calendar-links-2024-08-13-${randomString()}-schedule`,
|
||||
timeZone: "Europe/Rome",
|
||||
isDefault: true,
|
||||
};
|
||||
await schedulesService.createUserSchedule(user.id, userSchedule);
|
||||
const event = await eventTypesRepositoryFixture.create(
|
||||
{
|
||||
title: `calendar-links-2024-08-13-${randomString()}-event-type`,
|
||||
slug: `calendar-links-2024-08-13-${randomString()}-event-type-slug`,
|
||||
length: 60,
|
||||
},
|
||||
user.id
|
||||
);
|
||||
|
||||
booking = await bookingsRepositoryFixture.create({
|
||||
user: {
|
||||
connect: {
|
||||
id: user.id,
|
||||
},
|
||||
},
|
||||
startTime: new Date(Date.UTC(2020, 0, 8, 12, 0, 0)),
|
||||
endTime: new Date(Date.UTC(2020, 0, 8, 13, 0, 0)),
|
||||
uid: `calendar-links-2024-08-13-booking-${randomString()}`,
|
||||
title: "Test Booking",
|
||||
eventType: {
|
||||
connect: {
|
||||
id: event.id,
|
||||
},
|
||||
},
|
||||
location: "integrations:daily",
|
||||
customInputs: {},
|
||||
metadata: {},
|
||||
attendees: {
|
||||
create: {
|
||||
email: "[email protected]",
|
||||
name: "John Doe",
|
||||
locale: "en",
|
||||
timeZone: "America/New_York",
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
create: {
|
||||
name: "John Doe",
|
||||
email: "[email protected]",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
app = moduleRef.createNestApplication();
|
||||
bootstrap(app as NestExpressApplication);
|
||||
|
||||
await app.init();
|
||||
});
|
||||
|
||||
async function createOAuthClient(organizationId: number) {
|
||||
const data = {
|
||||
logo: "logo-url",
|
||||
name: "name",
|
||||
redirectUris: ["http://localhost:5555"],
|
||||
permissions: 32,
|
||||
};
|
||||
const secret = "secret";
|
||||
|
||||
const client = await oauthClientRepositoryFixture.create(organizationId, data, secret);
|
||||
return client;
|
||||
}
|
||||
|
||||
it("should get calendar links for a booking", async () => {
|
||||
const response = await request(app.getHttpServer())
|
||||
.get(`/v2/bookings/${booking.uid}/calendar-links`)
|
||||
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
|
||||
.expect(200);
|
||||
|
||||
expect(response.body.status).toEqual(SUCCESS_STATUS);
|
||||
expect(response.body.data).toBeDefined();
|
||||
|
||||
const googleCalendarLink = response.body.data.find((item: { id: string }) => item.id === 'googleCalendar').link;
|
||||
const microsoftOfficeLink = response.body.data.find((item: { id: string }) => item.id === 'microsoftOffice').link;
|
||||
const microsoftOutlookLink = response.body.data.find((item: { id: string }) => item.id === 'microsoftOutlook').link;
|
||||
const icsLink = response.body.data.find((item: { id: string }) => item.id === 'ics').link;
|
||||
|
||||
expect(googleCalendarLink).toMatch(/^https:\/\/calendar\.google\.com\//);
|
||||
expect(microsoftOfficeLink).toMatch(/^https:\/\/outlook\.office\.com\//);
|
||||
expect(microsoftOutlookLink).toMatch(/^https:\/\/outlook\.live\.com\//);
|
||||
expect(icsLink).toMatch(/^data:text\/calendar,/);
|
||||
});
|
||||
|
||||
it("should return 404 for non-existent booking", async () => {
|
||||
await request(app.getHttpServer())
|
||||
.get(`/v2/bookings/non-existent-uid/calendar-links`)
|
||||
.set(CAL_API_VERSION_HEADER, VERSION_2024_08_13)
|
||||
.expect(404);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await oauthClientRepositoryFixture.delete(oAuthClient.id);
|
||||
await teamRepositoryFixture.delete(organization.id);
|
||||
await userRepositoryFixture.deleteByEmail(user.email);
|
||||
await bookingsRepositoryFixture.deleteAllBookings(user.id, user.email);
|
||||
await app.close();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { IsEnum, IsString } from "class-validator";
|
||||
|
||||
import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
|
||||
|
||||
export class CalendarLink {
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: "The label of the calendar link",
|
||||
})
|
||||
label!: string;
|
||||
|
||||
@IsString()
|
||||
@ApiProperty({
|
||||
description: "The link to the calendar",
|
||||
})
|
||||
link!: string;
|
||||
}
|
||||
|
||||
export class CalendarLinksOutput_2024_08_13 {
|
||||
@ApiProperty({
|
||||
description: "The status of the request, always 'success' for successful responses",
|
||||
example: SUCCESS_STATUS,
|
||||
})
|
||||
@IsEnum([SUCCESS_STATUS, ERROR_STATUS])
|
||||
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS;
|
||||
|
||||
@ApiProperty({
|
||||
description: "Calendar links for the booking",
|
||||
type: [CalendarLink],
|
||||
})
|
||||
data!: CalendarLink[];
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BookingsRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/bookings.repository";
|
||||
import { CalendarLink } from "@/ee/bookings/2024-08-13/outputs/calendar-links.output";
|
||||
import { InputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/input.service";
|
||||
import { OutputBookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/output.service";
|
||||
import { PlatformBookingsService } from "@/ee/bookings/shared/platform-bookings.service";
|
||||
@@ -15,6 +16,7 @@ import { z } from "zod";
|
||||
|
||||
import {
|
||||
handleNewRecurringBooking,
|
||||
getTranslation,
|
||||
getAllUserBookings,
|
||||
handleInstantMeeting,
|
||||
handleCancelBooking,
|
||||
@@ -22,6 +24,7 @@ import {
|
||||
roundRobinManualReassignment,
|
||||
handleMarkNoShow,
|
||||
confirmBookingHandler,
|
||||
getCalendarLinks,
|
||||
} from "@calcom/platform-libraries";
|
||||
import { handleNewBooking } from "@calcom/platform-libraries";
|
||||
import {
|
||||
@@ -549,4 +552,32 @@ export class BookingsService_2024_08_13 {
|
||||
|
||||
return this.getBooking(bookingUid);
|
||||
}
|
||||
|
||||
async getCalendarLinks(bookingUid: string): Promise<CalendarLink[]> {
|
||||
const booking = await this.bookingsRepository.getByUidWithAttendeesAndUserAndEvent(bookingUid);
|
||||
|
||||
if (!booking) {
|
||||
throw new NotFoundException(`Booking with uid ${bookingUid} not found`);
|
||||
}
|
||||
|
||||
if (!booking.eventTypeId) {
|
||||
throw new BadRequestException(`Booking with uid ${bookingUid} has no event type`);
|
||||
}
|
||||
|
||||
const eventType = await this.eventTypesRepository.getEventTypeByIdIncludeUsersAndTeam(booking.eventTypeId);
|
||||
if (!eventType) {
|
||||
throw new BadRequestException(`Booking with uid ${bookingUid} has no event type`);
|
||||
}
|
||||
// TODO: Maybe we should get locale from query params?
|
||||
return getCalendarLinks({
|
||||
booking,
|
||||
eventType: {
|
||||
...eventType,
|
||||
// TODO: Support dynamic event bookings later. It would require a slug input it seems
|
||||
isDynamic: false,
|
||||
},
|
||||
// It can be made customizable through the API endpoint later.
|
||||
t: await getTranslation("en", "common"),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
import { PrismaReadService } from "@/modules/prisma/prisma-read.service";
|
||||
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
||||
import { UsersService } from "@/modules/users/services/users.service";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import { InputEventTransformed_2024_06_14 } from "@calcom/platform-types";
|
||||
|
||||
@Injectable()
|
||||
@@ -76,6 +75,22 @@ export class EventTypesRepository_2024_06_14 {
|
||||
});
|
||||
}
|
||||
|
||||
async getEventTypeByIdIncludeUsersAndTeam(eventTypeId: number) {
|
||||
const eventType = await this.dbRead.prisma.eventType.findUnique({
|
||||
where: { id: eventTypeId },
|
||||
include: { users: true, team: true },
|
||||
});
|
||||
|
||||
if (!eventType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
...eventType,
|
||||
recurringEvent: eventType.recurringEvent as Prisma.JsonObject | null | undefined,
|
||||
};
|
||||
}
|
||||
|
||||
async getEventTypeByIdWithOwnerAndTeam(eventTypeId: number) {
|
||||
return this.dbRead.prisma.eventType.findUnique({
|
||||
where: { id: eventTypeId },
|
||||
|
||||
@@ -4260,6 +4260,47 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v2/bookings/{bookingUid}/calendar-links": {
|
||||
"get": {
|
||||
"operationId": "BookingsController_2024_08_13_getCalendarLinks",
|
||||
"summary": "Get 'Add to Calendar' links for a booking",
|
||||
"description": "Retrieve calendar links for a booking that can be used to add the event to various calendar services. Returns links for Google Calendar, Microsoft Office, Microsoft Outlook, and a downloadable ICS file.",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "cal-api-version",
|
||||
"in": "header",
|
||||
"description": "Must be set to `2024-08-13`",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bookingUid",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/CalendarLinksOutput_2024_08_13"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
"Bookings"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/v2/calendars/ics-feed/save": {
|
||||
"post": {
|
||||
"operationId": "CalendarsController_createIcsFeed",
|
||||
@@ -17803,6 +17844,44 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"CalendarLink": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string",
|
||||
"description": "The label of the calendar link"
|
||||
},
|
||||
"link": {
|
||||
"type": "string",
|
||||
"description": "The link to the calendar"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"label",
|
||||
"link"
|
||||
]
|
||||
},
|
||||
"CalendarLinksOutput_2024_08_13": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "object",
|
||||
"description": "The status of the request, always 'success' for successful responses",
|
||||
"example": "success"
|
||||
},
|
||||
"data": {
|
||||
"description": "Calendar links for the booking",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/CalendarLink"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"status",
|
||||
"data"
|
||||
]
|
||||
},
|
||||
"CreateTeamMembershipInput": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { Environment } from "@/env";
|
||||
import "dotenv/config";
|
||||
|
||||
const env: Partial<Omit<Environment, "NODE_ENV">> = {
|
||||
API_URL: "http://localhost",
|
||||
@@ -22,6 +23,7 @@ const env: Partial<Omit<Environment, "NODE_ENV">> = {
|
||||
RATE_LIMIT_DEFAULT_BLOCK_DURATION_MS: 60000,
|
||||
IS_TEAM_BILLING_ENABLED: false,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
process.env = {
|
||||
|
||||
@@ -2,12 +2,10 @@
|
||||
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible";
|
||||
import classNames from "classnames";
|
||||
import { createEvent } from "ics";
|
||||
import { useSession } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { Fragment, useEffect, useState } from "react";
|
||||
import { RRule } from "rrule";
|
||||
import { Toaster } from "sonner";
|
||||
import { z } from "zod";
|
||||
|
||||
@@ -28,6 +26,7 @@ import {
|
||||
SystemField,
|
||||
TITLE_FIELD,
|
||||
} from "@calcom/features/bookings/lib/SystemField";
|
||||
import { getCalendarLinks, CalendarLinkType } from "@calcom/lib/bookings/getCalendarLinks";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import {
|
||||
formatToLocalizedDate,
|
||||
@@ -133,9 +132,13 @@ export default function Success(props: PageProps) {
|
||||
) {
|
||||
rescheduleLocation = bookingInfo.responses.location.optionValue;
|
||||
}
|
||||
const locationVideoCallUrl: string | undefined = bookingMetadataSchema.parse(
|
||||
bookingInfo?.metadata || {}
|
||||
)?.videoCallUrl;
|
||||
|
||||
const parsedBookingMetadata = bookingMetadataSchema.parse(bookingInfo?.metadata || {});
|
||||
const bookingWithParsedMetadata = {
|
||||
...bookingInfo,
|
||||
metadata: parsedBookingMetadata,
|
||||
};
|
||||
const locationVideoCallUrl = bookingWithParsedMetadata.metadata?.videoCallUrl;
|
||||
|
||||
const status = bookingInfo?.status;
|
||||
const reschedule = bookingInfo.status === BookingStatus.ACCEPTED;
|
||||
@@ -152,6 +155,21 @@ export default function Success(props: PageProps) {
|
||||
const isHost = props.isLoggedInUserHost;
|
||||
|
||||
const [date, setDate] = useState(dayjs.utc(bookingInfo.startTime));
|
||||
const calendarLinks = getCalendarLinks({
|
||||
booking: bookingWithParsedMetadata,
|
||||
eventType: eventType,
|
||||
t,
|
||||
});
|
||||
|
||||
// TODO: We could transform the JSX to just iterate over calendarLinks and render a link for each type
|
||||
const icsLink = calendarLinks.find((link) => link.id === CalendarLinkType.ICS)?.link;
|
||||
const microsoftOfficeLink = calendarLinks.find(
|
||||
(link) => link.id === CalendarLinkType.MICROSOFT_OFFICE
|
||||
)?.link;
|
||||
const microsoftOutlookLink = calendarLinks.find(
|
||||
(link) => link.id === CalendarLinkType.MICROSOFT_OUTLOOK
|
||||
)?.link;
|
||||
const googleCalendarLink = calendarLinks.find((link) => link.id === CalendarLinkType.GOOGLE_CALENDAR)?.link;
|
||||
|
||||
const isBackgroundTransparent = useIsBackgroundTransparent();
|
||||
const isEmbed = useIsEmbed();
|
||||
@@ -272,37 +290,6 @@ export default function Success(props: PageProps) {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
function eventLink(): string {
|
||||
const optional: { location?: string } = {};
|
||||
if (locationVideoCallUrl) {
|
||||
optional["location"] = locationVideoCallUrl;
|
||||
}
|
||||
|
||||
const event = createEvent({
|
||||
start: [
|
||||
date.toDate().getUTCFullYear(),
|
||||
(date.toDate().getUTCMonth() as number) + 1,
|
||||
date.toDate().getUTCDate(),
|
||||
date.toDate().getUTCHours(),
|
||||
date.toDate().getUTCMinutes(),
|
||||
],
|
||||
startInputType: "utc",
|
||||
title: eventName,
|
||||
description: eventType.description ? eventType.description : undefined,
|
||||
/** formatted to required type of description ^ */
|
||||
duration: {
|
||||
minutes: calculatedDuration,
|
||||
},
|
||||
...optional,
|
||||
});
|
||||
|
||||
if (event.error) {
|
||||
throw event.error;
|
||||
}
|
||||
|
||||
return encodeURIComponent(event.value ? event.value : false);
|
||||
}
|
||||
|
||||
function getTitle(): string {
|
||||
const titleSuffix = props.recurringBookings ? "_recurring" : "";
|
||||
const titlePrefix = isRoundRobin ? "round_robin_" : "";
|
||||
@@ -805,118 +792,67 @@ export default function Success(props: PageProps) {
|
||||
{t("add_to_calendar")}
|
||||
</span>
|
||||
<div className="justify-left mt-1 flex text-left sm:mt-0">
|
||||
<Link
|
||||
href={`https://calendar.google.com/calendar/r/eventedit?dates=${date
|
||||
.utc()
|
||||
.format("YYYYMMDDTHHmmss[Z]")}/${date
|
||||
.add(calculatedDuration, "minute")
|
||||
.utc()
|
||||
.format("YYYYMMDDTHHmmss[Z]")}&text=${eventName}&details=${
|
||||
eventType.description
|
||||
}${
|
||||
typeof locationVideoCallUrl === "string"
|
||||
? `&location=${encodeURIComponent(locationVideoCallUrl)}`
|
||||
: ""
|
||||
}${
|
||||
eventType.recurringEvent
|
||||
? `&recur=${encodeURIComponent(
|
||||
new RRule(eventType.recurringEvent).toString()
|
||||
)}`
|
||||
: ""
|
||||
}`}
|
||||
className="text-default border-subtle h-10 w-10 rounded-sm border px-3 py-2 ltr:mr-2 rtl:ml-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Google</title>
|
||||
<path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />
|
||||
</svg>
|
||||
</Link>
|
||||
<Link
|
||||
href={
|
||||
encodeURI(
|
||||
`https://outlook.live.com/calendar/0/deeplink/compose?body=${
|
||||
eventType.description
|
||||
}&enddt=${date
|
||||
.add(calculatedDuration, "minute")
|
||||
.utc()
|
||||
.format()}&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=${date
|
||||
.utc()
|
||||
.format()}&subject=${eventName}`
|
||||
) +
|
||||
(locationVideoCallUrl
|
||||
? `&location=${encodeURIComponent(locationVideoCallUrl)}`
|
||||
: "")
|
||||
}
|
||||
className="border-subtle text-default mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Microsoft Outlook</title>
|
||||
<path d="M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V10.85l1.24.72h.01q.1.07.18.18.07.12.07.25zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.8v-2.73zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z" />
|
||||
</svg>
|
||||
</Link>
|
||||
<Link
|
||||
href={
|
||||
encodeURI(
|
||||
`https://outlook.office.com/calendar/0/deeplink/compose?body=${
|
||||
eventType.description
|
||||
}&enddt=${date
|
||||
.add(calculatedDuration, "minute")
|
||||
.utc()
|
||||
.format()}&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=${date
|
||||
.utc()
|
||||
.format()}&subject=${eventName}`
|
||||
) +
|
||||
(locationVideoCallUrl
|
||||
? `&location=${encodeURIComponent(locationVideoCallUrl)}`
|
||||
: "")
|
||||
}
|
||||
className="text-default border-subtle mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Microsoft Office</title>
|
||||
<path d="M21.53 4.306v15.363q0 .807-.472 1.433-.472.627-1.253.85l-6.888 1.974q-.136.037-.29.055-.156.019-.293.019-.396 0-.72-.105-.321-.106-.656-.292l-4.505-2.544q-.248-.137-.391-.366-.143-.23-.143-.515 0-.434.304-.738.304-.305.739-.305h5.831V4.964l-4.38 1.563q-.533.187-.856.658-.322.472-.322 1.03v8.078q0 .496-.248.912-.25.416-.683.651l-2.072 1.13q-.286.148-.571.148-.497 0-.844-.347-.348-.347-.348-.844V6.563q0-.62.33-1.19.328-.571.874-.881L11.07.285q.248-.136.534-.21.285-.075.57-.075.211 0 .38.031.166.031.364.093l6.888 1.899q.384.11.7.329.317.217.547.52.23.305.353.67.125.367.125.764zm-1.588 15.363V4.306q0-.273-.16-.478-.163-.204-.423-.28l-3.388-.93q-.397-.111-.794-.23-.397-.117-.794-.216v19.68l4.976-1.427q.26-.074.422-.28.161-.204.161-.477z" />
|
||||
</svg>
|
||||
</Link>
|
||||
{(() => {
|
||||
try {
|
||||
const calendarLink = eventLink();
|
||||
if (!calendarLink) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={`data:text/calendar,${calendarLink}`}
|
||||
className="border-subtle text-default mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
download={`${eventType.title}.ics`}>
|
||||
<svg
|
||||
version="1.1"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 1000 1000"
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4">
|
||||
<title>{t("other")}</title>
|
||||
<path d="M971.3,154.9c0-34.7-28.2-62.9-62.9-62.9H611.7c-1.3,0-2.6,0.1-3.9,0.2V10L28.7,87.3v823.4L607.8,990v-84.6c1.3,0.1,2.6,0.2,3.9,0.2h296.7c34.7,0,62.9-28.2,62.9-62.9V154.9z M607.8,636.1h44.6v-50.6h-44.6v-21.9h44.6v-50.6h-44.6v-92h277.9v230.2c0,3.8-3.1,7-7,7H607.8V636.1z M117.9,644.7l-50.6-2.4V397.5l50.6-2.2V644.7z M288.6,607.3c17.6,0.6,37.3-2.8,49.1-7.2l9.1,48c-11,5.1-35.6,9.9-66.9,8.3c-85.4-4.3-127.5-60.7-127.5-132.6c0-86.2,57.8-136.7,133.2-140.1c30.3-1.3,53.7,4,64.3,9.2l-12.2,48.9c-12.1-4.9-28.8-9.2-49.5-8.6c-45.3,1.2-79.5,30.1-79.5,87.4C208.8,572.2,237.8,605.7,288.6,607.3z M455.5,665.2c-32.4-1.6-63.7-11.3-79.1-20.5l12.6-50.7c16.8,9.1,42.9,18.5,70.4,19.4c30.1,1,46.3-10.7,46.3-29.3c0-17.8-14-28.1-48.8-40.6c-46.9-16.4-76.8-41.7-76.8-81.5c0-46.6,39.3-84.1,106.8-87.1c33.3-1.5,58.3,4.2,76.5,11.2l-15.4,53.3c-12.1-5.3-33.5-12.8-62.3-12c-28.3,0.8-41.9,13.6-41.9,28.1c0,17.8,16.1,25.5,53.6,39c52.9,18.5,78.4,45.3,78.4,86.4C575.6,629.7,536.2,669.2,455.5,665.2z M935.3,842.7c0,14.9-12.1,27-27,27H611.7c-1.3,0-2.6-0.2-3.9-0.4V686.2h270.9c19.2,0,34.9-15.6,34.9-34.9V398.4c0-19.2-15.6-34.9-34.9-34.9h-47.1v-32.3H808v32.3h-44.8v-32.3h-22.7v32.3h-43.3v-32.3h-22.7v32.3H628v-32.3h-20.2v-203c1.31.2,2.6-0.4,3.9-0.4h296.7c14.9,0,27,12.1,27,27L935.3,842.7L935.3,842.7z" />
|
||||
</svg>
|
||||
</Link>
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to generate .ics download link:", error);
|
||||
return null;
|
||||
}
|
||||
})()}
|
||||
{googleCalendarLink && (
|
||||
<Link
|
||||
href={googleCalendarLink}
|
||||
className="text-default border-subtle h-10 w-10 rounded-sm border px-3 py-2 ltr:mr-2 rtl:ml-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Google</title>
|
||||
<path d="M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" />
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
{microsoftOutlookLink && (
|
||||
<Link
|
||||
href={microsoftOutlookLink}
|
||||
className="border-subtle text-default mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Microsoft Outlook</title>
|
||||
<path d="M7.88 12.04q0 .45-.11.87-.1.41-.33.74-.22.33-.58.52-.37.2-.87.2t-.85-.2q-.35-.21-.57-.55-.22-.33-.33-.75-.1-.42-.1-.86t.1-.87q.1-.43.34-.76.22-.34.59-.54.36-.2.87-.2t.86.2q.35.21.57.55.22.34.31.77.1.43.1.88zM24 12v9.38q0 .46-.33.8-.33.32-.8.32H7.13q-.46 0-.8-.33-.32-.33-.32-.8V18H1q-.41 0-.7-.3-.3-.29-.3-.7V7q0-.41.3-.7Q.58 6 1 6h6.5V2.55q0-.44.3-.75.3-.3.75-.3h12.9q.44 0 .75.3.3.3.3.75V10.85l1.24.72h.01q.1.07.18.18.07.12.07.25zm-6-8.25v3h3v-3zm0 4.5v3h3v-3zm0 4.5v1.83l3.05-1.83zm-5.25-9v3h3.75v-3zm0 4.5v3h3.75v-3zm0 4.5v2.03l2.41 1.5 1.34-.8v-2.73zM9 3.75V6h2l.13.01.12.04v-2.3zM5.98 15.98q.9 0 1.6-.3.7-.32 1.19-.86.48-.55.73-1.28.25-.74.25-1.61 0-.83-.25-1.55-.24-.71-.71-1.24t-1.15-.83q-.68-.3-1.55-.3-.92 0-1.64.3-.71.3-1.2.85-.5.54-.75 1.3-.25.74-.25 1.63 0 .85.26 1.56.26.72.74 1.23.48.52 1.17.81.69.3 1.56.3zM7.5 21h12.39L12 16.08V17q0 .41-.3.7-.29.3-.7.3H7.5zm15-.13v-7.24l-5.9 3.54Z" />
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
{microsoftOfficeLink && (
|
||||
<Link
|
||||
href={microsoftOfficeLink}
|
||||
className="text-default border-subtle mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
target="_blank">
|
||||
<svg
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24">
|
||||
<title>Microsoft Office</title>
|
||||
<path d="M21.53 4.306v15.363q0 .807-.472 1.433-.472.627-1.253.85l-6.888 1.974q-.136.037-.29.055-.156.019-.293.019-.396 0-.72-.105-.321-.106-.656-.292l-4.505-2.544q-.248-.137-.391-.366-.143-.23-.143-.515 0-.434.304-.738.304-.305.739-.305h5.831V4.964l-4.38 1.563q-.533.187-.856.658-.322.472-.322 1.03v8.078q0 .496-.248.912-.25.416-.683.651l-2.072 1.13q-.286.148-.571.148-.497 0-.844-.347-.348-.347-.348-.844V6.563q0-.62.33-1.19.328-.571.874-.881L11.07.285q.248-.136.534-.21.285-.075.57-.075.211 0 .38.031.166.031.364.093l6.888 1.899q.384.11.7.329.317.217.547.52.23.305.353.67.125.367.125.764zm-1.588 15.363V4.306q0-.273-.16-.478-.163-.204-.423-.28l-3.388-.93q-.397-.111-.794-.23-.397-.117-.794-.216v19.68l4.976-1.427q.26-.074.422-.28.161-.204.161-.477z" />
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
{icsLink && (
|
||||
<Link
|
||||
href={icsLink}
|
||||
className="border-subtle text-default mx-2 h-10 w-10 rounded-sm border px-3 py-2"
|
||||
download={`${eventType.title}.ics`}>
|
||||
<svg
|
||||
version="1.1"
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 1000 1000"
|
||||
className="-mt-1.5 mr-1 inline-block h-4 w-4">
|
||||
<title>{t("other")}</title>
|
||||
<path d="M971.3,154.9c0-34.7-28.2-62.9-62.9-62.9H611.7c-1.3,0-2.6,0.1-3.9,0.2V10L28.7,87.3v823.4L607.8,990v-84.6c1.3,0.1,2.6,0.2,3.9,0.2h296.7c34.7,0,62.9-28.2,62.9-62.9V154.9z M607.8,636.1h44.6v-50.6h-44.6v-21.9h44.6v-50.6h-44.6v-92h277.9v230.2c0,3.8-3.1,7-7,7H607.8V636.1z M117.9,644.7l-50.6-2.4V397.5l50.6-2.2V644.7z M288.6,607.3c17.6,0.6,37.3-2.8,49.1-7.2l9.1,48c-11,5.1-35.6,9.9-66.9,8.3c-85.4-4.3-127.5-60.7-127.5-132.6c0-86.2,57.8-136.7,133.2-140.1c30.3-1.3,53.7,4,64.3,9.2l-12.2,48.9c-12.1-4.9-28.8-9.2-49.5-8.6c-45.3,1.2-79.5,30.1-79.5,87.4C208.8,572.2,237.8,605.7,288.6,607.3z M455.5,665.2c-32.4-1.6-63.7-11.3-79.1-20.5l12.6-50.7c16.8,9.1,42.9,18.5,70.4,19.4c30.1,1,46.3-10.7,46.3-29.3c0-17.8-14-28.1-48.8-40.6c-46.9-16.4-76.8-41.7-76.8-81.5c0-46.6,39.3-84.1,106.8-87.1c33.3-1.5,58.3,4.2,76.5,11.2l-15.4,53.3c-12.1-5.3-33.5-12.8-62.3-12c-28.3,0.8-41.9,13.6-41.9,28.1c0,17.8,16.1,25.5,53.6,39c52.9,18.5,78.4,45.3,78.4,86.4C575.6,629.7,536.2,669.2,455.5,665.2z M935.3,842.7c0,14.9-12.1,27-27,27H611.7c-1.3,0-2.6-0.2-3.9-0.4V686.2h270.9c19.2,0,34.9-15.6,34.9-34.9V398.4c0-19.2-15.6-34.9-34.9-34.9h-47.1v-32.3H808v32.3h-44.8v-32.3h-22.7v32.3h-43.3v-32.3h-22.7v32.3H628v-32.3h-20.2v-203c1.31.2,2.6-0.4,3.9-0.4h296.7c14.9,0,27,12.1,27,27L935.3,842.7L935.3,842.7z" />
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
+2602
-599
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,214 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { createEvent } from "ics";
|
||||
import { RRule } from "rrule";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent";
|
||||
|
||||
import { getCalendarLinks, CalendarLinkType } from "./getCalendarLinks";
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock("ics", () => ({
|
||||
createEvent: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@calcom/lib/isRecurringEvent", () => ({
|
||||
parseRecurringEvent: vi.fn(),
|
||||
}));
|
||||
|
||||
describe("getCalendarLinks", () => {
|
||||
// Mock data for tests
|
||||
const mockStartTime = new Date("2023-01-15T10:00:00Z");
|
||||
const mockEndTime = new Date("2023-01-15T11:00:00Z");
|
||||
const mockDayjsStartTime = dayjs(mockStartTime);
|
||||
const mockDayjsEndTime = dayjs(mockEndTime);
|
||||
|
||||
// Mock translation function
|
||||
const mockT = ((key: string) => key) as TFunction;
|
||||
|
||||
// Mock createEvent implementation
|
||||
const mockIcsValue = "BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR";
|
||||
|
||||
// Baseline mock objects that can be reused across tests
|
||||
const baseMockBooking = {
|
||||
startTime: mockStartTime,
|
||||
endTime: mockEndTime,
|
||||
location: "Test Location",
|
||||
title: "Test Title",
|
||||
responses: {},
|
||||
metadata: {},
|
||||
};
|
||||
|
||||
const baseMockEventType = {
|
||||
recurringEvent: {},
|
||||
description: "Test Description",
|
||||
eventName: "Test Event",
|
||||
isDynamic: false,
|
||||
length: 60,
|
||||
team: null,
|
||||
users: [{ name: "Test User" }],
|
||||
title: "Test Title",
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
// Reset mocks before each test
|
||||
vi.resetAllMocks();
|
||||
|
||||
// Default mock implementations
|
||||
(createEvent as jest.Mock).mockReturnValue({ value: mockIcsValue });
|
||||
(parseRecurringEvent as jest.Mock).mockReturnValue(null);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("should return all calendar links", async () => {
|
||||
const result = getCalendarLinks({ booking: baseMockBooking, eventType: baseMockEventType, t: mockT });
|
||||
const googleLink = result.find((link) => link.id === CalendarLinkType.GOOGLE_CALENDAR);
|
||||
const microsoftOfficeLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OFFICE);
|
||||
const microsoftOutlookLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OUTLOOK);
|
||||
const icsLink = result.find((link) => link.id === CalendarLinkType.ICS);
|
||||
|
||||
expect(result).toHaveLength(4);
|
||||
expect(googleLink).toBeDefined();
|
||||
expect(microsoftOfficeLink).toBeDefined();
|
||||
expect(microsoftOutlookLink).toBeDefined();
|
||||
expect(icsLink).toBeDefined();
|
||||
|
||||
(function verifyGoogleLink() {
|
||||
expect(googleLink?.link).toContain("https://calendar.google.com/calendar/r/eventedit");
|
||||
expect(googleLink?.link).toContain("dates=");
|
||||
expect(googleLink?.link).toContain(
|
||||
`${mockDayjsStartTime.utc().format("YYYYMMDDTHHmmss[Z]")}/${mockDayjsEndTime
|
||||
.utc()
|
||||
.format("YYYYMMDDTHHmmss[Z]")}`
|
||||
);
|
||||
expect(googleLink?.link).toContain(`details=${encodeURIComponent(baseMockEventType.description)}`);
|
||||
})();
|
||||
|
||||
(function verifyMicrosoftOfficeLink() {
|
||||
expect(microsoftOfficeLink?.link).toContain("https://outlook.office.com/calendar/0/deeplink/compose");
|
||||
expect(microsoftOfficeLink?.link).toContain("enddt=");
|
||||
expect(microsoftOfficeLink?.link).toContain("startdt=");
|
||||
expect(microsoftOfficeLink?.link).toContain("body=Test%20Description");
|
||||
})();
|
||||
|
||||
(function verifymicrosoftOutlookLink() {
|
||||
expect(microsoftOutlookLink?.link).toContain("https://outlook.live.com/calendar/0/deeplink/compose");
|
||||
expect(microsoftOutlookLink?.link).toContain("enddt=");
|
||||
expect(microsoftOutlookLink?.link).toContain("startdt=");
|
||||
expect(microsoftOutlookLink?.link).toContain("body=Test%20Description");
|
||||
})();
|
||||
|
||||
(function verifyIcsLink() {
|
||||
expect(icsLink).toBeDefined();
|
||||
expect(icsLink?.link).toContain("data:text/calendar");
|
||||
expect(icsLink?.link).toContain(encodeURIComponent(mockIcsValue));
|
||||
expect(createEvent).toHaveBeenCalled();
|
||||
expect(createEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
description: baseMockEventType.description,
|
||||
})
|
||||
);
|
||||
})();
|
||||
});
|
||||
|
||||
it("should use videoCallUrl from metadata when available", async () => {
|
||||
const videoCallUrl = "https://zoom.com/test";
|
||||
const booking = {
|
||||
...baseMockBooking,
|
||||
metadata: { videoCallUrl },
|
||||
};
|
||||
|
||||
const result = getCalendarLinks({ booking, eventType: baseMockEventType, t: mockT });
|
||||
|
||||
// Check that all links contain the videoCallUrl
|
||||
const googleLink = result.find((link) => link.id === CalendarLinkType.GOOGLE_CALENDAR);
|
||||
const microsoftOfficeLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OFFICE);
|
||||
const microsoftOutlookLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OUTLOOK);
|
||||
|
||||
expect(googleLink?.link).toContain(`location=${encodeURIComponent(videoCallUrl)}`);
|
||||
expect(microsoftOfficeLink?.link).toContain(`location=${encodeURIComponent(videoCallUrl)}`);
|
||||
expect(microsoftOutlookLink?.link).toContain(`location=${encodeURIComponent(videoCallUrl)}`);
|
||||
});
|
||||
|
||||
it("should handle custom title from dynamic event", async () => {
|
||||
const customTitle = "Custom Dynamic Title";
|
||||
const booking = {
|
||||
...baseMockBooking,
|
||||
responses: { title: customTitle, name: "Test Attendee" },
|
||||
};
|
||||
|
||||
const eventType = {
|
||||
...baseMockEventType,
|
||||
isDynamic: true, // This makes it use the custom title
|
||||
};
|
||||
|
||||
const result = getCalendarLinks({ booking, eventType, t: mockT });
|
||||
|
||||
const googleLink = result.find((link) => link.id === CalendarLinkType.GOOGLE_CALENDAR);
|
||||
expect(googleLink?.link).toContain(`details=${encodeURIComponent(eventType.description)}`);
|
||||
expect(googleLink?.link).toContain(`text=${customTitle}`);
|
||||
|
||||
// Check Office 365 link
|
||||
const microsoftOfficeLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OFFICE);
|
||||
expect(microsoftOfficeLink?.link).toContain("body=Test%20Description");
|
||||
expect(microsoftOfficeLink?.link).toContain(`subject=${customTitle}`);
|
||||
|
||||
// Check Outlook link
|
||||
const microsoftOutlookLink = result.find((link) => link.id === CalendarLinkType.MICROSOFT_OUTLOOK);
|
||||
expect(microsoftOutlookLink?.link).toContain("body=Test%20Description");
|
||||
expect(microsoftOutlookLink?.link).toContain(`subject=${encodeURIComponent(customTitle)}`);
|
||||
});
|
||||
|
||||
it("should handle recurring events - Only Google Calendar supports at the moment", async () => {
|
||||
// Mock a recurring event rule
|
||||
const mockRecurringRule = {
|
||||
freq: 2, // WEEKLY
|
||||
interval: 1,
|
||||
count: 5,
|
||||
};
|
||||
|
||||
(parseRecurringEvent as jest.Mock).mockReturnValue(mockRecurringRule);
|
||||
|
||||
const eventType = {
|
||||
...baseMockEventType,
|
||||
recurringEvent: { count: 5, freq: 2, interval: 1 },
|
||||
};
|
||||
|
||||
const mockRRuleString = "FREQ=WEEKLY;INTERVAL=1;COUNT=5";
|
||||
vi.spyOn(RRule.prototype, "toString").mockReturnValue(mockRRuleString);
|
||||
|
||||
const result = getCalendarLinks({ booking: baseMockBooking, eventType, t: mockT });
|
||||
const googleLink = result.find((link) => link.id === "googleCalendar");
|
||||
|
||||
expect(googleLink).toBeDefined();
|
||||
expect(googleLink?.link).toContain(`recur=${encodeURIComponent(mockRRuleString)}`);
|
||||
});
|
||||
|
||||
it("should handle error in ICS generation", async () => {
|
||||
// Mock createEvent to return an error
|
||||
(createEvent as jest.Mock).mockReturnValue({ error: new Error("ICS generation failed") });
|
||||
|
||||
// Mock console.error to avoid test output noise
|
||||
const consoleErrorSpy = vi.spyOn(console, "error").mockImplementation(() => undefined);
|
||||
|
||||
const result = getCalendarLinks({ booking: baseMockBooking, eventType: baseMockEventType, t: mockT });
|
||||
const icsLink = result.find((link) => link.id === "ics");
|
||||
|
||||
expect(icsLink).toBeDefined();
|
||||
expect(icsLink?.link).toBe("");
|
||||
expect(consoleErrorSpy).toHaveBeenCalled();
|
||||
|
||||
// Verify createEvent was called with the correct description
|
||||
expect(createEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
description: baseMockEventType.description,
|
||||
})
|
||||
);
|
||||
|
||||
consoleErrorSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,255 @@
|
||||
import type { Prisma } from "@prisma/client";
|
||||
import type { TFunction } from "i18next";
|
||||
import { createEvent } from "ics";
|
||||
import { RRule } from "rrule";
|
||||
import type { z } from "zod";
|
||||
|
||||
import type { Dayjs } from "@calcom/dayjs";
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import type { nameObjectSchema } from "@calcom/lib/event";
|
||||
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
import type { RecurringEvent } from "@calcom/types/Calendar";
|
||||
|
||||
import { getEventName } from "../event";
|
||||
|
||||
type RecurringEventOrPrismaJsonObject = RecurringEvent | Prisma.JsonObject | null | undefined;
|
||||
export const enum CalendarLinkType {
|
||||
GOOGLE_CALENDAR = "googleCalendar",
|
||||
MICROSOFT_OFFICE = "microsoftOffice",
|
||||
MICROSOFT_OUTLOOK = "microsoftOutlook",
|
||||
ICS = "ics",
|
||||
}
|
||||
|
||||
const buildICalLink = ({
|
||||
startTime,
|
||||
endTime,
|
||||
title,
|
||||
description,
|
||||
location,
|
||||
}: {
|
||||
startTime: Dayjs;
|
||||
endTime: Dayjs;
|
||||
title: string;
|
||||
description: string | null;
|
||||
location: string | null;
|
||||
}) => {
|
||||
const durationInMinutes = endTime.diff(startTime, "minutes");
|
||||
|
||||
const iCalEvent = createEvent({
|
||||
start: [
|
||||
startTime.toDate().getUTCFullYear(),
|
||||
(startTime.toDate().getUTCMonth() as number) + 1,
|
||||
startTime.toDate().getUTCDate(),
|
||||
startTime.toDate().getUTCHours(),
|
||||
startTime.toDate().getUTCMinutes(),
|
||||
],
|
||||
startInputType: "utc",
|
||||
title,
|
||||
duration: {
|
||||
minutes: durationInMinutes,
|
||||
},
|
||||
...(description ? { description } : {}),
|
||||
...(location ? { location } : {}),
|
||||
});
|
||||
|
||||
if (iCalEvent.error) {
|
||||
throw iCalEvent.error;
|
||||
}
|
||||
|
||||
return `data:text/calendar,${encodeURIComponent(iCalEvent.value ? iCalEvent.value : false)}`;
|
||||
};
|
||||
|
||||
const buildGoogleCalendarLink = ({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation,
|
||||
recurringEvent,
|
||||
}: {
|
||||
startTime: Dayjs;
|
||||
endTime: Dayjs;
|
||||
eventName: string;
|
||||
eventDescription: string | null;
|
||||
bookingLocation: string | null;
|
||||
recurringEvent: RecurringEventOrPrismaJsonObject;
|
||||
}) => {
|
||||
const startTimeInUtcFormat = startTime.utc().format("YYYYMMDDTHHmmss[Z]");
|
||||
const endTimeInUtcFormat = endTime.utc().format("YYYYMMDDTHHmmss[Z]");
|
||||
const recurrence = recurringEvent ? encodeURIComponent(new RRule(recurringEvent).toString()) : "";
|
||||
|
||||
const location = bookingLocation ? encodeURIComponent(bookingLocation) : "";
|
||||
const description = encodeURIComponent(eventDescription ?? "");
|
||||
|
||||
const googleCalendarLink = `https://calendar.google.com/calendar/r/eventedit?dates=${startTimeInUtcFormat}/${endTimeInUtcFormat}&text=${eventName}&details=${description}${
|
||||
location ? `&location=${location}` : ""
|
||||
}${recurrence ? `&recur=${recurrence}` : ""}`;
|
||||
|
||||
return googleCalendarLink;
|
||||
};
|
||||
|
||||
const buildMicrosoftOfficeLink = ({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation,
|
||||
}: {
|
||||
startTime: Dayjs;
|
||||
endTime: Dayjs;
|
||||
eventName: string;
|
||||
eventDescription: string | null;
|
||||
bookingLocation: string | null;
|
||||
}) => {
|
||||
const startTimeInUtcFormat = startTime.utc().format();
|
||||
const endTimeInUtcFormat = endTime.utc().format();
|
||||
const location = bookingLocation ? encodeURIComponent(bookingLocation) : "";
|
||||
const description = encodeURIComponent(eventDescription ?? "");
|
||||
|
||||
// TODO: Why do we need to encode URI this href but not the google calendar link?
|
||||
const microsoftOfficeLink = `https://outlook.office.com/calendar/0/deeplink/compose?body=${description}&enddt=${endTimeInUtcFormat}&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=${startTimeInUtcFormat}&subject=${eventName}${
|
||||
location ? `&location=${location}` : ""
|
||||
}`;
|
||||
return microsoftOfficeLink;
|
||||
};
|
||||
|
||||
const buildMicrosoftOutlookLink = ({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation,
|
||||
}: {
|
||||
startTime: Dayjs;
|
||||
endTime: Dayjs;
|
||||
eventName: string;
|
||||
eventDescription: string | null;
|
||||
bookingLocation: string | null;
|
||||
}) => {
|
||||
const startTimeInUtcFormat = startTime.utc().format();
|
||||
const endTimeInUtcFormat = endTime.utc().format();
|
||||
const location = bookingLocation ? encodeURIComponent(bookingLocation) : "";
|
||||
const microsoftOutlookLink =
|
||||
encodeURI(
|
||||
`https://outlook.live.com/calendar/0/deeplink/compose?body=${eventDescription}&enddt=${endTimeInUtcFormat}&path=%2Fcalendar%2Faction%2Fcompose&rru=addevent&startdt=${startTimeInUtcFormat}&subject=${eventName}`
|
||||
) + (location ? `&location=${location}` : "");
|
||||
return microsoftOutlookLink;
|
||||
};
|
||||
|
||||
export const getCalendarLinks = ({
|
||||
booking,
|
||||
eventType,
|
||||
t,
|
||||
}: {
|
||||
booking: {
|
||||
startTime: Date;
|
||||
endTime: Date;
|
||||
location: string | null;
|
||||
title: string;
|
||||
responses: Prisma.JsonObject;
|
||||
metadata: Prisma.JsonObject | null;
|
||||
};
|
||||
eventType: {
|
||||
recurringEvent: RecurringEventOrPrismaJsonObject;
|
||||
description?: string | null;
|
||||
eventName?: string | null;
|
||||
isDynamic: boolean;
|
||||
length: number;
|
||||
team?: {
|
||||
name: string;
|
||||
} | null;
|
||||
users: {
|
||||
name: string | null;
|
||||
}[];
|
||||
title: string;
|
||||
};
|
||||
t: TFunction;
|
||||
}) => {
|
||||
let evtName = eventType.eventName;
|
||||
const videoCallUrl = bookingMetadataSchema.parse(booking?.metadata || {})?.videoCallUrl ?? null;
|
||||
|
||||
if (eventType.isDynamic && booking.responses.title) {
|
||||
evtName = booking.responses.title as string;
|
||||
}
|
||||
const eventNameObject = {
|
||||
attendeeName: booking.responses.name as z.infer<typeof nameObjectSchema> | string,
|
||||
eventType: eventType.title,
|
||||
eventName: evtName,
|
||||
host: eventType.team?.name || eventType.users[0]?.name || "Nameless",
|
||||
location: booking.location,
|
||||
bookingFields: booking.responses,
|
||||
eventDuration: eventType.length,
|
||||
t,
|
||||
};
|
||||
|
||||
// Create event name and description
|
||||
const eventName = getEventName(eventNameObject, true);
|
||||
const eventDescription = eventType.description || "";
|
||||
|
||||
// Calculate start and end times
|
||||
const startTime = dayjs(booking.startTime);
|
||||
const endTime = dayjs(booking.endTime);
|
||||
const recurringEvent = eventType.recurringEvent;
|
||||
|
||||
const googleCalendarLink = buildGoogleCalendarLink({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation: videoCallUrl ?? null,
|
||||
recurringEvent,
|
||||
});
|
||||
|
||||
const microsoftOfficeLink = buildMicrosoftOfficeLink({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation: videoCallUrl,
|
||||
});
|
||||
|
||||
const microsoftOutlookLink = buildMicrosoftOutlookLink({
|
||||
startTime,
|
||||
endTime,
|
||||
eventName,
|
||||
eventDescription,
|
||||
bookingLocation: videoCallUrl,
|
||||
});
|
||||
|
||||
// Generate ICS file link
|
||||
let icsFileLink = "";
|
||||
try {
|
||||
icsFileLink = buildICalLink({
|
||||
startTime,
|
||||
endTime,
|
||||
title: eventName,
|
||||
description: eventDescription ?? null,
|
||||
location: videoCallUrl ?? null,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error generating ICS file", error);
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
label: "Google Calendar",
|
||||
id: CalendarLinkType.GOOGLE_CALENDAR,
|
||||
link: googleCalendarLink,
|
||||
},
|
||||
{
|
||||
label: "Microsoft Office",
|
||||
id: CalendarLinkType.MICROSOFT_OFFICE,
|
||||
link: microsoftOfficeLink,
|
||||
},
|
||||
{
|
||||
label: "Microsoft Outlook",
|
||||
id: CalendarLinkType.MICROSOFT_OUTLOOK,
|
||||
link: microsoftOutlookLink,
|
||||
},
|
||||
{
|
||||
label: "ICS",
|
||||
id: CalendarLinkType.ICS,
|
||||
link: icsFileLink,
|
||||
},
|
||||
];
|
||||
};
|
||||
@@ -22,9 +22,9 @@ export type EventNameObjectType = {
|
||||
eventName?: string | null;
|
||||
teamName?: string | null;
|
||||
host: string;
|
||||
location?: string;
|
||||
location?: string | null;
|
||||
eventDuration: number;
|
||||
bookingFields?: Prisma.JsonObject;
|
||||
bookingFields?: Prisma.JsonObject | null;
|
||||
t: TFunction;
|
||||
};
|
||||
|
||||
@@ -106,7 +106,7 @@ export function getEventName(eventNameObj: EventNameObjectType, forAttendeeView
|
||||
return dynamicEventName;
|
||||
}
|
||||
|
||||
export const validateCustomEventName = (value: string, bookingFields?: Prisma.JsonObject) => {
|
||||
export const validateCustomEventName = (value: string, bookingFields?: Prisma.JsonObject | null) => {
|
||||
let customInputVariables: string[] = [];
|
||||
if (bookingFields) {
|
||||
customInputVariables = Object.keys(bookingFields).map((customInput) => {
|
||||
|
||||
@@ -113,3 +113,4 @@ export { getTeamMemberEmailForResponseOrContactUsingUrlQuery };
|
||||
export { SelectedCalendarRepository } from "@calcom/lib/server/repository/selectedCalendar";
|
||||
export { encryptServiceAccountKey } from "@calcom/lib/server/serviceAccountKey";
|
||||
export { createHandler as createApiKeyHandler } from "@calcom/trpc/server/routers/viewer/apiKeys/create.handler";
|
||||
export { getCalendarLinks } from "@calcom/lib/bookings/getCalendarLinks";
|
||||
@@ -11,6 +11,7 @@
|
||||
"scripts": {
|
||||
"build": "yarn vite build",
|
||||
"build:watch": "yarn vite build --watch",
|
||||
"watch-lru-fix": "watch -n 1 'sed -i'' -e \"s/const CACHE = new lruCache\\.LRUCache({ max: 1e3 });/const CACHE = new lruCache({ max: 1e3 });/g\" ./dist/index.cjs'",
|
||||
"build:dev": "yarn vite build && sed -i'' -e 's/const CACHE = new lruCache\\.LRUCache({ max: 1e3 });/const CACHE = new lruCache({ max: 1e3 });/g' ./dist/index.cjs",
|
||||
"local": "node scripts/local.js && rm -rf dist && yarn build:dev && cd ../../.. && yarn",
|
||||
"publish": "yarn && node scripts/prepublish.js && rm -rf dist && yarn build && npm publish --access public",
|
||||
|
||||
@@ -2295,7 +2295,7 @@ __metadata:
|
||||
"@axiomhq/winston": ^1.2.0
|
||||
"@calcom/platform-constants": "*"
|
||||
"@calcom/platform-enums": "*"
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]4"
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]5"
|
||||
"@calcom/platform-libraries-0.0.2": "npm:@calcom/[email protected]"
|
||||
"@calcom/platform-types": "*"
|
||||
"@calcom/platform-utils": "*"
|
||||
@@ -2330,6 +2330,7 @@ __metadata:
|
||||
bull: ^4.12.4
|
||||
class-transformer: ^0.5.1
|
||||
class-validator: ^0.14.0
|
||||
concurrently: ^9.1.2
|
||||
cookie-parser: ^1.4.6
|
||||
dotenv: ^16.3.1
|
||||
fs-extra: ^11.2.0
|
||||
@@ -3341,13 +3342,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@calcom/platform-libraries@npm:@calcom/[email protected]4":
|
||||
version: 0.0.144
|
||||
resolution: "@calcom/platform-libraries@npm:0.0.144"
|
||||
"@calcom/platform-libraries@npm:@calcom/[email protected]5":
|
||||
version: 0.0.145
|
||||
resolution: "@calcom/platform-libraries@npm:0.0.145"
|
||||
dependencies:
|
||||
"@calcom/features": "*"
|
||||
"@calcom/lib": "*"
|
||||
checksum: 2b4ac2ca7bf343baf34106fdc68cece3fac9e9281112d05fb3a1ba1cd3c6357b4d1db9f844588908535fccc093ece36f295f4889ad868b3848030b9f3000b0d8
|
||||
checksum: 437d56504b989be8de50e98f30c0f154d7103bb1d28ff1df1cb37fae84ce27c2cf5eb93a80fdbd2b971ba935cf20e0341dc1047c2b8403b2e1831353ace1c742
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -18671,6 +18672,24 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"concurrently@npm:^9.1.2":
|
||||
version: 9.1.2
|
||||
resolution: "concurrently@npm:9.1.2"
|
||||
dependencies:
|
||||
chalk: ^4.1.2
|
||||
lodash: ^4.17.21
|
||||
rxjs: ^7.8.1
|
||||
shell-quote: ^1.8.1
|
||||
supports-color: ^8.1.1
|
||||
tree-kill: ^1.2.2
|
||||
yargs: ^17.7.2
|
||||
bin:
|
||||
conc: dist/bin/concurrently.js
|
||||
concurrently: dist/bin/concurrently.js
|
||||
checksum: 9e25e8ee6272ada26739aff1fb43e96ac458fafca82f45b8360bdd9115d60bbc679d282dfc52001b861b6e9f32b3063aed975691d8dec9e62807a9679763a1d8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"conf@npm:10.2.0":
|
||||
version: 10.2.0
|
||||
resolution: "conf@npm:10.2.0"
|
||||
@@ -34936,6 +34955,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"shell-quote@npm:^1.8.1":
|
||||
version: 1.8.2
|
||||
resolution: "shell-quote@npm:1.8.2"
|
||||
checksum: 1e97b62ced1c4c5135015978ebf273bed1f425a68cf84163e83fbb0f34b3ff9471e656720dab2b7cbb4ae0f58998e686d17d166c28dfb3662acd009e8bd7faed
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"shelljs@npm:0.8.5":
|
||||
version: 0.8.5
|
||||
resolution: "shelljs@npm:0.8.5"
|
||||
@@ -36999,7 +37025,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"tree-kill@npm:1.2.2":
|
||||
"tree-kill@npm:1.2.2, tree-kill@npm:^1.2.2":
|
||||
version: 1.2.2
|
||||
resolution: "tree-kill@npm:1.2.2"
|
||||
bin:
|
||||
|
||||
Reference in new issue
Block a user