chore(server): lint ignore error gen file (#7245)

This commit is contained in:
EYHN
2024-06-18 08:48:19 +00:00
parent 98258b0211
commit 390852f8be
3 changed files with 59 additions and 147 deletions

View File

@@ -12,6 +12,7 @@ storybook-static
web-static web-static
public public
packages/backend/server/src/schema.gql packages/backend/server/src/schema.gql
packages/backend/server/src/fundamentals/error/errors.gen.ts
packages/frontend/i18n/src/i18n-generated.ts packages/frontend/i18n/src/i18n-generated.ts
packages/frontend/graphql/src/graphql/index.ts packages/frontend/graphql/src/graphql/index.ts
tests/affine-legacy/**/static tests/affine-legacy/**/static

View File

@@ -133,6 +133,7 @@ function generateErrorArgs(name: string, args: ErrorArgs) {
export function generateUserFriendlyErrors() { export function generateUserFriendlyErrors() {
const output = [ const output = [
'/* eslint-disable */',
'// AUTO GENERATED FILE', '// AUTO GENERATED FILE',
`import { createUnionType, Field, ObjectType, registerEnumType } from '@nestjs/graphql';`, `import { createUnionType, Field, ObjectType, registerEnumType } from '@nestjs/graphql';`,
'', '',

View File

@@ -1,10 +1,6 @@
/* eslint-disable */
// AUTO GENERATED FILE // AUTO GENERATED FILE
import { import { createUnionType, Field, ObjectType, registerEnumType } from '@nestjs/graphql';
createUnionType,
Field,
ObjectType,
registerEnumType,
} from '@nestjs/graphql';
import { UserFriendlyError } from './def'; import { UserFriendlyError } from './def';
@@ -51,14 +47,11 @@ export class WrongSignInCredentials extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class UnknownOauthProviderDataType { class UnknownOauthProviderDataType {
@Field() name!: string; @Field() name!: string
} }
export class UnknownOauthProvider extends UserFriendlyError { export class UnknownOauthProvider extends UserFriendlyError {
constructor( constructor(args: UnknownOauthProviderDataType, message?: string | ((args: UnknownOauthProviderDataType) => string)) {
args: UnknownOauthProviderDataType,
message?: string | ((args: UnknownOauthProviderDataType) => string)
) {
super('invalid_input', 'unknown_oauth_provider', message, args); super('invalid_input', 'unknown_oauth_provider', message, args);
} }
} }
@@ -76,14 +69,11 @@ export class InvalidOauthCallbackState extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class MissingOauthQueryParameterDataType { class MissingOauthQueryParameterDataType {
@Field() name!: string; @Field() name!: string
} }
export class MissingOauthQueryParameter extends UserFriendlyError { export class MissingOauthQueryParameter extends UserFriendlyError {
constructor( constructor(args: MissingOauthQueryParameterDataType, message?: string | ((args: MissingOauthQueryParameterDataType) => string)) {
args: MissingOauthQueryParameterDataType,
message?: string | ((args: MissingOauthQueryParameterDataType) => string)
) {
super('bad_request', 'missing_oauth_query_parameter', message, args); super('bad_request', 'missing_oauth_query_parameter', message, args);
} }
} }
@@ -101,15 +91,12 @@ export class InvalidEmail extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class InvalidPasswordLengthDataType { class InvalidPasswordLengthDataType {
@Field() min!: number; @Field() min!: number
@Field() max!: number; @Field() max!: number
} }
export class InvalidPasswordLength extends UserFriendlyError { export class InvalidPasswordLength extends UserFriendlyError {
constructor( constructor(args: InvalidPasswordLengthDataType, message?: string | ((args: InvalidPasswordLengthDataType) => string)) {
args: InvalidPasswordLengthDataType,
message?: string | ((args: InvalidPasswordLengthDataType) => string)
) {
super('invalid_input', 'invalid_password_length', message, args); super('invalid_input', 'invalid_password_length', message, args);
} }
} }
@@ -169,53 +156,41 @@ export class EmailVerificationRequired extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class WorkspaceNotFoundDataType { class WorkspaceNotFoundDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
} }
export class WorkspaceNotFound extends UserFriendlyError { export class WorkspaceNotFound extends UserFriendlyError {
constructor( constructor(args: WorkspaceNotFoundDataType, message?: string | ((args: WorkspaceNotFoundDataType) => string)) {
args: WorkspaceNotFoundDataType,
message?: string | ((args: WorkspaceNotFoundDataType) => string)
) {
super('resource_not_found', 'workspace_not_found', message, args); super('resource_not_found', 'workspace_not_found', message, args);
} }
} }
@ObjectType() @ObjectType()
class NotInWorkspaceDataType { class NotInWorkspaceDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
} }
export class NotInWorkspace extends UserFriendlyError { export class NotInWorkspace extends UserFriendlyError {
constructor( constructor(args: NotInWorkspaceDataType, message?: string | ((args: NotInWorkspaceDataType) => string)) {
args: NotInWorkspaceDataType,
message?: string | ((args: NotInWorkspaceDataType) => string)
) {
super('action_forbidden', 'not_in_workspace', message, args); super('action_forbidden', 'not_in_workspace', message, args);
} }
} }
@ObjectType() @ObjectType()
class WorkspaceAccessDeniedDataType { class WorkspaceAccessDeniedDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
} }
export class WorkspaceAccessDenied extends UserFriendlyError { export class WorkspaceAccessDenied extends UserFriendlyError {
constructor( constructor(args: WorkspaceAccessDeniedDataType, message?: string | ((args: WorkspaceAccessDeniedDataType) => string)) {
args: WorkspaceAccessDeniedDataType,
message?: string | ((args: WorkspaceAccessDeniedDataType) => string)
) {
super('no_permission', 'workspace_access_denied', message, args); super('no_permission', 'workspace_access_denied', message, args);
} }
} }
@ObjectType() @ObjectType()
class WorkspaceOwnerNotFoundDataType { class WorkspaceOwnerNotFoundDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
} }
export class WorkspaceOwnerNotFound extends UserFriendlyError { export class WorkspaceOwnerNotFound extends UserFriendlyError {
constructor( constructor(args: WorkspaceOwnerNotFoundDataType, message?: string | ((args: WorkspaceOwnerNotFoundDataType) => string)) {
args: WorkspaceOwnerNotFoundDataType,
message?: string | ((args: WorkspaceOwnerNotFoundDataType) => string)
) {
super('internal_server_error', 'workspace_owner_not_found', message, args); super('internal_server_error', 'workspace_owner_not_found', message, args);
} }
} }
@@ -227,85 +202,67 @@ export class CantChangeWorkspaceOwner extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class DocNotFoundDataType { class DocNotFoundDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
@Field() docId!: string; @Field() docId!: string
} }
export class DocNotFound extends UserFriendlyError { export class DocNotFound extends UserFriendlyError {
constructor( constructor(args: DocNotFoundDataType, message?: string | ((args: DocNotFoundDataType) => string)) {
args: DocNotFoundDataType,
message?: string | ((args: DocNotFoundDataType) => string)
) {
super('resource_not_found', 'doc_not_found', message, args); super('resource_not_found', 'doc_not_found', message, args);
} }
} }
@ObjectType() @ObjectType()
class DocAccessDeniedDataType { class DocAccessDeniedDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
@Field() docId!: string; @Field() docId!: string
} }
export class DocAccessDenied extends UserFriendlyError { export class DocAccessDenied extends UserFriendlyError {
constructor( constructor(args: DocAccessDeniedDataType, message?: string | ((args: DocAccessDeniedDataType) => string)) {
args: DocAccessDeniedDataType,
message?: string | ((args: DocAccessDeniedDataType) => string)
) {
super('no_permission', 'doc_access_denied', message, args); super('no_permission', 'doc_access_denied', message, args);
} }
} }
@ObjectType() @ObjectType()
class VersionRejectedDataType { class VersionRejectedDataType {
@Field() version!: string; @Field() version!: string
@Field() serverVersion!: string; @Field() serverVersion!: string
} }
export class VersionRejected extends UserFriendlyError { export class VersionRejected extends UserFriendlyError {
constructor( constructor(args: VersionRejectedDataType, message?: string | ((args: VersionRejectedDataType) => string)) {
args: VersionRejectedDataType,
message?: string | ((args: VersionRejectedDataType) => string)
) {
super('action_forbidden', 'version_rejected', message, args); super('action_forbidden', 'version_rejected', message, args);
} }
} }
@ObjectType() @ObjectType()
class InvalidHistoryTimestampDataType { class InvalidHistoryTimestampDataType {
@Field() timestamp!: string; @Field() timestamp!: string
} }
export class InvalidHistoryTimestamp extends UserFriendlyError { export class InvalidHistoryTimestamp extends UserFriendlyError {
constructor( constructor(args: InvalidHistoryTimestampDataType, message?: string | ((args: InvalidHistoryTimestampDataType) => string)) {
args: InvalidHistoryTimestampDataType,
message?: string | ((args: InvalidHistoryTimestampDataType) => string)
) {
super('invalid_input', 'invalid_history_timestamp', message, args); super('invalid_input', 'invalid_history_timestamp', message, args);
} }
} }
@ObjectType() @ObjectType()
class DocHistoryNotFoundDataType { class DocHistoryNotFoundDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
@Field() docId!: string; @Field() docId!: string
@Field() timestamp!: number; @Field() timestamp!: number
} }
export class DocHistoryNotFound extends UserFriendlyError { export class DocHistoryNotFound extends UserFriendlyError {
constructor( constructor(args: DocHistoryNotFoundDataType, message?: string | ((args: DocHistoryNotFoundDataType) => string)) {
args: DocHistoryNotFoundDataType,
message?: string | ((args: DocHistoryNotFoundDataType) => string)
) {
super('resource_not_found', 'doc_history_not_found', message, args); super('resource_not_found', 'doc_history_not_found', message, args);
} }
} }
@ObjectType() @ObjectType()
class BlobNotFoundDataType { class BlobNotFoundDataType {
@Field() workspaceId!: string; @Field() workspaceId!: string
@Field() blobId!: string; @Field() blobId!: string
} }
export class BlobNotFound extends UserFriendlyError { export class BlobNotFound extends UserFriendlyError {
constructor( constructor(args: BlobNotFoundDataType, message?: string | ((args: BlobNotFoundDataType) => string)) {
args: BlobNotFoundDataType,
message?: string | ((args: BlobNotFoundDataType) => string)
) {
super('resource_not_found', 'blob_not_found', message, args); super('resource_not_found', 'blob_not_found', message, args);
} }
} }
@@ -335,32 +292,21 @@ export class FailedToCheckout extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class SubscriptionAlreadyExistsDataType { class SubscriptionAlreadyExistsDataType {
@Field() plan!: string; @Field() plan!: string
} }
export class SubscriptionAlreadyExists extends UserFriendlyError { export class SubscriptionAlreadyExists extends UserFriendlyError {
constructor( constructor(args: SubscriptionAlreadyExistsDataType, message?: string | ((args: SubscriptionAlreadyExistsDataType) => string)) {
args: SubscriptionAlreadyExistsDataType, super('resource_already_exists', 'subscription_already_exists', message, args);
message?: string | ((args: SubscriptionAlreadyExistsDataType) => string)
) {
super(
'resource_already_exists',
'subscription_already_exists',
message,
args
);
} }
} }
@ObjectType() @ObjectType()
class SubscriptionNotExistsDataType { class SubscriptionNotExistsDataType {
@Field() plan!: string; @Field() plan!: string
} }
export class SubscriptionNotExists extends UserFriendlyError { export class SubscriptionNotExists extends UserFriendlyError {
constructor( constructor(args: SubscriptionNotExistsDataType, message?: string | ((args: SubscriptionNotExistsDataType) => string)) {
args: SubscriptionNotExistsDataType,
message?: string | ((args: SubscriptionNotExistsDataType) => string)
) {
super('resource_not_found', 'subscription_not_exists', message, args); super('resource_not_found', 'subscription_not_exists', message, args);
} }
} }
@@ -378,14 +324,11 @@ export class SubscriptionExpired extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class SameSubscriptionRecurringDataType { class SameSubscriptionRecurringDataType {
@Field() recurring!: string; @Field() recurring!: string
} }
export class SameSubscriptionRecurring extends UserFriendlyError { export class SameSubscriptionRecurring extends UserFriendlyError {
constructor( constructor(args: SameSubscriptionRecurringDataType, message?: string | ((args: SameSubscriptionRecurringDataType) => string)) {
args: SameSubscriptionRecurringDataType,
message?: string | ((args: SameSubscriptionRecurringDataType) => string)
) {
super('bad_request', 'same_subscription_recurring', message, args); super('bad_request', 'same_subscription_recurring', message, args);
} }
} }
@@ -397,15 +340,12 @@ export class CustomerPortalCreateFailed extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class SubscriptionPlanNotFoundDataType { class SubscriptionPlanNotFoundDataType {
@Field() plan!: string; @Field() plan!: string
@Field() recurring!: string; @Field() recurring!: string
} }
export class SubscriptionPlanNotFound extends UserFriendlyError { export class SubscriptionPlanNotFound extends UserFriendlyError {
constructor( constructor(args: SubscriptionPlanNotFoundDataType, message?: string | ((args: SubscriptionPlanNotFoundDataType) => string)) {
args: SubscriptionPlanNotFoundDataType,
message?: string | ((args: SubscriptionPlanNotFoundDataType) => string)
) {
super('resource_not_found', 'subscription_plan_not_found', message, args); super('resource_not_found', 'subscription_plan_not_found', message, args);
} }
} }
@@ -459,14 +399,11 @@ export class CopilotMessageNotFound extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class CopilotPromptNotFoundDataType { class CopilotPromptNotFoundDataType {
@Field() name!: string; @Field() name!: string
} }
export class CopilotPromptNotFound extends UserFriendlyError { export class CopilotPromptNotFound extends UserFriendlyError {
constructor( constructor(args: CopilotPromptNotFoundDataType, message?: string | ((args: CopilotPromptNotFoundDataType) => string)) {
args: CopilotPromptNotFoundDataType,
message?: string | ((args: CopilotPromptNotFoundDataType) => string)
) {
super('resource_not_found', 'copilot_prompt_not_found', message, args); super('resource_not_found', 'copilot_prompt_not_found', message, args);
} }
} }
@@ -490,29 +427,23 @@ export class CopilotQuotaExceeded extends UserFriendlyError {
} }
@ObjectType() @ObjectType()
class RuntimeConfigNotFoundDataType { class RuntimeConfigNotFoundDataType {
@Field() key!: string; @Field() key!: string
} }
export class RuntimeConfigNotFound extends UserFriendlyError { export class RuntimeConfigNotFound extends UserFriendlyError {
constructor( constructor(args: RuntimeConfigNotFoundDataType, message?: string | ((args: RuntimeConfigNotFoundDataType) => string)) {
args: RuntimeConfigNotFoundDataType,
message?: string | ((args: RuntimeConfigNotFoundDataType) => string)
) {
super('resource_not_found', 'runtime_config_not_found', message, args); super('resource_not_found', 'runtime_config_not_found', message, args);
} }
} }
@ObjectType() @ObjectType()
class InvalidRuntimeConfigTypeDataType { class InvalidRuntimeConfigTypeDataType {
@Field() key!: string; @Field() key!: string
@Field() want!: string; @Field() want!: string
@Field() get!: string; @Field() get!: string
} }
export class InvalidRuntimeConfigType extends UserFriendlyError { export class InvalidRuntimeConfigType extends UserFriendlyError {
constructor( constructor(args: InvalidRuntimeConfigTypeDataType, message?: string | ((args: InvalidRuntimeConfigTypeDataType) => string)) {
args: InvalidRuntimeConfigTypeDataType,
message?: string | ((args: InvalidRuntimeConfigTypeDataType) => string)
) {
super('invalid_input', 'invalid_runtime_config_type', message, args); super('invalid_input', 'invalid_runtime_config_type', message, args);
} }
} }
@@ -582,35 +513,14 @@ export enum ErrorNames {
COPILOT_QUOTA_EXCEEDED, COPILOT_QUOTA_EXCEEDED,
RUNTIME_CONFIG_NOT_FOUND, RUNTIME_CONFIG_NOT_FOUND,
INVALID_RUNTIME_CONFIG_TYPE, INVALID_RUNTIME_CONFIG_TYPE,
MAILER_SERVICE_IS_NOT_CONFIGURED, MAILER_SERVICE_IS_NOT_CONFIGURED
} }
registerEnumType(ErrorNames, { registerEnumType(ErrorNames, {
name: 'ErrorNames', name: 'ErrorNames'
}); })
export const ErrorDataUnionType = createUnionType({ export const ErrorDataUnionType = createUnionType({
name: 'ErrorDataUnion', name: 'ErrorDataUnion',
types: () => types: () =>
[ [UnknownOauthProviderDataType, MissingOauthQueryParameterDataType, InvalidPasswordLengthDataType, WorkspaceNotFoundDataType, NotInWorkspaceDataType, WorkspaceAccessDeniedDataType, WorkspaceOwnerNotFoundDataType, DocNotFoundDataType, DocAccessDeniedDataType, VersionRejectedDataType, InvalidHistoryTimestampDataType, DocHistoryNotFoundDataType, BlobNotFoundDataType, SubscriptionAlreadyExistsDataType, SubscriptionNotExistsDataType, SameSubscriptionRecurringDataType, SubscriptionPlanNotFoundDataType, CopilotPromptNotFoundDataType, RuntimeConfigNotFoundDataType, InvalidRuntimeConfigTypeDataType] as const,
UnknownOauthProviderDataType,
MissingOauthQueryParameterDataType,
InvalidPasswordLengthDataType,
WorkspaceNotFoundDataType,
NotInWorkspaceDataType,
WorkspaceAccessDeniedDataType,
WorkspaceOwnerNotFoundDataType,
DocNotFoundDataType,
DocAccessDeniedDataType,
VersionRejectedDataType,
InvalidHistoryTimestampDataType,
DocHistoryNotFoundDataType,
BlobNotFoundDataType,
SubscriptionAlreadyExistsDataType,
SubscriptionNotExistsDataType,
SameSubscriptionRecurringDataType,
SubscriptionPlanNotFoundDataType,
CopilotPromptNotFoundDataType,
RuntimeConfigNotFoundDataType,
InvalidRuntimeConfigTypeDataType,
] as const,
}); });