Spaces:
Build error
Build error
twenty / packages /twenty-server /src /engine /metadata-modules /page-layout-tab /controllers /page-layout-tab.controller.ts
| import { | |
| Body, | |
| Controller, | |
| Delete, | |
| Get, | |
| Param, | |
| Patch, | |
| Post, | |
| Query, | |
| UseFilters, | |
| UseGuards, | |
| } from '@nestjs/common'; | |
| import { PermissionFlagType } from 'twenty-shared/constants'; | |
| import { isDefined } from 'twenty-shared/utils'; | |
| import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity'; | |
| import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator'; | |
| import { NoPermissionGuard } from 'src/engine/guards/no-permission.guard'; | |
| import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard'; | |
| import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard'; | |
| import { FlatEntityMapsRestApiExceptionFilter } from 'src/engine/metadata-modules/flat-entity/filters/flat-entity-maps-rest-api-exception.filter'; | |
| import { CreatePageLayoutTabInput } from 'src/engine/metadata-modules/page-layout-tab/dtos/inputs/create-page-layout-tab.input'; | |
| import { UpdatePageLayoutTabInput } from 'src/engine/metadata-modules/page-layout-tab/dtos/inputs/update-page-layout-tab.input'; | |
| import { type PageLayoutTabDTO } from 'src/engine/metadata-modules/page-layout-tab/dtos/page-layout-tab.dto'; | |
| import { | |
| generatePageLayoutTabExceptionMessage, | |
| PageLayoutTabException, | |
| PageLayoutTabExceptionCode, | |
| PageLayoutTabExceptionMessageKey, | |
| } from 'src/engine/metadata-modules/page-layout-tab/exceptions/page-layout-tab.exception'; | |
| import { PageLayoutTabRestApiExceptionFilter } from 'src/engine/metadata-modules/page-layout-tab/filters/page-layout-tab-rest-api-exception.filter'; | |
| import { PageLayoutTabService } from 'src/engine/metadata-modules/page-layout-tab/services/page-layout-tab.service'; | |
| import { PermissionsRestApiExceptionFilter } from 'src/engine/metadata-modules/permissions/utils/permissions-rest-api-exception.filter'; | |
| import { WorkspaceMigrationRunnerRestApiExceptionFilter } from 'src/engine/workspace-manager/workspace-migration/filters/workspace-migration-runner-rest-api-exception.filter'; | |
| ('rest/metadata/pageLayoutTabs') | |
| (WorkspaceAuthGuard) | |
| ( | |
| PermissionsRestApiExceptionFilter, | |
| PageLayoutTabRestApiExceptionFilter, | |
| FlatEntityMapsRestApiExceptionFilter, | |
| WorkspaceMigrationRunnerRestApiExceptionFilter, | |
| ) | |
| export class PageLayoutTabController { | |
| constructor(private readonly pageLayoutTabService: PageLayoutTabService) {} | |
| () | |
| (NoPermissionGuard) | |
| async findMany( | |
| () workspace: WorkspaceEntity, | |
| ('pageLayoutId') pageLayoutId: string, | |
| ): Promise<PageLayoutTabDTO[]> { | |
| if (!isDefined(pageLayoutId)) { | |
| throw new PageLayoutTabException( | |
| generatePageLayoutTabExceptionMessage( | |
| PageLayoutTabExceptionMessageKey.PAGE_LAYOUT_ID_REQUIRED, | |
| ), | |
| PageLayoutTabExceptionCode.INVALID_PAGE_LAYOUT_TAB_DATA, | |
| ); | |
| } | |
| return this.pageLayoutTabService.findByPageLayoutId({ | |
| workspaceId: workspace.id, | |
| pageLayoutId, | |
| }); | |
| } | |
| (':id') | |
| (NoPermissionGuard) | |
| async findOne( | |
| ('id') id: string, | |
| () workspace: WorkspaceEntity, | |
| ): Promise<PageLayoutTabDTO | null> { | |
| return this.pageLayoutTabService.findByIdOrThrow({ | |
| id, | |
| workspaceId: workspace.id, | |
| }); | |
| } | |
| () | |
| (SettingsPermissionGuard(PermissionFlagType.LAYOUTS)) | |
| async create( | |
| () input: CreatePageLayoutTabInput, | |
| () workspace: WorkspaceEntity, | |
| ): Promise<PageLayoutTabDTO> { | |
| return this.pageLayoutTabService.create({ | |
| createPageLayoutTabInput: input, | |
| workspaceId: workspace.id, | |
| }); | |
| } | |
| (':id') | |
| (SettingsPermissionGuard(PermissionFlagType.LAYOUTS)) | |
| async update( | |
| ('id') id: string, | |
| () input: UpdatePageLayoutTabInput, | |
| () workspace: WorkspaceEntity, | |
| ): Promise<PageLayoutTabDTO> { | |
| return this.pageLayoutTabService.update({ | |
| id, | |
| workspaceId: workspace.id, | |
| updateData: input, | |
| }); | |
| } | |
| (':id') | |
| (SettingsPermissionGuard(PermissionFlagType.LAYOUTS)) | |
| async destroy( | |
| ('id') id: string, | |
| () workspace: WorkspaceEntity, | |
| ): Promise<boolean> { | |
| return this.pageLayoutTabService.destroy({ | |
| id, | |
| workspaceId: workspace.id, | |
| }); | |
| } | |
| } | |