b7f5445926
## Problem The ESLint rule `graphql-resolvers-should-be-guarded` introduced in #15392 was failing on main because the guard `SettingsPermissionsGuard` had inconsistent naming. ## Root Cause The guard was named `SettingsPermissionsGuard` (with an 's') which was inconsistent with other permission guards: - ✅ `CustomPermissionGuard` - ✅ `NoPermissionGuard` - ✅ `ImpersonatePermissionGuard` - ❌ `SettingsPermissionsGuard` (inconsistent!) The ESLint rule checks if guard names end with `PermissionGuard`, but `SettingsPermissionsGuard` ends with `sGuard`, so it wasn't recognized as a permission guard. ## Solution Renamed the guard to be consistent with the naming convention: 1. ✅ Renamed file: `settings-permissions.guard.ts` → `settings-permission.guard.ts` 2. ✅ Renamed export: `SettingsPermissionsGuard` → `SettingsPermissionGuard` 3. ✅ Renamed internal class: `SettingsPermissionsMixin` → `SettingsPermissionMixin` 4. ✅ Updated all 122 references across 44 files in the codebase 5. ✅ Renamed test file: `settings-permissions.guard.spec.ts` → `settings-permission.guard.spec.ts` ## Testing - ✅ `npx nx run twenty-server:lint` passes - ✅ `npx nx run twenty-server:typecheck` passes - ✅ No references to the old name remain in the codebase - ✅ All previously failing resolver files now pass ESLint validation ## Related Fixes issues introduced in #15392
85 lines
3.4 KiB
TypeScript
85 lines
3.4 KiB
TypeScript
import { UseFilters, UseGuards, UsePipes } from '@nestjs/common';
|
|
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';
|
|
|
|
import { PreventNestToAutoLogGraphqlErrorsFilter } from 'src/engine/core-modules/graphql/filters/prevent-nest-to-auto-log-graphql-errors.filter';
|
|
import { ResolverValidationPipe } from 'src/engine/core-modules/graphql/pipes/resolver-validation.pipe';
|
|
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
|
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator';
|
|
import { SettingsPermissionGuard } from 'src/engine/guards/settings-permission.guard';
|
|
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard';
|
|
import { PermissionFlagType } from 'src/engine/metadata-modules/permissions/constants/permission-flag-type.constants';
|
|
import { FindManyRemoteTablesInput } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/find-many-remote-tables-input';
|
|
import { RemoteTableInput } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/remote-table-input';
|
|
import { RemoteTableDTO } from 'src/engine/metadata-modules/remote-server/remote-table/dtos/remote-table.dto';
|
|
import { RemoteTableService } from 'src/engine/metadata-modules/remote-server/remote-table/remote-table.service';
|
|
import { remoteTableGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/remote-server/remote-table/utils/remote-table-graphql-api-exception-handler.util';
|
|
|
|
@UseGuards(WorkspaceAuthGuard)
|
|
@UsePipes(ResolverValidationPipe)
|
|
@UseFilters(PreventNestToAutoLogGraphqlErrorsFilter)
|
|
@Resolver()
|
|
export class RemoteTableResolver {
|
|
constructor(private readonly remoteTableService: RemoteTableService) {}
|
|
|
|
@Query(() => [RemoteTableDTO])
|
|
async findDistantTablesWithStatus(
|
|
@Args('input') input: FindManyRemoteTablesInput,
|
|
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
|
|
) {
|
|
try {
|
|
return await this.remoteTableService.findDistantTablesWithStatus(
|
|
input.id,
|
|
workspaceId,
|
|
input.shouldFetchPendingSchemaUpdates,
|
|
);
|
|
} catch (error) {
|
|
remoteTableGraphqlApiExceptionHandler(error);
|
|
}
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
@UseGuards(SettingsPermissionGuard(PermissionFlagType.DATA_MODEL))
|
|
async syncRemoteTable(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
|
|
) {
|
|
try {
|
|
return await this.remoteTableService.syncRemoteTable(input, workspaceId);
|
|
} catch (error) {
|
|
remoteTableGraphqlApiExceptionHandler(error);
|
|
}
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
@UseGuards(SettingsPermissionGuard(PermissionFlagType.DATA_MODEL))
|
|
async unsyncRemoteTable(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
|
|
) {
|
|
try {
|
|
return await this.remoteTableService.unsyncRemoteTable(
|
|
input,
|
|
workspaceId,
|
|
);
|
|
} catch (error) {
|
|
remoteTableGraphqlApiExceptionHandler(error);
|
|
}
|
|
}
|
|
|
|
@Mutation(() => RemoteTableDTO)
|
|
@UseGuards(SettingsPermissionGuard(PermissionFlagType.DATA_MODEL))
|
|
async syncRemoteTableSchemaChanges(
|
|
@Args('input') input: RemoteTableInput,
|
|
@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,
|
|
) {
|
|
try {
|
|
return await this.remoteTableService.syncRemoteTableSchemaChanges(
|
|
input,
|
|
workspaceId,
|
|
);
|
|
} catch (error) {
|
|
remoteTableGraphqlApiExceptionHandler(error);
|
|
}
|
|
}
|
|
}
|