refactor: platform default event types (#19225)

* feat: add areDefaultEventTypesEnabled to PlatformOAuthClient

* feat: specify areDefaultEventTypesEnabled when creating OAuth client

* feat: specify areDefaultEventTypesEnabled when updating OAuth client

* feat: display areDefaultEventTypesEnabled in OAuth clients list

* refactor: set areDefaultEventTypesEnabled by default to false on API level

* feat: v2 API CREATE managed user toggle default event types

* refactor: centralize OAuth inputs and outputs in platform/types

* fix: correct response types for OAuth hooks

* refactor: web/lib/hooks/settings/platform/oauth-clients/useOAuthClients.ts

* refactor: web/lib/hooks/settings/platform/oauth-clients/useOAuthClients.ts

* refactor: split web OAuth hooks into separate files

* refactor: split web OAuth hooks into separate files

* docs: v2 OAuth client inputs and outputs

* refactor: update and create oauth client inputs
This commit is contained in:
Lauris Skraucis authored and GitHub committed 2025-02-26 12:06:08 -03:00
1 parent 07789ba697
commit e437dfa000
35 files changed
+519 -138

No files matched your search

+1
View File
@@ -10,5 +10,6 @@ export * from "./event-types";
export * from "./organizations";
export * from "./teams";
export * from "./embed";
export * from "./oauth-clients";
export * from "./routing-forms";
export * from "./me";
+1
View File
@@ -0,0 +1 @@
export * from "./outputs";
@@ -0,0 +1 @@
export * from "./me";
+15
View File
@@ -0,0 +1,15 @@
import { z } from "zod";
export const userSchemaResponse = z.object({
id: z.number().int(),
email: z.string(),
timeFormat: z.number().int().default(12),
defaultScheduleId: z.number().int().nullable(),
weekStart: z.string(),
timeZone: z.string().default("Europe/London"),
username: z.string(),
organizationId: z.number().nullable(),
organization: z.object({ isPlatform: z.boolean(), id: z.number() }).optional(),
});
export type UserResponse = z.infer<typeof userSchemaResponse>;
@@ -1,8 +1,11 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsArray, IsEnum, IsOptional, IsBoolean, IsString } from "class-validator";
import { PERMISSION_MAP } from "@calcom/platform-constants";
export const ARE_DEFAULT_EVENT_TYPES_ENABLED_DOCS =
"If true, when creating a managed user the managed user will have 4 default event types: 30 and 60 minutes without Cal video, 30 and 60 minutes with Cal video. Set this as false if you want to create a managed user and then manually create event types for the user.";
export class CreateOAuthClientInput {
@IsOptional()
@IsString()
@@ -47,4 +50,14 @@ export class CreateOAuthClientInput {
@IsBoolean()
@ApiPropertyOptional()
areEmailsEnabled?: boolean;
@IsOptional()
@IsBoolean()
@Transform(({ value }) => value ?? false)
@ApiPropertyOptional({
type: Boolean,
default: false,
description: ARE_DEFAULT_EVENT_TYPES_ENABLED_DOCS,
})
areDefaultEventTypesEnabled? = false;
}
@@ -1,6 +1,8 @@
import { ApiPropertyOptional } from "@nestjs/swagger";
import { IsArray, IsBoolean, IsOptional, IsString } from "class-validator";
import { ARE_DEFAULT_EVENT_TYPES_ENABLED_DOCS } from "./create-oauth-client.input";
export class UpdateOAuthClientInput {
@IsOptional()
@IsString()
@@ -37,4 +39,12 @@ export class UpdateOAuthClientInput {
@IsBoolean()
@ApiPropertyOptional()
areEmailsEnabled?: boolean;
@IsOptional()
@IsBoolean()
@ApiPropertyOptional({
type: Boolean,
description: ARE_DEFAULT_EVENT_TYPES_ENABLED_DOCS,
})
areDefaultEventTypesEnabled?: boolean;
}
@@ -0,0 +1,16 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsString } from "class-validator";
export class CreateOAuthClientOutput {
@ApiProperty({
example: "clsx38nbl0001vkhlwin9fmt0",
})
@IsString()
clientId!: string;
@ApiProperty({
example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoib2F1dGgtY2xpZW50Iiwi",
})
@IsString()
clientSecret!: string;
}
@@ -1 +1,2 @@
export * from "./oauth-client.output";
export * from "./create-oauth-client.output";
@@ -44,6 +44,18 @@ export class PlatformOAuthClientDto {
@IsDate()
createdAt!: Date;
@IsBoolean()
@ApiProperty({ example: true })
areEmailsEnabled!: boolean;
@IsBoolean()
@ApiProperty({
example: true,
description:
"If enabled, when creating a managed user the managed user will have 4 default event types: 30 and 60 minutes without Cal video, 30 and 60 minutes with Cal video. Leave this disabled if you want to create a managed user and then manually create event types for the user.",
})
areDefaultEventTypesEnabled!: boolean;
@ApiPropertyOptional({ example: "https://example.com/booking-redirect" })
@IsOptional()
@IsUrl()
@@ -58,9 +70,4 @@ export class PlatformOAuthClientDto {
@IsOptional()
@IsUrl()
bookingRescheduleRedirectUri?: string;
@ApiPropertyOptional({ example: false })
@IsOptional()
@IsBoolean()
areEmailsEnabled?: boolean;
}
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "PlatformOAuthClient" ADD COLUMN "areDefaultEventTypesEnabled" BOOLEAN NOT NULL DEFAULT true;
+1
View File
@@ -1519,6 +1519,7 @@ model PlatformOAuthClient {
bookingCancelRedirectUri String?
bookingRescheduleRedirectUri String?
areEmailsEnabled Boolean @default(false)
areDefaultEventTypesEnabled Boolean @default(true)
createdAt DateTime @default(now())
}