-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic atoms in barebone example platform apps (#13006)
* example app * example app * dev move * fix: more entry points * fixup! fix: more entry points * refactor: v2 API (#12913) * Use Boolean only instead of git add src/modules/auth/guard/organization-roles/organization-roles.guard.ts * move tests next to files they test * replace .. in import paths with absolute path * camelCase instead of snake_case for access and refresh token variables * user sanitize function Typescript friendly * restructure oAuth clients folder: example for other folders * restructure bookings module * organize modules in auth, endpoints, repositories, services * organize auth module * organize repositories * organize inputs * rename OAuthClientGuard to OAuthClientCredentialsGuard * add error messages * add error messages * clientId as param in oauth-flow & schema mapping * camelCase instead of snake_case for clientId and clientSecret * access token guard as passport strategy * folder structure as features * get rid of index files * feat: endpoint for deleting oAuth users & oAuth users returned data (#12912) * feat: delete oAuth users * check if access token matches userId in parameter * driveby: return only user id and email in oauth users endpoints * Connect CalProvider and GCal * Connect CalProvider and GCal * return response interceptor to handle failed requests * handle failed requests using axios intercepter * cal provider refresh tokens, external gcal * external gcal * cal provider refresh and retries * remove console.log * refactor * ignore built atoms css * remove change to token repo * refactor * refactor * downdgrade vite of unrelated packages * move gcal endpoints to platform * gcal service * refactor: use atoms provider --------- Co-authored-by: Lauris Skraucis <[email protected]> Co-authored-by: Ryukemeister <[email protected]>
- Loading branch information
1 parent
158ac7d
commit f6c9447
Showing
63 changed files
with
1,188 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { GcalController } from "@/ee/gcal/gcal.controller"; | ||
import { AppsRepository } from "@/modules/apps/apps.repository"; | ||
import { GcalService } from "@/modules/apps/services/gcal.service"; | ||
import { CredentialsRepository } from "@/modules/credentials/credentials.repository"; | ||
import { OAuthClientModule } from "@/modules/oauth-clients/oauth-client.module"; | ||
import { PrismaModule } from "@/modules/prisma/prisma.module"; | ||
import { SelectedCalendarsRepository } from "@/modules/selected-calendars/selected-calendars.repository"; | ||
import { TokensModule } from "@/modules/tokens/tokens.module"; | ||
import { Module } from "@nestjs/common"; | ||
import { ConfigService } from "@nestjs/config"; | ||
|
||
@Module({ | ||
imports: [PrismaModule, TokensModule, OAuthClientModule], | ||
providers: [AppsRepository, ConfigService, CredentialsRepository, SelectedCalendarsRepository, GcalService], | ||
controllers: [GcalController], | ||
}) | ||
export class GcalModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { GcalModule } from "@/ee/gcal/gcal.module"; | ||
import { ProviderModule } from "@/ee/provider/provider.module"; | ||
import type { MiddlewareConsumer, NestModule } from "@nestjs/common"; | ||
import { Module } from "@nestjs/common"; | ||
|
||
@Module({ | ||
imports: [GcalModule, ProviderModule], | ||
}) | ||
export class PlatformEndpointsModule implements NestModule { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
configure(_consumer: MiddlewareConsumer) { | ||
// TODO: apply ratelimits | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator"; | ||
import { AccessTokenGuard } from "@/modules/auth/guards/access-token/access-token.guard"; | ||
import { UserReturned } from "@/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller"; | ||
import { OAuthClientRepository } from "@/modules/oauth-clients/oauth-client.repository"; | ||
import { TokensRepository } from "@/modules/tokens/tokens.repository"; | ||
import { | ||
BadRequestException, | ||
Controller, | ||
Get, | ||
HttpCode, | ||
HttpStatus, | ||
Logger, | ||
NotFoundException, | ||
Param, | ||
UnauthorizedException, | ||
UseGuards, | ||
} from "@nestjs/common"; | ||
|
||
import { SUCCESS_STATUS } from "@calcom/platform-constants"; | ||
import { ApiResponse } from "@calcom/platform-types"; | ||
|
||
@Controller({ | ||
path: "platform/provider", | ||
version: "2", | ||
}) | ||
export class CalProviderController { | ||
private readonly logger = new Logger("Platform Provider Controller"); | ||
|
||
constructor( | ||
private readonly tokensRepository: TokensRepository, | ||
private readonly oauthClientRepository: OAuthClientRepository | ||
) {} | ||
|
||
@Get("/:clientId") | ||
@HttpCode(HttpStatus.OK) | ||
async verifyClientId(@Param("clientId") clientId: string): Promise<ApiResponse> { | ||
if (!clientId) { | ||
throw new NotFoundException(); | ||
} | ||
const oAuthClient = await this.oauthClientRepository.getOAuthClient(clientId); | ||
|
||
if (!oAuthClient) throw new UnauthorizedException(); | ||
|
||
return { | ||
status: SUCCESS_STATUS, | ||
}; | ||
} | ||
|
||
@Get("/:clientId/access-token") | ||
@HttpCode(HttpStatus.OK) | ||
@UseGuards(AccessTokenGuard) | ||
async verifyAccessToken( | ||
@Param("clientId") clientId: string, | ||
@GetUser() user: UserReturned | ||
): Promise<ApiResponse> { | ||
if (!clientId) { | ||
throw new BadRequestException(); | ||
} | ||
|
||
if (!user) { | ||
throw new UnauthorizedException(); | ||
} | ||
|
||
return { | ||
status: SUCCESS_STATUS, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CalProviderController } from "@/ee/provider/provider.controller"; | ||
import { CredentialsRepository } from "@/modules/credentials/credentials.repository"; | ||
import { OAuthClientModule } from "@/modules/oauth-clients/oauth-client.module"; | ||
import { PrismaModule } from "@/modules/prisma/prisma.module"; | ||
import { TokensModule } from "@/modules/tokens/tokens.module"; | ||
import { Module } from "@nestjs/common"; | ||
|
||
@Module({ | ||
imports: [PrismaModule, TokensModule, OAuthClientModule], | ||
providers: [CredentialsRepository], | ||
controllers: [CalProviderController], | ||
}) | ||
export class ProviderModule {} |
Oops, something went wrong.