feat(server): add blocked state to workspace docs (#10585)

close CLOUD-162
This commit is contained in:
fengmk2
2025-03-05 12:49:33 +00:00
parent 70a0337ea3
commit 43ded6aa38
6 changed files with 55 additions and 9 deletions

View File

@@ -439,6 +439,12 @@ export const USER_FRIENDLY_ERRORS = {
message: ({ docId, action }) =>
`You do not have permission to perform ${action} action on doc ${docId}.`,
},
doc_update_blocked: {
type: 'action_forbidden',
args: { spaceId: 'string', docId: 'string' },
message: ({ spaceId, docId }) =>
`Doc ${docId} under Space ${spaceId} is blocked from updating.`,
},
version_rejected: {
type: 'action_forbidden',
args: { version: 'string', serverVersion: 'string' },

View File

@@ -334,6 +334,17 @@ export class DocActionDenied extends UserFriendlyError {
}
}
@ObjectType()
class DocUpdateBlockedDataType {
@Field() spaceId!: string
@Field() docId!: string
}
export class DocUpdateBlocked extends UserFriendlyError {
constructor(args: DocUpdateBlockedDataType, message?: string | ((args: DocUpdateBlockedDataType) => string)) {
super('action_forbidden', 'doc_update_blocked', message, args);
}
}
@ObjectType()
class VersionRejectedDataType {
@Field() version!: string
@Field() serverVersion!: string
@@ -871,6 +882,7 @@ export enum ErrorNames {
CAN_NOT_REVOKE_YOURSELF,
DOC_NOT_FOUND,
DOC_ACTION_DENIED,
DOC_UPDATE_BLOCKED,
VERSION_REJECTED,
INVALID_HISTORY_TIMESTAMP,
DOC_HISTORY_NOT_FOUND,
@@ -942,5 +954,5 @@ registerEnumType(ErrorNames, {
export const ErrorDataUnionType = createUnionType({
name: 'ErrorDataUnion',
types: () =>
[GraphqlBadRequestDataType, QueryTooLongDataType, WrongSignInCredentialsDataType, UnknownOauthProviderDataType, InvalidOauthCallbackCodeDataType, MissingOauthQueryParameterDataType, InvalidEmailDataType, InvalidPasswordLengthDataType, WorkspacePermissionNotFoundDataType, SpaceNotFoundDataType, MemberNotFoundInSpaceDataType, NotInSpaceDataType, AlreadyInSpaceDataType, SpaceAccessDeniedDataType, SpaceOwnerNotFoundDataType, SpaceShouldHaveOnlyOneOwnerDataType, DocNotFoundDataType, DocActionDeniedDataType, VersionRejectedDataType, InvalidHistoryTimestampDataType, DocHistoryNotFoundDataType, BlobNotFoundDataType, ExpectToGrantDocUserRolesDataType, ExpectToRevokeDocUserRolesDataType, ExpectToUpdateDocUserRoleDataType, UnsupportedSubscriptionPlanDataType, SubscriptionAlreadyExistsDataType, SubscriptionNotExistsDataType, SameSubscriptionRecurringDataType, SubscriptionPlanNotFoundDataType, CopilotDocNotFoundDataType, CopilotMessageNotFoundDataType, CopilotPromptNotFoundDataType, CopilotProviderSideErrorDataType, CopilotInvalidContextDataType, CopilotContextFileNotSupportedDataType, CopilotFailedToModifyContextDataType, CopilotFailedToMatchContextDataType, RuntimeConfigNotFoundDataType, InvalidRuntimeConfigTypeDataType, InvalidLicenseUpdateParamsDataType, WorkspaceMembersExceedLimitToDowngradeDataType, UnsupportedClientVersionDataType] as const,
[GraphqlBadRequestDataType, QueryTooLongDataType, WrongSignInCredentialsDataType, UnknownOauthProviderDataType, InvalidOauthCallbackCodeDataType, MissingOauthQueryParameterDataType, InvalidEmailDataType, InvalidPasswordLengthDataType, WorkspacePermissionNotFoundDataType, SpaceNotFoundDataType, MemberNotFoundInSpaceDataType, NotInSpaceDataType, AlreadyInSpaceDataType, SpaceAccessDeniedDataType, SpaceOwnerNotFoundDataType, SpaceShouldHaveOnlyOneOwnerDataType, DocNotFoundDataType, DocActionDeniedDataType, DocUpdateBlockedDataType, VersionRejectedDataType, InvalidHistoryTimestampDataType, DocHistoryNotFoundDataType, BlobNotFoundDataType, ExpectToGrantDocUserRolesDataType, ExpectToRevokeDocUserRolesDataType, ExpectToUpdateDocUserRoleDataType, UnsupportedSubscriptionPlanDataType, SubscriptionAlreadyExistsDataType, SubscriptionNotExistsDataType, SameSubscriptionRecurringDataType, SubscriptionPlanNotFoundDataType, CopilotDocNotFoundDataType, CopilotMessageNotFoundDataType, CopilotPromptNotFoundDataType, CopilotProviderSideErrorDataType, CopilotInvalidContextDataType, CopilotContextFileNotSupportedDataType, CopilotFailedToModifyContextDataType, CopilotFailedToMatchContextDataType, RuntimeConfigNotFoundDataType, InvalidRuntimeConfigTypeDataType, InvalidLicenseUpdateParamsDataType, WorkspaceMembersExceedLimitToDowngradeDataType, UnsupportedClientVersionDataType] as const,
});