[Billing for self host] End dummy enterprise key validity (#19560)
<img width="1504" height="755" alt="Screenshot 2026-04-10 at 16 40 07" src="https://github.com/user-attachments/assets/68a12e40-a077-48df-9e18-885493520a32" /> Re-using hasValidEnterpriseKey to avoid breaking changes. This will be entirely removed in the next versions.
This commit is contained in:
@@ -63,6 +63,7 @@ import { UpsertRowLevelPermissionPredicatesInput } from 'src/engine/metadata-mod
|
||||
import { RowLevelPermissionPredicateGroupDTO } from 'src/engine/metadata-modules/row-level-permission-predicate/dtos/row-level-permission-predicate-group.dto';
|
||||
import { RowLevelPermissionPredicateDTO } from 'src/engine/metadata-modules/row-level-permission-predicate/dtos/row-level-permission-predicate.dto';
|
||||
import { UpsertRowLevelPermissionPredicatesResultDTO } from 'src/engine/metadata-modules/row-level-permission-predicate/dtos/upsert-row-level-permission-predicates-result.dto';
|
||||
import { RowLevelPermissionPredicateGraphqlApiExceptionFilter } from 'src/engine/metadata-modules/row-level-permission-predicate/filters/row-level-permission-predicate-graphql-api-exception.filter';
|
||||
import { RowLevelPermissionPredicateGroupService } from 'src/engine/metadata-modules/row-level-permission-predicate/services/row-level-permission-predicate-group.service';
|
||||
import { RowLevelPermissionPredicateService } from 'src/engine/metadata-modules/row-level-permission-predicate/services/row-level-permission-predicate.service';
|
||||
import { UserRoleService } from 'src/engine/metadata-modules/user-role/user-role.service';
|
||||
@@ -77,6 +78,7 @@ import { WorkspaceMemberWorkspaceEntity } from 'src/modules/workspace-member/sta
|
||||
SettingsPermissionGuard(PermissionFlagType.ROLES),
|
||||
)
|
||||
@UseFilters(
|
||||
RowLevelPermissionPredicateGraphqlApiExceptionFilter,
|
||||
PermissionsGraphqlApiExceptionFilter,
|
||||
PreventNestToAutoLogGraphqlErrorsFilter,
|
||||
)
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/* @license Enterprise */
|
||||
|
||||
import { Catch, type ExceptionFilter } from '@nestjs/common';
|
||||
|
||||
import { RowLevelPermissionPredicateException } from 'src/engine/metadata-modules/row-level-permission-predicate/exceptions/row-level-permission-predicate.exception';
|
||||
import { rowLevelPermissionPredicateGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/row-level-permission-predicate/utils/row-level-permission-predicate-graphql-api-exception-handler.util';
|
||||
|
||||
@Catch(RowLevelPermissionPredicateException)
|
||||
export class RowLevelPermissionPredicateGraphqlApiExceptionFilter
|
||||
implements ExceptionFilter
|
||||
{
|
||||
catch(exception: RowLevelPermissionPredicateException) {
|
||||
return rowLevelPermissionPredicateGraphqlApiExceptionHandler(exception);
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
ForbiddenError,
|
||||
InternalServerError,
|
||||
NotFoundError,
|
||||
UserInputError,
|
||||
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
import {
|
||||
RowLevelPermissionPredicateException,
|
||||
RowLevelPermissionPredicateExceptionCode,
|
||||
} from 'src/engine/metadata-modules/row-level-permission-predicate/exceptions/row-level-permission-predicate.exception';
|
||||
import { rowLevelPermissionPredicateGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/row-level-permission-predicate/utils/row-level-permission-predicate-graphql-api-exception-handler.util';
|
||||
|
||||
describe('rowLevelPermissionPredicateGraphqlApiExceptionHandler', () => {
|
||||
it('should throw ForbiddenError for ROW_LEVEL_PERMISSION_FEATURE_DISABLED', () => {
|
||||
const exception = new RowLevelPermissionPredicateException(
|
||||
'Row level permission predicate feature is disabled.',
|
||||
RowLevelPermissionPredicateExceptionCode.ROW_LEVEL_PERMISSION_FEATURE_DISABLED,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
rowLevelPermissionPredicateGraphqlApiExceptionHandler(exception),
|
||||
).toThrow(ForbiddenError);
|
||||
});
|
||||
|
||||
it('should throw NotFoundError for ROW_LEVEL_PERMISSION_PREDICATE_NOT_FOUND', () => {
|
||||
const exception = new RowLevelPermissionPredicateException(
|
||||
'Predicate not found',
|
||||
RowLevelPermissionPredicateExceptionCode.ROW_LEVEL_PERMISSION_PREDICATE_NOT_FOUND,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
rowLevelPermissionPredicateGraphqlApiExceptionHandler(exception),
|
||||
).toThrow(NotFoundError);
|
||||
});
|
||||
|
||||
it('should throw UserInputError for INVALID_ROW_LEVEL_PERMISSION_PREDICATE_DATA', () => {
|
||||
const exception = new RowLevelPermissionPredicateException(
|
||||
'Invalid data',
|
||||
RowLevelPermissionPredicateExceptionCode.INVALID_ROW_LEVEL_PERMISSION_PREDICATE_DATA,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
rowLevelPermissionPredicateGraphqlApiExceptionHandler(exception),
|
||||
).toThrow(UserInputError);
|
||||
});
|
||||
|
||||
it('should throw InternalServerError for INTERNAL_SERVER_ERROR', () => {
|
||||
const exception = new RowLevelPermissionPredicateException(
|
||||
'Unexpected',
|
||||
RowLevelPermissionPredicateExceptionCode.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
rowLevelPermissionPredicateGraphqlApiExceptionHandler(exception),
|
||||
).toThrow(InternalServerError);
|
||||
});
|
||||
});
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/* @license Enterprise */
|
||||
|
||||
import { assertUnreachable } from 'twenty-shared/utils';
|
||||
|
||||
import {
|
||||
ForbiddenError,
|
||||
InternalServerError,
|
||||
NotFoundError,
|
||||
UserInputError,
|
||||
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||
import {
|
||||
type RowLevelPermissionPredicateException,
|
||||
RowLevelPermissionPredicateExceptionCode,
|
||||
} from 'src/engine/metadata-modules/row-level-permission-predicate/exceptions/row-level-permission-predicate.exception';
|
||||
|
||||
export const rowLevelPermissionPredicateGraphqlApiExceptionHandler = (
|
||||
error: RowLevelPermissionPredicateException,
|
||||
) => {
|
||||
switch (error.code) {
|
||||
case RowLevelPermissionPredicateExceptionCode.ROW_LEVEL_PERMISSION_FEATURE_DISABLED:
|
||||
case RowLevelPermissionPredicateExceptionCode.UNAUTHORIZED_ROLE_MODIFICATION:
|
||||
case RowLevelPermissionPredicateExceptionCode.UNAUTHORIZED_OBJECT_MODIFICATION:
|
||||
throw new ForbiddenError(error);
|
||||
case RowLevelPermissionPredicateExceptionCode.INVALID_ROW_LEVEL_PERMISSION_PREDICATE_DATA:
|
||||
throw new UserInputError(error);
|
||||
case RowLevelPermissionPredicateExceptionCode.ROW_LEVEL_PERMISSION_PREDICATE_NOT_FOUND:
|
||||
case RowLevelPermissionPredicateExceptionCode.FIELD_METADATA_NOT_FOUND:
|
||||
case RowLevelPermissionPredicateExceptionCode.OBJECT_METADATA_NOT_FOUND:
|
||||
case RowLevelPermissionPredicateExceptionCode.ROLE_NOT_FOUND:
|
||||
throw new NotFoundError(error);
|
||||
case RowLevelPermissionPredicateExceptionCode.INTERNAL_SERVER_ERROR:
|
||||
throw new InternalServerError(error);
|
||||
default: {
|
||||
return assertUnreachable(error.code);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user