From f889886b31eddd6e57597920e5a036b76fe7c7fd Mon Sep 17 00:00:00 2001 From: forehalo Date: Wed, 19 Mar 2025 17:00:20 +0000 Subject: [PATCH] refactor(server): e2e utilities (#11000) --- .prettierignore | 2 +- oxlint.json | 2 +- packages/backend/server/package.json | 1 + .../server/src/__tests__/e2e/app.spec.ts | 13 ++ .../server/src/__tests__/e2e/create-app.ts | 164 +++++++++++++++++- .../server/src/__tests__/e2e/prelude.ts | 7 + .../backend/server/src/__tests__/e2e/test.ts | 4 +- packages/backend/server/tsconfig.json | 1 + packages/common/debug/package.json | 1 + packages/common/error/package.json | 1 + .../{frontend => common}/graphql/README.md | 0 .../{frontend => common}/graphql/codegen.yml | 0 .../graphql/export-gql-plugin.cjs | 0 .../{frontend => common}/graphql/package.json | 0 .../graphql/src/__tests__/fetcher.spec.ts | 0 .../graphql/src/fetcher.ts | 0 .../graphql/src/graphql/activate-license.gql | 0 .../src/graphql/admin-server-config.gql | 0 .../graphql/src/graphql/blob-delete.gql | 0 .../graphql/src/graphql/blob-list.gql | 0 .../src/graphql/blob-release-deleted.gql | 0 .../graphql/src/graphql/blob-set.gql | 0 .../src/graphql/cancel-subscription.gql | 0 .../graphql/src/graphql/change-email.gql | 0 .../src/graphql/change-password-url.gql | 0 .../graphql/src/graphql/change-password.gql | 0 .../graphql/copilot-context-category-add.gql | 0 .../copilot-context-category-remove.gql | 0 .../src/graphql/copilot-context-create.gql | 0 .../src/graphql/copilot-context-doc-add.gql | 0 .../graphql/copilot-context-doc-remove.gql | 0 .../src/graphql/copilot-context-file-add.gql | 0 .../graphql/copilot-context-file-match.gql | 0 .../graphql/copilot-context-file-remove.gql | 0 .../graphql/copilot-context-list-object.gql | 0 .../src/graphql/copilot-context-list.gql | 0 .../copilot-context-workspace-match.gql | 0 .../copilot-context-workspace-query.gql | 0 .../copilot-context-workspace-queue.gql | 0 .../src/graphql/copilot-history-get-ids.gql | 0 .../src/graphql/copilot-history-list.gql | 0 .../src/graphql/copilot-message-create.gql | 0 .../src/graphql/copilot-prompt-list.gql | 0 .../src/graphql/copilot-prompt-update.gql | 0 .../graphql/src/graphql/copilot-quota.gql | 0 .../src/graphql/copilot-session-cleanup.gql | 0 .../src/graphql/copilot-session-create.gql | 0 .../src/graphql/copilot-session-fork.gql | 0 .../src/graphql/copilot-session-update.gql | 0 .../src/graphql/copilot-sessions-get.gql | 0 .../src/graphql/create-checkout-link.gql | 0 .../src/graphql/create-customer-portal.gql | 0 .../create-self-host-customer-portal.gql | 0 .../graphql/src/graphql/create-user.gql | 0 .../graphql/src/graphql/create-workspace.gql | 0 .../src/graphql/deactivate-license.gql | 0 .../graphql/src/graphql/delete-account.gql | 0 .../graphql/src/graphql/delete-user.gql | 0 .../graphql/src/graphql/delete-workspace.gql | 0 .../graphql/src/graphql/disable-user.gql | 0 .../src/graphql/doc-role-permissions.gql | 0 .../graphql/src/graphql/enable-user.gql | 0 .../fragments/credentials-requirement.gql | 0 .../src/graphql/fragments/password-limits.gql | 0 .../src/graphql/generate-license-key.gql | 0 .../src/graphql/get-current-user-features.gql | 0 .../graphql/src/graphql/get-current-user.gql | 0 .../src/graphql/get-doc-default-role.gql | 0 .../graphql/src/graphql/get-invite-info.gql | 0 .../graphql/src/graphql/get-is-admin.gql | 0 .../graphql/src/graphql/get-is-owner.gql | 0 .../graphql/src/graphql/get-license.gql | 0 .../get-member-count-by-workspace-id.gql | 0 .../graphql/get-members-by-workspace-id.gql | 0 .../src/graphql/get-oauth-providers.gql | 0 .../graphql/get-page-granted-users-list.gql | 0 .../src/graphql/get-public-user-by-id.gql | 0 .../src/graphql/get-server-runtime-config.gql | 0 .../graphql/get-server-service-configs.gql | 0 .../graphql/src/graphql/get-user-by-email.gql | 0 .../graphql/src/graphql/get-user-features.gql | 0 .../graphql/src/graphql/get-user.gql | 0 .../graphql/src/graphql/get-users-count.gql | 0 .../src/graphql/get-workspace-info.gql | 0 .../src/graphql/get-workspace-page-by-id.gql | 0 .../src/graphql/get-workspace-page-meta.gql | 0 .../graphql/get-workspace-public-by-id.gql | 0 .../graphql/get-workspace-public-pages.gql | 0 .../graphql/get-workspace-subscription.gql | 0 .../graphql/src/graphql/get-workspace.gql | 0 .../graphql/src/graphql/get-workspaces.gql | 0 .../src/graphql/grant-doc-user-roles.gql | 0 .../graphql/src/graphql/histories.gql | 0 .../graphql/src/graphql/import-users.gql | 0 .../graphql/src/graphql/index.ts | 0 .../graphql/src/graphql/invoices-count.gql | 0 .../graphql/src/graphql/invoices.gql | 0 .../graphql/src/graphql/leave-workspace.gql | 0 .../src/graphql/list-notifications.gql | 0 .../graphql/src/graphql/list-users.gql | 0 .../graphql/src/graphql/mention-user.gql | 0 .../src/graphql/notification-count.gql | 0 .../graphql/src/graphql/prices.gql | 0 .../graphql/src/graphql/public-page.gql | 0 .../graphql/src/graphql/quota.gql | 0 .../graphql/src/graphql/read-notification.gql | 0 .../graphql/src/graphql/recover-doc.gql | 0 .../graphql/src/graphql/remove-avatar.gql | 0 .../src/graphql/resume-subscription.gql | 0 .../src/graphql/revoke-doc-user-roles.gql | 0 .../src/graphql/revoke-member-permission.gql | 0 .../src/graphql/revoke-public-page.gql | 0 .../graphql/src/graphql/send-change-email.gql | 0 .../graphql/send-change-password-email.gql | 0 .../src/graphql/send-set-password-email.gql | 0 .../src/graphql/send-verify-change-email.gql | 0 .../graphql/src/graphql/send-verify-email.gql | 0 .../graphql/src/graphql/server-config.gql | 0 .../graphql/set-workspace-public-by-id.gql | 0 .../graphql/src/graphql/subscription.gql | 0 .../src/graphql/update-account-features.gql | 0 .../graphql/src/graphql/update-account.gql | 0 .../src/graphql/update-doc-default-role.gql | 0 .../src/graphql/update-doc-user-role.gql | 0 .../graphql/update-server-runtime-configs.gql | 0 .../graphql/update-subscription-billing.gql | 0 .../src/graphql/update-user-profile.gql | 0 .../graphql/src/graphql/upload-avatar.gql | 0 .../graphql/src/graphql/verify-email.gql | 0 .../graphql/src/graphql/workspace-config.gql | 0 .../src/graphql/workspace-enable-ai.gql | 0 .../graphql/workspace-enable-url-preview.gql | 0 .../src/graphql/workspace-intive-by-email.gql | 0 .../graphql/workspace-intive-by-emails.gql | 0 .../workspace-invite-accept-by-invite-id.gql | 0 .../src/graphql/workspace-invite-batch.gql | 0 .../src/graphql/workspace-invite-link.gql | 0 .../graphql/workspace-invite-revoke-link.gql | 0 .../src/graphql/workspace-invoices.gql | 0 .../graphql/src/graphql/workspace-quota.gql | 0 .../graphql/workspace-role-permissions.gql | 0 .../src/graphql/workspace-team-approve.gql | 0 .../src/graphql/workspace-team-grant.gql | 0 .../{frontend => common}/graphql/src/index.ts | 0 .../graphql/src/schema.ts | 0 .../graphql/tsconfig.json | 6 +- packages/common/nbstore/tsconfig.json | 2 +- packages/frontend/admin/tsconfig.json | 2 +- packages/frontend/component/tsconfig.json | 2 +- packages/frontend/core/tsconfig.json | 2 +- tools/utils/src/workspace.gen.ts | 29 ++-- tsconfig.json | 2 +- yarn.lock | 5 +- 153 files changed, 214 insertions(+), 32 deletions(-) rename packages/{frontend => common}/graphql/README.md (100%) rename packages/{frontend => common}/graphql/codegen.yml (100%) rename packages/{frontend => common}/graphql/export-gql-plugin.cjs (100%) rename packages/{frontend => common}/graphql/package.json (100%) rename packages/{frontend => common}/graphql/src/__tests__/fetcher.spec.ts (100%) rename packages/{frontend => common}/graphql/src/fetcher.ts (100%) rename packages/{frontend => common}/graphql/src/graphql/activate-license.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/admin-server-config.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/blob-delete.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/blob-list.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/blob-release-deleted.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/blob-set.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/cancel-subscription.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/change-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/change-password-url.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/change-password.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-category-add.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-category-remove.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-create.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-doc-add.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-doc-remove.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-file-add.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-file-match.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-file-remove.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-list-object.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-list.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-workspace-match.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-workspace-query.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-context-workspace-queue.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-history-get-ids.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-history-list.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-message-create.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-prompt-list.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-prompt-update.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-quota.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-session-cleanup.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-session-create.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-session-fork.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-session-update.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/copilot-sessions-get.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/create-checkout-link.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/create-customer-portal.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/create-self-host-customer-portal.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/create-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/create-workspace.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/deactivate-license.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/delete-account.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/delete-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/delete-workspace.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/disable-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/doc-role-permissions.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/enable-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/fragments/credentials-requirement.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/fragments/password-limits.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/generate-license-key.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-current-user-features.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-current-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-doc-default-role.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-invite-info.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-is-admin.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-is-owner.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-license.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-member-count-by-workspace-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-members-by-workspace-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-oauth-providers.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-page-granted-users-list.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-public-user-by-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-server-runtime-config.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-server-service-configs.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-user-by-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-user-features.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-users-count.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-info.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-page-by-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-page-meta.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-public-by-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-public-pages.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace-subscription.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspace.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/get-workspaces.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/grant-doc-user-roles.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/histories.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/import-users.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/index.ts (100%) rename packages/{frontend => common}/graphql/src/graphql/invoices-count.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/invoices.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/leave-workspace.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/list-notifications.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/list-users.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/mention-user.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/notification-count.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/prices.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/public-page.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/quota.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/read-notification.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/recover-doc.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/remove-avatar.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/resume-subscription.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/revoke-doc-user-roles.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/revoke-member-permission.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/revoke-public-page.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/send-change-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/send-change-password-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/send-set-password-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/send-verify-change-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/send-verify-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/server-config.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/set-workspace-public-by-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/subscription.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-account-features.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-account.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-doc-default-role.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-doc-user-role.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-server-runtime-configs.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-subscription-billing.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/update-user-profile.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/upload-avatar.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/verify-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-config.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-enable-ai.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-enable-url-preview.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-intive-by-email.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-intive-by-emails.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-invite-accept-by-invite-id.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-invite-batch.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-invite-link.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-invite-revoke-link.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-invoices.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-quota.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-role-permissions.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-team-approve.gql (100%) rename packages/{frontend => common}/graphql/src/graphql/workspace-team-grant.gql (100%) rename packages/{frontend => common}/graphql/src/index.ts (100%) rename packages/{frontend => common}/graphql/src/schema.ts (100%) rename packages/{frontend => common}/graphql/tsconfig.json (66%) diff --git a/.prettierignore b/.prettierignore index b0e1d1209..99e291466 100644 --- a/.prettierignore +++ b/.prettierignore @@ -24,13 +24,13 @@ test-results **/*.gen.ts **/*.gql **/*.d.ts -packages/frontend/graphql/src/graphql/index.ts # per files tools/cli/src/webpack/error-handler.js packages/backend/native/index.d.ts packages/backend/server/src/__tests__/__snapshots__ packages/common/native/fixtures/** +packages/common/graphql/src/graphql/index.ts packages/frontend/native/index.d.ts packages/frontend/native/index.js packages/frontend/apps/android/App/app/build/** diff --git a/oxlint.json b/oxlint.json index cdee1d161..f55ff3a5d 100644 --- a/oxlint.json +++ b/oxlint.json @@ -27,11 +27,11 @@ "**/*.gen.ts", "**/*.gql", "**/*.d.ts", - "packages/frontend/graphql/src/graphql/index.ts", "tools/cli/src/webpack/error-handler.js", "packages/backend/native/index.d.ts", "packages/backend/server/src/__tests__/__snapshots__", "packages/common/native/fixtures/**", + "packages/common/graphql/src/graphql/index.ts", "packages/frontend/native/index.d.ts", "packages/frontend/native/index.js", "packages/frontend/apps/android/App/app/build/**", diff --git a/packages/backend/server/package.json b/packages/backend/server/package.json index aa1ad3e18..d91a7fe88 100644 --- a/packages/backend/server/package.json +++ b/packages/backend/server/package.json @@ -114,6 +114,7 @@ "devDependencies": { "@affine-tools/cli": "workspace:*", "@affine-tools/utils": "workspace:*", + "@affine/graphql": "workspace:*", "@affine/server-native": "workspace:*", "@faker-js/faker": "^9.6.0", "@nestjs/testing": "patch:@nestjs/testing@npm%3A10.4.15#~/.yarn/patches/@nestjs-testing-npm-10.4.15-d591a1705a.patch", diff --git a/packages/backend/server/src/__tests__/e2e/app.spec.ts b/packages/backend/server/src/__tests__/e2e/app.spec.ts index 7c808c0b6..6df243f1c 100644 --- a/packages/backend/server/src/__tests__/e2e/app.spec.ts +++ b/packages/backend/server/src/__tests__/e2e/app.spec.ts @@ -1,5 +1,18 @@ +import { getCurrentUserQuery } from '@affine/graphql'; + import { app, e2e } from './test'; e2e('should create test app correctly', async t => { t.truthy(app); }); + +e2e('should handle http request', async t => { + const res = await app.GET('/info'); + t.is(res.status, 200); + t.is(res.body.compatibility, AFFiNE.version); +}); + +e2e('should handle gql request', async t => { + const user = await app.gql({ query: getCurrentUserQuery }); + t.is(user.currentUser, null); +}); diff --git a/packages/backend/server/src/__tests__/e2e/create-app.ts b/packages/backend/server/src/__tests__/e2e/create-app.ts index b92ed3f43..d1a0b3975 100644 --- a/packages/backend/server/src/__tests__/e2e/create-app.ts +++ b/packages/backend/server/src/__tests__/e2e/create-app.ts @@ -1,8 +1,13 @@ +import assert from 'node:assert'; + +import { gqlFetcherFactory } from '@affine/graphql'; import { INestApplication } from '@nestjs/common'; import { NestApplication } from '@nestjs/core'; import { Test, TestingModuleBuilder } from '@nestjs/testing'; +import { PrismaClient } from '@prisma/client'; import cookieParser from 'cookie-parser'; import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.mjs'; +import supertest from 'supertest'; import { AFFiNELogger, @@ -12,10 +17,16 @@ import { OneMB, } from '../../base'; import { SocketIoAdapter } from '../../base/websocket'; -import { AuthGuard } from '../../core/auth'; +import { AuthGuard, AuthService } from '../../core/auth'; import { Mailer } from '../../core/mail'; -import { MockMailer } from '../mocks'; -import { TEST_LOG_LEVEL } from '../utils'; +import { + createFactory, + MockedUser, + MockMailer, + MockUser, + MockUserInput, +} from '../mocks'; +import { parseCookies, TEST_LOG_LEVEL } from '../utils'; interface TestingAppMetadata { tapModule?(m: TestingModuleBuilder): void; @@ -23,18 +34,158 @@ interface TestingAppMetadata { } export class TestingApp extends NestApplication { - get mails() { - return this.get(Mailer, { strict: false }) as MockMailer; + private sessionCookie: string | null = null; + private currentUserCookie: string | null = null; + private readonly userCookies: Set = new Set(); + + create = createFactory(this.get(PrismaClient, { strict: false })); + mails = this.get(Mailer, { strict: false }) as MockMailer; + + get url() { + const server = this.getHttpServer(); + if (!server.address()) { + server.listen(); + } + return `http://localhost:${server.address().port}`; } async [Symbol.asyncDispose]() { await this.close(); } + + request( + method: 'options' | 'get' | 'post' | 'put' | 'delete' | 'patch', + path: string + ): supertest.Test { + return supertest(this.getHttpServer()) + [method](path) + .set('Cookie', [ + `${AuthService.sessionCookieName}=${this.sessionCookie ?? ''}`, + `${AuthService.userCookieName}=${this.currentUserCookie ?? ''}`, + ]); + } + + gql = gqlFetcherFactory('', async (_input, init) => { + assert(init, 'no request content'); + assert(init.body, 'body is required for gql request'); + assert(init.headers, 'headers is required for gql request'); + + const res = await this.request('post', '/graphql') + .send(init?.body) + .set('accept', 'application/json') + .set(init.headers as Record); + + return new Response(Buffer.from(JSON.stringify(res.body)), { + status: res.status, + headers: res.headers, + }); + }); + + OPTIONS(path: string): supertest.Test { + return this.request('options', path); + } + + GET(path: string): supertest.Test { + return this.request('get', path); + } + + POST(path: string): supertest.Test { + return this.request('post', path).on( + 'response', + (res: supertest.Response) => { + const cookies = parseCookies(res); + + if (AuthService.sessionCookieName in cookies) { + if (this.sessionCookie !== cookies[AuthService.sessionCookieName]) { + this.userCookies.clear(); + } + + this.sessionCookie = cookies[AuthService.sessionCookieName]; + this.currentUserCookie = cookies[AuthService.userCookieName]; + if (this.currentUserCookie) { + this.userCookies.add(this.currentUserCookie); + } + } + return res; + } + ); + } + + PUT(path: string): supertest.Test { + return this.request('put', path); + } + + DELETE(path: string): supertest.Test { + return this.request('delete', path); + } + + PATCH(path: string): supertest.Test { + return this.request('patch', path); + } + + async createUser(overrides?: Partial) { + return await this.create(MockUser, overrides); + } + + async signup(overrides?: Partial) { + const user = await this.create(MockUser, overrides); + await this.login(user); + return user; + } + + async login(user: MockedUser) { + await this.POST('/api/auth/sign-in') + .send({ + email: user.email, + password: user.password, + }) + .expect(200); + } + + async switchUser(userOrId: string | { id: string }) { + if (!this.sessionCookie) { + throw new Error('No user is logged in.'); + } + + const userId = typeof userOrId === 'string' ? userOrId : userOrId.id; + + if (userId === this.currentUserCookie) { + return; + } + + if (this.userCookies.has(userId)) { + this.currentUserCookie = userId; + } else { + throw new Error(`User [${userId}] is not logged in.`); + } + } + + async logout(userId?: string) { + const res = await this.GET( + '/api/auth/sign-out' + (userId ? `?user_id=${userId}` : '') + ).expect(200); + const cookies = parseCookies(res); + this.sessionCookie = cookies[AuthService.sessionCookieName]; + if (!this.sessionCookie) { + this.currentUserCookie = null; + this.userCookies.clear(); + } else { + this.currentUserCookie = cookies[AuthService.userCookieName]; + if (userId) { + this.userCookies.delete(userId); + } + } + } } +let GLOBAL_APP_INSTANCE: TestingApp | null = null; export async function createApp( metadata: TestingAppMetadata = {} ): Promise { + if (GLOBAL_APP_INSTANCE) { + return GLOBAL_APP_INSTANCE; + } + const { buildAppModule } = await import('../../app.module'); const { tapModule, tapApp } = metadata; @@ -81,5 +232,8 @@ export async function createApp( tapApp(app); } + await app.init(); + + GLOBAL_APP_INSTANCE = app; return app; } diff --git a/packages/backend/server/src/__tests__/e2e/prelude.ts b/packages/backend/server/src/__tests__/e2e/prelude.ts index e63a0e593..2cf31cef9 100644 --- a/packages/backend/server/src/__tests__/e2e/prelude.ts +++ b/packages/backend/server/src/__tests__/e2e/prelude.ts @@ -1,4 +1,11 @@ +import { getBuildConfig } from '@affine-tools/utils/build-config'; +import { Package } from '@affine-tools/utils/workspace'; + import { createApp } from './create-app'; +globalThis.BUILD_CONFIG = getBuildConfig(new Package('@affine/web'), { + mode: 'development', + channel: 'canary', +}); // @ts-expect-error testing globalThis.app = await createApp(); diff --git a/packages/backend/server/src/__tests__/e2e/test.ts b/packages/backend/server/src/__tests__/e2e/test.ts index a35938c8e..30ac3998a 100644 --- a/packages/backend/server/src/__tests__/e2e/test.ts +++ b/packages/backend/server/src/__tests__/e2e/test.ts @@ -1,8 +1,10 @@ import test, { registerCompletionHandler } from 'ava'; +import { type TestingApp } from './create-app'; + export const e2e = test; // @ts-expect-error created in prelude.ts -export const app = globalThis.app; +export const app: TestingApp = globalThis.app; registerCompletionHandler(() => { app.close(); diff --git a/packages/backend/server/tsconfig.json b/packages/backend/server/tsconfig.json index 45ba2e7e2..26fc078e1 100644 --- a/packages/backend/server/tsconfig.json +++ b/packages/backend/server/tsconfig.json @@ -14,6 +14,7 @@ "references": [ { "path": "../../../tools/cli" }, { "path": "../../../tools/utils" }, + { "path": "../../common/graphql" }, { "path": "../native" } ] } diff --git a/packages/common/debug/package.json b/packages/common/debug/package.json index 2b466432e..10c9c7b4d 100644 --- a/packages/common/debug/package.json +++ b/packages/common/debug/package.json @@ -1,6 +1,7 @@ { "name": "@affine/debug", "private": true, + "type": "module", "exports": { ".": "./src/index.ts" }, diff --git a/packages/common/error/package.json b/packages/common/error/package.json index cb6a983dc..1e2d7545f 100644 --- a/packages/common/error/package.json +++ b/packages/common/error/package.json @@ -2,6 +2,7 @@ "name": "@affine/error", "version": "0.20.0", "private": true, + "type": "module", "exports": { ".": "./src/index.ts" }, diff --git a/packages/frontend/graphql/README.md b/packages/common/graphql/README.md similarity index 100% rename from packages/frontend/graphql/README.md rename to packages/common/graphql/README.md diff --git a/packages/frontend/graphql/codegen.yml b/packages/common/graphql/codegen.yml similarity index 100% rename from packages/frontend/graphql/codegen.yml rename to packages/common/graphql/codegen.yml diff --git a/packages/frontend/graphql/export-gql-plugin.cjs b/packages/common/graphql/export-gql-plugin.cjs similarity index 100% rename from packages/frontend/graphql/export-gql-plugin.cjs rename to packages/common/graphql/export-gql-plugin.cjs diff --git a/packages/frontend/graphql/package.json b/packages/common/graphql/package.json similarity index 100% rename from packages/frontend/graphql/package.json rename to packages/common/graphql/package.json diff --git a/packages/frontend/graphql/src/__tests__/fetcher.spec.ts b/packages/common/graphql/src/__tests__/fetcher.spec.ts similarity index 100% rename from packages/frontend/graphql/src/__tests__/fetcher.spec.ts rename to packages/common/graphql/src/__tests__/fetcher.spec.ts diff --git a/packages/frontend/graphql/src/fetcher.ts b/packages/common/graphql/src/fetcher.ts similarity index 100% rename from packages/frontend/graphql/src/fetcher.ts rename to packages/common/graphql/src/fetcher.ts diff --git a/packages/frontend/graphql/src/graphql/activate-license.gql b/packages/common/graphql/src/graphql/activate-license.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/activate-license.gql rename to packages/common/graphql/src/graphql/activate-license.gql diff --git a/packages/frontend/graphql/src/graphql/admin-server-config.gql b/packages/common/graphql/src/graphql/admin-server-config.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/admin-server-config.gql rename to packages/common/graphql/src/graphql/admin-server-config.gql diff --git a/packages/frontend/graphql/src/graphql/blob-delete.gql b/packages/common/graphql/src/graphql/blob-delete.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/blob-delete.gql rename to packages/common/graphql/src/graphql/blob-delete.gql diff --git a/packages/frontend/graphql/src/graphql/blob-list.gql b/packages/common/graphql/src/graphql/blob-list.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/blob-list.gql rename to packages/common/graphql/src/graphql/blob-list.gql diff --git a/packages/frontend/graphql/src/graphql/blob-release-deleted.gql b/packages/common/graphql/src/graphql/blob-release-deleted.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/blob-release-deleted.gql rename to packages/common/graphql/src/graphql/blob-release-deleted.gql diff --git a/packages/frontend/graphql/src/graphql/blob-set.gql b/packages/common/graphql/src/graphql/blob-set.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/blob-set.gql rename to packages/common/graphql/src/graphql/blob-set.gql diff --git a/packages/frontend/graphql/src/graphql/cancel-subscription.gql b/packages/common/graphql/src/graphql/cancel-subscription.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/cancel-subscription.gql rename to packages/common/graphql/src/graphql/cancel-subscription.gql diff --git a/packages/frontend/graphql/src/graphql/change-email.gql b/packages/common/graphql/src/graphql/change-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/change-email.gql rename to packages/common/graphql/src/graphql/change-email.gql diff --git a/packages/frontend/graphql/src/graphql/change-password-url.gql b/packages/common/graphql/src/graphql/change-password-url.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/change-password-url.gql rename to packages/common/graphql/src/graphql/change-password-url.gql diff --git a/packages/frontend/graphql/src/graphql/change-password.gql b/packages/common/graphql/src/graphql/change-password.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/change-password.gql rename to packages/common/graphql/src/graphql/change-password.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-category-add.gql b/packages/common/graphql/src/graphql/copilot-context-category-add.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-category-add.gql rename to packages/common/graphql/src/graphql/copilot-context-category-add.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-category-remove.gql b/packages/common/graphql/src/graphql/copilot-context-category-remove.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-category-remove.gql rename to packages/common/graphql/src/graphql/copilot-context-category-remove.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-create.gql b/packages/common/graphql/src/graphql/copilot-context-create.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-create.gql rename to packages/common/graphql/src/graphql/copilot-context-create.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-doc-add.gql b/packages/common/graphql/src/graphql/copilot-context-doc-add.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-doc-add.gql rename to packages/common/graphql/src/graphql/copilot-context-doc-add.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-doc-remove.gql b/packages/common/graphql/src/graphql/copilot-context-doc-remove.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-doc-remove.gql rename to packages/common/graphql/src/graphql/copilot-context-doc-remove.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-file-add.gql b/packages/common/graphql/src/graphql/copilot-context-file-add.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-file-add.gql rename to packages/common/graphql/src/graphql/copilot-context-file-add.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-file-match.gql b/packages/common/graphql/src/graphql/copilot-context-file-match.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-file-match.gql rename to packages/common/graphql/src/graphql/copilot-context-file-match.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-file-remove.gql b/packages/common/graphql/src/graphql/copilot-context-file-remove.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-file-remove.gql rename to packages/common/graphql/src/graphql/copilot-context-file-remove.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-list-object.gql b/packages/common/graphql/src/graphql/copilot-context-list-object.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-list-object.gql rename to packages/common/graphql/src/graphql/copilot-context-list-object.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-list.gql b/packages/common/graphql/src/graphql/copilot-context-list.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-list.gql rename to packages/common/graphql/src/graphql/copilot-context-list.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-workspace-match.gql b/packages/common/graphql/src/graphql/copilot-context-workspace-match.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-workspace-match.gql rename to packages/common/graphql/src/graphql/copilot-context-workspace-match.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-workspace-query.gql b/packages/common/graphql/src/graphql/copilot-context-workspace-query.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-workspace-query.gql rename to packages/common/graphql/src/graphql/copilot-context-workspace-query.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-context-workspace-queue.gql b/packages/common/graphql/src/graphql/copilot-context-workspace-queue.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-context-workspace-queue.gql rename to packages/common/graphql/src/graphql/copilot-context-workspace-queue.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-history-get-ids.gql b/packages/common/graphql/src/graphql/copilot-history-get-ids.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-history-get-ids.gql rename to packages/common/graphql/src/graphql/copilot-history-get-ids.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-history-list.gql b/packages/common/graphql/src/graphql/copilot-history-list.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-history-list.gql rename to packages/common/graphql/src/graphql/copilot-history-list.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-message-create.gql b/packages/common/graphql/src/graphql/copilot-message-create.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-message-create.gql rename to packages/common/graphql/src/graphql/copilot-message-create.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-prompt-list.gql b/packages/common/graphql/src/graphql/copilot-prompt-list.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-prompt-list.gql rename to packages/common/graphql/src/graphql/copilot-prompt-list.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-prompt-update.gql b/packages/common/graphql/src/graphql/copilot-prompt-update.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-prompt-update.gql rename to packages/common/graphql/src/graphql/copilot-prompt-update.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-quota.gql b/packages/common/graphql/src/graphql/copilot-quota.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-quota.gql rename to packages/common/graphql/src/graphql/copilot-quota.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-session-cleanup.gql b/packages/common/graphql/src/graphql/copilot-session-cleanup.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-session-cleanup.gql rename to packages/common/graphql/src/graphql/copilot-session-cleanup.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-session-create.gql b/packages/common/graphql/src/graphql/copilot-session-create.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-session-create.gql rename to packages/common/graphql/src/graphql/copilot-session-create.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-session-fork.gql b/packages/common/graphql/src/graphql/copilot-session-fork.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-session-fork.gql rename to packages/common/graphql/src/graphql/copilot-session-fork.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-session-update.gql b/packages/common/graphql/src/graphql/copilot-session-update.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-session-update.gql rename to packages/common/graphql/src/graphql/copilot-session-update.gql diff --git a/packages/frontend/graphql/src/graphql/copilot-sessions-get.gql b/packages/common/graphql/src/graphql/copilot-sessions-get.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/copilot-sessions-get.gql rename to packages/common/graphql/src/graphql/copilot-sessions-get.gql diff --git a/packages/frontend/graphql/src/graphql/create-checkout-link.gql b/packages/common/graphql/src/graphql/create-checkout-link.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/create-checkout-link.gql rename to packages/common/graphql/src/graphql/create-checkout-link.gql diff --git a/packages/frontend/graphql/src/graphql/create-customer-portal.gql b/packages/common/graphql/src/graphql/create-customer-portal.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/create-customer-portal.gql rename to packages/common/graphql/src/graphql/create-customer-portal.gql diff --git a/packages/frontend/graphql/src/graphql/create-self-host-customer-portal.gql b/packages/common/graphql/src/graphql/create-self-host-customer-portal.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/create-self-host-customer-portal.gql rename to packages/common/graphql/src/graphql/create-self-host-customer-portal.gql diff --git a/packages/frontend/graphql/src/graphql/create-user.gql b/packages/common/graphql/src/graphql/create-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/create-user.gql rename to packages/common/graphql/src/graphql/create-user.gql diff --git a/packages/frontend/graphql/src/graphql/create-workspace.gql b/packages/common/graphql/src/graphql/create-workspace.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/create-workspace.gql rename to packages/common/graphql/src/graphql/create-workspace.gql diff --git a/packages/frontend/graphql/src/graphql/deactivate-license.gql b/packages/common/graphql/src/graphql/deactivate-license.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/deactivate-license.gql rename to packages/common/graphql/src/graphql/deactivate-license.gql diff --git a/packages/frontend/graphql/src/graphql/delete-account.gql b/packages/common/graphql/src/graphql/delete-account.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/delete-account.gql rename to packages/common/graphql/src/graphql/delete-account.gql diff --git a/packages/frontend/graphql/src/graphql/delete-user.gql b/packages/common/graphql/src/graphql/delete-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/delete-user.gql rename to packages/common/graphql/src/graphql/delete-user.gql diff --git a/packages/frontend/graphql/src/graphql/delete-workspace.gql b/packages/common/graphql/src/graphql/delete-workspace.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/delete-workspace.gql rename to packages/common/graphql/src/graphql/delete-workspace.gql diff --git a/packages/frontend/graphql/src/graphql/disable-user.gql b/packages/common/graphql/src/graphql/disable-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/disable-user.gql rename to packages/common/graphql/src/graphql/disable-user.gql diff --git a/packages/frontend/graphql/src/graphql/doc-role-permissions.gql b/packages/common/graphql/src/graphql/doc-role-permissions.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/doc-role-permissions.gql rename to packages/common/graphql/src/graphql/doc-role-permissions.gql diff --git a/packages/frontend/graphql/src/graphql/enable-user.gql b/packages/common/graphql/src/graphql/enable-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/enable-user.gql rename to packages/common/graphql/src/graphql/enable-user.gql diff --git a/packages/frontend/graphql/src/graphql/fragments/credentials-requirement.gql b/packages/common/graphql/src/graphql/fragments/credentials-requirement.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/fragments/credentials-requirement.gql rename to packages/common/graphql/src/graphql/fragments/credentials-requirement.gql diff --git a/packages/frontend/graphql/src/graphql/fragments/password-limits.gql b/packages/common/graphql/src/graphql/fragments/password-limits.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/fragments/password-limits.gql rename to packages/common/graphql/src/graphql/fragments/password-limits.gql diff --git a/packages/frontend/graphql/src/graphql/generate-license-key.gql b/packages/common/graphql/src/graphql/generate-license-key.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/generate-license-key.gql rename to packages/common/graphql/src/graphql/generate-license-key.gql diff --git a/packages/frontend/graphql/src/graphql/get-current-user-features.gql b/packages/common/graphql/src/graphql/get-current-user-features.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-current-user-features.gql rename to packages/common/graphql/src/graphql/get-current-user-features.gql diff --git a/packages/frontend/graphql/src/graphql/get-current-user.gql b/packages/common/graphql/src/graphql/get-current-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-current-user.gql rename to packages/common/graphql/src/graphql/get-current-user.gql diff --git a/packages/frontend/graphql/src/graphql/get-doc-default-role.gql b/packages/common/graphql/src/graphql/get-doc-default-role.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-doc-default-role.gql rename to packages/common/graphql/src/graphql/get-doc-default-role.gql diff --git a/packages/frontend/graphql/src/graphql/get-invite-info.gql b/packages/common/graphql/src/graphql/get-invite-info.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-invite-info.gql rename to packages/common/graphql/src/graphql/get-invite-info.gql diff --git a/packages/frontend/graphql/src/graphql/get-is-admin.gql b/packages/common/graphql/src/graphql/get-is-admin.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-is-admin.gql rename to packages/common/graphql/src/graphql/get-is-admin.gql diff --git a/packages/frontend/graphql/src/graphql/get-is-owner.gql b/packages/common/graphql/src/graphql/get-is-owner.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-is-owner.gql rename to packages/common/graphql/src/graphql/get-is-owner.gql diff --git a/packages/frontend/graphql/src/graphql/get-license.gql b/packages/common/graphql/src/graphql/get-license.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-license.gql rename to packages/common/graphql/src/graphql/get-license.gql diff --git a/packages/frontend/graphql/src/graphql/get-member-count-by-workspace-id.gql b/packages/common/graphql/src/graphql/get-member-count-by-workspace-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-member-count-by-workspace-id.gql rename to packages/common/graphql/src/graphql/get-member-count-by-workspace-id.gql diff --git a/packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql b/packages/common/graphql/src/graphql/get-members-by-workspace-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-members-by-workspace-id.gql rename to packages/common/graphql/src/graphql/get-members-by-workspace-id.gql diff --git a/packages/frontend/graphql/src/graphql/get-oauth-providers.gql b/packages/common/graphql/src/graphql/get-oauth-providers.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-oauth-providers.gql rename to packages/common/graphql/src/graphql/get-oauth-providers.gql diff --git a/packages/frontend/graphql/src/graphql/get-page-granted-users-list.gql b/packages/common/graphql/src/graphql/get-page-granted-users-list.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-page-granted-users-list.gql rename to packages/common/graphql/src/graphql/get-page-granted-users-list.gql diff --git a/packages/frontend/graphql/src/graphql/get-public-user-by-id.gql b/packages/common/graphql/src/graphql/get-public-user-by-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-public-user-by-id.gql rename to packages/common/graphql/src/graphql/get-public-user-by-id.gql diff --git a/packages/frontend/graphql/src/graphql/get-server-runtime-config.gql b/packages/common/graphql/src/graphql/get-server-runtime-config.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-server-runtime-config.gql rename to packages/common/graphql/src/graphql/get-server-runtime-config.gql diff --git a/packages/frontend/graphql/src/graphql/get-server-service-configs.gql b/packages/common/graphql/src/graphql/get-server-service-configs.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-server-service-configs.gql rename to packages/common/graphql/src/graphql/get-server-service-configs.gql diff --git a/packages/frontend/graphql/src/graphql/get-user-by-email.gql b/packages/common/graphql/src/graphql/get-user-by-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-user-by-email.gql rename to packages/common/graphql/src/graphql/get-user-by-email.gql diff --git a/packages/frontend/graphql/src/graphql/get-user-features.gql b/packages/common/graphql/src/graphql/get-user-features.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-user-features.gql rename to packages/common/graphql/src/graphql/get-user-features.gql diff --git a/packages/frontend/graphql/src/graphql/get-user.gql b/packages/common/graphql/src/graphql/get-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-user.gql rename to packages/common/graphql/src/graphql/get-user.gql diff --git a/packages/frontend/graphql/src/graphql/get-users-count.gql b/packages/common/graphql/src/graphql/get-users-count.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-users-count.gql rename to packages/common/graphql/src/graphql/get-users-count.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-info.gql b/packages/common/graphql/src/graphql/get-workspace-info.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-info.gql rename to packages/common/graphql/src/graphql/get-workspace-info.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-page-by-id.gql b/packages/common/graphql/src/graphql/get-workspace-page-by-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-page-by-id.gql rename to packages/common/graphql/src/graphql/get-workspace-page-by-id.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-page-meta.gql b/packages/common/graphql/src/graphql/get-workspace-page-meta.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-page-meta.gql rename to packages/common/graphql/src/graphql/get-workspace-page-meta.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-public-by-id.gql b/packages/common/graphql/src/graphql/get-workspace-public-by-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-public-by-id.gql rename to packages/common/graphql/src/graphql/get-workspace-public-by-id.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-public-pages.gql b/packages/common/graphql/src/graphql/get-workspace-public-pages.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-public-pages.gql rename to packages/common/graphql/src/graphql/get-workspace-public-pages.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace-subscription.gql b/packages/common/graphql/src/graphql/get-workspace-subscription.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace-subscription.gql rename to packages/common/graphql/src/graphql/get-workspace-subscription.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspace.gql b/packages/common/graphql/src/graphql/get-workspace.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspace.gql rename to packages/common/graphql/src/graphql/get-workspace.gql diff --git a/packages/frontend/graphql/src/graphql/get-workspaces.gql b/packages/common/graphql/src/graphql/get-workspaces.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/get-workspaces.gql rename to packages/common/graphql/src/graphql/get-workspaces.gql diff --git a/packages/frontend/graphql/src/graphql/grant-doc-user-roles.gql b/packages/common/graphql/src/graphql/grant-doc-user-roles.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/grant-doc-user-roles.gql rename to packages/common/graphql/src/graphql/grant-doc-user-roles.gql diff --git a/packages/frontend/graphql/src/graphql/histories.gql b/packages/common/graphql/src/graphql/histories.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/histories.gql rename to packages/common/graphql/src/graphql/histories.gql diff --git a/packages/frontend/graphql/src/graphql/import-users.gql b/packages/common/graphql/src/graphql/import-users.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/import-users.gql rename to packages/common/graphql/src/graphql/import-users.gql diff --git a/packages/frontend/graphql/src/graphql/index.ts b/packages/common/graphql/src/graphql/index.ts similarity index 100% rename from packages/frontend/graphql/src/graphql/index.ts rename to packages/common/graphql/src/graphql/index.ts diff --git a/packages/frontend/graphql/src/graphql/invoices-count.gql b/packages/common/graphql/src/graphql/invoices-count.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/invoices-count.gql rename to packages/common/graphql/src/graphql/invoices-count.gql diff --git a/packages/frontend/graphql/src/graphql/invoices.gql b/packages/common/graphql/src/graphql/invoices.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/invoices.gql rename to packages/common/graphql/src/graphql/invoices.gql diff --git a/packages/frontend/graphql/src/graphql/leave-workspace.gql b/packages/common/graphql/src/graphql/leave-workspace.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/leave-workspace.gql rename to packages/common/graphql/src/graphql/leave-workspace.gql diff --git a/packages/frontend/graphql/src/graphql/list-notifications.gql b/packages/common/graphql/src/graphql/list-notifications.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/list-notifications.gql rename to packages/common/graphql/src/graphql/list-notifications.gql diff --git a/packages/frontend/graphql/src/graphql/list-users.gql b/packages/common/graphql/src/graphql/list-users.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/list-users.gql rename to packages/common/graphql/src/graphql/list-users.gql diff --git a/packages/frontend/graphql/src/graphql/mention-user.gql b/packages/common/graphql/src/graphql/mention-user.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/mention-user.gql rename to packages/common/graphql/src/graphql/mention-user.gql diff --git a/packages/frontend/graphql/src/graphql/notification-count.gql b/packages/common/graphql/src/graphql/notification-count.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/notification-count.gql rename to packages/common/graphql/src/graphql/notification-count.gql diff --git a/packages/frontend/graphql/src/graphql/prices.gql b/packages/common/graphql/src/graphql/prices.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/prices.gql rename to packages/common/graphql/src/graphql/prices.gql diff --git a/packages/frontend/graphql/src/graphql/public-page.gql b/packages/common/graphql/src/graphql/public-page.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/public-page.gql rename to packages/common/graphql/src/graphql/public-page.gql diff --git a/packages/frontend/graphql/src/graphql/quota.gql b/packages/common/graphql/src/graphql/quota.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/quota.gql rename to packages/common/graphql/src/graphql/quota.gql diff --git a/packages/frontend/graphql/src/graphql/read-notification.gql b/packages/common/graphql/src/graphql/read-notification.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/read-notification.gql rename to packages/common/graphql/src/graphql/read-notification.gql diff --git a/packages/frontend/graphql/src/graphql/recover-doc.gql b/packages/common/graphql/src/graphql/recover-doc.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/recover-doc.gql rename to packages/common/graphql/src/graphql/recover-doc.gql diff --git a/packages/frontend/graphql/src/graphql/remove-avatar.gql b/packages/common/graphql/src/graphql/remove-avatar.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/remove-avatar.gql rename to packages/common/graphql/src/graphql/remove-avatar.gql diff --git a/packages/frontend/graphql/src/graphql/resume-subscription.gql b/packages/common/graphql/src/graphql/resume-subscription.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/resume-subscription.gql rename to packages/common/graphql/src/graphql/resume-subscription.gql diff --git a/packages/frontend/graphql/src/graphql/revoke-doc-user-roles.gql b/packages/common/graphql/src/graphql/revoke-doc-user-roles.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/revoke-doc-user-roles.gql rename to packages/common/graphql/src/graphql/revoke-doc-user-roles.gql diff --git a/packages/frontend/graphql/src/graphql/revoke-member-permission.gql b/packages/common/graphql/src/graphql/revoke-member-permission.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/revoke-member-permission.gql rename to packages/common/graphql/src/graphql/revoke-member-permission.gql diff --git a/packages/frontend/graphql/src/graphql/revoke-public-page.gql b/packages/common/graphql/src/graphql/revoke-public-page.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/revoke-public-page.gql rename to packages/common/graphql/src/graphql/revoke-public-page.gql diff --git a/packages/frontend/graphql/src/graphql/send-change-email.gql b/packages/common/graphql/src/graphql/send-change-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/send-change-email.gql rename to packages/common/graphql/src/graphql/send-change-email.gql diff --git a/packages/frontend/graphql/src/graphql/send-change-password-email.gql b/packages/common/graphql/src/graphql/send-change-password-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/send-change-password-email.gql rename to packages/common/graphql/src/graphql/send-change-password-email.gql diff --git a/packages/frontend/graphql/src/graphql/send-set-password-email.gql b/packages/common/graphql/src/graphql/send-set-password-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/send-set-password-email.gql rename to packages/common/graphql/src/graphql/send-set-password-email.gql diff --git a/packages/frontend/graphql/src/graphql/send-verify-change-email.gql b/packages/common/graphql/src/graphql/send-verify-change-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/send-verify-change-email.gql rename to packages/common/graphql/src/graphql/send-verify-change-email.gql diff --git a/packages/frontend/graphql/src/graphql/send-verify-email.gql b/packages/common/graphql/src/graphql/send-verify-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/send-verify-email.gql rename to packages/common/graphql/src/graphql/send-verify-email.gql diff --git a/packages/frontend/graphql/src/graphql/server-config.gql b/packages/common/graphql/src/graphql/server-config.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/server-config.gql rename to packages/common/graphql/src/graphql/server-config.gql diff --git a/packages/frontend/graphql/src/graphql/set-workspace-public-by-id.gql b/packages/common/graphql/src/graphql/set-workspace-public-by-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/set-workspace-public-by-id.gql rename to packages/common/graphql/src/graphql/set-workspace-public-by-id.gql diff --git a/packages/frontend/graphql/src/graphql/subscription.gql b/packages/common/graphql/src/graphql/subscription.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/subscription.gql rename to packages/common/graphql/src/graphql/subscription.gql diff --git a/packages/frontend/graphql/src/graphql/update-account-features.gql b/packages/common/graphql/src/graphql/update-account-features.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-account-features.gql rename to packages/common/graphql/src/graphql/update-account-features.gql diff --git a/packages/frontend/graphql/src/graphql/update-account.gql b/packages/common/graphql/src/graphql/update-account.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-account.gql rename to packages/common/graphql/src/graphql/update-account.gql diff --git a/packages/frontend/graphql/src/graphql/update-doc-default-role.gql b/packages/common/graphql/src/graphql/update-doc-default-role.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-doc-default-role.gql rename to packages/common/graphql/src/graphql/update-doc-default-role.gql diff --git a/packages/frontend/graphql/src/graphql/update-doc-user-role.gql b/packages/common/graphql/src/graphql/update-doc-user-role.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-doc-user-role.gql rename to packages/common/graphql/src/graphql/update-doc-user-role.gql diff --git a/packages/frontend/graphql/src/graphql/update-server-runtime-configs.gql b/packages/common/graphql/src/graphql/update-server-runtime-configs.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-server-runtime-configs.gql rename to packages/common/graphql/src/graphql/update-server-runtime-configs.gql diff --git a/packages/frontend/graphql/src/graphql/update-subscription-billing.gql b/packages/common/graphql/src/graphql/update-subscription-billing.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-subscription-billing.gql rename to packages/common/graphql/src/graphql/update-subscription-billing.gql diff --git a/packages/frontend/graphql/src/graphql/update-user-profile.gql b/packages/common/graphql/src/graphql/update-user-profile.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/update-user-profile.gql rename to packages/common/graphql/src/graphql/update-user-profile.gql diff --git a/packages/frontend/graphql/src/graphql/upload-avatar.gql b/packages/common/graphql/src/graphql/upload-avatar.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/upload-avatar.gql rename to packages/common/graphql/src/graphql/upload-avatar.gql diff --git a/packages/frontend/graphql/src/graphql/verify-email.gql b/packages/common/graphql/src/graphql/verify-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/verify-email.gql rename to packages/common/graphql/src/graphql/verify-email.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-config.gql b/packages/common/graphql/src/graphql/workspace-config.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-config.gql rename to packages/common/graphql/src/graphql/workspace-config.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-enable-ai.gql b/packages/common/graphql/src/graphql/workspace-enable-ai.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-enable-ai.gql rename to packages/common/graphql/src/graphql/workspace-enable-ai.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-enable-url-preview.gql b/packages/common/graphql/src/graphql/workspace-enable-url-preview.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-enable-url-preview.gql rename to packages/common/graphql/src/graphql/workspace-enable-url-preview.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-intive-by-email.gql b/packages/common/graphql/src/graphql/workspace-intive-by-email.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-intive-by-email.gql rename to packages/common/graphql/src/graphql/workspace-intive-by-email.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-intive-by-emails.gql b/packages/common/graphql/src/graphql/workspace-intive-by-emails.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-intive-by-emails.gql rename to packages/common/graphql/src/graphql/workspace-intive-by-emails.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-invite-accept-by-invite-id.gql b/packages/common/graphql/src/graphql/workspace-invite-accept-by-invite-id.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-invite-accept-by-invite-id.gql rename to packages/common/graphql/src/graphql/workspace-invite-accept-by-invite-id.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-invite-batch.gql b/packages/common/graphql/src/graphql/workspace-invite-batch.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-invite-batch.gql rename to packages/common/graphql/src/graphql/workspace-invite-batch.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-invite-link.gql b/packages/common/graphql/src/graphql/workspace-invite-link.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-invite-link.gql rename to packages/common/graphql/src/graphql/workspace-invite-link.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-invite-revoke-link.gql b/packages/common/graphql/src/graphql/workspace-invite-revoke-link.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-invite-revoke-link.gql rename to packages/common/graphql/src/graphql/workspace-invite-revoke-link.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-invoices.gql b/packages/common/graphql/src/graphql/workspace-invoices.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-invoices.gql rename to packages/common/graphql/src/graphql/workspace-invoices.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-quota.gql b/packages/common/graphql/src/graphql/workspace-quota.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-quota.gql rename to packages/common/graphql/src/graphql/workspace-quota.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-role-permissions.gql b/packages/common/graphql/src/graphql/workspace-role-permissions.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-role-permissions.gql rename to packages/common/graphql/src/graphql/workspace-role-permissions.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-team-approve.gql b/packages/common/graphql/src/graphql/workspace-team-approve.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-team-approve.gql rename to packages/common/graphql/src/graphql/workspace-team-approve.gql diff --git a/packages/frontend/graphql/src/graphql/workspace-team-grant.gql b/packages/common/graphql/src/graphql/workspace-team-grant.gql similarity index 100% rename from packages/frontend/graphql/src/graphql/workspace-team-grant.gql rename to packages/common/graphql/src/graphql/workspace-team-grant.gql diff --git a/packages/frontend/graphql/src/index.ts b/packages/common/graphql/src/index.ts similarity index 100% rename from packages/frontend/graphql/src/index.ts rename to packages/common/graphql/src/index.ts diff --git a/packages/frontend/graphql/src/schema.ts b/packages/common/graphql/src/schema.ts similarity index 100% rename from packages/frontend/graphql/src/schema.ts rename to packages/common/graphql/src/schema.ts diff --git a/packages/frontend/graphql/tsconfig.json b/packages/common/graphql/tsconfig.json similarity index 66% rename from packages/frontend/graphql/tsconfig.json rename to packages/common/graphql/tsconfig.json index 98fa9f08b..605949f39 100644 --- a/packages/frontend/graphql/tsconfig.json +++ b/packages/common/graphql/tsconfig.json @@ -7,8 +7,8 @@ "tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo" }, "references": [ - { "path": "../../common/debug" }, - { "path": "../../common/env" }, - { "path": "../../common/error" } + { "path": "../debug" }, + { "path": "../env" }, + { "path": "../error" } ] } diff --git a/packages/common/nbstore/tsconfig.json b/packages/common/nbstore/tsconfig.json index 9586a8f30..67c938fb6 100644 --- a/packages/common/nbstore/tsconfig.json +++ b/packages/common/nbstore/tsconfig.json @@ -9,6 +9,6 @@ "references": [ { "path": "../infra" }, { "path": "../error" }, - { "path": "../../frontend/graphql" } + { "path": "../graphql" } ] } diff --git a/packages/frontend/admin/tsconfig.json b/packages/frontend/admin/tsconfig.json index 2f1a1405d..d92e6b678 100644 --- a/packages/frontend/admin/tsconfig.json +++ b/packages/frontend/admin/tsconfig.json @@ -9,7 +9,7 @@ "references": [ { "path": "../component" }, { "path": "../core" }, - { "path": "../graphql" }, + { "path": "../../common/graphql" }, { "path": "../../common/infra" } ] } diff --git a/packages/frontend/component/tsconfig.json b/packages/frontend/component/tsconfig.json index 7416b0faf..cd67ccdb7 100644 --- a/packages/frontend/component/tsconfig.json +++ b/packages/frontend/component/tsconfig.json @@ -15,7 +15,7 @@ { "path": "../../common/debug" }, { "path": "../electron-api" }, { "path": "../../common/error" }, - { "path": "../graphql" }, + { "path": "../../common/graphql" }, { "path": "../i18n" }, { "path": "../../../tools/utils" }, { "path": "../../../blocksuite/affine/all" } diff --git a/packages/frontend/core/tsconfig.json b/packages/frontend/core/tsconfig.json index d8e547789..f3e56ca57 100644 --- a/packages/frontend/core/tsconfig.json +++ b/packages/frontend/core/tsconfig.json @@ -12,7 +12,7 @@ { "path": "../electron-api" }, { "path": "../../common/env" }, { "path": "../../common/error" }, - { "path": "../graphql" }, + { "path": "../../common/graphql" }, { "path": "../i18n" }, { "path": "../../common/nbstore" }, { "path": "../track" }, diff --git a/tools/utils/src/workspace.gen.ts b/tools/utils/src/workspace.gen.ts index 15e610d46..cb6384eda 100644 --- a/tools/utils/src/workspace.gen.ts +++ b/tools/utils/src/workspace.gen.ts @@ -656,6 +656,7 @@ export const PackageList = [ workspaceDependencies: [ 'tools/cli', 'tools/utils', + 'packages/common/graphql', 'packages/backend/native', ], }, @@ -674,6 +675,15 @@ export const PackageList = [ name: '@affine/error', workspaceDependencies: [], }, + { + location: 'packages/common/graphql', + name: '@affine/graphql', + workspaceDependencies: [ + 'packages/common/debug', + 'packages/common/env', + 'packages/common/error', + ], + }, { location: 'packages/common/infra', name: '@toeverything/infra', @@ -690,7 +700,7 @@ export const PackageList = [ workspaceDependencies: [ 'packages/common/infra', 'packages/common/error', - 'packages/frontend/graphql', + 'packages/common/graphql', ], }, { @@ -699,7 +709,7 @@ export const PackageList = [ workspaceDependencies: [ 'packages/frontend/component', 'packages/frontend/core', - 'packages/frontend/graphql', + 'packages/common/graphql', 'packages/common/infra', ], }, @@ -783,7 +793,7 @@ export const PackageList = [ 'packages/common/debug', 'packages/frontend/electron-api', 'packages/common/error', - 'packages/frontend/graphql', + 'packages/common/graphql', 'packages/frontend/i18n', 'tools/utils', 'blocksuite/affine/all', @@ -798,7 +808,7 @@ export const PackageList = [ 'packages/frontend/electron-api', 'packages/common/env', 'packages/common/error', - 'packages/frontend/graphql', + 'packages/common/graphql', 'packages/frontend/i18n', 'packages/common/nbstore', 'packages/frontend/templates', @@ -812,15 +822,6 @@ export const PackageList = [ name: '@affine/electron-api', workspaceDependencies: ['packages/frontend/apps/electron'], }, - { - location: 'packages/frontend/graphql', - name: '@affine/graphql', - workspaceDependencies: [ - 'packages/common/debug', - 'packages/common/env', - 'packages/common/error', - ], - }, { location: 'packages/frontend/i18n', name: '@affine/i18n', @@ -987,6 +988,7 @@ export type PackageName = | '@affine/debug' | '@affine/env' | '@affine/error' + | '@affine/graphql' | '@toeverything/infra' | '@affine/nbstore' | '@affine/admin' @@ -999,7 +1001,6 @@ export type PackageName = | '@affine/component' | '@affine/core' | '@affine/electron-api' - | '@affine/graphql' | '@affine/i18n' | '@affine/media-capture-playground' | '@affine/native' diff --git a/tsconfig.json b/tsconfig.json index c7816b55c..5425687db 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -100,6 +100,7 @@ { "path": "./packages/common/debug" }, { "path": "./packages/common/env" }, { "path": "./packages/common/error" }, + { "path": "./packages/common/graphql" }, { "path": "./packages/common/infra" }, { "path": "./packages/common/nbstore" }, { "path": "./packages/frontend/admin" }, @@ -112,7 +113,6 @@ { "path": "./packages/frontend/component" }, { "path": "./packages/frontend/core" }, { "path": "./packages/frontend/electron-api" }, - { "path": "./packages/frontend/graphql" }, { "path": "./packages/frontend/i18n" }, { "path": "./packages/frontend/media-capture-playground" }, { "path": "./packages/frontend/native" }, diff --git a/yarn.lock b/yarn.lock index 52aa1e410..80f8a1210 100644 --- a/yarn.lock +++ b/yarn.lock @@ -596,9 +596,9 @@ __metadata: languageName: unknown linkType: soft -"@affine/graphql@workspace:*, @affine/graphql@workspace:packages/frontend/graphql": +"@affine/graphql@workspace:*, @affine/graphql@workspace:packages/common/graphql": version: 0.0.0-use.local - resolution: "@affine/graphql@workspace:packages/frontend/graphql" + resolution: "@affine/graphql@workspace:packages/common/graphql" dependencies: "@affine/debug": "workspace:*" "@affine/env": "workspace:*" @@ -844,6 +844,7 @@ __metadata: dependencies: "@affine-tools/cli": "workspace:*" "@affine-tools/utils": "workspace:*" + "@affine/graphql": "workspace:*" "@affine/server-native": "workspace:*" "@ai-sdk/google": "npm:^1.1.19" "@apollo/server": "npm:^4.11.2"