Scheduling infrastructure for absolutely everyone.
chore: rename platform endpoints provider/gcal (#14248)
Morganccc8cdc1ff29
diff --git a/apps/api/v2/src/ee/gcal/gcal.controller.e2e-spec.ts b/apps/api/v2/src/ee/gcal/gcal.controller.e2e-spec.tsindex 470a25cd247..598acb52329 100644--- a/apps/api/v2/src/ee/gcal/gcal.controller.e2e-spec.ts+++ b/apps/api/v2/src/ee/gcal/gcal.controller.e2e-spec.ts@@ -82,16 +82,16 @@ describe("Platform Gcal Endpoints", () => {expect(user).toBeDefined();});- it(`/GET/platform/gcal/oauth/auth-url: it should respond 401 with invalid access token`, async () => {+ it(`/GET/ee/gcal/oauth/auth-url: it should respond 401 with invalid access token`, async () => {await request(app.getHttpServer())- .get(`/api/v2/platform/gcal/oauth/auth-url`)+ .get(`/api/v2/ee/gcal/oauth/auth-url`).set("Authorization", `Bearer invalid_access_token`).expect(401);});- it(`/GET/platform/gcal/oauth/auth-url: it should auth-url to google oauth with valid access token `, async () => {+ it(`/GET/ee/gcal/oauth/auth-url: it should auth-url to google oauth with valid access token `, async () => {const response = await request(app.getHttpServer())- .get(`/api/v2/platform/gcal/oauth/auth-url`)+ .get(`/api/v2/ee/gcal/oauth/auth-url`).set("Authorization", `Bearer ${accessTokenSecret}`).set("Origin", CLIENT_REDIRECT_URI).expect(200);@@ -99,50 +99,50 @@ describe("Platform Gcal Endpoints", () => {expect(data.authUrl).toBeDefined();});- it(`/GET/platform/gcal/oauth/save: without oauth code`, async () => {+ it(`/GET/ee/gcal/oauth/save: without oauth code`, async () => {await request(app.getHttpServer()).get(- `/api/v2/platform/gcal/oauth/save?state=accessToken=${accessTokenSecret}&origin%3D${CLIENT_REDIRECT_URI}&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`+ `/api/v2/ee/gcal/oauth/save?state=accessToken=${accessTokenSecret}&origin%3D${CLIENT_REDIRECT_URI}&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`).expect(400);});- it(`/GET/platform/gcal/oauth/save: without access token`, async () => {+ it(`/GET/ee/gcal/oauth/save: without access token`, async () => {await request(app.getHttpServer()).get(- `/api/v2/platform/gcal/oauth/save?state=origin%3D${CLIENT_REDIRECT_URI}&code=4/0AfJohXmBuT7QVrEPlAJLBu4ZcSnyj5jtDoJqSW_riPUhPXQ70RPGkOEbVO3xs-OzQwpPQw&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`+ `/api/v2/ee/gcal/oauth/save?state=origin%3D${CLIENT_REDIRECT_URI}&code=4/0AfJohXmBuT7QVrEPlAJLBu4ZcSnyj5jtDoJqSW_riPUhPXQ70RPGkOEbVO3xs-OzQwpPQw&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`).expect(400);});- it(`/GET/platform/gcal/oauth/save: without origin`, async () => {+ it(`/GET/ee/gcal/oauth/save: without origin`, async () => {await request(app.getHttpServer()).get(- `/api/v2/platform/gcal/oauth/save?state=accessToken=${accessTokenSecret}&code=4/0AfJohXmBuT7QVrEPlAJLBu4ZcSnyj5jtDoJqSW_riPUhPXQ70RPGkOEbVO3xs-OzQwpPQw&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`+ `/api/v2/ee/gcal/oauth/save?state=accessToken=${accessTokenSecret}&code=4/0AfJohXmBuT7QVrEPlAJLBu4ZcSnyj5jtDoJqSW_riPUhPXQ70RPGkOEbVO3xs-OzQwpPQw&scope=https://www.googleapis.com/auth/calendar.readonly%20https://www.googleapis.com/auth/calendar.events`).expect(400);});- it(`/GET/platform/gcal/check with access token but without origin`, async () => {+ it(`/GET/ee/gcal/check with access token but without origin`, async () => {await request(app.getHttpServer())- .get(`/api/v2/platform/gcal/check`)+ .get(`/api/v2/ee/gcal/check`).set("Authorization", `Bearer ${accessTokenSecret}`).expect(400);});- it(`/GET/platform/gcal/check without access token`, async () => {- await request(app.getHttpServer()).get(`/api/v2/platform/gcal/check`).expect(401);+ it(`/GET/ee/gcal/check without access token`, async () => {+ await request(app.getHttpServer()).get(`/api/v2/ee/gcal/check`).expect(401);});- it(`/GET/platform/gcal/check with access token and origin but no credentials`, async () => {+ it(`/GET/ee/gcal/check with access token and origin but no credentials`, async () => {await request(app.getHttpServer())- .get(`/api/v2/platform/gcal/check`)+ .get(`/api/v2/ee/gcal/check`).set("Authorization", `Bearer ${accessTokenSecret}`).set("Origin", CLIENT_REDIRECT_URI).expect(400);});- it(`/GET/platform/gcal/check with access token and origin and gcal credentials`, async () => {+ it(`/GET/ee/gcal/check with access token and origin and gcal credentials`, async () => {gcalCredentials = await credentialsRepositoryFixture.create("google_calendar",{},@@ -150,7 +150,7 @@ describe("Platform Gcal Endpoints", () => {"google-calendar");await request(app.getHttpServer())- .get(`/api/v2/platform/gcal/check`)+ .get(`/api/v2/ee/gcal/check`).set("Authorization", `Bearer ${accessTokenSecret}`).set("Origin", CLIENT_REDIRECT_URI).expect(200);diff --git a/apps/api/v2/src/ee/gcal/gcal.controller.ts b/apps/api/v2/src/ee/gcal/gcal.controller.tsindex 9d5e1a76e2a..0108db5f6fc 100644--- a/apps/api/v2/src/ee/gcal/gcal.controller.ts+++ b/apps/api/v2/src/ee/gcal/gcal.controller.ts@@ -40,7 +40,7 @@ const CALENDAR_SCOPES = [];@Controller({- path: "platform/gcal",+ path: "ee/gcal",version: "2",})export class GcalController {@@ -55,7 +55,7 @@ export class GcalController {private readonly gcalService: GcalService) {}- private redirectUri = `${this.config.get("api.url")}/platform/gcal/oauth/save`;+ private redirectUri = `${this.config.get("api.url")}/ee/gcal/oauth/save`;@Get("/oauth/auth-url")@HttpCode(HttpStatus.OK)diff --git a/apps/api/v2/src/ee/provider/provider.controller.ts b/apps/api/v2/src/ee/provider/provider.controller.tsindex 192459e1f61..41e6e8240b6 100644--- a/apps/api/v2/src/ee/provider/provider.controller.ts+++ b/apps/api/v2/src/ee/provider/provider.controller.ts@@ -20,7 +20,7 @@ import { SUCCESS_STATUS } from "@calcom/platform-constants";import { ApiResponse } from "@calcom/platform-types";@Controller({- path: "platform/provider",+ path: "ee/provider",version: "2",})export class CalProviderController {diff --git a/apps/api/v2/swagger/documentation.json b/apps/api/v2/swagger/documentation.jsonindex bf15ab2cafb..f6e8124b07a 100644--- a/apps/api/v2/swagger/documentation.json+++ b/apps/api/v2/swagger/documentation.json@@ -22,7 +22,40 @@"/api/v2/events/public": {"get": {"operationId": "EventsController_getPublicEvent",- "parameters": [],+ "parameters": [+ {+ "name": "username",+ "required": true,+ "in": "query",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "eventSlug",+ "required": true,+ "in": "query",+ "schema": {+ "type": "string"+ }+ },+ {+ "name": "isTeamEvent",+ "required": false,+ "in": "query",+ "schema": {+ "type": "boolean"+ }+ },+ {+ "name": "org",+ "required": false,+ "in": "query",+ "schema": {+ "type": "string"+ }+ }+ ],"responses": {"200": {"description": "",@@ -55,7 +88,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/CreateUserInput"+ "$ref": "#/components/schemas/CreateManagedPlatformUserInput"}}}@@ -133,7 +166,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/UpdateUserInput"+ "$ref": "#/components/schemas/UpdateManagedPlatformUserInput"}}}@@ -578,7 +611,7 @@}}},- "/api/v2/platform/gcal/oauth/auth-url": {+ "/api/v2/ee/gcal/oauth/auth-url": {"get": {"operationId": "GcalController_redirect","parameters": [@@ -605,7 +638,7 @@}}},- "/api/v2/platform/gcal/oauth/save": {+ "/api/v2/ee/gcal/oauth/save": {"get": {"operationId": "GcalController_save","parameters": [@@ -640,7 +673,7 @@}}},- "/api/v2/platform/gcal/check": {+ "/api/v2/ee/gcal/check": {"get": {"operationId": "GcalController_check","parameters": [],@@ -658,7 +691,7 @@}}},- "/api/v2/platform/provider/{clientId}": {+ "/api/v2/ee/provider/{clientId}": {"get": {"operationId": "CalProviderController_verifyClientId","parameters": [@@ -685,7 +718,7 @@}}},- "/api/v2/platform/provider/{clientId}/access-token": {+ "/api/v2/ee/provider/{clientId}/access-token": {"get": {"operationId": "CalProviderController_verifyAccessToken","parameters": [@@ -895,7 +928,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/UpdateUserInput"+ "$ref": "#/components/schemas/UpdateManagedPlatformUserInput"}}}@@ -951,6 +984,22 @@}},"/api/v2/ee/bookings": {+ "get": {+ "operationId": "BookingsController_getBookings",+ "parameters": [],+ "responses": {+ "200": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "type": "object"+ }+ }+ }+ }+ }+ },"post": {"operationId": "BookingsController_createBooking","parameters": [],@@ -978,6 +1027,97 @@}}},+ "/api/v2/ee/bookings/{bookingUid}": {+ "get": {+ "operationId": "BookingsController_getBooking",+ "parameters": [+ {+ "name": "bookingUid",+ "required": true,+ "in": "path",+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "type": "object"+ }+ }+ }+ }+ }+ }+ },+ "/api/v2/ee/bookings/{bookingUid}/reschedule": {+ "get": {+ "operationId": "BookingsController_getBookingForReschedule",+ "parameters": [+ {+ "name": "bookingUid",+ "required": true,+ "in": "path",+ "schema": {+ "type": "string"+ }+ }+ ],+ "responses": {+ "200": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "type": "object"+ }+ }+ }+ }+ }+ }+ },+ "/api/v2/ee/bookings/{bookingId}/cancel": {+ "post": {+ "operationId": "BookingsController_cancelBooking",+ "parameters": [+ {+ "name": "bookingId",+ "required": true,+ "in": "path",+ "schema": {+ "type": "string"+ }+ }+ ],+ "requestBody": {+ "required": true,+ "content": {+ "application/json": {+ "schema": {+ "$ref": "#/components/schemas/CancelBookingInput"+ }+ }+ }+ },+ "responses": {+ "201": {+ "description": "",+ "content": {+ "application/json": {+ "schema": {+ "type": "object"+ }+ }+ }+ }+ }+ }+ },"/api/v2/ee/bookings/reccuring": {"post": {"operationId": "BookingsController_createReccuringBooking",@@ -1112,7 +1252,7 @@"servers": [],"components": {"schemas": {- "CreateUserInput": {+ "CreateManagedPlatformUserInput": {"type": "object","properties": {"email": {@@ -1124,9 +1264,6 @@"timeFormat": {"type": "number"},- "defaultScheduleId": {- "type": "number"- },"weekStart": {"type": "string"},@@ -1138,7 +1275,7 @@"email"]},- "UpdateUserInput": {+ "UpdateManagedPlatformUserInput": {"type": "object","properties": {"email": {@@ -1526,6 +1663,10 @@"hashedLink"]},+ "CancelBookingInput": {+ "type": "object",+ "properties": {}+ },"ReserveSlotInput": {"type": "object","properties": {}diff --git a/packages/platform/atoms/hooks/useGcal.ts b/packages/platform/atoms/hooks/useGcal.tsindex fc7a8b5b8d7..e54e94f44fd 100644--- a/packages/platform/atoms/hooks/useGcal.ts+++ b/packages/platform/atoms/hooks/useGcal.ts@@ -12,7 +12,7 @@ export const useGcal = ({ isAuth }: useGcalProps) => {const redirectToGcalOAuth = () => {http- ?.get("/platform/gcal/oauth/auth-url")+ ?.get("/ee/gcal/oauth/auth-url").then(({ data: responseBody }) => {if (responseBody.data?.authUrl) {window.location.href = responseBody.data.authUrl;@@ -24,7 +24,7 @@ export const useGcal = ({ isAuth }: useGcalProps) => {useEffect(() => {if (isAuth) {http- ?.get("/platform/gcal/check")+ ?.get("/ee/gcal/check").then(() => setAllowConnect(false)).catch(() => setAllowConnect(true)).finally(() => setChecked(true));diff --git a/packages/platform/atoms/hooks/useOAuthClient.ts b/packages/platform/atoms/hooks/useOAuthClient.tsindex da8940c992c..a6b26c8c327 100644--- a/packages/platform/atoms/hooks/useOAuthClient.ts+++ b/packages/platform/atoms/hooks/useOAuthClient.ts@@ -30,7 +30,7 @@ export const useOAuthClient = ({ clientId, apiUrl, refreshUrl, onError, onSuccesuseEffect(() => {if (clientId && http.getUrl() && prevClientId !== clientId) {try {- http.get<ApiResponse>(`/platform/provider/${clientId}`).catch((err: AxiosError) => {+ http.get<ApiResponse>(`/ee/provider/${clientId}`).catch((err: AxiosError) => {if (err.response?.status === 401) {onError("Invalid oAuth Client.");} else {diff --git a/packages/platform/atoms/hooks/useOAuthFlow.ts b/packages/platform/atoms/hooks/useOAuthFlow.tsindex efd5f120b40..7a58db798e4 100644--- a/packages/platform/atoms/hooks/useOAuthFlow.ts+++ b/packages/platform/atoms/hooks/useOAuthFlow.ts@@ -58,7 +58,7 @@ export const useOAuthFlow = ({ accessToken, refreshUrl, clientId, onError, onSuchttp.setAuthorizationHeader(accessToken);try {http- .get<ApiResponse>(`/platform/provider/${clientId}/access-token`)+ .get<ApiResponse>(`/ee/provider/${clientId}/access-token`).catch(async (err: AxiosError) => {if ((err.response?.status === 498 || err.response?.status === 401) && refreshUrl) {setIsRefreshing(true);diff --git a/packages/platform/examples/base/README.md b/packages/platform/examples/base/README.mdindex 8c1f26c621f..b9fd5133e1f 100644--- a/packages/platform/examples/base/README.md+++ b/packages/platform/examples/base/README.md@@ -29,7 +29,7 @@ REDIS_URL="redis://localhost:6379"2. Open ".env" file and paste client id from step 8 in `NEXT_PUBLIC_X_CAL_ID` and client secret in `X_CAL_SECRET_KEY`. If in step 2 you used the same environment variables, then `NEXT_PUBLIC_CALCOM_API_URL` can stay as is. Otherwise adjust the port to point to the same `API_PORT` as you used in step 2.10. Navigate to example app and setup database by running `rm -f prisma/dev.db && yarn prisma db push`.11. Start the example app by running `yarn dev` and go to `http://localhost:4321`.-12. In the Google Cloud Console "API & Services" "Credentials" `https://console.cloud.google.com/apis/credentials` open web project setup in step 1 and add `http://localhost:5555/api/v2/platform/gcal/oauth/save` to the authorized redirect URIs.+12. In the Google Cloud Console "API & Services" "Credentials" `https://console.cloud.google.com/apis/credentials` open web project setup in step 1 and add `http://localhost:5555/api/v2/ee/gcal/oauth/save` to the authorized redirect URIs.<img width="1000" alt="Screenshot 2024-03-21 at 09 42 36" src="https://github.com/calcom/atoms-examples/assets/42170848/82ce4d7a-fc08-489a-ab06-a8eb41a68a2a">