From 3942df369d7114ab477a9cd9d37c2823024714ec Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Tue, 14 May 2024 13:50:12 +0300 Subject: [PATCH] chore: open disableGuests for event-types apiv2 (#15001) * chore: open disableGuests for eventtypes apiv2 * fixup! chore: open disableGuests for eventtypes apiv2 * fixup! fixup! chore: open disableGuests for eventtypes apiv2 * chore: add disableGuests to create handler --- .../event-types.controller.e2e-spec.ts | 9 ++++- .../inputs/create-event-type.input.ts | 4 ++ .../inputs/update-event-type.input.ts | 6 +-- apps/api/v2/swagger/documentation.json | 38 +++++++++++++++++++ packages/prisma/zod/custom/eventtype.ts | 1 + 5 files changed, 54 insertions(+), 4 deletions(-) diff --git a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts index 77678f8387..870aed625a 100644 --- a/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts +++ b/apps/api/v2/src/ee/event-types/controllers/event-types.controller.e2e-spec.ts @@ -131,6 +131,7 @@ describe("Event types Endpoints", () => { description: "A description of the test event type.", length: 60, hidden: false, + disableGuests: true, locations: [ { type: "Online", @@ -148,6 +149,7 @@ describe("Event types Endpoints", () => { const responseBody: ApiSuccessResponse = response.body; expect(responseBody.data).toHaveProperty("id"); expect(responseBody.data.title).toEqual(body.title); + expect(responseBody.data.disableGuests).toEqual(body.disableGuests); eventType = responseBody.data; }); }); @@ -157,14 +159,19 @@ describe("Event types Endpoints", () => { const body: UpdateEventTypeInput = { title: newTitle, + disableGuests: false, }; return request(app.getHttpServer()) .patch(`/api/v2/event-types/${eventType.id}`) .send(body) .expect(200) - .then(async () => { + .then(async (response) => { + const responseBody: ApiSuccessResponse = response.body; + expect(responseBody.data.title).toEqual(newTitle); + expect(responseBody.data.disableGuests).toEqual(body.disableGuests); eventType.title = newTitle; + eventType.disableGuests = responseBody.data.disableGuests ?? false; }); }); diff --git a/apps/api/v2/src/ee/event-types/inputs/create-event-type.input.ts b/apps/api/v2/src/ee/event-types/inputs/create-event-type.input.ts index 469ea1f4ef..fb5b380164 100644 --- a/apps/api/v2/src/ee/event-types/inputs/create-event-type.input.ts +++ b/apps/api/v2/src/ee/event-types/inputs/create-event-type.input.ts @@ -41,6 +41,10 @@ export class CreateEventTypeInput { @IsArray() locations?: EventTypeLocation[]; + @IsBoolean() + @IsOptional() + disableGuests?: boolean; + // @ApiHideProperty() // @IsOptional() // @IsNumber() diff --git a/apps/api/v2/src/ee/event-types/inputs/update-event-type.input.ts b/apps/api/v2/src/ee/event-types/inputs/update-event-type.input.ts index d03e451d44..68a64d4204 100644 --- a/apps/api/v2/src/ee/event-types/inputs/update-event-type.input.ts +++ b/apps/api/v2/src/ee/event-types/inputs/update-event-type.input.ts @@ -322,9 +322,9 @@ export class UpdateEventTypeInput { // @IsOptional() // recurringEvent?: RecurringEvent; - // @IsBoolean() - // @IsOptional() - // disableGuests?: boolean; + @IsBoolean() + @IsOptional() + disableGuests?: boolean; // @IsBoolean() // @IsOptional() diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.json index ee4d0fba91..ffc41ecf72 100644 --- a/apps/api/v2/swagger/documentation.json +++ b/apps/api/v2/swagger/documentation.json @@ -404,6 +404,38 @@ ] } }, + "/v2/oauth-clients/{clientId}/managed-users": { + "get": { + "operationId": "OAuthClientsController_getOAuthClientManagedUsersById", + "summary": "", + "description": "⚠️ First, this endpoint requires `Cookie: next-auth.session-token=eyJhbGciOiJ` header. Log into Cal web app using owner of organization that was created after visiting `/settings/organizations/new`, refresh swagger docs, and the cookie will be added to requests automatically to pass the NextAuthGuard.\nSecond, make sure that the logged in user has organizationId set to pass the OrganizationRolesGuard guard.", + "parameters": [ + { + "name": "clientId", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetManagedUsersOutput" + } + } + } + } + }, + "tags": [ + "OAuth - development only" + ] + } + }, "/v2/oauth/{clientId}/authorize": { "post": { "operationId": "OAuthFlowController_authorize", @@ -2067,6 +2099,9 @@ "items": { "$ref": "#/components/schemas/EventTypeLocation" } + }, + "disableGuests": { + "type": "boolean" } }, "required": [ @@ -2749,6 +2784,9 @@ "items": { "$ref": "#/components/schemas/EventTypeLocation" } + }, + "disableGuests": { + "type": "boolean" } } }, diff --git a/packages/prisma/zod/custom/eventtype.ts b/packages/prisma/zod/custom/eventtype.ts index f3a9f49d2d..fb77284881 100755 --- a/packages/prisma/zod/custom/eventtype.ts +++ b/packages/prisma/zod/custom/eventtype.ts @@ -14,6 +14,7 @@ export const createEventTypeInput = z.object({ schedulingType: z.nativeEnum(SchedulingType).nullish(), locations: imports.eventTypeLocations, metadata: imports.EventTypeMetaDataSchema.optional(), + disableGuests: z.boolean().optional(), }) .partial({ hidden: true, locations: true }) .refine((data) => (data.teamId ? data.teamId && data.schedulingType : true), {