fix: platform libraries barrel file extract event-types (#19846)

* fix: event-types

* chore: added "+ group link" tip (#19809)

* added + link tip

* nit

---------

Co-authored-by: amrit <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Tushar Bhatt <[email protected]>

* Added fix to solve the id TypeError (#19810)

Co-authored-by: amrit <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Tushar Bhatt <[email protected]>

* Revert "fix: prevent background scroll on opening timezone select menu (#19789)" (#19814)

This reverts commit 1a96149ce3.

* fix: Calendar events attached to workflow emails are missing meeting link (#19790)

* fixup! fix: Calendar events attached to workflow emails are missing meeting link (#19790)

* chore: fix type errors

* fix: wrong import in e2e file

* fix: tsconfig api v2 for /event-types

* fix: import and refactor

* fixed remaning type issues

* undo extra changes

* bump platform libs

* Update event-types.controller.e2e-spec.ts

* fix: test with seats enabled

---------

Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: amrit <[email protected]>
Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Tushar Bhatt <[email protected]>
Co-authored-by: Harshit Singh <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
Co-authored-by: Morgan Vernay <[email protected]>
Co-authored-by: Morgan <[email protected]>
This commit is contained in:
27 files changed
+281 -150

No files matched your search

@@ -23,8 +23,8 @@ import {
import { ApiTags as DocsTags, ApiExcludeController as DocsExcludeController } from "@nestjs/swagger";
import { ERROR_STATUS, SUCCESS_STATUS } from "@calcom/platform-constants";
import type { UpdateEventTypeReturn } from "@calcom/platform-libraries";
import { ConnectedApps } from "@calcom/platform-libraries";
import type { UpdateEventTypeReturn } from "@calcom/platform-libraries/event-types";
import { ApiResponse } from "@calcom/platform-types";
/*
@@ -81,7 +81,7 @@ export class AtomsController {
): Promise<ApiResponse<unknown>> {
const { teamId } = queryParams;
const app = await this.eventTypesService.getEventTypesAppIntegration(appSlug, user.id, user.name, teamId);
const app = await this.eventTypesService.getEventTypesAppIntegration(appSlug, user, teamId);
return {
status: SUCCESS_STATUS,
@@ -124,7 +124,11 @@ export class AtomsController {
@Param("eventTypeId", ParseIntPipe) eventTypeId: number,
@Body() body: UpdateEventTypeReturn
): Promise<ApiResponse<UpdateEventTypeReturn>> {
const eventType = await this.eventTypesService.updateEventType(eventTypeId, body, user);
const eventType = await this.eventTypesService.updateEventType(
eventTypeId,
{ ...body, id: eventTypeId },
user
);
return {
status: SUCCESS_STATUS,
data: eventType,
@@ -140,7 +144,12 @@ export class AtomsController {
@Param("teamId", ParseIntPipe) teamId: number,
@Body() body: UpdateEventTypeReturn
): Promise<ApiResponse<UpdateEventTypeReturn>> {
const eventType = await this.eventTypesService.updateTeamEventType(eventTypeId, body, user, teamId);
const eventType = await this.eventTypesService.updateTeamEventType(
eventTypeId,
{ ...body, id: eventTypeId },
user,
teamId
);
return {
status: SUCCESS_STATUS,
data: eventType,
@@ -10,17 +10,11 @@ import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, NotFoundException, ForbiddenException } from "@nestjs/common";
import {
updateEventType,
TUpdateEventTypeInputSchema,
systemBeforeFieldEmail,
getEventTypeById,
getEnabledAppsFromCredentials,
getAppFromSlug,
MembershipRole,
EventTypeMetaDataSchema,
getClientSecretFromPayment,
getBulkEventTypes,
bulkUpdateEventsToDefaultLocation,
enrichUserWithDelegationConferencingCredentialsWithoutOrgId,
} from "@calcom/platform-libraries";
import type {
App,
@@ -31,6 +25,17 @@ import type {
TDependencyData,
CredentialPayload,
} from "@calcom/platform-libraries";
import {
getBulkEventTypes,
getEventTypeById,
bulkUpdateEventsToDefaultLocation,
} from "@calcom/platform-libraries/event-types";
import {
updateEventType,
TUpdateEventTypeInputSchema,
systemBeforeFieldEmail,
EventTypeMetaDataSchema,
} from "@calcom/platform-libraries/event-types";
import { PrismaClient } from "@calcom/prisma";
type EnabledAppType = App & {
@@ -104,7 +109,7 @@ export class EventTypesAtomService {
}
const eventType = await updateEventType({
input: { id: eventTypeId, ...body, bookingFields },
input: { ...body, id: eventTypeId, bookingFields },
ctx: {
user: eventTypeUser,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -117,7 +122,7 @@ export class EventTypesAtomService {
throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
}
return eventType.eventType;
return eventType;
}
async updateEventType(eventTypeId: number, body: TUpdateEventTypeInputSchema, user: UserWithProfile) {
@@ -134,7 +139,7 @@ export class EventTypesAtomService {
}
const eventType = await updateEventType({
input: { id: eventTypeId, ...body, bookingFields },
input: { ...body, id: eventTypeId, bookingFields },
ctx: {
user: eventTypeUser,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -147,10 +152,15 @@ export class EventTypesAtomService {
throw new NotFoundException(`Event type with id ${eventTypeId} not found`);
}
return eventType.eventType;
return eventType;
}
async checkCanUpdateTeamEventType(userId: number, eventTypeId: number, teamId: number, scheduleId: number) {
async checkCanUpdateTeamEventType(
userId: number,
eventTypeId: number,
teamId: number,
scheduleId: number | null | undefined
) {
await this.checkTeamOwnsEventType(userId, eventTypeId, teamId);
await this.teamEventTypeService.validateEventTypeExists(teamId, eventTypeId);
await this.eventTypeService.checkUserOwnsSchedule(userId, scheduleId);
@@ -179,11 +189,11 @@ export class EventTypesAtomService {
}
}
async getEventTypesAppIntegration(slug: string, userId: number, userName: string | null, teamId?: number) {
let credentials = await this.credentialsRepository.getAllUserCredentialsById(userId);
async getEventTypesAppIntegration(slug: string, user: UserWithProfile, teamId?: number) {
let credentials = await this.credentialsRepository.getAllUserCredentialsById(user.id);
let userTeams: TeamQuery[] = [];
if (teamId) {
const teamsQuery = await this.atomsRepository.getUserTeams(userId);
const teamsQuery = await this.atomsRepository.getUserTeams(user.id);
// If a team is a part of an org then include those apps
// Don't want to iterate over these parent teams
const filteredTeams: TeamQuery[] = [];
@@ -211,8 +221,17 @@ export class EventTypesAtomService {
credentials = credentials.concat(teamAppCredentials);
}
}
//TODO: enrich credentials for DelegationCredential
const enabledApps = await getEnabledAppsFromCredentials(credentials, {
// We only add delegationCredentials if the request for location options is for a user because DelegationCredential Credential is applicable to Users only.
const { credentials: allCredentials } = await enrichUserWithDelegationConferencingCredentialsWithoutOrgId(
{
user: {
...user,
credentials,
},
}
);
credentials = allCredentials;
const enabledApps = await getEnabledAppsFromCredentials(allCredentials, {
where: { slug },
});
const apps = await Promise.all(
@@ -265,7 +284,7 @@ export class EventTypesAtomService {
});
}
const credentialOwner: CredentialOwner = {
name: userName,
name: user.name,
teamId,
};
return {
@@ -4,7 +4,7 @@ import { TeamsRepository } from "@/modules/teams/teams/teams.repository";
import { UsersRepository } from "@/modules/users/users.repository";
import { BadRequestException, Injectable, NotFoundException } from "@nestjs/common";
import { transformTeamLocationsApiToInternal } from "@calcom/platform-libraries";
import { transformTeamLocationsApiToInternal } from "@calcom/platform-libraries/event-types";
import {
CreateTeamEventTypeInput_2024_06_14,
UpdateTeamEventTypeInput_2024_06_14,
@@ -12,6 +12,13 @@ import {
} from "@calcom/platform-types";
import { SchedulingType } from "@calcom/prisma/client";
export type TransformedCreateTeamEventTypeInput = Awaited<
ReturnType<InstanceType<typeof InputOrganizationsEventTypesService>["transformInputCreateTeamEventType"]>
>;
export type TransformedUpdateTeamEventTypeInput = Awaited<
ReturnType<InstanceType<typeof InputOrganizationsEventTypesService>["transformInputUpdateTeamEventType"]>
>;
@Injectable()
export class InputOrganizationsEventTypesService {
constructor(
@@ -1,5 +1,9 @@
import { MembershipsRepository } from "@/modules/memberships/memberships.repository";
import { OrganizationsEventTypesRepository } from "@/modules/organizations/event-types/organizations-event-types.repository";
import {
TransformedCreateTeamEventTypeInput,
TransformedUpdateTeamEventTypeInput,
} from "@/modules/organizations/event-types/services/input.service";
import { DatabaseTeamEventType } from "@/modules/organizations/event-types/services/output.service";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { TeamsEventTypesService } from "@/modules/teams/event-types/services/teams-event-types.service";
@@ -7,8 +11,8 @@ import { UsersService } from "@/modules/users/services/users.service";
import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, Logger } from "@nestjs/common";
import { createEventType } from "@calcom/platform-libraries";
import { InputTeamEventTransformed_2024_06_14 } from "@calcom/platform-types";
// eslint-disable-next-line @typescript-eslint/no-var-requires
import { createEventType } from "@calcom/platform-libraries/event-types";
@Injectable()
export class OrganizationsEventTypesService {
@@ -26,14 +30,16 @@ export class OrganizationsEventTypesService {
user: UserWithProfile,
teamId: number,
orgId: number,
body: InputTeamEventTransformed_2024_06_14
body: TransformedCreateTeamEventTypeInput
): Promise<DatabaseTeamEventType | DatabaseTeamEventType[]> {
const eventTypeUser = await this.getUserToCreateTeamEvent(user, orgId);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { hosts, children, destinationCalendar, ...rest } = body;
const { eventType: eventTypeCreated } = await createEventType({
input: { teamId: teamId, ...rest },
input: {
teamId: teamId,
...rest,
},
ctx: {
user: eventTypeUser,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -57,6 +63,7 @@ export class OrganizationsEventTypesService {
organization: { isOrgAdmin },
profile: { id: profileId || null },
metadata: user.metadata,
email: user.email,
};
}
@@ -87,7 +94,7 @@ export class OrganizationsEventTypesService {
async updateTeamEventType(
eventTypeId: number,
teamId: number,
body: InputTeamEventTransformed_2024_06_14,
body: TransformedUpdateTeamEventTypeInput,
user: UserWithProfile
): Promise<DatabaseTeamEventType | DatabaseTeamEventType[]> {
return this.teamsEventTypesService.updateTeamEventType(eventTypeId, teamId, body, user);
@@ -37,7 +37,7 @@ import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger";
import { plainToClass } from "class-transformer";
import { SUCCESS_STATUS } from "@calcom/platform-constants";
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries";
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries/event-types";
import { SkipTakePagination } from "@calcom/platform-types";
@Controller({
@@ -62,6 +62,15 @@ export class SelectedCalendarsRepository {
});
}
getUserEventTypeSelectedCalendar(userId: number) {
return this.dbRead.prisma.selectedCalendar.findMany({
where: {
userId,
eventTypeId: { not: null },
},
});
}
async addUserSelectedCalendar(
userId: number,
integration: string,
@@ -1,5 +1,9 @@
import { EventTypesRepository_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/event-types.repository";
import { EventTypesService_2024_06_14 } from "@/ee/event-types/event-types_2024_06_14/services/event-types.service";
import {
TransformedCreateTeamEventTypeInput,
TransformedUpdateTeamEventTypeInput,
} from "@/modules/organizations/event-types/services/input.service";
import { DatabaseTeamEventType } from "@/modules/organizations/event-types/services/output.service";
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
import { TeamsEventTypesRepository } from "@/modules/teams/event-types/teams-event-types.repository";
@@ -7,8 +11,7 @@ import { UsersService } from "@/modules/users/services/users.service";
import { UserWithProfile } from "@/modules/users/users.repository";
import { Injectable, NotFoundException, Logger } from "@nestjs/common";
import { createEventType, updateEventType } from "@calcom/platform-libraries";
import { InputTeamEventTransformed_2024_06_14 } from "@calcom/platform-types";
import { createEventType, updateEventType } from "@calcom/platform-libraries/event-types";
@Injectable()
export class TeamsEventTypesService {
@@ -25,7 +28,7 @@ export class TeamsEventTypesService {
async createTeamEventType(
user: UserWithProfile,
teamId: number,
body: InputTeamEventTransformed_2024_06_14
body: TransformedCreateTeamEventTypeInput
): Promise<DatabaseTeamEventType | DatabaseTeamEventType[]> {
const eventTypeUser = await this.getUserToCreateTeamEvent(user);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -62,6 +65,7 @@ export class TeamsEventTypesService {
organization: { id: null, isOrgAdmin: false, metadata: {}, requestedSlug: null },
profile: { id: profileId || null },
metadata: user.metadata,
email: user.email,
};
}
@@ -100,14 +104,16 @@ export class TeamsEventTypesService {
async updateTeamEventType(
eventTypeId: number,
teamId: number,
body: InputTeamEventTransformed_2024_06_14,
body: TransformedUpdateTeamEventTypeInput,
user: UserWithProfile
): Promise<DatabaseTeamEventType | DatabaseTeamEventType[]> {
await this.validateEventTypeExists(teamId, eventTypeId);
const eventTypeUser = await this.eventTypesService.getUserToUpdateEvent(user);
await updateEventType({
input: { id: eventTypeId, ...body },
input: {
id: eventTypeId,
...body,
},
ctx: {
user: eventTypeUser,
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -31,7 +31,7 @@ import { ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger";
import { plainToClass } from "class-transformer";
import { SUCCESS_STATUS } from "@calcom/platform-constants";
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries";
import { updateNewTeamMemberEventTypes } from "@calcom/platform-libraries/event-types";
import { SkipTakePagination } from "@calcom/platform-types";
@Controller({