From 70b93f2f5328da9eee6d397ee868821f7a308456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Mon, 28 Apr 2025 16:15:20 +0200 Subject: [PATCH] refactor(core): Split out database types (#14942) --- .../cli/src/__tests__/wait-tracker.test.ts | 2 +- packages/cli/src/active-workflow-manager.ts | 2 +- .../cli/src/commands/export/credentials.ts | 3 +- .../__tests__/me.controller.test.ts | 2 +- .../__tests__/owner.controller.test.ts | 2 +- .../cli/src/controllers/auth.controller.ts | 2 +- packages/cli/src/controllers/me.controller.ts | 2 +- .../oauth/abstract-oauth.controller.ts | 2 +- .../cli/src/controllers/users.controller.ts | 2 +- packages/cli/src/credentials-helper.ts | 2 +- .../src/credentials/credentials.service.ts | 2 +- .../databases/entities/credentials-entity.ts | 2 +- packages/cli/src/databases/entities/user.ts | 2 +- .../src/databases/entities/workflow-entity.ts | 2 +- .../1681134145996-AddUserActivatedProperty.ts | 2 +- .../1681134145996-AddUserActivatedProperty.ts | 2 +- .../1681134145996-AddUserActivatedProperty.ts | 2 +- .../__tests__/execution.repository.test.ts | 2 +- .../repositories/execution.repository.ts | 8 +- .../databases/repositories/tag.repository.ts | 2 +- .../source-control-export.service.ee.ts | 2 +- .../event-message-workflow.ts | 2 +- .../log-streaming-event-relay.test.ts | 2 +- .../__tests__/telemetry-event-relay.test.ts | 2 +- .../cli/src/events/maps/relay.event-map.ts | 2 +- .../__tests__/save-execution-progress.test.ts | 2 +- .../__tests__/execution.service.test.ts | 2 +- .../executions/execution-recovery.service.ts | 2 +- .../src/executions/execution.service.ee.ts | 4 +- .../cli/src/executions/execution.service.ts | 7 +- packages/cli/src/external-hooks.ts | 2 +- packages/cli/src/interfaces.ts | 113 +------------- .../insights-collection.service.test.ts | 2 +- .../__tests__/insights.service.test.ts | 2 +- .../database/entities/insights-by-period.ts | 3 +- .../database/entities/insights-raw.ts | 3 +- packages/cli/src/posthog/index.ts | 2 +- .../credentials/credentials.service.ts | 2 +- packages/cli/src/requests.ts | 2 +- .../__tests__/job-processor.service.test.ts | 2 +- .../src/services/annotation-tag.service.ee.ts | 2 +- packages/cli/src/services/import.service.ts | 2 +- packages/cli/src/services/tag.service.ts | 2 +- packages/cli/src/services/user.service.ts | 3 +- packages/cli/src/types-db.ts | 142 ++++++++++++++++++ .../webhooks/__tests__/waiting-forms.test.ts | 2 +- .../__tests__/waiting-webhooks.test.ts | 2 +- packages/cli/src/webhooks/waiting-forms.ts | 2 +- packages/cli/src/webhooks/waiting-webhooks.ts | 2 +- .../cli/src/workflows/workflow.service.ee.ts | 6 +- packages/cli/src/workflows/workflows.types.ts | 25 --- .../test/integration/shared/db/credentials.ts | 2 +- .../test/integration/shared/db/workflows.ts | 2 +- packages/cli/test/integration/shared/types.ts | 2 +- .../test/integration/shared/utils/users.ts | 2 +- .../workflows/workflows.controller.ee.test.ts | 2 +- 56 files changed, 207 insertions(+), 200 deletions(-) create mode 100644 packages/cli/src/types-db.ts delete mode 100644 packages/cli/src/workflows/workflows.types.ts diff --git a/packages/cli/src/__tests__/wait-tracker.test.ts b/packages/cli/src/__tests__/wait-tracker.test.ts index 6721c31bae..5f614f42f8 100644 --- a/packages/cli/src/__tests__/wait-tracker.test.ts +++ b/packages/cli/src/__tests__/wait-tracker.test.ts @@ -6,10 +6,10 @@ import { createDeferredPromise } from 'n8n-workflow'; import type { ActiveExecutions } from '@/active-executions'; import type { Project } from '@/databases/entities/project'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { IExecutionResponse } from '@/interfaces'; import type { MultiMainSetup } from '@/scaling/multi-main-setup.ee'; import { OrchestrationService } from '@/services/orchestration.service'; import type { OwnershipService } from '@/services/ownership.service'; +import type { IExecutionResponse } from '@/types-db'; import { WaitTracker } from '@/wait-tracker'; import type { WorkflowRunner } from '@/workflow-runner'; import { mockLogger } from '@test/mocking'; diff --git a/packages/cli/src/active-workflow-manager.ts b/packages/cli/src/active-workflow-manager.ts index 2cd6cc1937..58d78c63a4 100644 --- a/packages/cli/src/active-workflow-manager.ts +++ b/packages/cli/src/active-workflow-manager.ts @@ -46,11 +46,11 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { executeErrorWorkflow } from '@/execution-lifecycle/execute-error-workflow'; import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; -import type { IWorkflowDb } from '@/interfaces'; import { NodeTypes } from '@/node-types'; import { Publisher } from '@/scaling/pubsub/publisher.service'; import { ActiveWorkflowsService } from '@/services/active-workflows.service'; import { OrchestrationService } from '@/services/orchestration.service'; +import type { IWorkflowDb } from '@/types-db'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import { WebhookService } from '@/webhooks/webhook.service'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/commands/export/credentials.ts b/packages/cli/src/commands/export/credentials.ts index 9ab38daf0f..d30fe93251 100644 --- a/packages/cli/src/commands/export/credentials.ts +++ b/packages/cli/src/commands/export/credentials.ts @@ -6,7 +6,8 @@ import { UserError } from 'n8n-workflow'; import path from 'path'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import type { ICredentialsDb, ICredentialsDecryptedDb } from '@/interfaces'; +import type { ICredentialsDecryptedDb } from '@/interfaces'; +import type { ICredentialsDb } from '@/types-db'; import { BaseCommand } from '../base-command'; diff --git a/packages/cli/src/controllers/__tests__/me.controller.test.ts b/packages/cli/src/controllers/__tests__/me.controller.test.ts index 9ba6f8ada7..d960065ef5 100644 --- a/packages/cli/src/controllers/__tests__/me.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/me.controller.test.ts @@ -14,11 +14,11 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import type { PublicUser } from '@/interfaces'; import { License } from '@/license'; import { MfaService } from '@/mfa/mfa.service'; import type { AuthenticatedRequest, MeRequest } from '@/requests'; import { UserService } from '@/services/user.service'; +import type { PublicUser } from '@/types-db'; import { mockInstance } from '@test/mocking'; import { badPasswords } from '@test/test-data'; diff --git a/packages/cli/src/controllers/__tests__/owner.controller.test.ts b/packages/cli/src/controllers/__tests__/owner.controller.test.ts index b5065fa283..5d2fc4c971 100644 --- a/packages/cli/src/controllers/__tests__/owner.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/owner.controller.test.ts @@ -11,10 +11,10 @@ import type { SettingsRepository } from '@/databases/repositories/settings.repos import type { UserRepository } from '@/databases/repositories/user.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import type { EventService } from '@/events/event.service'; -import type { PublicUser } from '@/interfaces'; import type { AuthenticatedRequest } from '@/requests'; import type { PasswordUtility } from '@/services/password.utility'; import type { UserService } from '@/services/user.service'; +import type { PublicUser } from '@/types-db'; describe('OwnerController', () => { const configGetSpy = jest.spyOn(config, 'getEnv'); diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index 5eb2b7a805..d2e5e58cc8 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -13,7 +13,6 @@ import { AuthError } from '@/errors/response-errors/auth.error'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { EventService } from '@/events/event.service'; -import type { PublicUser } from '@/interfaces'; import { License } from '@/license'; import { MfaService } from '@/mfa/mfa.service'; import { PostHogClient } from '@/posthog'; @@ -24,6 +23,7 @@ import { isLdapCurrentAuthenticationMethod, isSamlCurrentAuthenticationMethod, } from '@/sso.ee/sso-helpers'; +import type { PublicUser } from '@/types-db'; @RestController() export class AuthController { diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index 14cb8b1aef..5c058f700f 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -17,12 +17,12 @@ import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.e import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; -import type { PublicUser } from '@/interfaces'; import { MfaService } from '@/mfa/mfa.service'; import { AuthenticatedRequest, MeRequest } from '@/requests'; import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; import { isSamlLicensedAndEnabled } from '@/sso.ee/saml/saml-helpers'; +import type { PublicUser } from '@/types-db'; import { PersonalizationSurveyAnswersV4 } from './survey-answers.dto'; @RestController('/me') diff --git a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts index 5cc188715e..61e3f6b9bf 100644 --- a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts +++ b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts @@ -15,9 +15,9 @@ import { AuthError } from '@/errors/response-errors/auth.error'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; -import type { ICredentialsDb } from '@/interfaces'; import type { AuthenticatedRequest, OAuthRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; +import type { ICredentialsDb } from '@/types-db'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; type CsrfStateParam = { diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index 5bb7cf73b3..5c6ae9e13e 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -26,12 +26,12 @@ import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import type { PublicUser } from '@/interfaces'; import { listQueryMiddleware } from '@/middlewares'; import { AuthenticatedRequest, ListQuery, UserRequest } from '@/requests'; import { FolderService } from '@/services/folder.service'; import { ProjectService } from '@/services/project.service.ee'; import { UserService } from '@/services/user.service'; +import type { PublicUser } from '@/types-db'; import { WorkflowService } from '@/workflows/workflow.service'; @RestController('/users') diff --git a/packages/cli/src/credentials-helper.ts b/packages/cli/src/credentials-helper.ts index 5e5436c93d..a600f9bdae 100644 --- a/packages/cli/src/credentials-helper.ts +++ b/packages/cli/src/credentials-helper.ts @@ -33,7 +33,7 @@ import { CredentialsOverwrites } from '@/credentials-overwrites'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import type { ICredentialsDb } from '@/interfaces'; +import type { ICredentialsDb } from '@/types-db'; import { RESPONSE_ERROR_MESSAGES } from './constants'; import { CredentialNotFoundError } from './errors/credential-not-found.error'; diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index 89fba37b6a..44f66cf0b4 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -32,7 +32,6 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; -import type { ICredentialsDb } from '@/interfaces'; import { userHasScopes } from '@/permissions.ee/check-access'; import type { CredentialRequest, ListQuery } from '@/requests'; import { CredentialsTester } from '@/services/credentials-tester.service'; @@ -40,6 +39,7 @@ import { OwnershipService } from '@/services/ownership.service'; import { ProjectService } from '@/services/project.service.ee'; import type { ScopesField } from '@/services/role.service'; import { RoleService } from '@/services/role.service'; +import type { ICredentialsDb } from '@/types-db'; import { CredentialsFinderService } from './credentials-finder.service'; diff --git a/packages/cli/src/databases/entities/credentials-entity.ts b/packages/cli/src/databases/entities/credentials-entity.ts index b4f1a10c38..cfb91d9c57 100644 --- a/packages/cli/src/databases/entities/credentials-entity.ts +++ b/packages/cli/src/databases/entities/credentials-entity.ts @@ -1,7 +1,7 @@ import { Column, Entity, Index, OneToMany } from '@n8n/typeorm'; import { IsObject, IsString, Length } from 'class-validator'; -import type { ICredentialsDb } from '@/interfaces'; +import type { ICredentialsDb } from '@/types-db'; import { WithTimestampsAndStringId } from './abstract-entity'; import type { SharedCredentials } from './shared-credentials'; diff --git a/packages/cli/src/databases/entities/user.ts b/packages/cli/src/databases/entities/user.ts index c2392fe0d0..adabd72eec 100644 --- a/packages/cli/src/databases/entities/user.ts +++ b/packages/cli/src/databases/entities/user.ts @@ -13,12 +13,12 @@ import { import { IsEmail, IsString, Length } from 'class-validator'; import type { IUser, IUserSettings } from 'n8n-workflow'; -import type { IPersonalizationSurveyAnswers } from '@/interfaces'; import { GLOBAL_OWNER_SCOPES, GLOBAL_MEMBER_SCOPES, GLOBAL_ADMIN_SCOPES, } from '@/permissions.ee/global-roles'; +import type { IPersonalizationSurveyAnswers } from '@/types-db'; import { NoUrl } from '@/validators/no-url.validator'; import { NoXss } from '@/validators/no-xss.validator'; diff --git a/packages/cli/src/databases/entities/workflow-entity.ts b/packages/cli/src/databases/entities/workflow-entity.ts index d008159175..b05c4863f1 100644 --- a/packages/cli/src/databases/entities/workflow-entity.ts +++ b/packages/cli/src/databases/entities/workflow-entity.ts @@ -12,7 +12,7 @@ import { Length } from 'class-validator'; import { IConnections, IDataObject, IWorkflowSettings, WorkflowFEMeta } from 'n8n-workflow'; import type { IBinaryKeyData, INode, IPairedItemData } from 'n8n-workflow'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; import { WithTimestampsAndStringId, dbType, jsonColumnType } from './abstract-entity'; import { type Folder } from './folder'; diff --git a/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts b/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts index 5a601e427c..4e9da99e0f 100644 --- a/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1681134145996-AddUserActivatedProperty.ts @@ -1,5 +1,5 @@ import type { MigrationContext, ReversibleMigration } from '@/databases/types'; -import type { UserSettings } from '@/interfaces'; +import type { UserSettings } from '@/types-db'; export class AddUserActivatedProperty1681134145996 implements ReversibleMigration { async up({ queryRunner, tablePrefix }: MigrationContext) { diff --git a/packages/cli/src/databases/migrations/postgresdb/1681134145996-AddUserActivatedProperty.ts b/packages/cli/src/databases/migrations/postgresdb/1681134145996-AddUserActivatedProperty.ts index d01930bc73..4b4693d0ed 100644 --- a/packages/cli/src/databases/migrations/postgresdb/1681134145996-AddUserActivatedProperty.ts +++ b/packages/cli/src/databases/migrations/postgresdb/1681134145996-AddUserActivatedProperty.ts @@ -1,5 +1,5 @@ import type { MigrationContext, ReversibleMigration } from '@/databases/types'; -import type { UserSettings } from '@/interfaces'; +import type { UserSettings } from '@/types-db'; export class AddUserActivatedProperty1681134145996 implements ReversibleMigration { async up({ queryRunner, tablePrefix }: MigrationContext) { diff --git a/packages/cli/src/databases/migrations/sqlite/1681134145996-AddUserActivatedProperty.ts b/packages/cli/src/databases/migrations/sqlite/1681134145996-AddUserActivatedProperty.ts index 463eb12e80..d09b823fa7 100644 --- a/packages/cli/src/databases/migrations/sqlite/1681134145996-AddUserActivatedProperty.ts +++ b/packages/cli/src/databases/migrations/sqlite/1681134145996-AddUserActivatedProperty.ts @@ -1,5 +1,5 @@ import type { MigrationContext, ReversibleMigration } from '@/databases/types'; -import type { UserSettings } from '@/interfaces'; +import type { UserSettings } from '@/types-db'; export class AddUserActivatedProperty1681134145996 implements ReversibleMigration { async up({ queryRunner, tablePrefix }: MigrationContext) { diff --git a/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts index a6195b4f67..14dbaa0f23 100644 --- a/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts @@ -10,7 +10,7 @@ import { nanoid } from 'nanoid'; import { ExecutionEntity } from '@/databases/entities/execution-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { IExecutionResponse } from '@/interfaces'; +import type { IExecutionResponse } from '@/types-db'; import { mockInstance, mockEntityManager } from '@test/mocking'; describe('ExecutionRepository', () => { diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 2c2dba656c..b9b9425af7 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -36,12 +36,8 @@ import { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mappin import { ExecutionAnnotation } from '@/databases/entities/execution-annotation.ee'; import { PostgresLiveRowsRetrievalError } from '@/errors/postgres-live-rows-retrieval.error'; import type { ExecutionSummaries } from '@/executions/execution.types'; -import type { - CreateExecutionPayload, - IExecutionBase, - IExecutionFlattedDb, - IExecutionResponse, -} from '@/interfaces'; +import type { CreateExecutionPayload, IExecutionFlattedDb } from '@/interfaces'; +import type { IExecutionBase, IExecutionResponse } from '@/types-db'; import { separate } from '@/utils'; import { ExecutionDataRepository } from './execution-data.repository'; diff --git a/packages/cli/src/databases/repositories/tag.repository.ts b/packages/cli/src/databases/repositories/tag.repository.ts index b6d1400920..cb70aea1a9 100644 --- a/packages/cli/src/databases/repositories/tag.repository.ts +++ b/packages/cli/src/databases/repositories/tag.repository.ts @@ -3,7 +3,7 @@ import type { EntityManager } from '@n8n/typeorm'; import { DataSource, In, Repository } from '@n8n/typeorm'; import intersection from 'lodash/intersection'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; import { TagEntity } from '../entities/tag-entity'; diff --git a/packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts b/packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts index 21a1dea438..cff6552f05 100644 --- a/packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts +++ b/packages/cli/src/environments.ee/source-control/source-control-export.service.ee.ts @@ -14,7 +14,7 @@ import { SharedWorkflowRepository } from '@/databases/repositories/shared-workfl import { TagRepository } from '@/databases/repositories/tag.repository'; import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; import { formatWorkflow } from '@/workflows/workflow.formatter'; import { diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-workflow.ts b/packages/cli/src/eventbus/event-message-classes/event-message-workflow.ts index 4d94f3d2c1..bf58dfeae0 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-workflow.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-workflow.ts @@ -1,7 +1,7 @@ import type { IWorkflowBase, JsonObject } from 'n8n-workflow'; import { EventMessageTypeNames } from 'n8n-workflow'; -import type { IExecutionBase } from '@/interfaces'; +import type { IExecutionBase } from '@/types-db'; import type { EventNamesWorkflowType } from '.'; import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; diff --git a/packages/cli/src/events/__tests__/log-streaming-event-relay.test.ts b/packages/cli/src/events/__tests__/log-streaming-event-relay.test.ts index 1729509210..557a063bb1 100644 --- a/packages/cli/src/events/__tests__/log-streaming-event-relay.test.ts +++ b/packages/cli/src/events/__tests__/log-streaming-event-relay.test.ts @@ -5,7 +5,7 @@ import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event import { EventService } from '@/events/event.service'; import type { RelayEventMap } from '@/events/maps/relay.event-map'; import { LogStreamingEventRelay } from '@/events/relays/log-streaming.event-relay'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; describe('LogStreamingEventRelay', () => { const eventBus = mock(); diff --git a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts index b99074335b..0e051d9f79 100644 --- a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts +++ b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts @@ -14,10 +14,10 @@ import type { WorkflowRepository } from '@/databases/repositories/workflow.repos import { EventService } from '@/events/event.service'; import type { RelayEventMap } from '@/events/maps/relay.event-map'; import { TelemetryEventRelay } from '@/events/relays/telemetry.event-relay'; -import type { IWorkflowDb } from '@/interfaces'; import type { License } from '@/license'; import type { NodeTypes } from '@/node-types'; import type { Telemetry } from '@/telemetry'; +import type { IWorkflowDb } from '@/types-db'; import { mockInstance } from '@test/mocking'; const flushPromises = async () => await new Promise((resolve) => setImmediate(resolve)); diff --git a/packages/cli/src/events/maps/relay.event-map.ts b/packages/cli/src/events/maps/relay.event-map.ts index 45fc762c3d..84929f937b 100644 --- a/packages/cli/src/events/maps/relay.event-map.ts +++ b/packages/cli/src/events/maps/relay.event-map.ts @@ -10,7 +10,7 @@ import type { import type { ConcurrencyQueueType } from '@/concurrency/concurrency-control.service'; import type { AuthProviderType } from '@/databases/entities/auth-identity'; import type { User } from '@/databases/entities/user'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; import type { AiEventMap } from './ai.event-map'; diff --git a/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts b/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts index 8c90c865fd..591d7a7c7b 100644 --- a/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts +++ b/packages/cli/src/execution-lifecycle/__tests__/save-execution-progress.test.ts @@ -4,7 +4,7 @@ import { Logger } from 'n8n-core'; import type { IRunExecutionData, ITaskData } from 'n8n-workflow'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { IExecutionResponse } from '@/interfaces'; +import type { IExecutionResponse } from '@/types-db'; import { mockInstance } from '@test/mocking'; import { saveExecutionProgress } from '../save-execution-progress'; diff --git a/packages/cli/src/executions/__tests__/execution.service.test.ts b/packages/cli/src/executions/__tests__/execution.service.test.ts index e425c1e588..74eb6dd1b9 100644 --- a/packages/cli/src/executions/__tests__/execution.service.test.ts +++ b/packages/cli/src/executions/__tests__/execution.service.test.ts @@ -9,9 +9,9 @@ import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.err import { MissingExecutionStopError } from '@/errors/missing-execution-stop.error'; import { ExecutionService } from '@/executions/execution.service'; import type { ExecutionRequest } from '@/executions/execution.types'; -import type { IExecutionResponse } from '@/interfaces'; import { ScalingService } from '@/scaling/scaling.service'; import type { Job } from '@/scaling/scaling.types'; +import type { IExecutionResponse } from '@/types-db'; import type { WaitTracker } from '@/wait-tracker'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/executions/execution-recovery.service.ts b/packages/cli/src/executions/execution-recovery.service.ts index c6224cdbd7..2b49105c4b 100644 --- a/packages/cli/src/executions/execution-recovery.service.ts +++ b/packages/cli/src/executions/execution-recovery.service.ts @@ -9,8 +9,8 @@ import { ExecutionRepository } from '@/databases/repositories/execution.reposito import { NodeCrashedError } from '@/errors/node-crashed.error'; import { WorkflowCrashedError } from '@/errors/workflow-crashed.error'; import { getLifecycleHooksForRegularMain } from '@/execution-lifecycle/execution-lifecycle-hooks'; -import type { IExecutionResponse } from '@/interfaces'; import { Push } from '@/push'; +import type { IExecutionResponse } from '@/types-db'; import type { EventMessageTypes } from '../eventbus/event-message-classes'; diff --git a/packages/cli/src/executions/execution.service.ee.ts b/packages/cli/src/executions/execution.service.ee.ts index b345ef6c99..93f3b63a63 100644 --- a/packages/cli/src/executions/execution.service.ee.ts +++ b/packages/cli/src/executions/execution.service.ee.ts @@ -1,8 +1,8 @@ import { Service } from '@n8n/di'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { IExecutionResponse, IExecutionFlattedResponse } from '@/interfaces'; -import type { WorkflowWithSharingsAndCredentials } from '@/workflows/workflows.types'; +import type { IExecutionFlattedResponse } from '@/interfaces'; +import type { WorkflowWithSharingsAndCredentials, IExecutionResponse } from '@/types-db'; import { ExecutionService } from './execution.service'; import type { ExecutionRequest } from './execution.types'; diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index fd8762ee38..84d787855d 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -33,13 +33,10 @@ import { MissingExecutionStopError } from '@/errors/missing-execution-stop.error import { QueuedExecutionRetryError } from '@/errors/queued-execution-retry.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { - CreateExecutionPayload, - IExecutionFlattedResponse, - IExecutionResponse, -} from '@/interfaces'; +import type { CreateExecutionPayload, IExecutionFlattedResponse } from '@/interfaces'; import { License } from '@/license'; import { NodeTypes } from '@/node-types'; +import type { IExecutionResponse } from '@/types-db'; import { WaitTracker } from '@/wait-tracker'; import { WorkflowRunner } from '@/workflow-runner'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; diff --git a/packages/cli/src/external-hooks.ts b/packages/cli/src/external-hooks.ts index 6f2990c0e9..af8168c068 100644 --- a/packages/cli/src/external-hooks.ts +++ b/packages/cli/src/external-hooks.ts @@ -15,7 +15,7 @@ import { CredentialsRepository } from '@/databases/repositories/credentials.repo import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { ICredentialsDb, PublicUser } from '@/interfaces'; +import type { ICredentialsDb, PublicUser } from '@/types-db'; type Repositories = { User: UserRepository; diff --git a/packages/cli/src/interfaces.ts b/packages/cli/src/interfaces.ts index a281bc1962..4b90feea5f 100644 --- a/packages/cli/src/interfaces.ts +++ b/packages/cli/src/interfaces.ts @@ -1,10 +1,9 @@ -import type { AssignableRole, GlobalRole, Scope } from '@n8n/permissions'; +import type { AssignableRole } from '@n8n/permissions'; import type { Application } from 'express'; import type { ExecutionError, ICredentialDataDecryptedObject, ICredentialsDecrypted, - ICredentialsEncrypted, IDeferredPromise, IExecuteResponsePromiseData, IRun, @@ -15,8 +14,6 @@ import type { WorkflowExecuteMode, ExecutionStatus, ExecutionSummary, - FeatureFlags, - IUserSettings, IWorkflowExecutionDataProcess, DeduplicationMode, DeduplicationItemTypes, @@ -24,15 +21,8 @@ import type { import type PCancelable from 'p-cancelable'; import type { ActiveWorkflowManager } from '@/active-workflow-manager'; -import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.ee'; -import type { AuthProviderType } from '@/databases/entities/auth-identity'; -import type { SharedCredentials } from '@/databases/entities/shared-credentials'; -import type { TagEntity } from '@/databases/entities/tag-entity'; -import type { User } from '@/databases/entities/user'; - -import type { Folder } from './databases/entities/folder'; -import type { ExternalHooks } from './external-hooks'; -import type { WorkflowWithSharingsAndCredentials } from './workflows/workflows.types'; +import type { ExternalHooks } from '@/external-hooks'; +import type { ICredentialsBase, IExecutionBase, ITagBase } from '@/types-db'; export interface ICredentialsTypeData { [key: string]: CredentialLoadingDetails; @@ -60,39 +50,15 @@ export interface IProcessedDataEntries { // tags // ---------------------------------- -export interface ITagBase { - id: string; - name: string; -} - export interface ITagToImport extends ITagBase { createdAt?: string; updatedAt?: string; } -export type UsageCount = { - usageCount: number; -}; - -export type ITagDb = Pick; - -export type ITagWithCountDb = ITagDb & UsageCount; - -export type IAnnotationTagDb = Pick; - -export type IAnnotationTagWithCountDb = IAnnotationTagDb & UsageCount; - // ---------------------------------- // workflows // ---------------------------------- -// Almost identical to editor-ui.Interfaces.ts -export interface IWorkflowDb extends IWorkflowBase { - triggerCount: number; - tags?: TagEntity[]; - parentFolder?: Folder | null; -} - export interface IWorkflowResponse extends IWorkflowBase { id: string; } @@ -110,41 +76,12 @@ export interface IWorkflowToImport // credentials // ---------------------------------- -export interface ICredentialsBase { - createdAt: Date; - updatedAt: Date; -} - -export interface ICredentialsDb extends ICredentialsBase, ICredentialsEncrypted { - id: string; - name: string; - shared?: SharedCredentials[]; -} - export type ICredentialsDecryptedDb = ICredentialsBase & ICredentialsDecrypted; export type ICredentialsDecryptedResponse = ICredentialsDecryptedDb; export type SaveExecutionDataType = 'all' | 'none'; -export interface IExecutionBase { - id: string; - mode: WorkflowExecuteMode; - createdAt: Date; // set by DB - startedAt: Date; - stoppedAt?: Date; // empty value means execution is still running - workflowId: string; - - /** - * @deprecated Use `status` instead - */ - finished: boolean; - retryOf?: string; // If it is a retry, the id of the execution it is a retry of. - retrySuccessId?: string; // If it failed and a retry did succeed. The id of the successful retry. - status: ExecutionStatus; - waitTill?: Date | null; -} - // Data in regular format with references export interface IExecutionDb extends IExecutionBase { data: IRunExecutionData; @@ -157,18 +94,6 @@ export type CreateExecutionPayload = Omit; -export interface IExecutionResponse extends IExecutionBase { - id: string; - data: IRunExecutionData; - retryOf?: string; - retrySuccessId?: string; - workflowData: IWorkflowBase | WorkflowWithSharingsAndCredentials; - customData: Record; - annotation: { - tags: ITagBase[]; - }; -} - // Flatted data to save memory when saving in database or transferring // via REST API export interface IExecutionFlatted extends IExecutionBase { @@ -221,16 +146,6 @@ export interface IExecutingWorkflowData { status: ExecutionStatus; } -export interface IPersonalizationSurveyAnswers { - email: string | null; - codingSkill: string | null; - companyIndustry: string[]; - companySize: string | null; - otherCompanyIndustry: string | null; - otherWorkArea: string | null; - workArea: string[] | string | null; -} - export interface IActiveDirectorySettings { enabled: boolean; } @@ -323,26 +238,6 @@ export interface ILicensePostResponse extends ILicenseReadResponse { managementToken: string; } -export interface PublicUser { - id: string; - email?: string; - firstName?: string; - lastName?: string; - personalizationAnswers?: IPersonalizationSurveyAnswers | null; - password?: string; - passwordResetToken?: string; - createdAt: Date; - isPending: boolean; - role?: GlobalRole; - globalScopes?: Scope[]; - signInType: AuthProviderType; - disabled: boolean; - settings?: IUserSettings | null; - inviteAcceptUrl?: string; - isOwner?: boolean; - featureFlags?: FeatureFlags; -} - export interface Invitation { email: string; role: AssignableRole; @@ -354,5 +249,3 @@ export interface N8nApp { externalHooks: ExternalHooks; activeWorkflowManager: ActiveWorkflowManager; } - -export type UserSettings = Pick; diff --git a/packages/cli/src/modules/insights/__tests__/insights-collection.service.test.ts b/packages/cli/src/modules/insights/__tests__/insights-collection.service.test.ts index 664f6d7e03..8004fd632e 100644 --- a/packages/cli/src/modules/insights/__tests__/insights-collection.service.test.ts +++ b/packages/cli/src/modules/insights/__tests__/insights-collection.service.test.ts @@ -14,10 +14,10 @@ import { import type { Project } from '@/databases/entities/project'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import type { IWorkflowDb } from '@/interfaces'; import type { TypeUnit } from '@/modules/insights/database/entities/insights-shared'; import { InsightsMetadataRepository } from '@/modules/insights/database/repositories/insights-metadata.repository'; import { InsightsRawRepository } from '@/modules/insights/database/repositories/insights-raw.repository'; +import type { IWorkflowDb } from '@/types-db'; import { createTeamProject } from '@test-integration/db/projects'; import { createWorkflow } from '@test-integration/db/workflows'; import * as testDb from '@test-integration/test-db'; diff --git a/packages/cli/src/modules/insights/__tests__/insights.service.test.ts b/packages/cli/src/modules/insights/__tests__/insights.service.test.ts index b50b1c0cac..df4487a449 100644 --- a/packages/cli/src/modules/insights/__tests__/insights.service.test.ts +++ b/packages/cli/src/modules/insights/__tests__/insights.service.test.ts @@ -6,8 +6,8 @@ import type { Logger } from 'n8n-core'; import type { Project } from '@/databases/entities/project'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { IWorkflowDb } from '@/interfaces'; import type { License } from '@/license'; +import type { IWorkflowDb } from '@/types-db'; import { createTeamProject } from '@test-integration/db/projects'; import { createWorkflow } from '@test-integration/db/workflows'; import * as testDb from '@test-integration/test-db'; diff --git a/packages/cli/src/modules/insights/database/entities/insights-by-period.ts b/packages/cli/src/modules/insights/database/entities/insights-by-period.ts index ef04da6c7e..973982ded8 100644 --- a/packages/cli/src/modules/insights/database/entities/insights-by-period.ts +++ b/packages/cli/src/modules/insights/database/entities/insights-by-period.ts @@ -8,6 +8,8 @@ import { } from '@n8n/typeorm'; import { UnexpectedError } from 'n8n-workflow'; +import { datetimeColumnType } from '@/databases/entities/abstract-entity'; + import { InsightsMetadata } from './insights-metadata'; import type { PeriodUnit } from './insights-shared'; import { @@ -18,7 +20,6 @@ import { PeriodUnitToNumber, TypeToNumber, } from './insights-shared'; -import { datetimeColumnType } from '../../../../databases/entities/abstract-entity'; @Entity() export class InsightsByPeriod extends BaseEntity { diff --git a/packages/cli/src/modules/insights/database/entities/insights-raw.ts b/packages/cli/src/modules/insights/database/entities/insights-raw.ts index 4c20e04e64..fddf90759d 100644 --- a/packages/cli/src/modules/insights/database/entities/insights-raw.ts +++ b/packages/cli/src/modules/insights/database/entities/insights-raw.ts @@ -3,8 +3,9 @@ import { Container } from '@n8n/di'; import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from '@n8n/typeorm'; import { UnexpectedError } from 'n8n-workflow'; +import { datetimeColumnType } from '@/databases/entities/abstract-entity'; + import { isValidTypeNumber, NumberToType, TypeToNumber } from './insights-shared'; -import { datetimeColumnType } from '../../../../databases/entities/abstract-entity'; export const { type: dbType } = Container.get(GlobalConfig).database; diff --git a/packages/cli/src/posthog/index.ts b/packages/cli/src/posthog/index.ts index 6dcc6dd650..65cb6d1df6 100644 --- a/packages/cli/src/posthog/index.ts +++ b/packages/cli/src/posthog/index.ts @@ -4,7 +4,7 @@ import { InstanceSettings } from 'n8n-core'; import type { FeatureFlags, ITelemetryTrackProperties } from 'n8n-workflow'; import type { PostHog } from 'posthog-node'; -import type { PublicUser } from '@/interfaces'; +import type { PublicUser } from '@/types-db'; @Service() export class PostHogClient { diff --git a/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts b/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts index 4e2754a12e..1cf29f3716 100644 --- a/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts +++ b/packages/cli/src/public-api/v1/handlers/credentials/credentials.service.ts @@ -16,8 +16,8 @@ import { SharedCredentialsRepository } from '@/databases/repositories/shared-cre import * as Db from '@/db'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import type { ICredentialsDb } from '@/interfaces'; import type { CredentialRequest } from '@/requests'; +import type { ICredentialsDb } from '@/types-db'; import type { IDependency, IJsonSchema } from '../../../types'; diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index f6b6f94e45..120e4c6d96 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -15,6 +15,7 @@ import type { Variables } from '@/databases/entities/variables'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { WorkflowHistory } from '@/databases/entities/workflow-history'; import type { ScopesField } from '@/services/role.service'; +import type { SlimProject } from '@/types-db'; export type APIRequest< RouteParams = {}, @@ -122,7 +123,6 @@ export namespace ListQuery { } type SlimUser = Pick; -export type SlimProject = Pick; export function hasSharing( workflows: ListQuery.Workflow.Plain[] | ListQuery.Workflow.WithSharing[], diff --git a/packages/cli/src/scaling/__tests__/job-processor.service.test.ts b/packages/cli/src/scaling/__tests__/job-processor.service.test.ts index b3236268b5..07626dea4c 100644 --- a/packages/cli/src/scaling/__tests__/job-processor.service.test.ts +++ b/packages/cli/src/scaling/__tests__/job-processor.service.test.ts @@ -7,10 +7,10 @@ import { CredentialsHelper } from '@/credentials-helper'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { VariablesService } from '@/environments.ee/variables/variables.service.ee'; import { ExternalHooks } from '@/external-hooks'; -import type { IExecutionResponse } from '@/interfaces'; import type { ManualExecutionService } from '@/manual-execution.service'; import { SecretsHelper } from '@/secrets-helpers.ee'; import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; +import type { IExecutionResponse } from '@/types-db'; import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; import { JobProcessor } from '../job-processor'; diff --git a/packages/cli/src/services/annotation-tag.service.ee.ts b/packages/cli/src/services/annotation-tag.service.ee.ts index 9c56a7bee4..33c106f5b3 100644 --- a/packages/cli/src/services/annotation-tag.service.ee.ts +++ b/packages/cli/src/services/annotation-tag.service.ee.ts @@ -3,7 +3,7 @@ import { Service } from '@n8n/di'; import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.ee'; import { AnnotationTagRepository } from '@/databases/repositories/annotation-tag.repository.ee'; import { validateEntity } from '@/generic-helpers'; -import type { IAnnotationTagDb, IAnnotationTagWithCountDb } from '@/interfaces'; +import type { IAnnotationTagDb, IAnnotationTagWithCountDb } from '@/types-db'; type GetAllResult = T extends { withUsageCount: true } ? IAnnotationTagWithCountDb[] diff --git a/packages/cli/src/services/import.service.ts b/packages/cli/src/services/import.service.ts index b0b0978058..22612a5a7f 100644 --- a/packages/cli/src/services/import.service.ts +++ b/packages/cli/src/services/import.service.ts @@ -11,7 +11,7 @@ import { WorkflowTagMapping } from '@/databases/entities/workflow-tag-mapping'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { TagRepository } from '@/databases/repositories/tag.repository'; import * as Db from '@/db'; -import type { ICredentialsDb, IWorkflowDb } from '@/interfaces'; +import type { ICredentialsDb, IWorkflowDb } from '@/types-db'; import { replaceInvalidCredentials } from '@/workflow-helpers'; @Service() diff --git a/packages/cli/src/services/tag.service.ts b/packages/cli/src/services/tag.service.ts index 1f6cdd88fe..6faa8278e0 100644 --- a/packages/cli/src/services/tag.service.ts +++ b/packages/cli/src/services/tag.service.ts @@ -4,7 +4,7 @@ import type { TagEntity } from '@/databases/entities/tag-entity'; import { TagRepository } from '@/databases/repositories/tag.repository'; import { ExternalHooks } from '@/external-hooks'; import { validateEntity } from '@/generic-helpers'; -import type { ITagWithCountDb } from '@/interfaces'; +import type { ITagWithCountDb } from '@/types-db'; type GetAllResult = T extends { withUsageCount: true } ? ITagWithCountDb[] : TagEntity[]; diff --git a/packages/cli/src/services/user.service.ts b/packages/cli/src/services/user.service.ts index aed8e3b6cb..d3bbe3745d 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -9,10 +9,11 @@ import { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; -import type { Invitation, PublicUser } from '@/interfaces'; +import type { Invitation } from '@/interfaces'; import type { PostHogClient } from '@/posthog'; import type { UserRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; +import type { PublicUser } from '@/types-db'; import { UserManagementMailer } from '@/user-management/email'; import { PublicApiKeyService } from './public-api-key.service'; diff --git a/packages/cli/src/types-db.ts b/packages/cli/src/types-db.ts new file mode 100644 index 0000000000..19e9753855 --- /dev/null +++ b/packages/cli/src/types-db.ts @@ -0,0 +1,142 @@ +import type { GlobalRole, Scope } from '@n8n/permissions'; +import type { + ICredentialsEncrypted, + IRunExecutionData, + IWorkflowBase, + WorkflowExecuteMode, + ExecutionStatus, + FeatureFlags, + IUserSettings, +} from 'n8n-workflow'; + +import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity.ee'; +import type { AuthProviderType } from '@/databases/entities/auth-identity'; +import type { Folder } from '@/databases/entities/folder'; +import type { Project } from '@/databases/entities/project'; +import type { SharedCredentials } from '@/databases/entities/shared-credentials'; +import type { SharedWorkflow } from '@/databases/entities/shared-workflow'; +import type { TagEntity } from '@/databases/entities/tag-entity'; +import type { User } from '@/databases/entities/user'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; + +export type UsageCount = { + usageCount: number; +}; + +export interface ITagBase { + id: string; + name: string; +} + +export interface ICredentialsBase { + createdAt: Date; + updatedAt: Date; +} + +export interface IExecutionBase { + id: string; + mode: WorkflowExecuteMode; + createdAt: Date; // set by DB + startedAt: Date; + stoppedAt?: Date; // empty value means execution is still running + workflowId: string; + + /** + * @deprecated Use `status` instead + */ + finished: boolean; + retryOf?: string; // If it is a retry, the id of the execution it is a retry of. + retrySuccessId?: string; // If it failed and a retry did succeed. The id of the successful retry. + status: ExecutionStatus; + waitTill?: Date | null; +} + +// Required by PublicUser +export interface IPersonalizationSurveyAnswers { + email: string | null; + codingSkill: string | null; + companyIndustry: string[]; + companySize: string | null; + otherCompanyIndustry: string | null; + otherWorkArea: string | null; + workArea: string[] | string | null; +} + +export type ITagDb = Pick; + +export type ITagWithCountDb = ITagDb & UsageCount; + +export type IAnnotationTagDb = Pick; + +export type IAnnotationTagWithCountDb = IAnnotationTagDb & UsageCount; + +// Almost identical to editor-ui.Interfaces.ts +export interface IWorkflowDb extends IWorkflowBase { + triggerCount: number; + tags?: TagEntity[]; + parentFolder?: Folder | null; +} + +export interface ICredentialsDb extends ICredentialsBase, ICredentialsEncrypted { + id: string; + name: string; + shared?: SharedCredentials[]; +} + +export interface IExecutionResponse extends IExecutionBase { + id: string; + data: IRunExecutionData; + retryOf?: string; + retrySuccessId?: string; + workflowData: IWorkflowBase | WorkflowWithSharingsAndCredentials; + customData: Record; + annotation: { + tags: ITagBase[]; + }; +} + +export interface PublicUser { + id: string; + email?: string; + firstName?: string; + lastName?: string; + personalizationAnswers?: IPersonalizationSurveyAnswers | null; + password?: string; + passwordResetToken?: string; + createdAt: Date; + isPending: boolean; + role?: GlobalRole; + globalScopes?: Scope[]; + signInType: AuthProviderType; + disabled: boolean; + settings?: IUserSettings | null; // External type from n8n-workflow + inviteAcceptUrl?: string; + isOwner?: boolean; + featureFlags?: FeatureFlags; // External type from n8n-workflow +} + +export type UserSettings = Pick; + +export type SlimProject = Pick; + +export interface CredentialUsedByWorkflow { + id: string; + name: string; + type?: string; + currentUserHasAccess: boolean; + homeProject: SlimProject | null; + sharedWithProjects: SlimProject[]; +} + +export interface WorkflowWithSharingsAndCredentials extends Omit { + homeProject?: SlimProject; + sharedWithProjects?: SlimProject[]; + usedCredentials?: CredentialUsedByWorkflow[]; + shared?: SharedWorkflow[]; +} + +export interface WorkflowWithSharingsMetaDataAndCredentials extends Omit { + homeProject?: SlimProject | null; + sharedWithProjects: SlimProject[]; + usedCredentials?: CredentialUsedByWorkflow[]; +} diff --git a/packages/cli/src/webhooks/__tests__/waiting-forms.test.ts b/packages/cli/src/webhooks/__tests__/waiting-forms.test.ts index 5d3696b7a4..4649317f70 100644 --- a/packages/cli/src/webhooks/__tests__/waiting-forms.test.ts +++ b/packages/cli/src/webhooks/__tests__/waiting-forms.test.ts @@ -3,9 +3,9 @@ import { mock } from 'jest-mock-extended'; import { FORM_NODE_TYPE, WAITING_FORMS_EXECUTION_STATUS, type Workflow } from 'n8n-workflow'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import type { IExecutionResponse } from '@/types-db'; import { WaitingForms } from '@/webhooks/waiting-forms'; -import type { IExecutionResponse } from '../../interfaces'; import type { WaitingWebhookRequest } from '../webhook.types'; describe('WaitingForms', () => { diff --git a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts index a752b46795..fd837146b4 100644 --- a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts +++ b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts @@ -4,7 +4,7 @@ import { mock } from 'jest-mock-extended'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { IExecutionResponse } from '@/interfaces'; +import type { IExecutionResponse } from '@/types-db'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; import type { IWebhookResponseCallbackData, WaitingWebhookRequest } from '@/webhooks/webhook.types'; diff --git a/packages/cli/src/webhooks/waiting-forms.ts b/packages/cli/src/webhooks/waiting-forms.ts index 69dbe3dfbe..8624e4c3bb 100644 --- a/packages/cli/src/webhooks/waiting-forms.ts +++ b/packages/cli/src/webhooks/waiting-forms.ts @@ -10,7 +10,7 @@ import { import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { IExecutionResponse } from '@/interfaces'; +import type { IExecutionResponse } from '@/types-db'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; import type { IWebhookResponseCallbackData, WaitingWebhookRequest } from './webhook.types'; diff --git a/packages/cli/src/webhooks/waiting-webhooks.ts b/packages/cli/src/webhooks/waiting-webhooks.ts index 0eefbde4ce..45104aa835 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -13,8 +13,8 @@ import { import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ConflictError } from '@/errors/response-errors/conflict.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { IExecutionResponse } from '@/interfaces'; import { NodeTypes } from '@/node-types'; +import type { IExecutionResponse } from '@/types-db'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; diff --git a/packages/cli/src/workflows/workflow.service.ee.ts b/packages/cli/src/workflows/workflow.service.ee.ts index 20f476bdb6..b03ddb967a 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -23,12 +23,12 @@ import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflo import { FolderService } from '@/services/folder.service'; import { OwnershipService } from '@/services/ownership.service'; import { ProjectService } from '@/services/project.service.ee'; - -import { WorkflowFinderService } from './workflow-finder.service'; import type { WorkflowWithSharingsAndCredentials, WorkflowWithSharingsMetaDataAndCredentials, -} from './workflows.types'; +} from '@/types-db'; + +import { WorkflowFinderService } from './workflow-finder.service'; @Service() export class EnterpriseWorkflowService { diff --git a/packages/cli/src/workflows/workflows.types.ts b/packages/cli/src/workflows/workflows.types.ts deleted file mode 100644 index 3f0df88a69..0000000000 --- a/packages/cli/src/workflows/workflows.types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { SharedWorkflow } from '@/databases/entities/shared-workflow'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { SlimProject } from '@/requests'; - -export interface WorkflowWithSharingsAndCredentials extends Omit { - homeProject?: SlimProject; - sharedWithProjects?: SlimProject[]; - usedCredentials?: CredentialUsedByWorkflow[]; - shared?: SharedWorkflow[]; -} - -export interface WorkflowWithSharingsMetaDataAndCredentials extends Omit { - homeProject?: SlimProject | null; - sharedWithProjects: SlimProject[]; - usedCredentials?: CredentialUsedByWorkflow[]; -} - -export interface CredentialUsedByWorkflow { - id: string; - name: string; - type?: string; - currentUserHasAccess: boolean; - homeProject: SlimProject | null; - sharedWithProjects: SlimProject[]; -} diff --git a/packages/cli/test/integration/shared/db/credentials.ts b/packages/cli/test/integration/shared/db/credentials.ts index 1db7fb1e48..b152bc813a 100644 --- a/packages/cli/test/integration/shared/db/credentials.ts +++ b/packages/cli/test/integration/shared/db/credentials.ts @@ -7,7 +7,7 @@ import type { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import type { ICredentialsDb } from '@/interfaces'; +import type { ICredentialsDb } from '@/types-db'; import type { CredentialPayload } from '../types'; diff --git a/packages/cli/test/integration/shared/db/workflows.ts b/packages/cli/test/integration/shared/db/workflows.ts index b73e0a45c7..7c8fe0b44d 100644 --- a/packages/cli/test/integration/shared/db/workflows.ts +++ b/packages/cli/test/integration/shared/db/workflows.ts @@ -10,7 +10,7 @@ import { User } from '@/databases/entities/user'; import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { IWorkflowDb } from '@/interfaces'; +import type { IWorkflowDb } from '@/types-db'; export async function createManyWorkflows( amount: number, diff --git a/packages/cli/test/integration/shared/types.ts b/packages/cli/test/integration/shared/types.ts index 27e79e004b..0c6170b2c1 100644 --- a/packages/cli/test/integration/shared/types.ts +++ b/packages/cli/test/integration/shared/types.ts @@ -7,7 +7,7 @@ import type TestAgent from 'supertest/lib/agent'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; -import type { ICredentialsDb } from '@/interfaces'; +import type { ICredentialsDb } from '@/types-db'; import type { LicenseMocker } from './license'; diff --git a/packages/cli/test/integration/shared/utils/users.ts b/packages/cli/test/integration/shared/utils/users.ts index 498e62bbb0..926a29233e 100644 --- a/packages/cli/test/integration/shared/utils/users.ts +++ b/packages/cli/test/integration/shared/utils/users.ts @@ -1,5 +1,5 @@ import type { User } from '@/databases/entities/user'; -import type { PublicUser } from '@/interfaces'; +import type { PublicUser } from '@/types-db'; export const validateUser = (user: PublicUser) => { expect(typeof user.id).toBe('string'); diff --git a/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts b/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts index 28a5168d35..b9fd56fd05 100644 --- a/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts +++ b/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts @@ -11,8 +11,8 @@ import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/types-db'; import { UserManagementMailer } from '@/user-management/email'; -import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types'; import { mockInstance } from '@test/mocking'; import { createFolder } from '@test-integration/db/folders';