diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/workspace-query-runner-job.module.ts b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/workspace-query-runner-job.module.ts index e99954324185..37caf4c1bbf2 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/workspace-query-runner-job.module.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-query-runner/jobs/workspace-query-runner-job.module.ts @@ -1,9 +1,7 @@ -import { HttpModule } from '@nestjs/axios'; import { Module } from '@nestjs/common'; import { RecordPositionBackfillJob } from 'src/engine/api/graphql/workspace-query-runner/jobs/record-position-backfill.job'; import { RecordPositionBackfillModule } from 'src/engine/api/graphql/workspace-query-runner/services/record-position-backfill-module'; -import { AnalyticsModule } from 'src/engine/core-modules/analytics/analytics.module'; import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; import { WorkspaceDataSourceModule } from 'src/engine/workspace-datasource/workspace-datasource.module'; diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts index b7d5b8e2f530..1ce887f83b02 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts @@ -38,6 +38,7 @@ import { AuthExceptionCode, } from 'src/engine/core-modules/auth/auth.exception'; import { OriginHeader } from 'src/engine/decorators/auth/origin-header.decorator'; +import { getWorkspaceSubdomainByOrigin } from 'src/engine/utils/get-workspace-subdomain-by-origin'; import { ChallengeInput } from './dto/challenge.input'; import { ImpersonateInput } from './dto/impersonate.input'; @@ -51,7 +52,6 @@ import { VerifyInput } from './dto/verify.input'; import { WorkspaceInviteHashValid } from './dto/workspace-invite-hash-valid.entity'; import { WorkspaceInviteHashValidInput } from './dto/workspace-invite-hash.input'; import { AuthService } from './services/auth.service'; -import { getWorkspaceSubdomainByOrigin } from 'src/engine/utils/get-workspace-subdomain-by-origin'; @Resolver() @UseFilters(AuthGraphqlApiExceptionFilter) diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts index e0c79e3e2f77..c40072a8c7eb 100644 --- a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts +++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts @@ -25,7 +25,6 @@ import { SAMLAuthGuard } from 'src/engine/core-modules/auth/guards/saml-auth.gua import { SSOProviderEnabledGuard } from 'src/engine/core-modules/auth/guards/sso-provider-enabled.guard'; import { AuthService } from 'src/engine/core-modules/auth/services/auth.service'; import { LoginTokenService } from 'src/engine/core-modules/auth/token/services/login-token.service'; -import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service'; import { SSOService } from 'src/engine/core-modules/sso/services/sso.service'; import { IdentityProviderType, diff --git a/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts b/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts index 2bd3d4ab359a..6ff8d2b59a36 100644 --- a/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts +++ b/packages/twenty-server/src/engine/core-modules/user-workspace/user-workspace.service.ts @@ -5,10 +5,7 @@ import { TypeOrmQueryService } from '@ptc-org/nestjs-query-typeorm'; import { Repository } from 'typeorm'; import { TypeORMService } from 'src/database/typeorm/typeorm.service'; -import { - AppToken, - AppTokenType, -} from 'src/engine/core-modules/app-token/app-token.entity'; +import { AppToken } from 'src/engine/core-modules/app-token/app-token.entity'; import { ObjectRecordCreateEvent } from 'src/engine/core-modules/event-emitter/types/object-record-create.event'; import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity'; import { User } from 'src/engine/core-modules/user/user.entity'; diff --git a/packages/twenty-server/src/engine/core-modules/user/user.resolver.ts b/packages/twenty-server/src/engine/core-modules/user/user.resolver.ts index b7692671ee27..348204c6e2a0 100644 --- a/packages/twenty-server/src/engine/core-modules/user/user.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/user/user.resolver.ts @@ -35,7 +35,6 @@ import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorat import { DemoEnvGuard } from 'src/engine/guards/demo.env.guard'; import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard'; import { streamToBuffer } from 'src/utils/stream-to-buffer'; -import { isDefined } from 'src/utils/is-defined'; const getHMACKey = (email?: string, key?: string | null) => { if (!email || !key) return null; diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts index 0bc987d458a6..310c00ecb99f 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts @@ -18,12 +18,12 @@ import { WorkspaceResolver } from 'src/engine/core-modules/workspace/workspace.r import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module'; import { WorkspaceMetadataCacheModule } from 'src/engine/metadata-modules/workspace-metadata-cache/workspace-metadata-cache.module'; import { WorkspaceManagerModule } from 'src/engine/workspace-manager/workspace-manager.module'; +import { WorkspaceInvitationModule } from 'src/engine/core-modules/workspace-invitation/workspace-invitation.module'; import { workspaceAutoResolverOpts } from './workspace.auto-resolver-opts'; import { Workspace } from './workspace.entity'; import { WorkspaceService } from './services/workspace.service'; -import { WorkspaceInvitationModule } from 'src/engine/core-modules/workspace-invitation/workspace-invitation.module'; @Module({ imports: [ diff --git a/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts b/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts index 7cf762165e68..c4821d42e0f2 100644 --- a/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts +++ b/packages/twenty-server/src/engine/core-modules/workspace/workspace.resolver.ts @@ -34,8 +34,8 @@ import { WorkspaceExceptionCode, } from 'src/engine/core-modules/workspace/workspace.exception'; import { PublicWorkspaceDataOutput } from 'src/engine/core-modules/workspace/dtos/public-workspace-data.output'; - import { OriginHeader } from 'src/engine/decorators/auth/origin-header.decorator'; + import { Workspace } from './workspace.entity'; import { WorkspaceService } from './services/workspace.service'; diff --git a/packages/twenty-server/src/engine/utils/__tests__/get-workspace-subdomain-by-origin.spec.ts b/packages/twenty-server/src/engine/utils/__tests__/get-workspace-subdomain-by-origin.spec.ts index dafc40c96fd5..452f46eec476 100644 --- a/packages/twenty-server/src/engine/utils/__tests__/get-workspace-subdomain-by-origin.spec.ts +++ b/packages/twenty-server/src/engine/utils/__tests__/get-workspace-subdomain-by-origin.spec.ts @@ -4,16 +4,19 @@ describe('getWorkspaceSubdomainByOrigin', () => { it('should return subdomain from origin', () => { const origin = 'https://subdomain.example.com'; const result = getWorkspaceSubdomainByOrigin(origin); + expect(result).toBe('subdomain'); }); it('should return undefined if origin is not a subdomain', () => { const origin = 'https://example.com'; const result = getWorkspaceSubdomainByOrigin(origin); + expect(result).toBe(undefined); }); it('should return undefined if subdomain is app', () => { const origin = 'https://app.example.com'; const result = getWorkspaceSubdomainByOrigin(origin); + expect(result).toBe(undefined); }); }); diff --git a/packages/twenty-server/src/utils/__tests__/workspace-url.utils.spec.ts b/packages/twenty-server/src/utils/__tests__/workspace-url.utils.spec.ts index 33f69492eed8..965df6e1fc3f 100644 --- a/packages/twenty-server/src/utils/__tests__/workspace-url.utils.spec.ts +++ b/packages/twenty-server/src/utils/__tests__/workspace-url.utils.spec.ts @@ -1,5 +1,5 @@ import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; -import { buildWorkspaceURL } from '../workspace-url.utils'; +import { buildWorkspaceURL } from 'src/utils/workspace-url.utils'; describe('buildWorkspaceURL', () => { it('should build workspace URL with subdomain', () => { diff --git a/packages/twenty-server/test/utils/createTestingService.utils.ts b/packages/twenty-server/test/utils/createTestingService.utils.ts deleted file mode 100644 index ba43d6f6aebd..000000000000 --- a/packages/twenty-server/test/utils/createTestingService.utils.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { Provider, Type } from '@nestjs/common'; -import { TestingModule, Test } from '@nestjs/testing'; -import { getRepositoryToken } from '@nestjs/typeorm'; -import { AuthService } from 'src/engine/core-modules/auth/services/auth.service'; - -function getDependencies(service: Type) { - const dependencies = Reflect.getMetadata('design:paramtypes', service); - // @ts-ignore - console.log('>>>>>>>>>>>>>>', service.context); - if (!dependencies) { - return []; - } - - return dependencies.reduce( - (acc, dep) => { - if (dep.name === 'Repository') { - const name = getRepositoryToken(dep); - console.log( - '>>>>>>>>>>>>>>', - Object.getOwnPropertyNames(dep.prototype), - ); - console.log('>>>>>>>>>>>>>>', dep.metadata); - acc.repositories['frite'] = dep; - } else { - acc.services[dep.name] = dep; - } - return acc; - }, - { - repositories: {}, - services: {}, - }, - ); -} - -export const createTestingService = async >( - service: T, - override?: { - repositories?: Record; - services?: Record; - }, -): Promise => { - const { services, repositories } = getDependencies(service); - - const module: TestingModule = await Test.createTestingModule({ - providers: [ - service, - // ...(Object.entries(repositories).map(([name, repository]) => ({ - // provide: repository, - // useValue: override?.repositories?.[name] ?? {}, - // })) as Provider[]), - ...(Object.entries(services).map(([name, service]) => ({ - provide: service, - useValue: override?.services?.[name] ?? {}, - })) as Provider[]), - ], - }).compile(); - - // @ts-ignore - return module.get(service); -}; - -createTestingService(AuthService);