feat(server): search user in workspace (#9870)

This commit is contained in:
forehalo
2025-01-23 08:09:16 +00:00
parent 2088b760bf
commit 85434fe309
4 changed files with 57 additions and 16 deletions

View File

@@ -250,6 +250,13 @@ export const USER_FRIENDLY_ERRORS = {
message: 'Resource not found.',
},
// Input errors
query_too_long: {
type: 'invalid_input',
args: { max: 'number' },
message: ({ max }) => `Query is too long, max length is ${max}.`,
},
// User Errors
user_not_found: {
type: 'resource_not_found',

View File

@@ -21,6 +21,16 @@ export class NotFound extends UserFriendlyError {
super('resource_not_found', 'not_found', message);
}
}
@ObjectType()
class QueryTooLongDataType {
@Field() max!: number
}
export class QueryTooLong extends UserFriendlyError {
constructor(args: QueryTooLongDataType, message?: string | ((args: QueryTooLongDataType) => string)) {
super('invalid_input', 'query_too_long', message, args);
}
}
export class UserNotFound extends UserFriendlyError {
constructor(message?: string) {
@@ -645,6 +655,7 @@ export enum ErrorNames {
INTERNAL_SERVER_ERROR,
TOO_MANY_REQUEST,
NOT_FOUND,
QUERY_TOO_LONG,
USER_NOT_FOUND,
USER_AVATAR_NOT_FOUND,
EMAIL_ALREADY_USED,
@@ -735,5 +746,5 @@ registerEnumType(ErrorNames, {
export const ErrorDataUnionType = createUnionType({
name: 'ErrorDataUnion',
types: () =>
[WrongSignInCredentialsDataType, UnknownOauthProviderDataType, MissingOauthQueryParameterDataType, InvalidEmailDataType, InvalidPasswordLengthDataType, SpaceNotFoundDataType, MemberNotFoundInSpaceDataType, NotInSpaceDataType, AlreadyInSpaceDataType, SpaceAccessDeniedDataType, SpaceOwnerNotFoundDataType, DocNotFoundDataType, DocAccessDeniedDataType, VersionRejectedDataType, InvalidHistoryTimestampDataType, DocHistoryNotFoundDataType, BlobNotFoundDataType, UnsupportedSubscriptionPlanDataType, SubscriptionAlreadyExistsDataType, SubscriptionNotExistsDataType, SameSubscriptionRecurringDataType, SubscriptionPlanNotFoundDataType, CopilotMessageNotFoundDataType, CopilotPromptNotFoundDataType, CopilotProviderSideErrorDataType, RuntimeConfigNotFoundDataType, InvalidRuntimeConfigTypeDataType, InvalidLicenseUpdateParamsDataType, WorkspaceMembersExceedLimitToDowngradeDataType] as const,
[QueryTooLongDataType, WrongSignInCredentialsDataType, UnknownOauthProviderDataType, MissingOauthQueryParameterDataType, InvalidEmailDataType, InvalidPasswordLengthDataType, SpaceNotFoundDataType, MemberNotFoundInSpaceDataType, NotInSpaceDataType, AlreadyInSpaceDataType, SpaceAccessDeniedDataType, SpaceOwnerNotFoundDataType, DocNotFoundDataType, DocAccessDeniedDataType, VersionRejectedDataType, InvalidHistoryTimestampDataType, DocHistoryNotFoundDataType, BlobNotFoundDataType, UnsupportedSubscriptionPlanDataType, SubscriptionAlreadyExistsDataType, SubscriptionNotExistsDataType, SameSubscriptionRecurringDataType, SubscriptionPlanNotFoundDataType, CopilotMessageNotFoundDataType, CopilotPromptNotFoundDataType, CopilotProviderSideErrorDataType, RuntimeConfigNotFoundDataType, InvalidRuntimeConfigTypeDataType, InvalidLicenseUpdateParamsDataType, WorkspaceMembersExceedLimitToDowngradeDataType] as const,
});