From 6d558c0607d39a9057049fb5b25094c07740dc6d Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:28:15 +0300 Subject: [PATCH 1/2] refactor(core): Enable import/order eslint rule --- packages/cli/.eslintrc.js | 12 +++- .../src/__tests__/active-executions.test.ts | 11 ++-- .../src/__tests__/credential-types.test.ts | 3 +- .../src/__tests__/credentials-helper.test.ts | 7 ++- packages/cli/src/__tests__/license.test.ts | 7 ++- .../cli/src/__tests__/wait-tracker.test.ts | 5 +- .../workflow-execute-additional-data.test.ts | 9 +-- .../src/__tests__/workflow-helpers.test.ts | 1 + .../cli/src/__tests__/workflow-runner.test.ts | 16 ++--- packages/cli/src/abstract-server.ts | 21 +++---- packages/cli/src/activation-errors.service.ts | 1 + packages/cli/src/active-executions.ts | 9 +-- packages/cli/src/active-workflow-manager.ts | 29 +++++---- .../src/auth/__tests__/auth.service.test.ts | 6 +- packages/cli/src/auth/auth.service.ts | 6 +- packages/cli/src/auth/jwt.ts | 3 +- packages/cli/src/auth/methods/email.ts | 7 ++- packages/cli/src/auth/methods/ldap.ts | 6 +- .../__tests__/collaboration.state.test.ts | 6 +- .../collaboration/collaboration.service.ts | 10 ++-- .../src/collaboration/collaboration.state.ts | 4 +- packages/cli/src/commands/audit.ts | 7 ++- packages/cli/src/commands/base-command.ts | 31 +++++----- .../src/commands/db/__tests__/revert.test.ts | 9 +-- packages/cli/src/commands/db/revert.ts | 5 +- packages/cli/src/commands/execute-batch.ts | 12 ++-- packages/cli/src/commands/execute.ts | 10 ++-- .../cli/src/commands/export/credentials.ts | 10 ++-- packages/cli/src/commands/export/workflow.ts | 8 ++- .../cli/src/commands/import/credentials.ts | 23 ++++---- packages/cli/src/commands/import/workflow.ts | 13 ++-- packages/cli/src/commands/ldap/reset.ts | 26 ++++---- packages/cli/src/commands/license/clear.ts | 4 +- packages/cli/src/commands/license/info.ts | 2 + packages/cli/src/commands/list/workflow.ts | 4 +- packages/cli/src/commands/mfa/disable.ts | 4 +- packages/cli/src/commands/start.ts | 33 ++++++----- packages/cli/src/commands/update/workflow.ts | 4 +- .../cli/src/commands/user-management/reset.ts | 4 +- packages/cli/src/commands/webhook.ts | 10 ++-- packages/cli/src/commands/worker.ts | 23 ++++---- .../concurrency-control.service.test.ts | 14 +++-- .../__tests__/concurrency-queue.test.ts | 1 + .../concurrency-control.service.ts | 16 ++--- .../cli/src/concurrency/concurrency-queue.ts | 1 + packages/cli/src/config/index.ts | 8 +-- packages/cli/src/config/schema.ts | 7 ++- packages/cli/src/config/types.ts | 3 +- packages/cli/src/config/utils.ts | 3 +- packages/cli/src/constants.ts | 2 +- .../__tests__/curl.controller.test.ts | 3 +- ...dynamic-node-parameters.controller.test.ts | 5 +- .../__tests__/me.controller.test.ts | 28 ++++----- .../__tests__/owner.controller.test.ts | 5 +- .../__tests__/translation.controller.test.ts | 3 +- .../user-settings.controller.test.ts | 5 +- .../__tests__/users.controller.test.ts | 8 ++- .../controllers/ai-assistant.controller.ts | 6 +- .../controllers/annotation-tags.controller.ts | 2 +- .../cli/src/controllers/auth.controller.ts | 28 ++++----- .../src/controllers/binary-data.controller.ts | 1 + .../community-packages.controller.ts | 10 ++-- .../cli/src/controllers/cta.controller.ts | 1 + .../cli/src/controllers/curl.controller.ts | 1 + .../cli/src/controllers/debug.controller.ts | 4 +- .../dynamic-node-parameters.controller.ts | 6 +- .../cli/src/controllers/e2e.controller.ts | 17 +++--- .../src/controllers/invitation.controller.ts | 18 +++--- packages/cli/src/controllers/me.controller.ts | 29 ++++----- .../cli/src/controllers/mfa.controller.ts | 4 +- .../src/controllers/node-types.controller.ts | 5 +- .../oauth1-credential.controller.test.ts | 19 +++--- .../oauth2-credential.controller.test.ts | 17 +++--- .../oauth/abstract-oauth.controller.ts | 18 +++--- .../oauth/oauth1-credential.controller.ts | 8 ++- .../oauth/oauth2-credential.controller.ts | 8 ++- .../controllers/orchestration.controller.ts | 2 +- .../cli/src/controllers/owner.controller.ts | 16 ++--- .../controllers/password-reset.controller.ts | 24 ++++---- .../cli/src/controllers/project.controller.ts | 17 +++--- .../cli/src/controllers/survey-answers.dto.ts | 3 +- .../cli/src/controllers/tags.controller.ts | 5 +- .../src/controllers/translation.controller.ts | 7 ++- .../controllers/user-settings.controller.ts | 3 +- .../cli/src/controllers/users.controller.ts | 34 +++++------ .../workflow-statistics.controller.ts | 6 +- packages/cli/src/crash-journal.ts | 5 +- packages/cli/src/credential-types.ts | 3 +- packages/cli/src/credentials-helper.ts | 16 +++-- packages/cli/src/credentials-overwrites.ts | 5 +- .../__tests__/credentials.service.test.ts | 5 +- .../src/credentials/credentials.controller.ts | 33 ++++++----- .../src/credentials/credentials.service.ee.ts | 16 ++--- .../src/credentials/credentials.service.ts | 49 +++++++-------- packages/cli/src/databases/config.ts | 14 ++--- packages/cli/src/databases/dsl/index.ts | 3 +- packages/cli/src/databases/dsl/table.ts | 3 +- .../src/databases/entities/abstract-entity.ts | 3 +- .../entities/annotation-tag-entity.ts | 6 +- .../entities/annotation-tag-mapping.ts | 3 +- .../src/databases/entities/auth-identity.ts | 1 + .../entities/auth-provider-sync-history.ts | 1 + .../cli/src/databases/entities/auth-user.ts | 1 + .../databases/entities/credentials-entity.ts | 6 +- .../databases/entities/event-destinations.ts | 3 +- .../entities/execution-annotation.ts | 5 +- .../src/databases/entities/execution-data.ts | 7 ++- .../databases/entities/execution-entity.ts | 8 ++- .../databases/entities/execution-metadata.ts | 1 + packages/cli/src/databases/entities/index.ts | 20 +++---- .../src/databases/entities/installed-nodes.ts | 1 + .../databases/entities/installed-packages.ts | 3 +- .../databases/entities/invalid-auth-token.ts | 1 + .../databases/entities/project-relation.ts | 3 +- .../cli/src/databases/entities/project.ts | 1 + .../cli/src/databases/entities/settings.ts | 2 +- .../databases/entities/shared-credentials.ts | 3 +- .../src/databases/entities/shared-workflow.ts | 3 +- .../cli/src/databases/entities/tag-entity.ts | 3 +- packages/cli/src/databases/entities/user.ts | 18 +++--- .../cli/src/databases/entities/variables.ts | 1 + .../src/databases/entities/webhook-entity.ts | 2 +- .../src/databases/entities/workflow-entity.ts | 9 ++- .../databases/entities/workflow-history.ts | 3 +- .../databases/entities/workflow-statistics.ts | 1 + .../entities/workflow-tag-mapping.ts | 1 + ...1630330987096-UpdateWorkflowCredentials.ts | 1 + .../common/1658930531669-AddNodeIds.ts | 3 +- .../common/1659888469333-AddJsonKeyPinData.ts | 3 +- ...669739707124-AddWorkflowVersionIdColumn.ts | 3 +- ...1726148419-RemoveWorkflowDataLoadedFlag.ts | 2 +- .../1700571993961-AddGlobalAdminRole.ts | 3 +- .../1711390882123-MoveSshKeysToDatabase.ts | 7 ++- .../common/1714133768519-CreateProject.ts | 7 ++- ...653148-AddConstraintToExecutionMetadata.ts | 3 +- .../1646992772331-CreateUserManagement.ts | 3 +- .../src/databases/migrations/mysqldb/index.ts | 29 ++++----- .../1646992772331-CreateUserManagement.ts | 3 +- .../databases/migrations/postgresdb/index.ts | 33 ++++++----- .../1646992772331-CreateUserManagement.ts | 3 +- ...690000000002-MigrateIntegerKeysToString.ts | 5 +- .../src/databases/migrations/sqlite/index.ts | 39 ++++++------ .../__tests__/execution.repository.test.ts | 4 +- .../shared-credentials.repository.test.ts | 6 +- .../__tests__/workflow-statistics.test.ts | 3 +- .../annotation-tag-mapping.repository.ts | 3 +- .../repositories/annotation-tag.repository.ts | 3 +- .../repositories/auth-identity.repository.ts | 3 +- .../auth-provider-sync-history.repository.ts | 3 +- .../repositories/auth-user.repository.ts | 3 +- .../repositories/credentials.repository.ts | 10 ++-- .../event-destinations.repository.ts | 3 +- .../execution-annotation.repository.ts | 3 +- .../repositories/execution-data.repository.ts | 3 +- .../execution-metadata.repository.ts | 3 +- .../repositories/execution.repository.ts | 38 ++++++------ .../installed-nodes.repository.ts | 3 +- .../installed-packages.repository.ts | 7 ++- .../invalid-auth-token.repository.ts | 3 +- .../license-metrics.repository.ts | 2 +- .../project-relation.repository.ts | 3 +- .../repositories/project.repository.ts | 3 +- .../repositories/settings.repository.ts | 8 ++- .../shared-credentials.repository.ts | 10 ++-- .../shared-workflow.repository.ts | 10 ++-- .../databases/repositories/tag.repository.ts | 5 +- .../databases/repositories/user.repository.ts | 5 +- .../repositories/variables.repository.ts | 3 +- .../repositories/webhook.repository.ts | 3 +- .../workflow-history.repository.ts | 3 +- .../workflow-statistics.repository.ts | 6 +- .../workflow-tag-mapping.repository.ts | 3 +- .../repositories/workflow.repository.ts | 8 ++- .../databases/subscribers/user-subscriber.ts | 3 +- packages/cli/src/databases/types.ts | 4 +- .../cli/src/databases/utils/generators.ts | 3 +- .../src/databases/utils/migration-helpers.ts | 10 ++-- .../cli/src/databases/utils/transformers.ts | 2 +- packages/cli/src/db.ts | 6 +- .../__tests__/controller.registry.test.ts | 6 +- .../decorators/__tests__/on-shutdown.test.ts | 3 +- .../cli/src/decorators/controller.registry.ts | 9 +-- packages/cli/src/decorators/licensed.ts | 1 + packages/cli/src/decorators/on-shutdown.ts | 5 +- .../cli/src/decorators/rest-controller.ts | 1 + packages/cli/src/decorators/route.ts | 3 +- packages/cli/src/decorators/scoped.ts | 1 + packages/cli/src/decorators/types.ts | 3 +- .../source-control-export.service.test.ts | 13 ++-- .../source-control-git.service.test.ts | 4 +- .../source-control-helper.ee.test.ts | 19 +++--- .../source-control-enabled-middleware.ee.ts | 1 + .../source-control-export.service.ee.ts | 34 ++++++----- .../source-control-git.service.ee.ts | 14 +++-- .../source-control-helper.ee.ts | 14 +++-- .../source-control-import.service.ee.ts | 58 +++++++++--------- .../source-control-preferences.service.ee.ts | 18 +++--- .../source-control.controller.ee.ts | 18 +++--- .../source-control.service.ee.ts | 52 ++++++++-------- .../types/exportable-credential.ts | 1 + .../types/exportable-workflow.ts | 1 + .../source-control/types/requests.ts | 15 ++--- .../types/source-control-generate-key-pair.ts | 1 + .../types/source-control-preferences.ts | 1 + .../types/source-control-push-work-folder.ts | 1 + .../variables/environment-helpers.ts | 1 + .../variables/variables.controller.ee.ts | 7 ++- .../variables/variables.service.ee.ts | 8 ++- packages/cli/src/error-reporting.ts | 7 ++- .../src/errors/feature-not-licensed.error.ts | 3 +- .../errors/subworkflow-policy-denial.error.ts | 3 +- .../src/errors/workflow-missing-id.error.ts | 3 +- .../cli/src/eventbus/event-bus.controller.ts | 4 +- .../abstract-event-message-options.ts | 1 + .../abstract-event-message.ts | 5 +- .../event-message-ai-node.ts | 5 +- .../event-message-audit.ts | 7 ++- .../event-message-execution.ts | 5 +- .../event-message-generic.ts | 3 +- .../event-message-node.ts | 5 +- .../event-message-workflow.ts | 8 ++- .../message-event-bus-destination-from-db.ts | 10 ++-- ...message-event-bus-destination-sentry.ee.ts | 6 +- ...message-event-bus-destination-syslog.ee.ts | 9 +-- ...essage-event-bus-destination-webhook.ee.ts | 10 ++-- .../message-event-bus-destination.ee.ts | 12 ++-- .../message-event-bus-log-writer-worker.ts | 1 + .../message-event-bus-log-writer.ts | 38 ++++++------ .../message-event-bus/message-event-bus.ts | 38 ++++++------ .../log-streaming-event-relay.test.ts | 7 ++- .../__tests__/telemetry-event-relay.test.ts | 23 ++++---- packages/cli/src/events/event-relay.ts | 4 +- packages/cli/src/events/event.service.ts | 6 +- .../src/events/log-streaming-event-relay.ts | 6 +- packages/cli/src/events/relay-event-map.ts | 6 +- .../cli/src/events/telemetry-event-relay.ts | 30 +++++----- .../__tests__/restore-binary-data-id.test.ts | 6 +- .../__tests__/save-execution-progress.test.ts | 11 ++-- .../restore-binary-data-id.ts | 5 +- .../save-execution-progress.ts | 5 +- .../shared/shared-hook-functions.ts | 11 ++-- .../to-save-settings.ts | 3 +- .../cli/src/executions/__tests__/constants.ts | 3 +- .../execution-recovery.service.test.ts | 25 ++++---- .../__tests__/execution.service.test.ts | 13 ++-- .../__tests__/executions.controller.test.ts | 7 ++- .../parse-range-query.middleware.test.ts | 5 +- .../executions/execution-recovery.service.ts | 22 +++---- .../src/executions/execution.service.ee.ts | 10 ++-- .../cli/src/executions/execution.service.ts | 38 ++++++------ .../cli/src/executions/execution.types.ts | 5 +- .../src/executions/executions.controller.ts | 20 ++++--- .../parse-range-query.middleware.ts | 10 ++-- packages/cli/src/executions/validation.ts | 1 + packages/cli/src/expression-evaluator.ts | 3 +- packages/cli/src/external-hooks.ts | 7 ++- .../external-secrets-manager.ee.test.ts | 11 ++-- .../external-secrets-helper.ee.ts | 3 +- .../external-secrets-manager.ee.ts | 15 +++-- .../external-secrets-providers.ee.ts | 8 ++- .../external-secrets.controller.ee.ts | 8 ++- .../external-secrets.service.ee.ts | 10 ++-- .../__tests__/azure-key-vault.test.ts | 3 +- .../__tests__/gcp-secrets-manager.test.ts | 5 +- .../aws-secrets/aws-secrets-client.ts | 5 +- .../aws-secrets/aws-secrets-manager.ts | 6 +- .../azure-key-vault/azure-key-vault.ts | 6 +- .../gcp-secrets-manager.ts | 4 +- .../external-secrets/providers/infisical.ts | 6 +- .../src/external-secrets/providers/vault.ts | 10 ++-- packages/cli/src/generic-helpers.ts | 8 ++- packages/cli/src/interfaces.ts | 14 ++--- .../cli/src/ldap/__tests__/helpers.test.ts | 6 +- packages/cli/src/ldap/helpers.ee.ts | 16 ++--- packages/cli/src/ldap/ldap.controller.ee.ts | 5 +- packages/cli/src/ldap/ldap.service.ee.ts | 27 ++++----- packages/cli/src/license.ts | 12 ++-- .../license/__tests__/license.service.test.ts | 9 +-- .../cli/src/license/license.controller.ts | 6 +- packages/cli/src/license/license.service.ts | 8 +-- .../cli/src/load-nodes-and-credentials.ts | 7 +-- packages/cli/src/logger.ts | 9 ++- .../__tests__/license-metrics.service.test.ts | 5 +- .../prometheus-metrics.service.test.ts | 14 +++-- .../src/metrics/license-metrics.service.ts | 3 +- .../src/metrics/prometheus-metrics.service.ts | 15 ++--- packages/cli/src/mfa/helpers.ts | 4 +- packages/cli/src/mfa/mfa.service.ts | 8 ++- packages/cli/src/middlewares/body-parser.ts | 15 ++--- .../list-query/__tests__/list-query.test.ts | 7 ++- .../list-query/dtos/base.filter.dto.ts | 3 +- .../list-query/dtos/base.select.dto.ts | 3 +- .../list-query/dtos/credentials.filter.dto.ts | 3 +- .../list-query/dtos/pagination.dto.ts | 3 +- .../list-query/dtos/user.filter.dto.ts | 3 +- .../list-query/dtos/workflow.filter.dto.ts | 2 +- .../cli/src/middlewares/list-query/filter.ts | 11 ++-- .../cli/src/middlewares/list-query/index.ts | 8 ++- .../src/middlewares/list-query/pagination.ts | 10 ++-- .../cli/src/middlewares/list-query/select.ts | 11 ++-- packages/cli/src/node-types.ts | 9 +-- packages/cli/src/permissions/check-access.ts | 12 ++-- .../cli/src/posthog/__tests__/posthog.test.ts | 5 +- packages/cli/src/posthog/index.ts | 7 ++- packages/cli/src/public-api/index.ts | 17 +++--- packages/cli/src/public-api/types.ts | 4 +- .../v1/handlers/audit/audit.handler.ts | 5 +- .../credentials/credentials.handler.ts | 14 ++--- .../credentials/credentials.middleware.ts | 7 ++- .../credentials/credentials.service.ts | 16 ++--- .../handlers/executions/executions.handler.ts | 13 ++-- .../v1/handlers/projects/projects.handler.ts | 8 ++- .../source-control/source-control.handler.ts | 14 +++-- .../v1/handlers/tags/tags.handler.ts | 14 ++--- .../v1/handlers/users/users.handler.ee.ts | 16 ++--- .../v1/handlers/users/users.service.ee.ts | 11 ++-- .../handlers/variables/variables.handler.ts | 8 ++- .../handlers/workflows/workflows.handler.ts | 30 +++++----- .../handlers/workflows/workflows.service.ts | 13 ++-- .../shared/middlewares/global.middleware.ts | 8 +-- .../v1/shared/services/pagination.service.ts | 1 + packages/cli/src/push/__tests__/index.test.ts | 7 +-- .../src/push/__tests__/websocket.push.test.ts | 9 ++- packages/cli/src/push/abstract.push.ts | 5 +- packages/cli/src/push/index.ts | 14 ++--- packages/cli/src/push/sse.push.ts | 4 +- packages/cli/src/push/types.ts | 2 +- packages/cli/src/push/websocket.push.ts | 8 ++- packages/cli/src/requests.ts | 19 +++--- packages/cli/src/response-helper.ts | 5 +- .../scaling/__tests__/scaling.service.test.ts | 20 ++++--- packages/cli/src/scaling/job-processor.ts | 14 +++-- packages/cli/src/scaling/scaling.service.ts | 20 ++++--- packages/cli/src/scaling/scaling.types.ts | 2 +- packages/cli/src/secrets-helpers.ts | 1 + .../credentials-risk-reporter.ts | 9 +-- .../risk-reporters/database-risk-reporter.ts | 7 ++- .../filesystem-risk-reporter.ts | 7 ++- .../risk-reporters/instance-risk-reporter.ts | 17 +++--- .../risk-reporters/nodes-risk-reporter.ts | 9 +-- .../security-audit/security-audit.service.ts | 3 +- packages/cli/src/server.ts | 29 +++++---- .../active-workflows.service.test.ts | 7 ++- .../community-packages.service.test.ts | 15 +++-- .../credentials-tester.service.test.ts | 5 +- .../execution-metadata.service.test.ts | 1 + .../services/__tests__/hooks.service.test.ts | 10 ++-- .../services/__tests__/jwt.service.test.ts | 3 +- .../services/__tests__/naming.service.test.ts | 8 +-- .../__tests__/orchestration.service.test.ts | 21 +++---- .../__tests__/ownership.service.test.ts | 17 +++--- .../__tests__/password.utility.test.ts | 3 +- .../services/__tests__/redis.service.test.ts | 3 +- .../services/__tests__/user.service.test.ts | 6 +- .../workflow-statistics.service.test.ts | 12 ++-- packages/cli/src/services/access.service.ts | 5 +- .../src/services/active-workflows.service.ts | 2 +- .../cli/src/services/ai-assistant.service.ts | 10 ++-- .../src/services/annotation-tag.service.ts | 5 +- .../__tests__/cache-mock.service.test.ts | 3 +- .../cache/__tests__/cache.service.test.ts | 7 ++- .../cli/src/services/cache/cache.service.ts | 8 +-- .../cli/src/services/cache/cache.types.ts | 1 + .../src/services/cache/redis.cache-manager.ts | 2 +- .../services/community-packages.service.ts | 21 ++++--- .../services/credentials-tester.service.ts | 14 ++--- packages/cli/src/services/cta.service.ts | 3 +- packages/cli/src/services/curl.service.ts | 5 +- .../dynamic-node-parameters.service.ts | 5 +- .../services/execution-metadata.service.ts | 3 +- packages/cli/src/services/frontend.service.ts | 33 ++++++----- packages/cli/src/services/hooks.service.ts | 24 ++++---- packages/cli/src/services/import.service.ts | 16 ++--- packages/cli/src/services/jwt.service.ts | 3 +- packages/cli/src/services/naming.service.ts | 3 +- .../orchestration.handler.base.service.ts | 7 ++- .../cli/src/services/orchestration.service.ts | 13 ++-- .../cli/src/services/orchestration/helpers.ts | 8 ++- .../main/handle-command-message-main.ts | 12 ++-- .../handle-worker-response-message-main.ts | 6 +- .../orchestration/main/multi-main-setup.ee.ts | 9 +-- .../orchestration.handler.main.service.ts | 7 ++- .../webhook/handle-command-message-webhook.ts | 10 ++-- .../orchestration.handler.webhook.service.ts | 5 +- .../webhook/orchestration.webhook.service.ts | 4 +- .../worker/handle-command-message-worker.ts | 16 ++--- .../orchestration.handler.worker.service.ts | 3 +- .../worker/orchestration.worker.service.ts | 4 +- .../services/orchestration/worker/types.ts | 4 +- .../cli/src/services/ownership.service.ts | 11 ++-- packages/cli/src/services/password.utility.ts | 5 +- packages/cli/src/services/project.service.ts | 30 +++++----- packages/cli/src/services/pruning.service.ts | 10 ++-- packages/cli/src/services/redis.service.ts | 3 +- .../services/redis/redis-client.service.ts | 7 ++- .../redis/redis-service-base-classes.ts | 2 + .../redis/redis-service-pub-sub-publisher.ts | 3 +- .../redis/redis-service-pub-sub-subscriber.ts | 1 + packages/cli/src/services/role.service.ts | 11 ++-- packages/cli/src/services/tag.service.ts | 7 ++- packages/cli/src/services/url.service.ts | 3 +- .../src/services/user-onboarding.service.ts | 2 +- packages/cli/src/services/user.service.ts | 12 ++-- .../services/workflow-statistics.service.ts | 10 ++-- .../__tests__/shutdown.service.test.ts | 5 +- packages/cli/src/shutdown/shutdown.service.ts | 7 ++- .../sso/saml/__tests__/saml-helpers.test.ts | 6 +- .../saml/__tests__/saml.service.ee.test.ts | 11 ++-- .../middleware/saml-enabled-middleware.ts | 1 + .../src/sso/saml/routes/saml.controller.ee.ts | 28 ++++----- packages/cli/src/sso/saml/saml-helpers.ts | 16 ++--- packages/cli/src/sso/saml/saml-validator.ts | 1 + packages/cli/src/sso/saml/saml.service.ee.ts | 36 +++++------ .../cli/src/sso/saml/service-provider.ee.ts | 4 +- packages/cli/src/sso/saml/types/requests.ts | 1 + .../src/sso/saml/types/saml-preferences.ts | 1 + packages/cli/src/sso/sso-helpers.ts | 5 +- .../subworkflow-policy-checker.test.ts | 21 +++---- .../subworkflow-policy-checker.service.ts | 13 ++-- .../src/telemetry/__tests__/telemetry.test.ts | 7 ++- packages/cli/src/telemetry/index.ts | 23 ++++---- packages/cli/src/typed-emitter.ts | 2 +- .../__tests__/user-management-mailer.test.ts | 2 +- .../src/user-management/email/node-mailer.ts | 9 +-- .../email/user-management-mailer.ts | 8 +-- .../src/user-management/permission-checker.ts | 4 +- packages/cli/src/utils.ts | 1 + .../__tests__/no-url.validator.test.ts | 3 +- .../__tests__/no-xss.validator.test.ts | 3 +- .../cli/src/validators/no-xss.validator.ts | 2 +- packages/cli/src/wait-tracker.ts | 5 +- ...test-webhook-registrations.service.test.ts | 3 +- .../webhooks/__tests__/test-webhooks.test.ts | 15 +++-- .../__tests__/waiting-webhooks.test.ts | 7 ++- .../__tests__/webhook-request-handler.test.ts | 4 +- .../__tests__/webhook.service.test.ts | 3 +- packages/cli/src/webhooks/live-webhooks.ts | 19 +++--- .../test-webhook-registrations.service.ts | 7 ++- packages/cli/src/webhooks/test-webhooks.ts | 30 +++++----- packages/cli/src/webhooks/waiting-webhooks.ts | 17 +++--- packages/cli/src/webhooks/webhook-helpers.ts | 29 +++++---- .../src/webhooks/webhook-request-handler.ts | 3 +- packages/cli/src/webhooks/webhook-server.ts | 1 + packages/cli/src/webhooks/webhook.service.ts | 7 ++- .../src/workflow-execute-additional-data.ts | 34 +++++------ packages/cli/src/workflow-helpers.ts | 4 +- packages/cli/src/workflow-runner.ts | 15 +++-- .../workflow-execution.service.test.ts | 4 +- .../workflows/workflow-execution.service.ts | 18 +++--- .../workflow-history-helper.ee.test.ts | 2 +- .../workflow-history.service.ee.test.ts | 5 +- .../workflow-history-helper.ee.ts | 5 +- .../workflow-history-manager.ee.ts | 4 +- .../workflow-history.controller.ee.ts | 11 ++-- .../workflow-history.service.ee.ts | 8 ++- .../src/workflows/workflow-sharing.service.ts | 10 ++-- .../workflows/workflow-static-data.service.ts | 5 +- .../cli/src/workflows/workflow.request.ts | 3 +- .../cli/src/workflows/workflow.service.ee.ts | 23 ++++---- .../cli/src/workflows/workflow.service.ts | 45 +++++++------- .../cli/src/workflows/workflows.controller.ts | 59 ++++++++++--------- .../activation-errors.service.test.ts | 3 +- .../active-workflow-manager.test.ts | 18 +++--- .../cli/test/integration/auth.api.test.ts | 4 +- packages/cli/test/integration/auth.mw.test.ts | 4 +- .../test/integration/binary-data.api.test.ts | 6 +- .../collaboration.service.test.ts | 17 +++--- .../commands/credentials.cmd.test.ts | 6 +- .../integration/commands/import.cmd.test.ts | 8 +-- .../integration/commands/ldap/reset.test.ts | 16 ++--- .../integration/commands/license.cmd.test.ts | 6 +- .../integration/commands/reset.cmd.test.ts | 18 +++--- .../commands/update/workflow.test.ts | 8 +-- .../integration/commands/worker.cmd.test.ts | 12 ++-- .../community-packages.api.test.ts | 6 +- ...dynamic-node-parameters.controller.test.ts | 4 +- .../controllers/invitation/assertions.ts | 2 + .../invitation.controller.integration.test.ts | 27 ++++----- .../controllers/oauth/oauth2.api.test.ts | 11 ++-- .../integration/credentials-helper.test.ts | 7 ++- .../credentials/credentials.api.ee.test.ts | 22 +++---- .../credentials/credentials.api.test.ts | 26 ++++---- .../credentials/credentials.service.test.ts | 12 ++-- .../cli/test/integration/cta.service.test.ts | 10 ++-- .../repositories/execution.repository.test.ts | 6 +- .../repositories/project.repository.test.ts | 12 ++-- .../repositories/workflow.repository.test.ts | 2 +- .../test/integration/debug.controller.test.ts | 12 ++-- .../source-control-import.service.test.ts | 25 ++++---- .../environments/source-control.test.ts | 8 +-- .../cli/test/integration/eventbus.ee.test.ts | 18 +++--- .../cli/test/integration/eventbus.test.ts | 4 +- .../execution.service.integration.test.ts | 14 +++-- .../integration/executions.controller.test.ts | 7 +-- .../external-secrets.api.test.ts | 22 +++---- .../healthcheck.controller.test.ts | 3 +- .../test/integration/import.service.test.ts | 21 ++++--- .../test/integration/ldap/ldap.api.test.ts | 14 ++--- .../license-metrics.repository.test.ts | 12 ++-- .../cli/test/integration/license.api.test.ts | 5 +- packages/cli/test/integration/me.api.test.ts | 14 ++--- .../cli/test/integration/mfa/mfa.api.test.ts | 6 +- .../middlewares/body-parser.test.ts | 5 +- .../cli/test/integration/owner.api.test.ts | 2 +- .../integration/password-reset.api.test.ts | 18 +++--- .../integration/permission-checker.test.ts | 23 ++++---- .../cli/test/integration/project.api.test.ts | 46 ++++++++------- .../project.service.integration.test.ts | 8 ++- .../integration/prometheus-metrics.test.ts | 9 +-- .../test/integration/pruning.service.test.ts | 14 ++--- .../public-api/credentials.test.ts | 12 ++-- .../integration/public-api/executions.test.ts | 28 ++++----- .../integration/public-api/projects.test.ts | 11 ++-- .../test/integration/public-api/tags.test.ts | 7 ++- .../integration/public-api/users.ee.test.ts | 10 ++-- .../test/integration/public-api/users.test.ts | 9 +-- .../integration/public-api/variables.test.ts | 5 +- .../integration/public-api/workflows.test.ts | 22 +++---- .../cli/test/integration/role.api.test.ts | 6 +- .../integration/saml/saml-helpers.test.ts | 2 +- .../test/integration/saml/saml.api.test.ts | 4 +- .../credentials-risk-reporter.test.ts | 16 ++--- .../database-risk-reporter.test.ts | 10 ++-- .../filesystem-risk-reporter.test.ts | 8 ++- .../instance-risk-reporter.test.ts | 16 ++--- .../nodes-risk-reporter.test.ts | 13 ++-- .../test/integration/security-audit/utils.ts | 9 +-- .../execution-metadata.service.test.ts | 4 +- .../services/project.service.test.ts | 14 +++-- .../workflow-static-data.service.test.ts | 13 ++-- .../test/integration/shared/db/credentials.ts | 8 ++- .../test/integration/shared/db/executions.ts | 9 +-- .../test/integration/shared/db/projects.ts | 9 +-- .../cli/test/integration/shared/db/tags.ts | 1 + .../cli/test/integration/shared/db/users.ts | 7 ++- .../test/integration/shared/db/variables.ts | 5 +- .../integration/shared/db/workflow-history.ts | 1 + .../shared/db/workflow-statistics.ts | 3 +- .../test/integration/shared/db/workflows.ts | 10 ++-- packages/cli/test/integration/shared/ldap.ts | 7 ++- .../cli/test/integration/shared/random.ts | 3 +- .../cli/test/integration/shared/test-db.ts | 8 +-- packages/cli/test/integration/shared/types.ts | 5 +- .../shared/utils/community-nodes.ts | 9 +-- .../test/integration/shared/utils/index.ts | 8 +-- .../integration/shared/utils/test-command.ts | 7 ++- .../integration/shared/utils/test-server.ts | 12 ++-- .../test/integration/shared/utils/users.ts | 2 +- .../cli/test/integration/shared/workflow.ts | 1 + .../cli/test/integration/tags.api.test.ts | 4 +- .../test/integration/user.repository.test.ts | 6 +- .../cli/test/integration/users.api.test.ts | 18 +++--- .../cli/test/integration/variables.test.ts | 4 +- .../cli/test/integration/webhooks.api.test.ts | 12 ++-- .../cli/test/integration/webhooks.test.ts | 13 ++-- .../workflow-history-manager.test.ts | 8 +-- .../integration/workflow-history.api.test.ts | 6 +- ...tag-mapping.repository.integration.test.ts | 5 +- .../workflow-sharing.service.test.ts | 6 +- .../workflows/workflow.service.ee.test.ts | 5 +- .../workflows/workflow.service.test.ts | 7 ++- ...er-with-active-workflow-manager.ee.test.ts | 10 ++-- .../workflows/workflows.controller.ee.test.ts | 22 +++---- .../workflows/workflows.controller.test.ts | 28 ++++----- packages/cli/test/setup-test-folder.ts | 2 +- .../cli/test/shared/external-secrets/utils.ts | 3 +- packages/cli/test/shared/mock-objects.ts | 3 +- packages/cli/test/shared/mocking.ts | 6 +- packages/cli/test/teardown.ts | 3 +- 569 files changed, 2887 insertions(+), 2393 deletions(-) diff --git a/packages/cli/.eslintrc.js b/packages/cli/.eslintrc.js index fd654771a5dd5..6c7c7227abbce 100644 --- a/packages/cli/.eslintrc.js +++ b/packages/cli/.eslintrc.js @@ -28,7 +28,17 @@ module.exports = { // TODO: Remove this 'import/no-cycle': 'warn', - 'import/order': 'off', + 'import/order': [ + 'error', + { + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, + groups: [['builtin', 'external'], 'internal', ['parent', 'index', 'sibling'], 'object'], + 'newlines-between': 'always', + }, + ], 'import/extensions': 'warn', '@typescript-eslint/ban-ts-comment': ['warn', { 'ts-ignore': true }], '@typescript-eslint/no-explicit-any': 'warn', diff --git a/packages/cli/src/__tests__/active-executions.test.ts b/packages/cli/src/__tests__/active-executions.test.ts index c23a204b656f4..98e7d1d099ad9 100644 --- a/packages/cli/src/__tests__/active-executions.test.ts +++ b/packages/cli/src/__tests__/active-executions.test.ts @@ -1,15 +1,16 @@ -import { ActiveExecutions } from '@/active-executions'; -import PCancelable from 'p-cancelable'; -import { v4 as uuid } from 'uuid'; +import { mock } from 'jest-mock-extended'; import type { IExecuteResponsePromiseData, IRun, IWorkflowExecutionDataProcess, } from 'n8n-workflow'; import { createDeferredPromise } from 'n8n-workflow'; -import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { mock } from 'jest-mock-extended'; +import PCancelable from 'p-cancelable'; +import { v4 as uuid } from 'uuid'; + +import { ActiveExecutions } from '@/active-executions'; import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; +import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { mockInstance } from '@test/mocking'; const FAKE_EXECUTION_ID = '15'; diff --git a/packages/cli/src/__tests__/credential-types.test.ts b/packages/cli/src/__tests__/credential-types.test.ts index b65e5a4aa3d2d..0ccb5ab771838 100644 --- a/packages/cli/src/__tests__/credential-types.test.ts +++ b/packages/cli/src/__tests__/credential-types.test.ts @@ -1,5 +1,6 @@ -import { CredentialTypes } from '@/credential-types'; import { Container } from 'typedi'; + +import { CredentialTypes } from '@/credential-types'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/__tests__/credentials-helper.test.ts b/packages/cli/src/__tests__/credentials-helper.test.ts index 50472518b138a..62cab968e4570 100644 --- a/packages/cli/src/__tests__/credentials-helper.test.ts +++ b/packages/cli/src/__tests__/credentials-helper.test.ts @@ -1,4 +1,3 @@ -import Container from 'typedi'; import type { IAuthenticateGeneric, ICredentialDataDecryptedObject, @@ -9,11 +8,13 @@ import type { } from 'n8n-workflow'; import { NodeConnectionType, deepCopy } from 'n8n-workflow'; import { Workflow } from 'n8n-workflow'; +import Container from 'typedi'; + import { CredentialsHelper } from '@/credentials-helper'; -import { NodeTypes } from '@/node-types'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { NodeTypes } from '@/node-types'; import { mockInstance } from '@test/mocking'; describe('CredentialsHelper', () => { diff --git a/packages/cli/src/__tests__/license.test.ts b/packages/cli/src/__tests__/license.test.ts index 712340664f3cd..83c33645aba25 100644 --- a/packages/cli/src/__tests__/license.test.ts +++ b/packages/cli/src/__tests__/license.test.ts @@ -1,12 +1,13 @@ import { LicenseManager } from '@n8n_io/license-sdk'; -import { InstanceSettings } from 'n8n-core'; import { mock } from 'jest-mock-extended'; +import { InstanceSettings } from 'n8n-core'; + import config from '@/config'; +import { N8N_VERSION } from '@/constants'; import { License } from '@/license'; import { Logger } from '@/logger'; -import { N8N_VERSION } from '@/constants'; -import { mockInstance } from '@test/mocking'; import { OrchestrationService } from '@/services/orchestration.service'; +import { mockInstance } from '@test/mocking'; jest.mock('@n8n_io/license-sdk'); diff --git a/packages/cli/src/__tests__/wait-tracker.test.ts b/packages/cli/src/__tests__/wait-tracker.test.ts index 19ce0e024fa58..a3d5e87d4b77e 100644 --- a/packages/cli/src/__tests__/wait-tracker.test.ts +++ b/packages/cli/src/__tests__/wait-tracker.test.ts @@ -1,9 +1,10 @@ -import { WaitTracker } from '@/wait-tracker'; import { mock } from 'jest-mock-extended'; + import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; import type { IExecutionResponse } from '@/interfaces'; -import { OrchestrationService } from '@/services/orchestration.service'; import type { MultiMainSetup } from '@/services/orchestration/main/multi-main-setup.ee'; +import { OrchestrationService } from '@/services/orchestration.service'; +import { WaitTracker } from '@/wait-tracker'; jest.useFakeTimers(); diff --git a/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts b/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts index 6fa8d8c0c0a88..6b715f175d242 100644 --- a/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts +++ b/packages/cli/src/__tests__/workflow-execute-additional-data.test.ts @@ -1,10 +1,11 @@ -import { VariablesService } from '@/environments/variables/variables.service.ee'; -import { mockInstance } from '@test/mocking'; -import { getBase } from '@/workflow-execute-additional-data'; import Container from 'typedi'; + import { CredentialsHelper } from '@/credentials-helper'; -import { SecretsHelper } from '@/secrets-helpers'; +import { VariablesService } from '@/environments/variables/variables.service.ee'; import { EventService } from '@/events/event.service'; +import { SecretsHelper } from '@/secrets-helpers'; +import { getBase } from '@/workflow-execute-additional-data'; +import { mockInstance } from '@test/mocking'; describe('WorkflowExecuteAdditionalData', () => { const variablesService = mockInstance(VariablesService); diff --git a/packages/cli/src/__tests__/workflow-helpers.test.ts b/packages/cli/src/__tests__/workflow-helpers.test.ts index 4fa0e6a721955..e24cfa1f68284 100644 --- a/packages/cli/src/__tests__/workflow-helpers.test.ts +++ b/packages/cli/src/__tests__/workflow-helpers.test.ts @@ -1,4 +1,5 @@ import type { Workflow, IWorkflowExecutionDataProcess } from 'n8n-workflow'; + import { getExecutionStartNode } from '@/workflow-helpers'; describe('WorkflowHelpers', () => { diff --git a/packages/cli/src/__tests__/workflow-runner.test.ts b/packages/cli/src/__tests__/workflow-runner.test.ts index a5eb9887a5120..9a3fcd67b4bc7 100644 --- a/packages/cli/src/__tests__/workflow-runner.test.ts +++ b/packages/cli/src/__tests__/workflow-runner.test.ts @@ -1,16 +1,16 @@ -import Container from 'typedi'; import { WorkflowHooks, type ExecutionError, type IWorkflowExecuteHooks } from 'n8n-workflow'; +import Container from 'typedi'; + +import config from '@/config'; import type { User } from '@/databases/entities/user'; +import { Telemetry } from '@/telemetry'; import { WorkflowRunner } from '@/workflow-runner'; -import config from '@/config'; - -import * as testDb from '@test-integration/test-db'; -import { setupTestServer } from '@test-integration/utils'; +import { mockInstance } from '@test/mocking'; +import { createExecution } from '@test-integration/db/executions'; import { createUser } from '@test-integration/db/users'; import { createWorkflow } from '@test-integration/db/workflows'; -import { createExecution } from '@test-integration/db/executions'; -import { mockInstance } from '@test/mocking'; -import { Telemetry } from '@/telemetry'; +import * as testDb from '@test-integration/test-db'; +import { setupTestServer } from '@test-integration/utils'; let owner: User; let runner: WorkflowRunner; diff --git a/packages/cli/src/abstract-server.ts b/packages/cli/src/abstract-server.ts index 46d10f71af171..b5892d173b8f4 100644 --- a/packages/cli/src/abstract-server.ts +++ b/packages/cli/src/abstract-server.ts @@ -1,28 +1,29 @@ -import { Container, Service } from 'typedi'; -import { readFile } from 'fs/promises'; -import type { Server } from 'http'; +import { GlobalConfig } from '@n8n/config'; +import compression from 'compression'; import express from 'express'; import { engine as expressHandlebars } from 'express-handlebars'; -import compression from 'compression'; +import { readFile } from 'fs/promises'; +import type { Server } from 'http'; import isbot from 'isbot'; +import { Container, Service } from 'typedi'; import config from '@/config'; import { N8N_VERSION, TEMPLATES_DIR, inDevelopment, inTest } from '@/constants'; import * as Db from '@/db'; -import { N8nInstanceType } from '@/interfaces'; +import { OnShutdown } from '@/decorators/on-shutdown'; import { ExternalHooks } from '@/external-hooks'; -import { send, sendErrorResponse } from '@/response-helper'; +import { N8nInstanceType } from '@/interfaces'; +import { Logger } from '@/logger'; import { rawBodyReader, bodyParser, corsMiddleware } from '@/middlewares'; +import { send, sendErrorResponse } from '@/response-helper'; import { WaitingForms } from '@/waiting-forms'; +import { LiveWebhooks } from '@/webhooks/live-webhooks'; import { TestWebhooks } from '@/webhooks/test-webhooks'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; import { createWebhookHandlerFor } from '@/webhooks/webhook-request-handler'; -import { LiveWebhooks } from '@/webhooks/live-webhooks'; + import { generateHostInstanceId } from './databases/utils/generators'; -import { Logger } from '@/logger'; import { ServiceUnavailableError } from './errors/response-errors/service-unavailable.error'; -import { OnShutdown } from '@/decorators/on-shutdown'; -import { GlobalConfig } from '@n8n/config'; @Service() export abstract class AbstractServer { diff --git a/packages/cli/src/activation-errors.service.ts b/packages/cli/src/activation-errors.service.ts index e06dcf6dee0e5..9ddcad9317d4e 100644 --- a/packages/cli/src/activation-errors.service.ts +++ b/packages/cli/src/activation-errors.service.ts @@ -1,4 +1,5 @@ import { Service } from 'typedi'; + import { CacheService } from '@/services/cache/cache.service'; @Service() diff --git a/packages/cli/src/active-executions.ts b/packages/cli/src/active-executions.ts index 36e308028f0e4..c22d1843f44b8 100644 --- a/packages/cli/src/active-executions.ts +++ b/packages/cli/src/active-executions.ts @@ -1,5 +1,3 @@ -import { Service } from 'typedi'; -import type PCancelable from 'p-cancelable'; import type { IDeferredPromise, IExecuteResponsePromiseData, @@ -14,16 +12,19 @@ import { sleep, } from 'n8n-workflow'; import { strict as assert } from 'node:assert'; +import type PCancelable from 'p-cancelable'; +import { Service } from 'typedi'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import type { ExecutionPayload, IExecutingWorkflowData, IExecutionDb, IExecutionsCurrentSummary, } from '@/interfaces'; -import { isWorkflowIdValid } from '@/utils'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { Logger } from '@/logger'; +import { isWorkflowIdValid } from '@/utils'; + import { ConcurrencyControlService } from './concurrency/concurrency-control.service'; import config from './config'; diff --git a/packages/cli/src/active-workflow-manager.ts b/packages/cli/src/active-workflow-manager.ts index e4541f293a279..44172ef564f73 100644 --- a/packages/cli/src/active-workflow-manager.ts +++ b/packages/cli/src/active-workflow-manager.ts @@ -1,8 +1,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { Service } from 'typedi'; import { ActiveWorkflows, NodeExecuteFunctions } from 'n8n-core'; - import type { ExecutionError, IDeferredPromise, @@ -25,30 +23,31 @@ import { WebhookPathTakenError, ApplicationError, } from 'n8n-workflow'; +import { Service } from 'typedi'; -import type { IWorkflowDb } from '@/interfaces'; -import * as WebhookHelpers from '@/webhooks/webhook-helpers'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; - -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ActivationErrorsService } from '@/activation-errors.service'; import { ActiveExecutions } from '@/active-executions'; -import { ExecutionService } from './executions/execution.service'; import { STARTING_NODES, WORKFLOW_REACTIVATE_INITIAL_TIMEOUT, WORKFLOW_REACTIVATE_MAX_TIMEOUT, } from '@/constants'; -import { NodeTypes } from '@/node-types'; -import { ExternalHooks } from '@/external-hooks'; -import { WebhookService } from '@/webhooks/webhook.service'; -import { Logger } from './logger'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { OrchestrationService } from '@/services/orchestration.service'; -import { ActivationErrorsService } from '@/activation-errors.service'; +import { OnShutdown } from '@/decorators/on-shutdown'; +import { ExternalHooks } from '@/external-hooks'; +import type { IWorkflowDb } from '@/interfaces'; +import { NodeTypes } from '@/node-types'; import { ActiveWorkflowsService } from '@/services/active-workflows.service'; +import { OrchestrationService } from '@/services/orchestration.service'; +import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +import { WebhookService } from '@/webhooks/webhook.service'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; import { WorkflowExecutionService } from '@/workflows/workflow-execution.service'; import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; -import { OnShutdown } from '@/decorators/on-shutdown'; + +import { ExecutionService } from './executions/execution.service'; +import { Logger } from './logger'; interface QueuedActivation { activationMode: WorkflowActivateMode; diff --git a/packages/cli/src/auth/__tests__/auth.service.test.ts b/packages/cli/src/auth/__tests__/auth.service.test.ts index fe9b51f2926c4..e160bbe11266a 100644 --- a/packages/cli/src/auth/__tests__/auth.service.test.ts +++ b/packages/cli/src/auth/__tests__/auth.service.test.ts @@ -1,6 +1,6 @@ -import jwt from 'jsonwebtoken'; -import { mock } from 'jest-mock-extended'; import type { NextFunction, Response } from 'express'; +import { mock } from 'jest-mock-extended'; +import jwt from 'jsonwebtoken'; import { AuthService } from '@/auth/auth.service'; import config from '@/config'; @@ -8,9 +8,9 @@ import { AUTH_COOKIE_NAME, Time } from '@/constants'; import type { User } from '@/databases/entities/user'; import type { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository'; import type { UserRepository } from '@/databases/repositories/user.repository'; +import type { AuthenticatedRequest } from '@/requests'; import { JwtService } from '@/services/jwt.service'; import type { UrlService } from '@/services/url.service'; -import type { AuthenticatedRequest } from '@/requests'; describe('AuthService', () => { config.set('userManagement.jwtSecret', 'random-secret'); diff --git a/packages/cli/src/auth/auth.service.ts b/packages/cli/src/auth/auth.service.ts index b4f7efb3ad8ec..481f25c897c02 100644 --- a/packages/cli/src/auth/auth.service.ts +++ b/packages/cli/src/auth/auth.service.ts @@ -1,7 +1,8 @@ -import Container, { Service } from 'typedi'; -import type { NextFunction, Response } from 'express'; +import { GlobalConfig } from '@n8n/config'; import { createHash } from 'crypto'; +import type { NextFunction, Response } from 'express'; import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken'; +import Container, { Service } from 'typedi'; import config from '@/config'; import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time } from '@/constants'; @@ -15,7 +16,6 @@ import { Logger } from '@/logger'; import type { AuthenticatedRequest } from '@/requests'; import { JwtService } from '@/services/jwt.service'; import { UrlService } from '@/services/url.service'; -import { GlobalConfig } from '@n8n/config'; interface AuthJwtPayload { /** User Id */ diff --git a/packages/cli/src/auth/jwt.ts b/packages/cli/src/auth/jwt.ts index 38d37ed33290d..63255f5f66fb1 100644 --- a/packages/cli/src/auth/jwt.ts +++ b/packages/cli/src/auth/jwt.ts @@ -1,7 +1,8 @@ -import { Container } from 'typedi'; import type { Response } from 'express'; +import { Container } from 'typedi'; import type { User } from '@/databases/entities/user'; + import { AuthService } from './auth.service'; // This method is still used by cloud hooks. diff --git a/packages/cli/src/auth/methods/email.ts b/packages/cli/src/auth/methods/email.ts index 58919e03f8168..723365057f66c 100644 --- a/packages/cli/src/auth/methods/email.ts +++ b/packages/cli/src/auth/methods/email.ts @@ -1,10 +1,11 @@ -import type { User } from '@/databases/entities/user'; -import { PasswordUtility } from '@/services/password.utility'; import { Container } from 'typedi'; -import { isLdapLoginEnabled } from '@/ldap/helpers.ee'; + +import type { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; import { EventService } from '@/events/event.service'; +import { isLdapLoginEnabled } from '@/ldap/helpers.ee'; +import { PasswordUtility } from '@/services/password.utility'; export const handleEmailLogin = async ( email: string, diff --git a/packages/cli/src/auth/methods/ldap.ts b/packages/cli/src/auth/methods/ldap.ts index 75627a543d250..b8fea259891f8 100644 --- a/packages/cli/src/auth/methods/ldap.ts +++ b/packages/cli/src/auth/methods/ldap.ts @@ -1,6 +1,7 @@ import { Container } from 'typedi'; -import { LdapService } from '@/ldap/ldap.service.ee'; +import type { User } from '@/databases/entities/user'; +import { EventService } from '@/events/event.service'; import { createLdapUserOnLocalDb, getUserByEmail, @@ -10,8 +11,7 @@ import { createLdapAuthIdentity, updateLdapUserOnLocalDb, } from '@/ldap/helpers.ee'; -import type { User } from '@/databases/entities/user'; -import { EventService } from '@/events/event.service'; +import { LdapService } from '@/ldap/ldap.service.ee'; export const handleLdapLogin = async ( loginId: string, diff --git a/packages/cli/src/collaboration/__tests__/collaboration.state.test.ts b/packages/cli/src/collaboration/__tests__/collaboration.state.test.ts index ba3e4a1ff4fc5..0bfd90de4bebd 100644 --- a/packages/cli/src/collaboration/__tests__/collaboration.state.test.ts +++ b/packages/cli/src/collaboration/__tests__/collaboration.state.test.ts @@ -1,7 +1,9 @@ -import { CollaborationState } from '../collaboration.state'; -import type { CacheService } from '@/services/cache/cache.service'; import { mock } from 'jest-mock-extended'; +import type { CacheService } from '@/services/cache/cache.service'; + +import { CollaborationState } from '../collaboration.state'; + const origDate = global.Date; const mockDateFactory = (currentDate: string) => { diff --git a/packages/cli/src/collaboration/collaboration.service.ts b/packages/cli/src/collaboration/collaboration.service.ts index 50ddbdec8ce8d..b7066eaf949c7 100644 --- a/packages/cli/src/collaboration/collaboration.service.ts +++ b/packages/cli/src/collaboration/collaboration.service.ts @@ -1,13 +1,13 @@ -import { Service } from 'typedi'; import type { Workflow } from 'n8n-workflow'; import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; +import { Service } from 'typedi'; -import { Push } from '@/push'; +import { CollaborationState } from '@/collaboration/collaboration.state'; +import type { User } from '@/databases/entities/user'; +import { UserRepository } from '@/databases/repositories/user.repository'; import type { ICollaboratorsChanged } from '@/interfaces'; +import { Push } from '@/push'; import type { OnPushMessage } from '@/push/types'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import type { User } from '@/databases/entities/user'; -import { CollaborationState } from '@/collaboration/collaboration.state'; import { AccessService } from '@/services/access.service'; import type { WorkflowClosedMessage, WorkflowOpenedMessage } from './collaboration.message'; diff --git a/packages/cli/src/collaboration/collaboration.state.ts b/packages/cli/src/collaboration/collaboration.state.ts index f6b9549460b18..00508ac11a753 100644 --- a/packages/cli/src/collaboration/collaboration.state.ts +++ b/packages/cli/src/collaboration/collaboration.state.ts @@ -1,10 +1,10 @@ -import { Service } from 'typedi'; import type { Workflow } from 'n8n-workflow'; +import { Service } from 'typedi'; import { Time } from '@/constants'; +import type { User } from '@/databases/entities/user'; import type { Iso8601DateTimeString } from '@/interfaces'; import { CacheService } from '@/services/cache/cache.service'; -import type { User } from '@/databases/entities/user'; type WorkflowCacheHash = Record; interface CacheEntry { diff --git a/packages/cli/src/commands/audit.ts b/packages/cli/src/commands/audit.ts index a447204b67779..e86c8c9ab5e79 100644 --- a/packages/cli/src/commands/audit.ts +++ b/packages/cli/src/commands/audit.ts @@ -1,11 +1,12 @@ -import { Container } from 'typedi'; import { Flags } from '@oclif/core'; import { ApplicationError } from 'n8n-workflow'; +import { Container } from 'typedi'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; -import { RISK_CATEGORIES } from '@/security-audit/constants'; import config from '@/config'; +import { RISK_CATEGORIES } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; import type { Risk } from '@/security-audit/types'; + import { BaseCommand } from './base-command'; export class SecurityAudit extends BaseCommand { diff --git a/packages/cli/src/commands/base-command.ts b/packages/cli/src/commands/base-command.ts index eb7e8b03f4922..2f995e610c3ce 100644 --- a/packages/cli/src/commands/base-command.ts +++ b/packages/cli/src/commands/base-command.ts @@ -1,29 +1,30 @@ import 'reflect-metadata'; -import { Container } from 'typedi'; -import { Command, Errors } from '@oclif/core'; import { GlobalConfig } from '@n8n/config'; -import { ApplicationError, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow'; +import { Command, Errors } from '@oclif/core'; import { BinaryDataService, InstanceSettings, ObjectStoreService } from 'n8n-core'; +import { ApplicationError, ErrorReporterProxy as ErrorReporter, sleep } from 'n8n-workflow'; +import { Container } from 'typedi'; + import type { AbstractServer } from '@/abstract-server'; -import { Logger } from '@/logger'; import config from '@/config'; -import * as Db from '@/db'; -import * as CrashJournal from '@/crash-journal'; import { LICENSE_FEATURES, inDevelopment, inTest } from '@/constants'; +import * as CrashJournal from '@/crash-journal'; +import { generateHostInstanceId } from '@/databases/utils/generators'; +import * as Db from '@/db'; import { initErrorHandling } from '@/error-reporting'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; +import { initExpressionEvaluator } from '@/expression-evaluator'; import { ExternalHooks } from '@/external-hooks'; -import { NodeTypes } from '@/node-types'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import type { N8nInstanceType } from '@/interfaces'; -import { PostHogClient } from '@/posthog'; import { License } from '@/license'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; -import { initExpressionEvaluator } from '@/expression-evaluator'; -import { generateHostInstanceId } from '@/databases/utils/generators'; -import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { Logger } from '@/logger'; +import { NodeTypes } from '@/node-types'; +import { PostHogClient } from '@/posthog'; import { ShutdownService } from '@/shutdown/shutdown.service'; -import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; export abstract class BaseCommand extends Command { protected logger = Container.get(Logger); diff --git a/packages/cli/src/commands/db/__tests__/revert.test.ts b/packages/cli/src/commands/db/__tests__/revert.test.ts index 1afa8be1901ee..9c7a37b53358a 100644 --- a/packages/cli/src/commands/db/__tests__/revert.test.ts +++ b/packages/cli/src/commands/db/__tests__/revert.test.ts @@ -1,11 +1,12 @@ -import { main } from '@/commands/db/revert'; -import { mockInstance } from '@test/mocking'; -import { Logger } from '@/logger'; -import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; import type { Migration, MigrationExecutor } from '@n8n/typeorm'; import { type DataSource } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; +import { main } from '@/commands/db/revert'; +import type { IrreversibleMigration, ReversibleMigration } from '@/databases/types'; +import { Logger } from '@/logger'; +import { mockInstance } from '@test/mocking'; + const logger = mockInstance(Logger); afterEach(() => { diff --git a/packages/cli/src/commands/db/revert.ts b/packages/cli/src/commands/db/revert.ts index aa74f1b1564aa..dc3776a6af944 100644 --- a/packages/cli/src/commands/db/revert.ts +++ b/packages/cli/src/commands/db/revert.ts @@ -1,13 +1,14 @@ -import { Command, Flags } from '@oclif/core'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { DataSourceOptions as ConnectionOptions } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { MigrationExecutor, DataSource as Connection } from '@n8n/typeorm'; +import { Command, Flags } from '@oclif/core'; import { Container } from 'typedi'; -import { Logger } from '@/logger'; + import { getConnectionOptions } from '@/databases/config'; import type { Migration } from '@/databases/types'; import { wrapMigration } from '@/databases/utils/migration-helpers'; +import { Logger } from '@/logger'; // This function is extracted to make it easier to unit test it. // Mocking turned into a mess due to this command using typeorm and the db diff --git a/packages/cli/src/commands/execute-batch.ts b/packages/cli/src/commands/execute-batch.ts index 81a94b5ea82f4..71540952b59d9 100644 --- a/packages/cli/src/commands/execute-batch.ts +++ b/packages/cli/src/commands/execute-batch.ts @@ -1,21 +1,21 @@ /* eslint-disable @typescript-eslint/no-loop-func */ -import { Container } from 'typedi'; import { Flags } from '@oclif/core'; import fs from 'fs'; -import os from 'os'; +import { diff } from 'json-diff'; +import pick from 'lodash/pick'; import type { IRun, ITaskData, IWorkflowExecutionDataProcess } from 'n8n-workflow'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import os from 'os'; import { sep } from 'path'; -import { diff } from 'json-diff'; -import pick from 'lodash/pick'; +import { Container } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; -import { WorkflowRunner } from '@/workflow-runner'; -import type { IWorkflowDb } from '@/interfaces'; import type { User } from '@/databases/entities/user'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { IWorkflowDb } from '@/interfaces'; import { OwnershipService } from '@/services/ownership.service'; import { findCliWorkflowStart } from '@/utils'; +import { WorkflowRunner } from '@/workflow-runner'; import { BaseCommand } from './base-command'; import type { diff --git a/packages/cli/src/commands/execute.ts b/packages/cli/src/commands/execute.ts index a9965097e0638..9a901fdfc56d5 100644 --- a/packages/cli/src/commands/execute.ts +++ b/packages/cli/src/commands/execute.ts @@ -1,15 +1,15 @@ -import { Container } from 'typedi'; import { Flags } from '@oclif/core'; import type { IWorkflowBase, IWorkflowExecutionDataProcess } from 'n8n-workflow'; import { ApplicationError, ExecutionBaseError } from 'n8n-workflow'; +import { Container } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; -import { WorkflowRunner } from '@/workflow-runner'; -import { findCliWorkflowStart, isWorkflowIdValid } from '@/utils'; -import { BaseCommand } from './base-command'; - import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { OwnershipService } from '@/services/ownership.service'; +import { findCliWorkflowStart, isWorkflowIdValid } from '@/utils'; +import { WorkflowRunner } from '@/workflow-runner'; + +import { BaseCommand } from './base-command'; export class Execute extends BaseCommand { static description = '\nExecutes a given workflow'; diff --git a/packages/cli/src/commands/export/credentials.ts b/packages/cli/src/commands/export/credentials.ts index fc1d62ab66081..4644c2556cade 100644 --- a/packages/cli/src/commands/export/credentials.ts +++ b/packages/cli/src/commands/export/credentials.ts @@ -1,12 +1,14 @@ import { Flags } from '@oclif/core'; import fs from 'fs'; -import path from 'path'; import { Credentials } from 'n8n-core'; +import { ApplicationError } from 'n8n-workflow'; +import path from 'path'; +import Container from 'typedi'; + +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import type { ICredentialsDb, ICredentialsDecryptedDb } from '@/interfaces'; + import { BaseCommand } from '../base-command'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import Container from 'typedi'; -import { ApplicationError } from 'n8n-workflow'; export class ExportCredentialsCommand extends BaseCommand { static description = 'Export credentials'; diff --git a/packages/cli/src/commands/export/workflow.ts b/packages/cli/src/commands/export/workflow.ts index a2e03e58820e5..8e129eec4d7e3 100644 --- a/packages/cli/src/commands/export/workflow.ts +++ b/packages/cli/src/commands/export/workflow.ts @@ -1,10 +1,12 @@ import { Flags } from '@oclif/core'; import fs from 'fs'; +import { ApplicationError } from 'n8n-workflow'; import path from 'path'; -import { BaseCommand } from '../base-command'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import Container from 'typedi'; -import { ApplicationError } from 'n8n-workflow'; + +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; + +import { BaseCommand } from '../base-command'; export class ExportWorkflowsCommand extends BaseCommand { static description = 'Export workflows'; diff --git a/packages/cli/src/commands/import/credentials.ts b/packages/cli/src/commands/import/credentials.ts index 9226f629c7d7f..5f9e06f256440 100644 --- a/packages/cli/src/commands/import/credentials.ts +++ b/packages/cli/src/commands/import/credentials.ts @@ -1,21 +1,22 @@ -import { Container } from 'typedi'; -import { Flags } from '@oclif/core'; -import { Cipher } from 'n8n-core'; -import fs from 'fs'; -import glob from 'fast-glob'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { EntityManager } from '@n8n/typeorm'; - -import * as Db from '@/db'; -import { SharedCredentials } from '@/databases/entities/shared-credentials'; -import { CredentialsEntity } from '@/databases/entities/credentials-entity'; -import { BaseCommand } from '../base-command'; +import { Flags } from '@oclif/core'; +import glob from 'fast-glob'; +import fs from 'fs'; +import { Cipher } from 'n8n-core'; import type { ICredentialsEncrypted } from 'n8n-workflow'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { Container } from 'typedi'; + import { UM_FIX_INSTRUCTION } from '@/constants'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { Project } from '@/databases/entities/project'; +import { SharedCredentials } from '@/databases/entities/shared-credentials'; import { User } from '@/databases/entities/user'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import * as Db from '@/db'; + +import { BaseCommand } from '../base-command'; export class ImportCredentialsCommand extends BaseCommand { static description = 'Import credentials'; diff --git a/packages/cli/src/commands/import/workflow.ts b/packages/cli/src/commands/import/workflow.ts index 0e5581479e2b2..2548ca9523362 100644 --- a/packages/cli/src/commands/import/workflow.ts +++ b/packages/cli/src/commands/import/workflow.ts @@ -1,19 +1,20 @@ -import { Container } from 'typedi'; import { Flags } from '@oclif/core'; -import { ApplicationError, jsonParse } from 'n8n-workflow'; -import fs from 'fs'; import glob from 'fast-glob'; +import fs from 'fs'; +import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { Container } from 'typedi'; import { UM_FIX_INSTRUCTION } from '@/constants'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { generateNanoId } from '@/databases/utils/generators'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import type { IWorkflowToImport } from '@/interfaces'; import { ImportService } from '@/services/import.service'; + import { BaseCommand } from '../base-command'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; function assertHasWorkflowsToImport(workflows: unknown): asserts workflows is IWorkflowToImport[] { if (!Array.isArray(workflows)) { diff --git a/packages/cli/src/commands/ldap/reset.ts b/packages/cli/src/commands/ldap/reset.ts index 5837825e59aa3..f9f1f3d0bb8bf 100644 --- a/packages/cli/src/commands/ldap/reset.ts +++ b/packages/cli/src/commands/ldap/reset.ts @@ -1,21 +1,23 @@ +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In } from '@n8n/typeorm'; +import { Flags } from '@oclif/core'; +import { ApplicationError } from 'n8n-workflow'; import Container from 'typedi'; -import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; + +import { UM_FIX_INSTRUCTION } from '@/constants'; +import { CredentialsService } from '@/credentials/credentials.service'; import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { BaseCommand } from '../base-command'; -import { Flags } from '@oclif/core'; -import { ApplicationError } from 'n8n-workflow'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; import { WorkflowService } from '@/workflows/workflow.service'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In } from '@n8n/typeorm'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import { CredentialsService } from '@/credentials/credentials.service'; -import { UM_FIX_INSTRUCTION } from '@/constants'; + +import { BaseCommand } from '../base-command'; const wrongFlagsError = 'You must use exactly one of `--userId`, `--projectId` or `--deleteWorkflowsAndCredentials`.'; diff --git a/packages/cli/src/commands/license/clear.ts b/packages/cli/src/commands/license/clear.ts index 8abafa97ad322..427a150ebb0c1 100644 --- a/packages/cli/src/commands/license/clear.ts +++ b/packages/cli/src/commands/license/clear.ts @@ -1,9 +1,11 @@ import { Container } from 'typedi'; + import { SETTINGS_LICENSE_CERT_KEY } from '@/constants'; -import { BaseCommand } from '../base-command'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { License } from '@/license'; +import { BaseCommand } from '../base-command'; + export class ClearLicenseCommand extends BaseCommand { static description = 'Clear license'; diff --git a/packages/cli/src/commands/license/info.ts b/packages/cli/src/commands/license/info.ts index 6789b4ff41df6..5f3e31a573b59 100644 --- a/packages/cli/src/commands/license/info.ts +++ b/packages/cli/src/commands/license/info.ts @@ -1,5 +1,7 @@ import { Container } from 'typedi'; + import { License } from '@/license'; + import { BaseCommand } from '../base-command'; export class LicenseInfoCommand extends BaseCommand { diff --git a/packages/cli/src/commands/list/workflow.ts b/packages/cli/src/commands/list/workflow.ts index 9a0cca8e13b37..39f5689fcc9dc 100644 --- a/packages/cli/src/commands/list/workflow.ts +++ b/packages/cli/src/commands/list/workflow.ts @@ -1,6 +1,8 @@ -import Container from 'typedi'; import { Flags } from '@oclif/core'; +import Container from 'typedi'; + import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; + import { BaseCommand } from '../base-command'; export class ListWorkflowCommand extends BaseCommand { diff --git a/packages/cli/src/commands/mfa/disable.ts b/packages/cli/src/commands/mfa/disable.ts index c7959d5cb5653..3458593252fb0 100644 --- a/packages/cli/src/commands/mfa/disable.ts +++ b/packages/cli/src/commands/mfa/disable.ts @@ -1,6 +1,8 @@ -import Container from 'typedi'; import { Flags } from '@oclif/core'; +import Container from 'typedi'; + import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; + import { BaseCommand } from '../base-command'; export class DisableMFACommand extends BaseCommand { diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 70cbdfbec6c33..1bcf5bd9cbe11 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -1,35 +1,36 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { Container } from 'typedi'; import { Flags, type Config } from '@oclif/core'; -import path from 'path'; -import { mkdir } from 'fs/promises'; -import { createReadStream, createWriteStream, existsSync } from 'fs'; -import { pipeline } from 'stream/promises'; -import replaceStream from 'replacestream'; import glob from 'fast-glob'; +import { createReadStream, createWriteStream, existsSync } from 'fs'; +import { mkdir } from 'fs/promises'; import { jsonParse, randomString, type IWorkflowExecutionDataProcess } from 'n8n-workflow'; +import path from 'path'; +import replaceStream from 'replacestream'; +import { pipeline } from 'stream/promises'; +import { Container } from 'typedi'; -import config from '@/config'; import { ActiveExecutions } from '@/active-executions'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { Server } from '@/server'; +import config from '@/config'; import { EDITOR_UI_DIST_DIR, LICENSE_FEATURES } from '@/constants'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { EventService } from '@/events/event.service'; +import { ExecutionService } from '@/executions/execution.service'; import { License } from '@/license'; -import { OrchestrationService } from '@/services/orchestration.service'; +import { Server } from '@/server'; import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service'; +import { OrchestrationService } from '@/services/orchestration.service'; +import { OwnershipService } from '@/services/ownership.service'; import { PruningService } from '@/services/pruning.service'; import { UrlService } from '@/services/url.service'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import { WaitTracker } from '@/wait-tracker'; -import { BaseCommand } from './base-command'; -import { ExecutionService } from '@/executions/execution.service'; -import { OwnershipService } from '@/services/ownership.service'; import { WorkflowRunner } from '@/workflow-runner'; -import { EventService } from '@/events/event.service'; + +import { BaseCommand } from './base-command'; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires const open = require('open'); diff --git a/packages/cli/src/commands/update/workflow.ts b/packages/cli/src/commands/update/workflow.ts index b51f6049f0197..6c88ed6c43b55 100644 --- a/packages/cli/src/commands/update/workflow.ts +++ b/packages/cli/src/commands/update/workflow.ts @@ -1,6 +1,8 @@ -import { Container } from 'typedi'; import { Flags } from '@oclif/core'; +import { Container } from 'typedi'; + import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; + import { BaseCommand } from '../base-command'; export class UpdateWorkflowCommand extends BaseCommand { diff --git a/packages/cli/src/commands/user-management/reset.ts b/packages/cli/src/commands/user-management/reset.ts index 5082a00fc9d91..3c6709e80214a 100644 --- a/packages/cli/src/commands/user-management/reset.ts +++ b/packages/cli/src/commands/user-management/reset.ts @@ -1,13 +1,15 @@ import { Container } from 'typedi'; + import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; + import { BaseCommand } from '../base-command'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; const defaultUserProps = { firstName: null, diff --git a/packages/cli/src/commands/webhook.ts b/packages/cli/src/commands/webhook.ts index 36e898761c90c..655ccee3665d8 100644 --- a/packages/cli/src/commands/webhook.ts +++ b/packages/cli/src/commands/webhook.ts @@ -1,14 +1,14 @@ -import { Container } from 'typedi'; import { Flags, type Config } from '@oclif/core'; import { ApplicationError } from 'n8n-workflow'; +import { Container } from 'typedi'; -import config from '@/config'; import { ActiveExecutions } from '@/active-executions'; +import config from '@/config'; +import { OrchestrationHandlerWebhookService } from '@/services/orchestration/webhook/orchestration.handler.webhook.service'; +import { OrchestrationWebhookService } from '@/services/orchestration/webhook/orchestration.webhook.service'; import { WebhookServer } from '@/webhooks/webhook-server'; -import { BaseCommand } from './base-command'; -import { OrchestrationWebhookService } from '@/services/orchestration/webhook/orchestration.webhook.service'; -import { OrchestrationHandlerWebhookService } from '@/services/orchestration/webhook/orchestration.handler.webhook.service'; +import { BaseCommand } from './base-command'; export class Webhook extends BaseCommand { static description = 'Starts n8n webhook process. Intercepts only production URLs.'; diff --git a/packages/cli/src/commands/worker.ts b/packages/cli/src/commands/worker.ts index c1cff69330216..c4637e03d9e89 100644 --- a/packages/cli/src/commands/worker.ts +++ b/packages/cli/src/commands/worker.ts @@ -1,26 +1,27 @@ -import { Container } from 'typedi'; import { Flags, type Config } from '@oclif/core'; import express from 'express'; import http from 'http'; import { ApplicationError } from 'n8n-workflow'; +import { Container } from 'typedi'; -import * as Db from '@/db'; -import * as ResponseHelper from '@/response-helper'; import config from '@/config'; -import type { ScalingService } from '@/scaling/scaling.service'; import { N8N_VERSION, inTest } from '@/constants'; -import type { ICredentialsOverwrite } from '@/interfaces'; import { CredentialsOverwrites } from '@/credentials-overwrites'; -import { rawBodyReader, bodyParser } from '@/middlewares'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import type { RedisServicePubSubSubscriber } from '@/services/redis/redis-service-pub-sub-subscriber'; +import * as Db from '@/db'; +import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error'; import { EventMessageGeneric } from '@/eventbus/event-message-classes/event-message-generic'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; +import type { ICredentialsOverwrite } from '@/interfaces'; +import { rawBodyReader, bodyParser } from '@/middlewares'; +import * as ResponseHelper from '@/response-helper'; +import { JobProcessor } from '@/scaling/job-processor'; +import type { ScalingService } from '@/scaling/scaling.service'; import { OrchestrationHandlerWorkerService } from '@/services/orchestration/worker/orchestration.handler.worker.service'; import { OrchestrationWorkerService } from '@/services/orchestration/worker/orchestration.worker.service'; -import { ServiceUnavailableError } from '@/errors/response-errors/service-unavailable.error'; +import type { RedisServicePubSubSubscriber } from '@/services/redis/redis-service-pub-sub-subscriber'; + import { BaseCommand } from './base-command'; -import { JobProcessor } from '@/scaling/job-processor'; -import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; export class Worker extends BaseCommand { static description = '\nStarts a n8n worker'; diff --git a/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts b/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts index 585c1bb172e1a..75239f5e5979e 100644 --- a/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts +++ b/packages/cli/src/concurrency/__tests__/concurrency-control.service.test.ts @@ -1,18 +1,20 @@ import { mock } from 'jest-mock-extended'; -import config from '@/config'; +import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; + import { CLOUD_TEMP_PRODUCTION_LIMIT, CLOUD_TEMP_REPORTABLE_THRESHOLDS, ConcurrencyControlService, } from '@/concurrency/concurrency-control.service'; -import type { Logger } from '@/logger'; -import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error'; -import { ConcurrencyQueue } from '../concurrency-queue'; -import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; +import config from '@/config'; import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error'; +import type { EventService } from '@/events/event.service'; import type { IExecutingWorkflowData } from '@/interfaces'; +import type { Logger } from '@/logger'; import type { Telemetry } from '@/telemetry'; -import type { EventService } from '@/events/event.service'; + +import { ConcurrencyQueue } from '../concurrency-queue'; describe('ConcurrencyControlService', () => { const logger = mock(); diff --git a/packages/cli/src/concurrency/__tests__/concurrency-queue.test.ts b/packages/cli/src/concurrency/__tests__/concurrency-queue.test.ts index 9d192a4035142..20a81b38c06c4 100644 --- a/packages/cli/src/concurrency/__tests__/concurrency-queue.test.ts +++ b/packages/cli/src/concurrency/__tests__/concurrency-queue.test.ts @@ -1,4 +1,5 @@ import { sleep } from 'n8n-workflow'; + import { ConcurrencyQueue } from '../concurrency-queue'; describe('ConcurrencyQueue', () => { diff --git a/packages/cli/src/concurrency/concurrency-control.service.ts b/packages/cli/src/concurrency/concurrency-control.service.ts index 718de25b72f08..45ef2e120695c 100644 --- a/packages/cli/src/concurrency/concurrency-control.service.ts +++ b/packages/cli/src/concurrency/concurrency-control.service.ts @@ -1,14 +1,16 @@ -import { Logger } from '@/logger'; -import config from '@/config'; +import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; import { Service } from 'typedi'; -import { ConcurrencyQueue } from './concurrency-queue'; -import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error'; -import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error'; + +import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { WorkflowExecuteMode as ExecutionMode } from 'n8n-workflow'; +import { InvalidConcurrencyLimitError } from '@/errors/invalid-concurrency-limit.error'; +import { UnknownExecutionModeError } from '@/errors/unknown-execution-mode.error'; +import { EventService } from '@/events/event.service'; import type { IExecutingWorkflowData } from '@/interfaces'; +import { Logger } from '@/logger'; import { Telemetry } from '@/telemetry'; -import { EventService } from '@/events/event.service'; + +import { ConcurrencyQueue } from './concurrency-queue'; export const CLOUD_TEMP_PRODUCTION_LIMIT = 999; export const CLOUD_TEMP_REPORTABLE_THRESHOLDS = [5, 10, 20, 50, 100, 200]; diff --git a/packages/cli/src/concurrency/concurrency-queue.ts b/packages/cli/src/concurrency/concurrency-queue.ts index 51a689e6388ae..c4c482226c20a 100644 --- a/packages/cli/src/concurrency/concurrency-queue.ts +++ b/packages/cli/src/concurrency/concurrency-queue.ts @@ -1,4 +1,5 @@ import { Service } from 'typedi'; + import { TypedEmitter } from '@/typed-emitter'; type ConcurrencyEvents = { diff --git a/packages/cli/src/config/index.ts b/packages/cli/src/config/index.ts index dedc803839292..6661057b9a5e6 100644 --- a/packages/cli/src/config/index.ts +++ b/packages/cli/src/config/index.ts @@ -1,11 +1,12 @@ -import { Container } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import convict from 'convict'; import dotenv from 'dotenv'; -import { readFileSync } from 'fs'; import { flatten } from 'flat'; +import { readFileSync } from 'fs'; import merge from 'lodash/merge'; -import { GlobalConfig } from '@n8n/config'; import { ApplicationError, setGlobalState } from 'n8n-workflow'; +import colors from 'picocolors'; +import { Container } from 'typedi'; import { inTest, inE2ETests } from '@/constants'; @@ -104,7 +105,6 @@ if (userManagement.jwtRefreshTimeoutHours >= userManagement.jwtSessionDurationHo config.set('userManagement.jwtRefreshTimeoutHours', 0); } -import colors from 'picocolors'; const executionProcess = config.getEnv('executions.process'); if (executionProcess) { console.error( diff --git a/packages/cli/src/config/schema.ts b/packages/cli/src/config/schema.ts index d3334d4ab1c57..ec3d401b655e7 100644 --- a/packages/cli/src/config/schema.ts +++ b/packages/cli/src/config/schema.ts @@ -1,10 +1,11 @@ -import path from 'path'; +import { GlobalConfig } from '@n8n/config'; import convict from 'convict'; -import { Container } from 'typedi'; import { InstanceSettings } from 'n8n-core'; import { LOG_LEVELS } from 'n8n-workflow'; +import path from 'path'; +import { Container } from 'typedi'; + import { ensureStringArray } from './utils'; -import { GlobalConfig } from '@n8n/config'; convict.addFormat({ name: 'comma-separated-list', diff --git a/packages/cli/src/config/types.ts b/packages/cli/src/config/types.ts index c8f488903d20d..b1a4b22b98908 100644 --- a/packages/cli/src/config/types.ts +++ b/packages/cli/src/config/types.ts @@ -1,6 +1,7 @@ +import type { RedisOptions } from 'ioredis'; import type { BinaryData } from 'n8n-core'; + import type { schema } from './schema'; -import type { RedisOptions } from 'ioredis'; // ----------------------------------- // transformers diff --git a/packages/cli/src/config/utils.ts b/packages/cli/src/config/utils.ts index 918bd9b97e669..ad2c8300c3004 100644 --- a/packages/cli/src/config/utils.ts +++ b/packages/cli/src/config/utils.ts @@ -1,7 +1,8 @@ -import { NotStringArrayError } from '@/errors/not-string-array.error'; import type { SchemaObj } from 'convict'; import { ApplicationError } from 'n8n-workflow'; +import { NotStringArrayError } from '@/errors/not-string-array.error'; + export const ensureStringArray = (values: string[], { env }: SchemaObj) => { if (!env) throw new ApplicationError('Missing env', { extra: { env } }); diff --git a/packages/cli/src/constants.ts b/packages/cli/src/constants.ts index 045d5a30e1cba..447b32e42fc3f 100644 --- a/packages/cli/src/constants.ts +++ b/packages/cli/src/constants.ts @@ -1,7 +1,7 @@ import { readFileSync } from 'fs'; -import { resolve, join, dirname } from 'path'; import type { n8n } from 'n8n-core'; import { jsonParse } from 'n8n-workflow'; +import { resolve, join, dirname } from 'path'; const { NODE_ENV, E2E_TESTS } = process.env; export const inProduction = NODE_ENV === 'production'; diff --git a/packages/cli/src/controllers/__tests__/curl.controller.test.ts b/packages/cli/src/controllers/__tests__/curl.controller.test.ts index 35c263349e3e4..0c23d925e48d0 100644 --- a/packages/cli/src/controllers/__tests__/curl.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/curl.controller.test.ts @@ -1,7 +1,8 @@ import type { Request } from 'express'; import { mock } from 'jest-mock-extended'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; + import { CurlController } from '@/controllers/curl.controller'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import type { CurlService } from '@/services/curl.service'; describe('CurlController', () => { diff --git a/packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts b/packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts index aff34c70985ca..ff983cdd4ab77 100644 --- a/packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/dynamic-node-parameters.controller.test.ts @@ -1,9 +1,10 @@ +import { mock } from 'jest-mock-extended'; +import type { ILoadOptions, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; + import { DynamicNodeParametersController } from '@/controllers/dynamic-node-parameters.controller'; import type { DynamicNodeParametersRequest } from '@/requests'; import type { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service'; -import { mock } from 'jest-mock-extended'; import * as AdditionalData from '@/workflow-execute-additional-data'; -import type { ILoadOptions, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; describe('DynamicNodeParametersController', () => { const service = mock(); diff --git a/packages/cli/src/controllers/__tests__/me.controller.test.ts b/packages/cli/src/controllers/__tests__/me.controller.test.ts index 74bd4da987ff1..28640df7916dc 100644 --- a/packages/cli/src/controllers/__tests__/me.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/me.controller.test.ts @@ -1,25 +1,25 @@ import type { Response } from 'express'; -import { Container } from 'typedi'; -import jwt from 'jsonwebtoken'; import { mock, anyObject } from 'jest-mock-extended'; +import jwt from 'jsonwebtoken'; +import { Container } from 'typedi'; -import type { PublicUser } from '@/interfaces'; -import type { User } from '@/databases/entities/user'; -import { API_KEY_PREFIX, MeController } from '@/controllers/me.controller'; import { AUTH_COOKIE_NAME } from '@/constants'; -import type { AuthenticatedRequest, MeRequest } from '@/requests'; -import { UserService } from '@/services/user.service'; -import { ExternalHooks } from '@/external-hooks'; -import { License } from '@/license'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { EventService } from '@/events/event.service'; -import { badPasswords } from '@test/test-data'; -import { mockInstance } from '@test/mocking'; +import { API_KEY_PREFIX, MeController } from '@/controllers/me.controller'; +import type { User } from '@/databases/entities/user'; import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; import { InvalidAuthTokenRepository } from '@/databases/repositories/invalid-auth-token.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { MfaService } from '@/mfa/mfa.service'; +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 { mockInstance } from '@test/mocking'; +import { badPasswords } from '@test/test-data'; const browserId = 'test-browser-id'; diff --git a/packages/cli/src/controllers/__tests__/owner.controller.test.ts b/packages/cli/src/controllers/__tests__/owner.controller.test.ts index f8f313a58c9af..0fd42aae438f1 100644 --- a/packages/cli/src/controllers/__tests__/owner.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/owner.controller.test.ts @@ -1,7 +1,7 @@ -import Container from 'typedi'; import type { Response } from 'express'; import { anyObject, mock } from 'jest-mock-extended'; import jwt from 'jsonwebtoken'; +import Container from 'typedi'; import type { AuthService } from '@/auth/auth.service'; import config from '@/config'; @@ -12,9 +12,8 @@ import type { UserRepository } from '@/databases/repositories/user.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { License } from '@/license'; import type { OwnerRequest } from '@/requests'; -import type { UserService } from '@/services/user.service'; import { PasswordUtility } from '@/services/password.utility'; - +import type { UserService } from '@/services/user.service'; import { mockInstance } from '@test/mocking'; import { badPasswords } from '@test/test-data'; diff --git a/packages/cli/src/controllers/__tests__/translation.controller.test.ts b/packages/cli/src/controllers/__tests__/translation.controller.test.ts index 129a2f91a6b7b..5164ed820be93 100644 --- a/packages/cli/src/controllers/__tests__/translation.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/translation.controller.test.ts @@ -1,12 +1,13 @@ import { mock } from 'jest-mock-extended'; + import config from '@/config'; import type { TranslationRequest } from '@/controllers/translation.controller'; import { TranslationController, CREDENTIAL_TRANSLATIONS_DIR, } from '@/controllers/translation.controller'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import type { CredentialTypes } from '@/credential-types'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; describe('TranslationController', () => { const configGetSpy = jest.spyOn(config, 'getEnv'); diff --git a/packages/cli/src/controllers/__tests__/user-settings.controller.test.ts b/packages/cli/src/controllers/__tests__/user-settings.controller.test.ts index f12920eecc2da..6baca97d35912 100644 --- a/packages/cli/src/controllers/__tests__/user-settings.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/user-settings.controller.test.ts @@ -1,8 +1,9 @@ +import { mock } from 'jest-mock-extended'; +import type { NpsSurveyState } from 'n8n-workflow'; + import { UserSettingsController } from '@/controllers/user-settings.controller'; import type { NpsSurveyRequest } from '@/requests'; import type { UserService } from '@/services/user.service'; -import { mock } from 'jest-mock-extended'; -import type { NpsSurveyState } from 'n8n-workflow'; const NOW = 1717607016208; jest.useFakeTimers({ diff --git a/packages/cli/src/controllers/__tests__/users.controller.test.ts b/packages/cli/src/controllers/__tests__/users.controller.test.ts index a7c83b49255a9..216360651ec3c 100644 --- a/packages/cli/src/controllers/__tests__/users.controller.test.ts +++ b/packages/cli/src/controllers/__tests__/users.controller.test.ts @@ -1,11 +1,13 @@ import { mock } from 'jest-mock-extended'; -import { UsersController } from '../users.controller'; -import type { UserRequest } from '@/requests'; -import type { EventService } from '@/events/event.service'; + import type { User } from '@/databases/entities/user'; import type { UserRepository } from '@/databases/repositories/user.repository'; +import type { EventService } from '@/events/event.service'; +import type { UserRequest } from '@/requests'; import type { ProjectService } from '@/services/project.service'; +import { UsersController } from '../users.controller'; + describe('UsersController', () => { const eventService = mock(); const userRepository = mock(); diff --git a/packages/cli/src/controllers/ai-assistant.controller.ts b/packages/cli/src/controllers/ai-assistant.controller.ts index fb11e15d1aa35..c910be0a2461c 100644 --- a/packages/cli/src/controllers/ai-assistant.controller.ts +++ b/packages/cli/src/controllers/ai-assistant.controller.ts @@ -1,8 +1,8 @@ -import type { Response } from 'express'; import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; -import { WritableStream } from 'node:stream/web'; -import { strict as assert } from 'node:assert'; +import type { Response } from 'express'; import { ErrorReporterProxy } from 'n8n-workflow'; +import { strict as assert } from 'node:assert'; +import { WritableStream } from 'node:stream/web'; import { Post, RestController } from '@/decorators'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; diff --git a/packages/cli/src/controllers/annotation-tags.controller.ts b/packages/cli/src/controllers/annotation-tags.controller.ts index a66137d51748c..ff43c2ef7e229 100644 --- a/packages/cli/src/controllers/annotation-tags.controller.ts +++ b/packages/cli/src/controllers/annotation-tags.controller.ts @@ -1,6 +1,6 @@ import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators'; -import { AnnotationTagService } from '@/services/annotation-tag.service'; import { AnnotationTagsRequest } from '@/requests'; +import { AnnotationTagService } from '@/services/annotation-tag.service'; @RestController('/annotation-tags') export class AnnotationTagsController { diff --git a/packages/cli/src/controllers/auth.controller.ts b/packages/cli/src/controllers/auth.controller.ts index 0b9fb8c4c24fa..25f069ad20b72 100644 --- a/packages/cli/src/controllers/auth.controller.ts +++ b/packages/cli/src/controllers/auth.controller.ts @@ -1,29 +1,29 @@ -import validator from 'validator'; import { Response } from 'express'; +import { ApplicationError } from 'n8n-workflow'; +import validator from 'validator'; +import { handleEmailLogin, handleLdapLogin } from '@/auth'; import { AuthService } from '@/auth/auth.service'; -import { Get, Post, RestController } from '@/decorators'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import type { User } from '@/databases/entities/user'; -import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { Get, Post, RestController } from '@/decorators'; +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 { handleEmailLogin, handleLdapLogin } from '@/auth'; +import { License } from '@/license'; +import { Logger } from '@/logger'; +import { MfaService } from '@/mfa/mfa.service'; import { PostHogClient } from '@/posthog'; +import { AuthenticatedRequest, LoginRequest, UserRequest } from '@/requests'; +import { UserService } from '@/services/user.service'; import { getCurrentAuthenticationMethod, isLdapCurrentAuthenticationMethod, isSamlCurrentAuthenticationMethod, } from '@/sso/sso-helpers'; -import { License } from '@/license'; -import { UserService } from '@/services/user.service'; -import { MfaService } from '@/mfa/mfa.service'; -import { Logger } from '@/logger'; -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 { ApplicationError } from 'n8n-workflow'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { EventService } from '@/events/event.service'; @RestController() export class AuthController { diff --git a/packages/cli/src/controllers/binary-data.controller.ts b/packages/cli/src/controllers/binary-data.controller.ts index 63390f46ab989..ecf3460be0568 100644 --- a/packages/cli/src/controllers/binary-data.controller.ts +++ b/packages/cli/src/controllers/binary-data.controller.ts @@ -1,5 +1,6 @@ import express from 'express'; import { BinaryDataService, FileNotFoundError, isValidNonDefaultMode } from 'n8n-core'; + import { Get, RestController } from '@/decorators'; import { BinaryDataRequest } from '@/requests'; diff --git a/packages/cli/src/controllers/community-packages.controller.ts b/packages/cli/src/controllers/community-packages.controller.ts index a947fd668f2aa..5caf835f60a9c 100644 --- a/packages/cli/src/controllers/community-packages.controller.ts +++ b/packages/cli/src/controllers/community-packages.controller.ts @@ -3,15 +3,15 @@ import { STARTER_TEMPLATE_NAME, UNKNOWN_FAILURE_REASON, } from '@/constants'; -import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators'; -import { NodeRequest } from '@/requests'; import type { InstalledPackages } from '@/databases/entities/installed-packages'; -import type { CommunityPackages } from '@/interfaces'; -import { Push } from '@/push'; -import { CommunityPackagesService } from '@/services/community-packages.service'; +import { Delete, Get, Patch, Post, RestController, GlobalScope } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; +import type { CommunityPackages } from '@/interfaces'; +import { Push } from '@/push'; +import { NodeRequest } from '@/requests'; +import { CommunityPackagesService } from '@/services/community-packages.service'; const { PACKAGE_NOT_INSTALLED, diff --git a/packages/cli/src/controllers/cta.controller.ts b/packages/cli/src/controllers/cta.controller.ts index 5cd41a1dcd810..bea2476163aa8 100644 --- a/packages/cli/src/controllers/cta.controller.ts +++ b/packages/cli/src/controllers/cta.controller.ts @@ -1,4 +1,5 @@ import express from 'express'; + import { Get, RestController } from '@/decorators'; import { AuthenticatedRequest } from '@/requests'; import { CtaService } from '@/services/cta.service'; diff --git a/packages/cli/src/controllers/curl.controller.ts b/packages/cli/src/controllers/curl.controller.ts index 91338b3eadc26..e7a12b831f2af 100644 --- a/packages/cli/src/controllers/curl.controller.ts +++ b/packages/cli/src/controllers/curl.controller.ts @@ -1,4 +1,5 @@ import { Request } from 'express'; + import { Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { CurlService, flattenObject } from '@/services/curl.service'; diff --git a/packages/cli/src/controllers/debug.controller.ts b/packages/cli/src/controllers/debug.controller.ts index 3b340aad7e2a3..9fd2b067d317f 100644 --- a/packages/cli/src/controllers/debug.controller.ts +++ b/packages/cli/src/controllers/debug.controller.ts @@ -1,7 +1,7 @@ -import { Get, RestController } from '@/decorators'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { OrchestrationService } from '@/services/orchestration.service'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { Get, RestController } from '@/decorators'; +import { OrchestrationService } from '@/services/orchestration.service'; @RestController('/debug') export class DebugController { diff --git a/packages/cli/src/controllers/dynamic-node-parameters.controller.ts b/packages/cli/src/controllers/dynamic-node-parameters.controller.ts index 3ce7dd1a3a79c..f3df53d95b0e1 100644 --- a/packages/cli/src/controllers/dynamic-node-parameters.controller.ts +++ b/packages/cli/src/controllers/dynamic-node-parameters.controller.ts @@ -1,10 +1,10 @@ import type { INodePropertyOptions, NodeParameterValueType } from 'n8n-workflow'; import { Post, RestController } from '@/decorators'; -import { getBase } from '@/workflow-execute-additional-data'; -import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service'; -import { DynamicNodeParametersRequest } from '@/requests'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { DynamicNodeParametersRequest } from '@/requests'; +import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service'; +import { getBase } from '@/workflow-execute-additional-data'; @RestController('/dynamic-node-parameters') export class DynamicNodeParametersController { diff --git a/packages/cli/src/controllers/e2e.controller.ts b/packages/cli/src/controllers/e2e.controller.ts index 8e1434b9b4db9..7a132401d1d65 100644 --- a/packages/cli/src/controllers/e2e.controller.ts +++ b/packages/cli/src/controllers/e2e.controller.ts @@ -1,22 +1,23 @@ import { Request } from 'express'; +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; + +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; +import { LICENSE_FEATURES, LICENSE_QUOTAS, UNLIMITED_LICENSE_QUOTA, inE2ETests } from '@/constants'; +import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import { License } from '@/license'; -import { LICENSE_FEATURES, LICENSE_QUOTAS, UNLIMITED_LICENSE_QUOTA, inE2ETests } from '@/constants'; import { Patch, Post, RestController } from '@/decorators'; -import type { UserSetupPayload } from '@/requests'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import type { BooleanLicenseFeature, IPushDataType, NumericLicenseFeature } from '@/interfaces'; +import { License } from '@/license'; +import { Logger } from '@/logger'; import { MfaService } from '@/mfa/mfa.service'; import { Push } from '@/push'; +import type { UserSetupPayload } from '@/requests'; import { CacheService } from '@/services/cache/cache.service'; import { PasswordUtility } from '@/services/password.utility'; -import Container from 'typedi'; -import { Logger } from '@/logger'; -import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; if (!inE2ETests) { Container.get(Logger).error('E2E endpoints only allowed during E2E tests'); diff --git a/packages/cli/src/controllers/invitation.controller.ts b/packages/cli/src/controllers/invitation.controller.ts index 259bef0061ccb..411ab7a03f4b9 100644 --- a/packages/cli/src/controllers/invitation.controller.ts +++ b/packages/cli/src/controllers/invitation.controller.ts @@ -3,21 +3,21 @@ import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; import config from '@/config'; -import { Post, GlobalScope, RestController } from '@/decorators'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; -import { UserRequest } from '@/requests'; -import { License } from '@/license'; -import { UserService } from '@/services/user.service'; -import { Logger } from '@/logger'; -import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; -import { PasswordUtility } from '@/services/password.utility'; -import { PostHogClient } from '@/posthog'; import type { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; +import { Post, GlobalScope, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; -import { ExternalHooks } from '@/external-hooks'; import { EventService } from '@/events/event.service'; +import { ExternalHooks } from '@/external-hooks'; +import { License } from '@/license'; +import { Logger } from '@/logger'; +import { PostHogClient } from '@/posthog'; +import { UserRequest } from '@/requests'; +import { PasswordUtility } from '@/services/password.utility'; +import { UserService } from '@/services/user.service'; +import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; @RestController('/invitations') export class InvitationController { diff --git a/packages/cli/src/controllers/me.controller.ts b/packages/cli/src/controllers/me.controller.ts index e571420d8de93..f42b63e4dfcb9 100644 --- a/packages/cli/src/controllers/me.controller.ts +++ b/packages/cli/src/controllers/me.controller.ts @@ -1,30 +1,31 @@ -import validator from 'validator'; import { plainToInstance } from 'class-transformer'; -import { type RequestHandler, Response } from 'express'; import { randomBytes } from 'crypto'; +import { type RequestHandler, Response } from 'express'; +import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; +import type { User } from '@/databases/entities/user'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { Delete, Get, Patch, Post, RestController } from '@/decorators'; -import { PasswordUtility } from '@/services/password.utility'; +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 { validateEntity } from '@/generic-helpers'; -import type { User } from '@/databases/entities/user'; +import type { PublicUser } from '@/interfaces'; +import { Logger } from '@/logger'; +import { MfaService } from '@/mfa/mfa.service'; +import { isApiEnabled } from '@/public-api'; import { AuthenticatedRequest, MeRequest, UserSettingsUpdatePayload, UserUpdatePayload, } from '@/requests'; -import type { PublicUser } from '@/interfaces'; -import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; +import { PasswordUtility } from '@/services/password.utility'; import { UserService } from '@/services/user.service'; -import { Logger } from '@/logger'; -import { ExternalHooks } from '@/external-hooks'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { isApiEnabled } from '@/public-api'; -import { EventService } from '@/events/event.service'; -import { MfaService } from '@/mfa/mfa.service'; -import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error'; +import { isSamlLicensedAndEnabled } from '@/sso/saml/saml-helpers'; + import { PersonalizationSurveyAnswersV4 } from './survey-answers.dto'; export const API_KEY_PREFIX = 'n8n_api_'; diff --git a/packages/cli/src/controllers/mfa.controller.ts b/packages/cli/src/controllers/mfa.controller.ts index 3d10736a1ac3e..f0af1032655fb 100644 --- a/packages/cli/src/controllers/mfa.controller.ts +++ b/packages/cli/src/controllers/mfa.controller.ts @@ -1,7 +1,7 @@ import { Get, Post, RestController } from '@/decorators'; -import { AuthenticatedRequest, MFA } from '@/requests'; -import { MfaService } from '@/mfa/mfa.service'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { MfaService } from '@/mfa/mfa.service'; +import { AuthenticatedRequest, MFA } from '@/requests'; @RestController('/mfa') export class MFAController { diff --git a/packages/cli/src/controllers/node-types.controller.ts b/packages/cli/src/controllers/node-types.controller.ts index 122b9f1fbdbdc..b8c50eb61d128 100644 --- a/packages/cli/src/controllers/node-types.controller.ts +++ b/packages/cli/src/controllers/node-types.controller.ts @@ -1,9 +1,10 @@ +import { Request } from 'express'; import { readFile } from 'fs/promises'; import get from 'lodash/get'; -import { Request } from 'express'; import type { INodeTypeDescription, INodeTypeNameVersion } from 'n8n-workflow'; -import { Post, RestController } from '@/decorators'; + import config from '@/config'; +import { Post, RestController } from '@/decorators'; import { NodeTypes } from '@/node-types'; @RestController('/node-types') diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts index 8eb93d5e46ab3..b2c0d13f21c65 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth1-credential.controller.test.ts @@ -1,24 +1,23 @@ -import nock from 'nock'; -import Container from 'typedi'; -import type { Response } from 'express'; import Csrf from 'csrf'; -import { Cipher } from 'n8n-core'; +import type { Response } from 'express'; import { mock } from 'jest-mock-extended'; +import { Cipher } from 'n8n-core'; +import nock from 'nock'; +import Container from 'typedi'; import { OAuth1CredentialController } from '@/controllers/oauth/oauth1-credential.controller'; +import { CredentialsHelper } from '@/credentials-helper'; import { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { User } from '@/databases/entities/user'; -import type { OAuthRequest } from '@/requests'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logger'; import { VariablesService } from '@/environments/variables/variables.service.ee'; -import { SecretsHelper } from '@/secrets-helpers'; -import { CredentialsHelper } from '@/credentials-helper'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; - +import { ExternalHooks } from '@/external-hooks'; +import { Logger } from '@/logger'; +import type { OAuthRequest } from '@/requests'; +import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; describe('OAuth1CredentialController', () => { diff --git a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts index 09c64a76b3077..139ab9a9834d3 100644 --- a/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts +++ b/packages/cli/src/controllers/oauth/__tests__/oauth2-credential.controller.test.ts @@ -1,24 +1,23 @@ -import nock from 'nock'; -import Container from 'typedi'; import Csrf from 'csrf'; import { type Response } from 'express'; -import { Cipher } from 'n8n-core'; import { mock } from 'jest-mock-extended'; +import { Cipher } from 'n8n-core'; +import nock from 'nock'; +import Container from 'typedi'; import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller'; +import { CredentialsHelper } from '@/credentials-helper'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { User } from '@/databases/entities/user'; -import type { OAuthRequest } from '@/requests'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { ExternalHooks } from '@/external-hooks'; -import { Logger } from '@/logger'; import { VariablesService } from '@/environments/variables/variables.service.ee'; -import { SecretsHelper } from '@/secrets-helpers'; -import { CredentialsHelper } from '@/credentials-helper'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; - +import { ExternalHooks } from '@/external-hooks'; +import { Logger } from '@/logger'; +import type { OAuthRequest } from '@/requests'; +import { SecretsHelper } from '@/secrets-helpers'; import { mockInstance } from '@test/mocking'; describe('OAuth2CredentialController', () => { diff --git a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts index 6ec5fffae9611..6750c7c2a3070 100644 --- a/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts +++ b/packages/cli/src/controllers/oauth/abstract-oauth.controller.ts @@ -1,24 +1,24 @@ -import { Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import Csrf from 'csrf'; import type { Response } from 'express'; import { Credentials } from 'n8n-core'; import type { ICredentialDataDecryptedObject, IWorkflowExecuteAdditionalData } from 'n8n-workflow'; import { jsonParse, ApplicationError } from 'n8n-workflow'; +import { Service } from 'typedi'; +import { RESPONSE_ERROR_MESSAGES } from '@/constants'; +import { CredentialsHelper } from '@/credentials-helper'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +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 { OAuthRequest } from '@/requests'; -import { RESPONSE_ERROR_MESSAGES } from '@/constants'; -import { CredentialsHelper } from '@/credentials-helper'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; import { Logger } from '@/logger'; -import { ExternalHooks } from '@/external-hooks'; +import type { OAuthRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { GlobalConfig } from '@n8n/config'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; export interface CsrfStateParam { cid: string; diff --git a/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts b/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts index 5ec036a2aaa98..1d21c2f33278a 100644 --- a/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts +++ b/packages/cli/src/controllers/oauth/oauth1-credential.controller.ts @@ -1,14 +1,16 @@ -import { Response } from 'express'; import type { AxiosRequestConfig } from 'axios'; import axios from 'axios'; +import { createHmac } from 'crypto'; +import { Response } from 'express'; import type { RequestOptions } from 'oauth-1.0a'; import clientOAuth1 from 'oauth-1.0a'; -import { createHmac } from 'crypto'; + import { Get, RestController } from '@/decorators'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { OAuthRequest } from '@/requests'; import { sendErrorResponse } from '@/response-helper'; + import { AbstractOAuthController, type CsrfStateParam } from './abstract-oauth.controller'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; interface OAuth1CredentialData { signatureMethod: 'HMAC-SHA256' | 'HMAC-SHA512' | 'HMAC-SHA1'; diff --git a/packages/cli/src/controllers/oauth/oauth2-credential.controller.ts b/packages/cli/src/controllers/oauth/oauth2-credential.controller.ts index 5e2d3a0fb2476..fdce783c6eb0d 100644 --- a/packages/cli/src/controllers/oauth/oauth2-credential.controller.ts +++ b/packages/cli/src/controllers/oauth/oauth2-credential.controller.ts @@ -1,14 +1,16 @@ import type { ClientOAuth2Options, OAuth2CredentialData } from '@n8n/client-oauth2'; import { ClientOAuth2 } from '@n8n/client-oauth2'; import { Response } from 'express'; -import pkceChallenge from 'pkce-challenge'; -import * as qs from 'querystring'; import omit from 'lodash/omit'; import set from 'lodash/set'; import split from 'lodash/split'; -import { Get, RestController } from '@/decorators'; import { jsonStringify } from 'n8n-workflow'; +import pkceChallenge from 'pkce-challenge'; +import * as qs from 'querystring'; + +import { Get, RestController } from '@/decorators'; import { OAuthRequest } from '@/requests'; + import { AbstractOAuthController, type CsrfStateParam } from './abstract-oauth.controller'; import { GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE as GENERIC_OAUTH2_CREDENTIALS_WITH_EDITABLE_SCOPE } from '../../constants'; diff --git a/packages/cli/src/controllers/orchestration.controller.ts b/packages/cli/src/controllers/orchestration.controller.ts index 852d6f7cc3f27..a5235d1169604 100644 --- a/packages/cli/src/controllers/orchestration.controller.ts +++ b/packages/cli/src/controllers/orchestration.controller.ts @@ -1,7 +1,7 @@ import { Post, RestController, GlobalScope } from '@/decorators'; +import { License } from '@/license'; import { OrchestrationRequest } from '@/requests'; import { OrchestrationService } from '@/services/orchestration.service'; -import { License } from '@/license'; @RestController('/orchestration') export class OrchestrationController { diff --git a/packages/cli/src/controllers/owner.controller.ts b/packages/cli/src/controllers/owner.controller.ts index 5f464e2bba6e9..76a0191359a1f 100644 --- a/packages/cli/src/controllers/owner.controller.ts +++ b/packages/cli/src/controllers/owner.controller.ts @@ -1,19 +1,19 @@ -import validator from 'validator'; import { Response } from 'express'; +import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; import config from '@/config'; -import { validateEntity } from '@/generic-helpers'; -import { GlobalScope, Post, RestController } from '@/decorators'; -import { PasswordUtility } from '@/services/password.utility'; -import { OwnerRequest } from '@/requests'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { PostHogClient } from '@/posthog'; -import { UserService } from '@/services/user.service'; -import { Logger } from '@/logger'; +import { GlobalScope, Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { EventService } from '@/events/event.service'; +import { validateEntity } from '@/generic-helpers'; +import { Logger } from '@/logger'; +import { PostHogClient } from '@/posthog'; +import { OwnerRequest } from '@/requests'; +import { PasswordUtility } from '@/services/password.utility'; +import { UserService } from '@/services/user.service'; @RestController('/owner') export class OwnerController { diff --git a/packages/cli/src/controllers/password-reset.controller.ts b/packages/cli/src/controllers/password-reset.controller.ts index 22fb5d55a3fa1..ed566cf129c30 100644 --- a/packages/cli/src/controllers/password-reset.controller.ts +++ b/packages/cli/src/controllers/password-reset.controller.ts @@ -2,24 +2,24 @@ import { Response } from 'express'; import validator from 'validator'; import { AuthService } from '@/auth/auth.service'; -import { Get, Post, RestController } from '@/decorators'; -import { PasswordUtility } from '@/services/password.utility'; -import { UserManagementMailer } from '@/user-management/email'; -import { PasswordResetRequest } from '@/requests'; -import { isSamlCurrentAuthenticationMethod } from '@/sso/sso-helpers'; -import { UserService } from '@/services/user.service'; -import { License } from '@/license'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; -import { MfaService } from '@/mfa/mfa.service'; -import { Logger } from '@/logger'; -import { ExternalHooks } from '@/external-hooks'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { Get, Post, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { EventService } from '@/events/event.service'; +import { ExternalHooks } from '@/external-hooks'; +import { License } from '@/license'; +import { Logger } from '@/logger'; +import { MfaService } from '@/mfa/mfa.service'; +import { PasswordResetRequest } from '@/requests'; +import { PasswordUtility } from '@/services/password.utility'; +import { UserService } from '@/services/user.service'; +import { isSamlCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { UserManagementMailer } from '@/user-management/email'; @RestController() export class PasswordResetController { diff --git a/packages/cli/src/controllers/project.controller.ts b/packages/cli/src/controllers/project.controller.ts index 9c3311af064f0..415e0e9519130 100644 --- a/packages/cli/src/controllers/project.controller.ts +++ b/packages/cli/src/controllers/project.controller.ts @@ -1,4 +1,10 @@ +import { combineScopes } from '@n8n/permissions'; +import type { Scope } from '@n8n/permissions'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In, Not } from '@n8n/typeorm'; + import type { Project } from '@/databases/entities/project'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { Get, Post, @@ -9,21 +15,16 @@ import { ProjectScope, Delete, } from '@/decorators'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { EventService } from '@/events/event.service'; import { ProjectRequest } from '@/requests'; import { ProjectService, TeamProjectOverQuotaError, UnlicensedProjectRoleError, } from '@/services/project.service'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { combineScopes } from '@n8n/permissions'; -import type { Scope } from '@n8n/permissions'; import { RoleService } from '@/services/role.service'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In, Not } from '@n8n/typeorm'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { EventService } from '@/events/event.service'; @RestController('/projects') export class ProjectController { diff --git a/packages/cli/src/controllers/survey-answers.dto.ts b/packages/cli/src/controllers/survey-answers.dto.ts index 25d9bfacfc87f..1b0e94d1a8876 100644 --- a/packages/cli/src/controllers/survey-answers.dto.ts +++ b/packages/cli/src/controllers/survey-answers.dto.ts @@ -1,8 +1,9 @@ -import { NoXss } from '@/validators/no-xss.validator'; import { Expose } from 'class-transformer'; import { IsString, IsArray, IsOptional, IsEmail, IsEnum } from 'class-validator'; import type { IPersonalizationSurveyAnswersV4 } from 'n8n-workflow'; +import { NoXss } from '@/validators/no-xss.validator'; + export class PersonalizationSurveyAnswersV4 implements IPersonalizationSurveyAnswersV4 { @NoXss() @Expose() diff --git a/packages/cli/src/controllers/tags.controller.ts b/packages/cli/src/controllers/tags.controller.ts index beaf1e56e70d4..a6551a021d2e7 100644 --- a/packages/cli/src/controllers/tags.controller.ts +++ b/packages/cli/src/controllers/tags.controller.ts @@ -1,9 +1,10 @@ import { Request, Response, NextFunction } from 'express'; + import config from '@/config'; import { Delete, Get, Middleware, Patch, Post, RestController, GlobalScope } from '@/decorators'; -import { TagService } from '@/services/tag.service'; -import { TagsRequest } from '@/requests'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { TagsRequest } from '@/requests'; +import { TagService } from '@/services/tag.service'; @RestController('/tags') export class TagsController { diff --git a/packages/cli/src/controllers/translation.controller.ts b/packages/cli/src/controllers/translation.controller.ts index 03a8c3b035763..485e290cad719 100644 --- a/packages/cli/src/controllers/translation.controller.ts +++ b/packages/cli/src/controllers/translation.controller.ts @@ -1,12 +1,13 @@ import type { Request } from 'express'; -import { join } from 'path'; import { access } from 'fs/promises'; -import { Get, RestController } from '@/decorators'; +import { join } from 'path'; + import config from '@/config'; import { NODES_BASE_DIR } from '@/constants'; +import { CredentialTypes } from '@/credential-types'; +import { Get, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; -import { CredentialTypes } from '@/credential-types'; export const CREDENTIAL_TRANSLATIONS_DIR = 'n8n-nodes-base/dist/credentials/translations'; export const NODE_HEADERS_PATH = join(NODES_BASE_DIR, 'dist/nodes/headers'); diff --git a/packages/cli/src/controllers/user-settings.controller.ts b/packages/cli/src/controllers/user-settings.controller.ts index aff1415710b8f..7b0fede08c415 100644 --- a/packages/cli/src/controllers/user-settings.controller.ts +++ b/packages/cli/src/controllers/user-settings.controller.ts @@ -1,8 +1,9 @@ +import type { NpsSurveyState } from 'n8n-workflow'; + import { Patch, RestController } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NpsSurveyRequest } from '@/requests'; import { UserService } from '@/services/user.service'; -import type { NpsSurveyState } from 'n8n-workflow'; function getNpsSurveyState(state: unknown): NpsSurveyState | undefined { if (typeof state !== 'object' || state === null) { diff --git a/packages/cli/src/controllers/users.controller.ts b/packages/cli/src/controllers/users.controller.ts index 567b44bc719ab..7124013354654 100644 --- a/packages/cli/src/controllers/users.controller.ts +++ b/packages/cli/src/controllers/users.controller.ts @@ -1,33 +1,33 @@ import { plainToInstance } from 'class-transformer'; import { AuthService } from '@/auth/auth.service'; +import { CredentialsService } from '@/credentials/credentials.service'; +import { AuthIdentity } from '@/databases/entities/auth-identity'; +import { Project } from '@/databases/entities/project'; import { User } from '@/databases/entities/user'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { GlobalScope, Delete, Get, RestController, Patch, Licensed } from '@/decorators'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +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 { validateEntity } from '@/generic-helpers'; +import type { PublicUser } from '@/interfaces'; +import { Logger } from '@/logger'; +import { listQueryMiddleware } from '@/middlewares'; import { ListQuery, UserRequest, UserRoleChangePayload, UserSettingsUpdatePayload, } from '@/requests'; -import type { PublicUser } from '@/interfaces'; -import { AuthIdentity } from '@/databases/entities/auth-identity'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { UserRepository } from '@/databases/repositories/user.repository'; +import { ProjectService } from '@/services/project.service'; import { UserService } from '@/services/user.service'; -import { listQueryMiddleware } from '@/middlewares'; -import { Logger } from '@/logger'; -import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { ExternalHooks } from '@/external-hooks'; -import { validateEntity } from '@/generic-helpers'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { Project } from '@/databases/entities/project'; import { WorkflowService } from '@/workflows/workflow.service'; -import { CredentialsService } from '@/credentials/credentials.service'; -import { ProjectService } from '@/services/project.service'; -import { EventService } from '@/events/event.service'; @RestController('/users') export class UsersController { diff --git a/packages/cli/src/controllers/workflow-statistics.controller.ts b/packages/cli/src/controllers/workflow-statistics.controller.ts index dd8207ed5a0c6..1268643b146e2 100644 --- a/packages/cli/src/controllers/workflow-statistics.controller.ts +++ b/packages/cli/src/controllers/workflow-statistics.controller.ts @@ -1,12 +1,14 @@ import { Response, NextFunction } from 'express'; -import { Get, Middleware, RestController } from '@/decorators'; + import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; +import { Get, Middleware, RestController } from '@/decorators'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; import type { IWorkflowStatisticsDataLoaded } from '@/interfaces'; import { Logger } from '@/logger'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; + import { StatisticsRequest } from './workflow-statistics.types'; interface WorkflowStatisticsData { diff --git a/packages/cli/src/crash-journal.ts b/packages/cli/src/crash-journal.ts index dcba654a3d8a8..184702c44673f 100644 --- a/packages/cli/src/crash-journal.ts +++ b/packages/cli/src/crash-journal.ts @@ -1,9 +1,10 @@ import { existsSync } from 'fs'; import { mkdir, utimes, open, rm } from 'fs/promises'; -import { join, dirname } from 'path'; -import { Container } from 'typedi'; import { InstanceSettings } from 'n8n-core'; import { sleep } from 'n8n-workflow'; +import { join, dirname } from 'path'; +import { Container } from 'typedi'; + import { inProduction } from '@/constants'; import { Logger } from '@/logger'; diff --git a/packages/cli/src/credential-types.ts b/packages/cli/src/credential-types.ts index 8d665c75923c2..24e2d9f2bac4f 100644 --- a/packages/cli/src/credential-types.ts +++ b/packages/cli/src/credential-types.ts @@ -1,4 +1,3 @@ -import { Service } from 'typedi'; import { loadClassInIsolation } from 'n8n-core'; import { ApplicationError, @@ -6,6 +5,8 @@ import { type ICredentialTypes, type LoadedClass, } from 'n8n-workflow'; +import { Service } from 'typedi'; + import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; diff --git a/packages/cli/src/credentials-helper.ts b/packages/cli/src/credentials-helper.ts index bb65a94750c1f..e57ad2c6d3265 100644 --- a/packages/cli/src/credentials-helper.ts +++ b/packages/cli/src/credentials-helper.ts @@ -2,9 +2,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ -import { Service } from 'typedi'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In } from '@n8n/typeorm'; import { Credentials, NodeExecuteFunctions } from 'n8n-core'; - import type { ICredentialDataDecryptedObject, ICredentialsExpressionResolveValues, @@ -26,19 +26,17 @@ import type { IDataObject, } from 'n8n-workflow'; import { ICredentialsHelper, NodeHelpers, Workflow, ApplicationError } from 'n8n-workflow'; +import { Service } from 'typedi'; -import type { ICredentialsDb } from '@/interfaces'; - -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { CredentialTypes } from '@/credential-types'; import { CredentialsOverwrites } from '@/credentials-overwrites'; -import { RESPONSE_ERROR_MESSAGES } from './constants'; - +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 { RESPONSE_ERROR_MESSAGES } from './constants'; import { CredentialNotFoundError } from './errors/credential-not-found.error'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In } from '@n8n/typeorm'; import { CacheService } from './services/cache/cache.service'; const mockNode = { diff --git a/packages/cli/src/credentials-overwrites.ts b/packages/cli/src/credentials-overwrites.ts index 79a641e4d689a..ec14bf7eccd61 100644 --- a/packages/cli/src/credentials-overwrites.ts +++ b/packages/cli/src/credentials-overwrites.ts @@ -1,9 +1,10 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import { deepCopy, jsonParse } from 'n8n-workflow'; -import type { ICredentialsOverwrite } from '@/interfaces'; +import { Service } from 'typedi'; + import { CredentialTypes } from '@/credential-types'; +import type { ICredentialsOverwrite } from '@/interfaces'; import { Logger } from '@/logger'; @Service() diff --git a/packages/cli/src/credentials/__tests__/credentials.service.test.ts b/packages/cli/src/credentials/__tests__/credentials.service.test.ts index 12bf0b615762a..4d1cbd5256ca3 100644 --- a/packages/cli/src/credentials/__tests__/credentials.service.test.ts +++ b/packages/cli/src/credentials/__tests__/credentials.service.test.ts @@ -1,9 +1,10 @@ -import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow'; import { mock } from 'jest-mock-extended'; +import { CREDENTIAL_EMPTY_VALUE, type ICredentialType } from 'n8n-workflow'; + import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { CredentialTypes } from '@/credential-types'; import { CredentialsService } from '@/credentials/credentials.service'; +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; describe('CredentialsService', () => { const credType = mock({ diff --git a/packages/cli/src/credentials/credentials.controller.ts b/packages/cli/src/credentials/credentials.controller.ts index adb22d6169f1a..41d9d163baa35 100644 --- a/packages/cli/src/credentials/credentials.controller.ts +++ b/packages/cli/src/credentials/credentials.controller.ts @@ -1,16 +1,13 @@ -import { deepCopy } from 'n8n-workflow'; import { GlobalConfig } from '@n8n/config'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { deepCopy } from 'n8n-workflow'; +import { z } from 'zod'; -import { CredentialsService } from './credentials.service'; -import { CredentialRequest } from '@/requests'; -import { Logger } from '@/logger'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; -import { NamingService } from '@/services/naming.service'; -import { License } from '@/license'; -import { EnterpriseCredentialsService } from './credentials.service.ee'; +import { SharedCredentials } from '@/databases/entities/shared-credentials'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import * as Db from '@/db'; import { Delete, Get, @@ -22,15 +19,19 @@ import { ProjectScope, } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { EventService } from '@/events/event.service'; +import { License } from '@/license'; +import { Logger } from '@/logger'; +import { listQueryMiddleware } from '@/middlewares'; +import { CredentialRequest } from '@/requests'; +import { NamingService } from '@/services/naming.service'; import { UserManagementMailer } from '@/user-management/email'; -import * as Db from '@/db'; import * as utils from '@/utils'; -import { listQueryMiddleware } from '@/middlewares'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { SharedCredentials } from '@/databases/entities/shared-credentials'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import { z } from 'zod'; -import { EventService } from '@/events/event.service'; + +import { CredentialsService } from './credentials.service'; +import { EnterpriseCredentialsService } from './credentials.service.ee'; @RestController('/credentials') export class CredentialsController { diff --git a/packages/cli/src/credentials/credentials.service.ee.ts b/packages/cli/src/credentials/credentials.service.ee.ts index 3f42d3bff8c3f..116137374acf9 100644 --- a/packages/cli/src/credentials/credentials.service.ee.ts +++ b/packages/cli/src/credentials/credentials.service.ee.ts @@ -1,19 +1,21 @@ // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In, type EntityManager } from '@n8n/typeorm'; +import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; +import { Service } from 'typedi'; + +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import { Project } from '@/databases/entities/project'; +import { SharedCredentials } from '@/databases/entities/shared-credentials'; import type { User } from '@/databases/entities/user'; -import { CredentialsService } from './credentials.service'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; -import { Service } from 'typedi'; -import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { TransferCredentialError } from '@/errors/response-errors/transfer-credential.error'; import { OwnershipService } from '@/services/ownership.service'; -import { Project } from '@/databases/entities/project'; import { ProjectService } from '@/services/project.service'; -import { TransferCredentialError } from '@/errors/response-errors/transfer-credential.error'; -import { SharedCredentials } from '@/databases/entities/shared-credentials'; import { RoleService } from '@/services/role.service'; +import { CredentialsService } from './credentials.service'; + @Service() export class EnterpriseCredentialsService { constructor( diff --git a/packages/cli/src/credentials/credentials.service.ts b/packages/cli/src/credentials/credentials.service.ts index edfb1f4e6f5c7..43041a84b11ae 100644 --- a/packages/cli/src/credentials/credentials.service.ts +++ b/packages/cli/src/credentials/credentials.service.ts @@ -1,3 +1,11 @@ +import type { Scope } from '@n8n/permissions'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { + In, + type EntityManager, + type FindOptionsRelations, + type FindOptionsWhere, +} from '@n8n/typeorm'; import { Credentials } from 'n8n-core'; import type { ICredentialDataDecryptedObject, @@ -6,39 +14,32 @@ import type { INodeProperties, } from 'n8n-workflow'; import { ApplicationError, CREDENTIAL_EMPTY_VALUE, deepCopy, NodeHelpers } from 'n8n-workflow'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { - In, - type EntityManager, - type FindOptionsRelations, - type FindOptionsWhere, -} from '@n8n/typeorm'; -import type { Scope } from '@n8n/permissions'; -import * as Db from '@/db'; -import type { ICredentialsDb } from '@/interfaces'; -import { createCredentialsFromCredentialsEntity } from '@/credentials-helper'; +import { Service } from 'typedi'; + import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; +import { CredentialTypes } from '@/credential-types'; +import { createCredentialsFromCredentialsEntity } from '@/credentials-helper'; import { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { ProjectRelation } from '@/databases/entities/project-relation'; import { SharedCredentials } from '@/databases/entities/shared-credentials'; -import { validateEntity } from '@/generic-helpers'; -import { ExternalHooks } from '@/external-hooks'; import type { User } from '@/databases/entities/user'; -import type { CredentialRequest, ListQuery } from '@/requests'; -import { CredentialTypes } from '@/credential-types'; -import { OwnershipService } from '@/services/ownership.service'; -import { Logger } from '@/logger'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { Service } from 'typedi'; -import { CredentialsTester } from '@/services/credentials-tester.service'; import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { ProjectService } from '@/services/project.service'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import * as Db from '@/db'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { ProjectRelation } from '@/databases/entities/project-relation'; -import { RoleService } from '@/services/role.service'; -import { UserRepository } from '@/databases/repositories/user.repository'; +import { ExternalHooks } from '@/external-hooks'; +import { validateEntity } from '@/generic-helpers'; +import type { ICredentialsDb } from '@/interfaces'; +import { Logger } from '@/logger'; import { userHasScope } from '@/permissions/check-access'; +import type { CredentialRequest, ListQuery } from '@/requests'; +import { CredentialsTester } from '@/services/credentials-tester.service'; +import { OwnershipService } from '@/services/ownership.service'; +import { ProjectService } from '@/services/project.service'; +import { RoleService } from '@/services/role.service'; export type CredentialsGetSharedOptions = | { allowGlobalScope: true; globalScope: Scope } diff --git a/packages/cli/src/databases/config.ts b/packages/cli/src/databases/config.ts index 51c1c43842ed7..8845bd0b13f66 100644 --- a/packages/cli/src/databases/config.ts +++ b/packages/cli/src/databases/config.ts @@ -1,20 +1,20 @@ -import path from 'path'; -import { Container } from 'typedi'; -import type { TlsOptions } from 'tls'; +import { GlobalConfig } from '@n8n/config'; import type { DataSourceOptions, LoggerOptions } from '@n8n/typeorm'; +import type { MysqlConnectionOptions } from '@n8n/typeorm/driver/mysql/MysqlConnectionOptions'; +import type { PostgresConnectionOptions } from '@n8n/typeorm/driver/postgres/PostgresConnectionOptions'; import type { SqliteConnectionOptions } from '@n8n/typeorm/driver/sqlite/SqliteConnectionOptions'; import type { SqlitePooledConnectionOptions } from '@n8n/typeorm/driver/sqlite-pooled/SqlitePooledConnectionOptions'; -import type { PostgresConnectionOptions } from '@n8n/typeorm/driver/postgres/PostgresConnectionOptions'; -import type { MysqlConnectionOptions } from '@n8n/typeorm/driver/mysql/MysqlConnectionOptions'; import { InstanceSettings } from 'n8n-core'; import { ApplicationError } from 'n8n-workflow'; -import { GlobalConfig } from '@n8n/config'; +import path from 'path'; +import type { TlsOptions } from 'tls'; +import { Container } from 'typedi'; import { entities } from './entities'; -import { subscribers } from './subscribers'; import { mysqlMigrations } from './migrations/mysqldb'; import { postgresMigrations } from './migrations/postgresdb'; import { sqliteMigrations } from './migrations/sqlite'; +import { subscribers } from './subscribers'; const getCommonOptions = () => { const { tablePrefix: entityPrefix, logging: loggingConfig } = diff --git a/packages/cli/src/databases/dsl/index.ts b/packages/cli/src/databases/dsl/index.ts index c60e5819f476e..7784705f89949 100644 --- a/packages/cli/src/databases/dsl/index.ts +++ b/packages/cli/src/databases/dsl/index.ts @@ -1,5 +1,7 @@ import type { QueryRunner } from '@n8n/typeorm'; + import { Column } from './column'; +import { CreateIndex, DropIndex } from './indices'; import { AddColumns, AddForeignKey, @@ -10,7 +12,6 @@ import { DropNotNull, DropTable, } from './table'; -import { CreateIndex, DropIndex } from './indices'; export const createSchemaBuilder = (tablePrefix: string, queryRunner: QueryRunner) => ({ column: (name: string) => new Column(name), diff --git a/packages/cli/src/databases/dsl/table.ts b/packages/cli/src/databases/dsl/table.ts index 414be858f8b9b..78ed98272cc43 100644 --- a/packages/cli/src/databases/dsl/table.ts +++ b/packages/cli/src/databases/dsl/table.ts @@ -1,8 +1,9 @@ import type { TableForeignKeyOptions, TableIndexOptions, QueryRunner } from '@n8n/typeorm'; import { Table, TableColumn, TableForeignKey } from '@n8n/typeorm'; +import { ApplicationError } from 'n8n-workflow'; import LazyPromise from 'p-lazy'; + import { Column } from './column'; -import { ApplicationError } from 'n8n-workflow'; abstract class TableOperation extends LazyPromise { abstract execute(queryRunner: QueryRunner): Promise; diff --git a/packages/cli/src/databases/entities/abstract-entity.ts b/packages/cli/src/databases/entities/abstract-entity.ts index c8195ebc50e96..0626a5621f83a 100644 --- a/packages/cli/src/databases/entities/abstract-entity.ts +++ b/packages/cli/src/databases/entities/abstract-entity.ts @@ -1,4 +1,3 @@ -import { Container } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import type { ColumnOptions } from '@n8n/typeorm'; import { @@ -9,6 +8,8 @@ import { UpdateDateColumn, } from '@n8n/typeorm'; import type { Class } from 'n8n-core'; +import { Container } from 'typedi'; + import { generateNanoId } from '../utils/generators'; export const { type: dbType } = Container.get(GlobalConfig).database; diff --git a/packages/cli/src/databases/entities/annotation-tag-entity.ts b/packages/cli/src/databases/entities/annotation-tag-entity.ts index b62853cb796d4..e89c75a5a8316 100644 --- a/packages/cli/src/databases/entities/annotation-tag-entity.ts +++ b/packages/cli/src/databases/entities/annotation-tag-entity.ts @@ -1,8 +1,10 @@ import { Column, Entity, Index, ManyToMany, OneToMany } from '@n8n/typeorm'; import { IsString, Length } from 'class-validator'; -import { WithTimestampsAndStringId } from './abstract-entity'; -import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; + import type { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping'; +import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; + +import { WithTimestampsAndStringId } from './abstract-entity'; @Entity() export class AnnotationTagEntity extends WithTimestampsAndStringId { diff --git a/packages/cli/src/databases/entities/annotation-tag-mapping.ts b/packages/cli/src/databases/entities/annotation-tag-mapping.ts index 9a4948c2ccbfa..2fa4fc79c1adf 100644 --- a/packages/cli/src/databases/entities/annotation-tag-mapping.ts +++ b/packages/cli/src/databases/entities/annotation-tag-mapping.ts @@ -1,6 +1,7 @@ import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import type { ExecutionAnnotation } from './execution-annotation'; + import type { AnnotationTagEntity } from './annotation-tag-entity'; +import type { ExecutionAnnotation } from './execution-annotation'; /** * This entity represents the junction table between the execution annotations and the tags diff --git a/packages/cli/src/databases/entities/auth-identity.ts b/packages/cli/src/databases/entities/auth-identity.ts index c0507866146cd..f54b1b6ef4c08 100644 --- a/packages/cli/src/databases/entities/auth-identity.ts +++ b/packages/cli/src/databases/entities/auth-identity.ts @@ -1,4 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryColumn, Unique } from '@n8n/typeorm'; + import { WithTimestamps } from './abstract-entity'; import { User } from './user'; diff --git a/packages/cli/src/databases/entities/auth-provider-sync-history.ts b/packages/cli/src/databases/entities/auth-provider-sync-history.ts index f9885843124d2..626f6205eb8c4 100644 --- a/packages/cli/src/databases/entities/auth-provider-sync-history.ts +++ b/packages/cli/src/databases/entities/auth-provider-sync-history.ts @@ -1,4 +1,5 @@ import { Column, Entity, PrimaryGeneratedColumn } from '@n8n/typeorm'; + import { datetimeColumnType } from './abstract-entity'; import { AuthProviderType } from './auth-identity'; diff --git a/packages/cli/src/databases/entities/auth-user.ts b/packages/cli/src/databases/entities/auth-user.ts index 1f8b6960c8578..55cd7a9d349ed 100644 --- a/packages/cli/src/databases/entities/auth-user.ts +++ b/packages/cli/src/databases/entities/auth-user.ts @@ -1,4 +1,5 @@ import { Column, Entity } from '@n8n/typeorm'; + import { User } from './user'; @Entity({ name: 'user' }) diff --git a/packages/cli/src/databases/entities/credentials-entity.ts b/packages/cli/src/databases/entities/credentials-entity.ts index 5b63fb9e46fb8..bbfc137f85f36 100644 --- a/packages/cli/src/databases/entities/credentials-entity.ts +++ b/packages/cli/src/databases/entities/credentials-entity.ts @@ -1,9 +1,11 @@ import { Column, Entity, Index, OneToMany } from '@n8n/typeorm'; import { IsObject, IsString, Length } from 'class-validator'; -import type { SharedCredentials } from './shared-credentials'; -import { WithTimestampsAndStringId } from './abstract-entity'; + import type { ICredentialsDb } from '@/interfaces'; +import { WithTimestampsAndStringId } from './abstract-entity'; +import type { SharedCredentials } from './shared-credentials'; + @Entity() export class CredentialsEntity extends WithTimestampsAndStringId implements ICredentialsDb { @Column({ length: 128 }) diff --git a/packages/cli/src/databases/entities/event-destinations.ts b/packages/cli/src/databases/entities/event-destinations.ts index 88829690b36c4..f148ed983feb7 100644 --- a/packages/cli/src/databases/entities/event-destinations.ts +++ b/packages/cli/src/databases/entities/event-destinations.ts @@ -1,5 +1,6 @@ -import { MessageEventBusDestinationOptions } from 'n8n-workflow'; import { Column, Entity, PrimaryColumn } from '@n8n/typeorm'; +import { MessageEventBusDestinationOptions } from 'n8n-workflow'; + import { WithTimestamps, jsonColumnType } from './abstract-entity'; @Entity({ name: 'event_destinations' }) diff --git a/packages/cli/src/databases/entities/execution-annotation.ts b/packages/cli/src/databases/entities/execution-annotation.ts index 804bf99c153b7..33943f63305a7 100644 --- a/packages/cli/src/databases/entities/execution-annotation.ts +++ b/packages/cli/src/databases/entities/execution-annotation.ts @@ -10,10 +10,11 @@ import { PrimaryGeneratedColumn, RelationId, } from '@n8n/typeorm'; -import { ExecutionEntity } from './execution-entity'; +import type { AnnotationVote } from 'n8n-workflow'; + import type { AnnotationTagEntity } from './annotation-tag-entity'; import type { AnnotationTagMapping } from './annotation-tag-mapping'; -import type { AnnotationVote } from 'n8n-workflow'; +import { ExecutionEntity } from './execution-entity'; @Entity({ name: 'execution_annotations' }) export class ExecutionAnnotation { diff --git a/packages/cli/src/databases/entities/execution-data.ts b/packages/cli/src/databases/entities/execution-data.ts index b33b87659ee58..532e3a505cfee 100644 --- a/packages/cli/src/databases/entities/execution-data.ts +++ b/packages/cli/src/databases/entities/execution-data.ts @@ -1,9 +1,10 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import { idStringifier } from '../utils/transformers'; -import { ExecutionEntity } from './execution-entity'; -import { jsonColumnType } from './abstract-entity'; import { IWorkflowBase } from 'n8n-workflow'; +import { jsonColumnType } from './abstract-entity'; +import { ExecutionEntity } from './execution-entity'; +import { idStringifier } from '../utils/transformers'; + @Entity() export class ExecutionData { @Column('text') diff --git a/packages/cli/src/databases/entities/execution-entity.ts b/packages/cli/src/databases/entities/execution-entity.ts index 7a4f595fe6ce0..d44cb6c3f021d 100644 --- a/packages/cli/src/databases/entities/execution-entity.ts +++ b/packages/cli/src/databases/entities/execution-entity.ts @@ -1,4 +1,3 @@ -import { ExecutionStatus, WorkflowExecuteMode } from 'n8n-workflow'; import { Column, Entity, @@ -11,12 +10,15 @@ import { Relation, DeleteDateColumn, } from '@n8n/typeorm'; +import { ExecutionStatus, WorkflowExecuteMode } from 'n8n-workflow'; + +import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; + import { datetimeColumnType } from './abstract-entity'; -import { idStringifier } from '../utils/transformers'; import type { ExecutionData } from './execution-data'; import type { ExecutionMetadata } from './execution-metadata'; import { WorkflowEntity } from './workflow-entity'; -import type { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; +import { idStringifier } from '../utils/transformers'; @Entity() @Index(['workflowId', 'id']) diff --git a/packages/cli/src/databases/entities/execution-metadata.ts b/packages/cli/src/databases/entities/execution-metadata.ts index 1cdf6d8f68951..cac786dbe9be2 100644 --- a/packages/cli/src/databases/entities/execution-metadata.ts +++ b/packages/cli/src/databases/entities/execution-metadata.ts @@ -1,4 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryGeneratedColumn } from '@n8n/typeorm'; + import { ExecutionEntity } from './execution-entity'; @Entity() diff --git a/packages/cli/src/databases/entities/index.ts b/packages/cli/src/databases/entities/index.ts index 114df0723f2a8..8ae29ababd6aa 100644 --- a/packages/cli/src/databases/entities/index.ts +++ b/packages/cli/src/databases/entities/index.ts @@ -1,11 +1,19 @@ +import { AnnotationTagEntity } from './annotation-tag-entity'; +import { AnnotationTagMapping } from './annotation-tag-mapping'; import { AuthIdentity } from './auth-identity'; import { AuthProviderSyncHistory } from './auth-provider-sync-history'; import { AuthUser } from './auth-user'; import { CredentialsEntity } from './credentials-entity'; import { EventDestinations } from './event-destinations'; +import { ExecutionAnnotation } from './execution-annotation'; +import { ExecutionData } from './execution-data'; import { ExecutionEntity } from './execution-entity'; +import { ExecutionMetadata } from './execution-metadata'; import { InstalledNodes } from './installed-nodes'; import { InstalledPackages } from './installed-packages'; +import { InvalidAuthToken } from './invalid-auth-token'; +import { Project } from './project'; +import { ProjectRelation } from './project-relation'; import { Settings } from './settings'; import { SharedCredentials } from './shared-credentials'; import { SharedWorkflow } from './shared-workflow'; @@ -14,17 +22,9 @@ import { User } from './user'; import { Variables } from './variables'; import { WebhookEntity } from './webhook-entity'; import { WorkflowEntity } from './workflow-entity'; -import { WorkflowTagMapping } from './workflow-tag-mapping'; -import { WorkflowStatistics } from './workflow-statistics'; -import { ExecutionMetadata } from './execution-metadata'; -import { ExecutionData } from './execution-data'; import { WorkflowHistory } from './workflow-history'; -import { Project } from './project'; -import { ProjectRelation } from './project-relation'; -import { InvalidAuthToken } from './invalid-auth-token'; -import { AnnotationTagEntity } from './annotation-tag-entity'; -import { AnnotationTagMapping } from './annotation-tag-mapping'; -import { ExecutionAnnotation } from './execution-annotation'; +import { WorkflowStatistics } from './workflow-statistics'; +import { WorkflowTagMapping } from './workflow-tag-mapping'; export const entities = { AnnotationTagEntity, diff --git a/packages/cli/src/databases/entities/installed-nodes.ts b/packages/cli/src/databases/entities/installed-nodes.ts index 271dbe3ec2e54..26c0ce75e07de 100644 --- a/packages/cli/src/databases/entities/installed-nodes.ts +++ b/packages/cli/src/databases/entities/installed-nodes.ts @@ -1,4 +1,5 @@ import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; + import { InstalledPackages } from './installed-packages'; @Entity() diff --git a/packages/cli/src/databases/entities/installed-packages.ts b/packages/cli/src/databases/entities/installed-packages.ts index cea8fbaa4902e..830c3c40e2e25 100644 --- a/packages/cli/src/databases/entities/installed-packages.ts +++ b/packages/cli/src/databases/entities/installed-packages.ts @@ -1,6 +1,7 @@ import { Column, Entity, JoinColumn, OneToMany, PrimaryColumn } from '@n8n/typeorm'; -import type { InstalledNodes } from './installed-nodes'; + import { WithTimestamps } from './abstract-entity'; +import type { InstalledNodes } from './installed-nodes'; @Entity() export class InstalledPackages extends WithTimestamps { diff --git a/packages/cli/src/databases/entities/invalid-auth-token.ts b/packages/cli/src/databases/entities/invalid-auth-token.ts index 53874f34d6b32..67c8112c514a1 100644 --- a/packages/cli/src/databases/entities/invalid-auth-token.ts +++ b/packages/cli/src/databases/entities/invalid-auth-token.ts @@ -1,4 +1,5 @@ import { Column, Entity, PrimaryColumn } from '@n8n/typeorm'; + import { datetimeColumnType } from './abstract-entity'; @Entity() diff --git a/packages/cli/src/databases/entities/project-relation.ts b/packages/cli/src/databases/entities/project-relation.ts index 2f0686c30c4f0..736ef2b223fab 100644 --- a/packages/cli/src/databases/entities/project-relation.ts +++ b/packages/cli/src/databases/entities/project-relation.ts @@ -1,7 +1,8 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import { User } from './user'; + import { WithTimestamps } from './abstract-entity'; import { Project } from './project'; +import { User } from './user'; // personalOwner is only used for personal projects export type ProjectRole = diff --git a/packages/cli/src/databases/entities/project.ts b/packages/cli/src/databases/entities/project.ts index 41cad38e4a9e4..88c4ed009a26c 100644 --- a/packages/cli/src/databases/entities/project.ts +++ b/packages/cli/src/databases/entities/project.ts @@ -1,4 +1,5 @@ import { Column, Entity, OneToMany } from '@n8n/typeorm'; + import { WithTimestampsAndStringId } from './abstract-entity'; import type { ProjectRelation } from './project-relation'; import type { SharedCredentials } from './shared-credentials'; diff --git a/packages/cli/src/databases/entities/settings.ts b/packages/cli/src/databases/entities/settings.ts index 8fcb38325a43d..674e2e2aa3c13 100644 --- a/packages/cli/src/databases/entities/settings.ts +++ b/packages/cli/src/databases/entities/settings.ts @@ -1,5 +1,5 @@ -import type { IDataObject } from 'n8n-workflow'; import { Column, Entity, PrimaryColumn } from '@n8n/typeorm'; +import type { IDataObject } from 'n8n-workflow'; interface ISettingsDb { key: string; diff --git a/packages/cli/src/databases/entities/shared-credentials.ts b/packages/cli/src/databases/entities/shared-credentials.ts index 328d2dccfac7c..24428584ca37b 100644 --- a/packages/cli/src/databases/entities/shared-credentials.ts +++ b/packages/cli/src/databases/entities/shared-credentials.ts @@ -1,6 +1,7 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import { CredentialsEntity } from './credentials-entity'; + import { WithTimestamps } from './abstract-entity'; +import { CredentialsEntity } from './credentials-entity'; import { Project } from './project'; export type CredentialSharingRole = 'credential:owner' | 'credential:user'; diff --git a/packages/cli/src/databases/entities/shared-workflow.ts b/packages/cli/src/databases/entities/shared-workflow.ts index b2ed7f2b57faa..d77f749f7b48c 100644 --- a/packages/cli/src/databases/entities/shared-workflow.ts +++ b/packages/cli/src/databases/entities/shared-workflow.ts @@ -1,7 +1,8 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import { WorkflowEntity } from './workflow-entity'; + import { WithTimestamps } from './abstract-entity'; import { Project } from './project'; +import { WorkflowEntity } from './workflow-entity'; export type WorkflowSharingRole = 'workflow:owner' | 'workflow:editor'; diff --git a/packages/cli/src/databases/entities/tag-entity.ts b/packages/cli/src/databases/entities/tag-entity.ts index ce2d9e7aea24c..0cf9a4ffa1a40 100644 --- a/packages/cli/src/databases/entities/tag-entity.ts +++ b/packages/cli/src/databases/entities/tag-entity.ts @@ -1,8 +1,9 @@ import { Column, Entity, Index, ManyToMany, OneToMany } from '@n8n/typeorm'; import { IsString, Length } from 'class-validator'; + +import { WithTimestampsAndStringId } from './abstract-entity'; import type { WorkflowEntity } from './workflow-entity'; import type { WorkflowTagMapping } from './workflow-tag-mapping'; -import { WithTimestampsAndStringId } from './abstract-entity'; @Entity() export class TagEntity extends WithTimestampsAndStringId { diff --git a/packages/cli/src/databases/entities/user.ts b/packages/cli/src/databases/entities/user.ts index 956bebd1b27e3..32b257fcd1fe8 100644 --- a/packages/cli/src/databases/entities/user.ts +++ b/packages/cli/src/databases/entities/user.ts @@ -1,3 +1,4 @@ +import { hasScope, type ScopeOptions, type Scope } from '@n8n/permissions'; import { AfterLoad, AfterUpdate, @@ -11,21 +12,22 @@ import { } from '@n8n/typeorm'; import { IsEmail, IsString, Length } from 'class-validator'; import type { IUser, IUserSettings } from 'n8n-workflow'; -import type { SharedWorkflow } from './shared-workflow'; -import type { SharedCredentials } from './shared-credentials'; -import { NoXss } from '@/validators/no-xss.validator'; -import { objectRetriever, lowerCaser } from '../utils/transformers'; -import { WithTimestamps, jsonColumnType } from './abstract-entity'; + import type { IPersonalizationSurveyAnswers } from '@/interfaces'; -import type { AuthIdentity } from './auth-identity'; import { GLOBAL_OWNER_SCOPES, GLOBAL_MEMBER_SCOPES, GLOBAL_ADMIN_SCOPES, } from '@/permissions/global-roles'; -import { hasScope, type ScopeOptions, type Scope } from '@n8n/permissions'; -import type { ProjectRelation } from './project-relation'; import { NoUrl } from '@/validators/no-url.validator'; +import { NoXss } from '@/validators/no-xss.validator'; + +import { WithTimestamps, jsonColumnType } from './abstract-entity'; +import type { AuthIdentity } from './auth-identity'; +import type { ProjectRelation } from './project-relation'; +import type { SharedCredentials } from './shared-credentials'; +import type { SharedWorkflow } from './shared-workflow'; +import { objectRetriever, lowerCaser } from '../utils/transformers'; export type GlobalRole = 'global:owner' | 'global:admin' | 'global:member'; export type AssignableRole = Exclude; diff --git a/packages/cli/src/databases/entities/variables.ts b/packages/cli/src/databases/entities/variables.ts index 7670e08f9ffc9..d6bf10431eecc 100644 --- a/packages/cli/src/databases/entities/variables.ts +++ b/packages/cli/src/databases/entities/variables.ts @@ -1,4 +1,5 @@ import { Column, Entity } from '@n8n/typeorm'; + import { WithStringId } from './abstract-entity'; @Entity() diff --git a/packages/cli/src/databases/entities/webhook-entity.ts b/packages/cli/src/databases/entities/webhook-entity.ts index b8dafabe2b897..26066b8379910 100644 --- a/packages/cli/src/databases/entities/webhook-entity.ts +++ b/packages/cli/src/databases/entities/webhook-entity.ts @@ -1,5 +1,5 @@ -import { IHttpRequestMethods } from 'n8n-workflow'; import { Column, Entity, Index, PrimaryColumn } from '@n8n/typeorm'; +import { IHttpRequestMethods } from 'n8n-workflow'; @Entity() @Index(['webhookId', 'method', 'pathLength']) diff --git a/packages/cli/src/databases/entities/workflow-entity.ts b/packages/cli/src/databases/entities/workflow-entity.ts index 0aa8ff0d81d2b..b03cf2c28d9cb 100644 --- a/packages/cli/src/databases/entities/workflow-entity.ts +++ b/packages/cli/src/databases/entities/workflow-entity.ts @@ -1,17 +1,16 @@ +import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, OneToMany } from '@n8n/typeorm'; import { Length } from 'class-validator'; - import { IConnections, IDataObject, IWorkflowSettings, WorkflowFEMeta } from 'n8n-workflow'; import type { IBinaryKeyData, INode, IPairedItemData } from 'n8n-workflow'; -import { Column, Entity, Index, JoinColumn, JoinTable, ManyToMany, OneToMany } from '@n8n/typeorm'; +import type { IWorkflowDb } from '@/interfaces'; -import type { TagEntity } from './tag-entity'; +import { WithTimestampsAndStringId, dbType, jsonColumnType } from './abstract-entity'; import type { SharedWorkflow } from './shared-workflow'; +import type { TagEntity } from './tag-entity'; import type { WorkflowStatistics } from './workflow-statistics'; import type { WorkflowTagMapping } from './workflow-tag-mapping'; import { objectRetriever, sqlite } from '../utils/transformers'; -import { WithTimestampsAndStringId, dbType, jsonColumnType } from './abstract-entity'; -import type { IWorkflowDb } from '@/interfaces'; @Entity() export class WorkflowEntity extends WithTimestampsAndStringId implements IWorkflowDb { diff --git a/packages/cli/src/databases/entities/workflow-history.ts b/packages/cli/src/databases/entities/workflow-history.ts index f15f2e76b940d..73a2b055d19f0 100644 --- a/packages/cli/src/databases/entities/workflow-history.ts +++ b/packages/cli/src/databases/entities/workflow-history.ts @@ -1,7 +1,8 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; -import { WithTimestamps, jsonColumnType } from './abstract-entity'; import { IConnections } from 'n8n-workflow'; import type { INode } from 'n8n-workflow'; + +import { WithTimestamps, jsonColumnType } from './abstract-entity'; import { WorkflowEntity } from './workflow-entity'; @Entity() diff --git a/packages/cli/src/databases/entities/workflow-statistics.ts b/packages/cli/src/databases/entities/workflow-statistics.ts index e220bcfebec6c..e3ad753d54614 100644 --- a/packages/cli/src/databases/entities/workflow-statistics.ts +++ b/packages/cli/src/databases/entities/workflow-statistics.ts @@ -1,4 +1,5 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; + import { datetimeColumnType } from './abstract-entity'; import { WorkflowEntity } from './workflow-entity'; diff --git a/packages/cli/src/databases/entities/workflow-tag-mapping.ts b/packages/cli/src/databases/entities/workflow-tag-mapping.ts index 641113f083a47..768216ebc648a 100644 --- a/packages/cli/src/databases/entities/workflow-tag-mapping.ts +++ b/packages/cli/src/databases/entities/workflow-tag-mapping.ts @@ -1,4 +1,5 @@ import { Entity, JoinColumn, ManyToOne, PrimaryColumn } from '@n8n/typeorm'; + import type { TagEntity } from './tag-entity'; import type { WorkflowEntity } from './workflow-entity'; diff --git a/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts b/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts index 02a25e5d41984..3976ad3109699 100644 --- a/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts +++ b/packages/cli/src/databases/migrations/common/1630330987096-UpdateWorkflowCredentials.ts @@ -1,4 +1,5 @@ import type { IWorkflowBase } from 'n8n-workflow'; + import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { MigrationContext, ReversibleMigration } from '@/databases/types'; diff --git a/packages/cli/src/databases/migrations/common/1658930531669-AddNodeIds.ts b/packages/cli/src/databases/migrations/common/1658930531669-AddNodeIds.ts index 22a7af34cc6c0..c47d496794201 100644 --- a/packages/cli/src/databases/migrations/common/1658930531669-AddNodeIds.ts +++ b/packages/cli/src/databases/migrations/common/1658930531669-AddNodeIds.ts @@ -1,7 +1,8 @@ import type { INode } from 'n8n-workflow'; +import { v4 as uuid } from 'uuid'; + import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { MigrationContext, ReversibleMigration } from '@/databases/types'; -import { v4 as uuid } from 'uuid'; type Workflow = Pick & { nodes: string | INode[] }; diff --git a/packages/cli/src/databases/migrations/common/1659888469333-AddJsonKeyPinData.ts b/packages/cli/src/databases/migrations/common/1659888469333-AddJsonKeyPinData.ts index b9ab3216ce98b..84d3040a10d7b 100644 --- a/packages/cli/src/databases/migrations/common/1659888469333-AddJsonKeyPinData.ts +++ b/packages/cli/src/databases/migrations/common/1659888469333-AddJsonKeyPinData.ts @@ -1,6 +1,7 @@ -import { isObjectLiteral } from '@/utils'; import type { IDataObject, INodeExecutionData } from 'n8n-workflow'; + import type { MigrationContext, IrreversibleMigration } from '@/databases/types'; +import { isObjectLiteral } from '@/utils'; type OldPinnedData = { [nodeName: string]: IDataObject[] }; type NewPinnedData = { [nodeName: string]: INodeExecutionData[] }; diff --git a/packages/cli/src/databases/migrations/common/1669739707124-AddWorkflowVersionIdColumn.ts b/packages/cli/src/databases/migrations/common/1669739707124-AddWorkflowVersionIdColumn.ts index 36d95530b0ad6..8013ee299eba8 100644 --- a/packages/cli/src/databases/migrations/common/1669739707124-AddWorkflowVersionIdColumn.ts +++ b/packages/cli/src/databases/migrations/common/1669739707124-AddWorkflowVersionIdColumn.ts @@ -1,6 +1,7 @@ -import type { MigrationContext, ReversibleMigration } from '@/databases/types'; import { v4 as uuidv4 } from 'uuid'; +import type { MigrationContext, ReversibleMigration } from '@/databases/types'; + type Workflow = { id: number }; export class AddWorkflowVersionIdColumn1669739707124 implements ReversibleMigration { diff --git a/packages/cli/src/databases/migrations/common/1671726148419-RemoveWorkflowDataLoadedFlag.ts b/packages/cli/src/databases/migrations/common/1671726148419-RemoveWorkflowDataLoadedFlag.ts index 47c26982e3ecb..d3e38e2adf395 100644 --- a/packages/cli/src/databases/migrations/common/1671726148419-RemoveWorkflowDataLoadedFlag.ts +++ b/packages/cli/src/databases/migrations/common/1671726148419-RemoveWorkflowDataLoadedFlag.ts @@ -1,5 +1,5 @@ -import type { MigrationContext, ReversibleMigration } from '@/databases/types'; import { StatisticsNames } from '@/databases/entities/workflow-statistics'; +import type { MigrationContext, ReversibleMigration } from '@/databases/types'; export class RemoveWorkflowDataLoadedFlag1671726148419 implements ReversibleMigration { async up({ escape, dbType, runQuery }: MigrationContext) { diff --git a/packages/cli/src/databases/migrations/common/1700571993961-AddGlobalAdminRole.ts b/packages/cli/src/databases/migrations/common/1700571993961-AddGlobalAdminRole.ts index 5e12a35d842e2..b2bd406622969 100644 --- a/packages/cli/src/databases/migrations/common/1700571993961-AddGlobalAdminRole.ts +++ b/packages/cli/src/databases/migrations/common/1700571993961-AddGlobalAdminRole.ts @@ -1,6 +1,7 @@ -import type { MigrationContext, ReversibleMigration } from '@/databases/types'; import { ApplicationError } from 'n8n-workflow'; +import type { MigrationContext, ReversibleMigration } from '@/databases/types'; + export class AddGlobalAdminRole1700571993961 implements ReversibleMigration { async up({ escape, runQuery }: MigrationContext) { const tableName = escape.tableName('role'); diff --git a/packages/cli/src/databases/migrations/common/1711390882123-MoveSshKeysToDatabase.ts b/packages/cli/src/databases/migrations/common/1711390882123-MoveSshKeysToDatabase.ts index ff2c16807d11a..f8d4eb60a907b 100644 --- a/packages/cli/src/databases/migrations/common/1711390882123-MoveSshKeysToDatabase.ts +++ b/packages/cli/src/databases/migrations/common/1711390882123-MoveSshKeysToDatabase.ts @@ -1,8 +1,9 @@ -import path from 'node:path'; -import { readFile, writeFile, rm } from 'node:fs/promises'; -import Container from 'typedi'; import { Cipher, InstanceSettings } from 'n8n-core'; import { jsonParse } from 'n8n-workflow'; +import { readFile, writeFile, rm } from 'node:fs/promises'; +import path from 'node:path'; +import Container from 'typedi'; + import type { MigrationContext, ReversibleMigration } from '@/databases/types'; /** diff --git a/packages/cli/src/databases/migrations/common/1714133768519-CreateProject.ts b/packages/cli/src/databases/migrations/common/1714133768519-CreateProject.ts index 9bcf26ee9a4ec..fe101fac7aba2 100644 --- a/packages/cli/src/databases/migrations/common/1714133768519-CreateProject.ts +++ b/packages/cli/src/databases/migrations/common/1714133768519-CreateProject.ts @@ -1,9 +1,10 @@ -import type { MigrationContext, ReversibleMigration } from '@/databases/types'; +import { ApplicationError } from 'n8n-workflow'; +import { nanoid } from 'nanoid'; + import type { ProjectRole } from '@/databases/entities/project-relation'; import type { User } from '@/databases/entities/user'; +import type { MigrationContext, ReversibleMigration } from '@/databases/types'; import { generateNanoId } from '@/databases/utils/generators'; -import { ApplicationError } from 'n8n-workflow'; -import { nanoid } from 'nanoid'; const projectAdminRole: ProjectRole = 'project:personalOwner'; diff --git a/packages/cli/src/databases/migrations/common/1720101653148-AddConstraintToExecutionMetadata.ts b/packages/cli/src/databases/migrations/common/1720101653148-AddConstraintToExecutionMetadata.ts index 1cfa42a9e0dd1..392b84aa17bdc 100644 --- a/packages/cli/src/databases/migrations/common/1720101653148-AddConstraintToExecutionMetadata.ts +++ b/packages/cli/src/databases/migrations/common/1720101653148-AddConstraintToExecutionMetadata.ts @@ -1,6 +1,7 @@ -import type { MigrationContext, ReversibleMigration } from '@/databases/types'; import { nanoid } from 'nanoid'; +import type { MigrationContext, ReversibleMigration } from '@/databases/types'; + export class AddConstraintToExecutionMetadata1720101653148 implements ReversibleMigration { async up(context: MigrationContext) { const { createTable, dropTable, column } = context.schemaBuilder; diff --git a/packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts index 063ea7580e42a..9f054c3d23279 100644 --- a/packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts +++ b/packages/cli/src/databases/migrations/mysqldb/1646992772331-CreateUserManagement.ts @@ -1,6 +1,7 @@ -import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; import { v4 as uuid } from 'uuid'; +import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; + export class CreateUserManagement1646992772331 implements ReversibleMigration { async up({ queryRunner, tablePrefix, loadSurveyFromDisk }: MigrationContext) { await queryRunner.query( diff --git a/packages/cli/src/databases/migrations/mysqldb/index.ts b/packages/cli/src/databases/migrations/mysqldb/index.ts index 05f9fad15dede..f3660f905de0f 100644 --- a/packages/cli/src/databases/migrations/mysqldb/index.ts +++ b/packages/cli/src/databases/migrations/mysqldb/index.ts @@ -1,12 +1,14 @@ import type { Migration } from '@/databases/types'; + +import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns'; import { InitialMigration1588157391238 } from './1588157391238-InitialMigration'; import { WebhookModel1592447867632 } from './1592447867632-WebhookModel'; import { CreateIndexStoppedAt1594902918301 } from './1594902918301-CreateIndexStoppedAt'; -import { AddWebhookId1611149998770 } from './1611149998770-AddWebhookId'; import { MakeStoppedAtNullable1607431743767 } from './1607431743767-MakeStoppedAtNullable'; +import { AddWebhookId1611149998770 } from './1611149998770-AddWebhookId'; import { ChangeDataSize1615306975123 } from './1615306975123-ChangeDataSize'; -import { ChangeCredentialDataSize1620729500000 } from './1620729500000-ChangeCredentialDataSize'; import { CreateTagEntity1617268711084 } from './1617268711084-CreateTagEntity'; +import { ChangeCredentialDataSize1620729500000 } from './1620729500000-ChangeCredentialDataSize'; import { UniqueWorkflowNames1620826335440 } from './1620826335440-UniqueWorkflowNames'; import { CertifyCorrectCollation1623936588000 } from './1623936588000-CertifyCorrectCollation'; import { AddWaitColumnId1626183952959 } from './1626183952959-AddWaitColumn'; @@ -14,53 +16,52 @@ import { UpdateWorkflowCredentials1630451444017 } from './1630451444017-UpdateWo import { AddExecutionEntityIndexes1644424784709 } from './1644424784709-AddExecutionEntityIndexes'; import { CreateUserManagement1646992772331 } from './1646992772331-CreateUserManagement'; import { LowerCaseUserEmail1648740597343 } from './1648740597343-LowerCaseUserEmail'; -import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { CommunityNodes1652254514003 } from './1652254514003-CommunityNodes'; +import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { AddAPIKeyColumn1652905585850 } from './1652905585850-AddAPIKeyColumn'; import { IntroducePinData1654090101303 } from './1654090101303-IntroducePinData'; import { AddNodeIds1658932910559 } from './1658932910559-AddNodeIds'; import { AddJsonKeyPinData1659895550980 } from './1659895550980-AddJsonKeyPinData'; import { CreateCredentialsUserRole1660062385367 } from './1660062385367-CreateCredentialsUserRole'; -import { WorkflowStatistics1664196174002 } from './1664196174002-WorkflowStatistics'; import { CreateWorkflowsEditorRole1663755770894 } from './1663755770894-CreateWorkflowsEditorRole'; +import { WorkflowStatistics1664196174002 } from './1664196174002-WorkflowStatistics'; import { CreateCredentialUsageTable1665484192213 } from './1665484192213-CreateCredentialUsageTable'; import { RemoveCredentialUsageTable1665754637026 } from './1665754637026-RemoveCredentialUsageTable'; import { AddWorkflowVersionIdColumn1669739707125 } from './1669739707125-AddWorkflowVersionIdColumn'; import { AddTriggerCountColumn1669823906994 } from './1669823906994-AddTriggerCountColumn'; -import { RemoveWorkflowDataLoadedFlag1671726148420 } from './1671726148420-RemoveWorkflowDataLoadedFlag'; import { MessageEventBusDestinations1671535397530 } from './1671535397530-MessageEventBusDestinations'; +import { RemoveWorkflowDataLoadedFlag1671726148420 } from './1671726148420-RemoveWorkflowDataLoadedFlag'; import { DeleteExecutionsWithWorkflows1673268682475 } from './1673268682475-DeleteExecutionsWithWorkflows'; -import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; -import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions'; import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus'; import { UpdateRunningExecutionStatus1677236788851 } from './1677236788851-UpdateRunningExecutionStatus'; -import { CreateExecutionMetadataTable1679416281779 } from './1679416281779-CreateExecutionMetadataTable'; import { CreateVariables1677501636753 } from './1677501636753-CreateVariables'; +import { CreateExecutionMetadataTable1679416281779 } from './1679416281779-CreateExecutionMetadataTable'; import { AddUserActivatedProperty1681134145996 } from './1681134145996-AddUserActivatedProperty'; +import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; import { MigrateIntegerKeysToString1690000000001 } from './1690000000001-MigrateIntegerKeysToString'; import { SeparateExecutionData1690000000030 } from './1690000000030-SeparateExecutionData'; import { FixExecutionDataType1690000000031 } from './1690000000031-FixExecutionDataType'; -import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; +import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; +import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; +import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030-RemoveResetPasswordColumns'; import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex'; -import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns'; import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable'; -import { DisallowOrphanExecutions1693554410387 } from '../common/1693554410387-DisallowOrphanExecutions'; import { ExecutionSoftDelete1693491613982 } from '../common/1693491613982-ExecutionSoftDelete'; +import { DisallowOrphanExecutions1693554410387 } from '../common/1693554410387-DisallowOrphanExecutions'; import { AddWorkflowMetadata1695128658538 } from '../common/1695128658538-AddWorkflowMetadata'; import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections'; import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole'; -import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMapping'; import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus'; import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase'; import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess'; +import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable'; -import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; -import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { AddConstraintToExecutionMetadata1720101653148 } from '../common/1720101653148-AddConstraintToExecutionMetadata'; import { CreateInvalidAuthTokenTable1723627610222 } from '../common/1723627610222-CreateInvalidAuthTokenTable'; +import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { CreateAnnotationTables1724753530828 } from '../common/1724753530828-CreateExecutionAnnotationTables'; export const mysqlMigrations: Migration[] = [ diff --git a/packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts index 5a0581a16e910..1777820e34a24 100644 --- a/packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts +++ b/packages/cli/src/databases/migrations/postgresdb/1646992772331-CreateUserManagement.ts @@ -1,6 +1,7 @@ -import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; import { v4 as uuid } from 'uuid'; +import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; + export class CreateUserManagement1646992772331 implements ReversibleMigration { async up({ queryRunner, tablePrefix, loadSurveyFromDisk }: MigrationContext) { await queryRunner.query( diff --git a/packages/cli/src/databases/migrations/postgresdb/index.ts b/packages/cli/src/databases/migrations/postgresdb/index.ts index 0b0f17e8a3592..e3ad5afa57e62 100644 --- a/packages/cli/src/databases/migrations/postgresdb/index.ts +++ b/packages/cli/src/databases/migrations/postgresdb/index.ts @@ -1,9 +1,11 @@ import type { Migration } from '@/databases/types'; + +import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns'; import { InitialMigration1587669153312 } from './1587669153312-InitialMigration'; import { WebhookModel1589476000887 } from './1589476000887-WebhookModel'; import { CreateIndexStoppedAt1594828256133 } from './1594828256133-CreateIndexStoppedAt'; -import { AddWebhookId1611144599516 } from './1611144599516-AddWebhookId'; import { MakeStoppedAtNullable1607431743768 } from './1607431743768-MakeStoppedAtNullable'; +import { AddWebhookId1611144599516 } from './1611144599516-AddWebhookId'; import { CreateTagEntity1617270242566 } from './1617270242566-CreateTagEntity'; import { UniqueWorkflowNames1620824779533 } from './1620824779533-UniqueWorkflowNames'; import { AddwaitTill1626176912946 } from './1626176912946-AddwaitTill'; @@ -12,55 +14,54 @@ import { AddExecutionEntityIndexes1644422880309 } from './1644422880309-AddExecu import { IncreaseTypeVarcharLimit1646834195327 } from './1646834195327-IncreaseTypeVarcharLimit'; import { CreateUserManagement1646992772331 } from './1646992772331-CreateUserManagement'; import { LowerCaseUserEmail1648740597343 } from './1648740597343-LowerCaseUserEmail'; -import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { CommunityNodes1652254514002 } from './1652254514002-CommunityNodes'; +import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { AddAPIKeyColumn1652905585850 } from './1652905585850-AddAPIKeyColumn'; import { IntroducePinData1654090467022 } from './1654090467022-IntroducePinData'; import { AddNodeIds1658932090381 } from './1658932090381-AddNodeIds'; import { AddJsonKeyPinData1659902242948 } from './1659902242948-AddJsonKeyPinData'; import { CreateCredentialsUserRole1660062385367 } from './1660062385367-CreateCredentialsUserRole'; -import { WorkflowStatistics1664196174001 } from './1664196174001-WorkflowStatistics'; import { CreateWorkflowsEditorRole1663755770893 } from './1663755770893-CreateWorkflowsEditorRole'; +import { WorkflowStatistics1664196174001 } from './1664196174001-WorkflowStatistics'; import { CreateCredentialUsageTable1665484192212 } from './1665484192212-CreateCredentialUsageTable'; import { RemoveCredentialUsageTable1665754637025 } from './1665754637025-RemoveCredentialUsageTable'; import { AddWorkflowVersionIdColumn1669739707126 } from './1669739707126-AddWorkflowVersionIdColumn'; import { AddTriggerCountColumn1669823906995 } from './1669823906995-AddTriggerCountColumn'; -import { RemoveWorkflowDataLoadedFlag1671726148421 } from './1671726148421-RemoveWorkflowDataLoadedFlag'; import { MessageEventBusDestinations1671535397530 } from './1671535397530-MessageEventBusDestinations'; +import { RemoveWorkflowDataLoadedFlag1671726148421 } from './1671726148421-RemoveWorkflowDataLoadedFlag'; import { DeleteExecutionsWithWorkflows1673268682475 } from './1673268682475-DeleteExecutionsWithWorkflows'; -import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; -import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions'; import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus'; import { UpdateRunningExecutionStatus1677236854063 } from './1677236854063-UpdateRunningExecutionStatus'; -import { CreateExecutionMetadataTable1679416281778 } from './1679416281778-CreateExecutionMetadataTable'; import { CreateVariables1677501636754 } from './1677501636754-CreateVariables'; +import { CreateExecutionMetadataTable1679416281778 } from './1679416281778-CreateExecutionMetadataTable'; import { AddUserActivatedProperty1681134145996 } from './1681134145996-AddUserActivatedProperty'; +import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; import { MigrateIntegerKeysToString1690000000000 } from './1690000000000-MigrateIntegerKeysToString'; import { SeparateExecutionData1690000000020 } from './1690000000020-SeparateExecutionData'; -import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; -import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030-RemoveResetPasswordColumns'; import { AddMissingPrimaryKeyOnExecutionData1690787606731 } from './1690787606731-AddMissingPrimaryKeyOnExecutionData'; +import { MigrateToTimestampTz1694091729095 } from './1694091729095-MigrateToTimestampTz'; +import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; +import { FixExecutionMetadataSequence1721377157740 } from './1721377157740-FixExecutionMetadataSequence'; +import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; +import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; +import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030-RemoveResetPasswordColumns'; import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex'; -import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns'; import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable'; -import { DisallowOrphanExecutions1693554410387 } from '../common/1693554410387-DisallowOrphanExecutions'; import { ExecutionSoftDelete1693491613982 } from '../common/1693491613982-ExecutionSoftDelete'; +import { DisallowOrphanExecutions1693554410387 } from '../common/1693554410387-DisallowOrphanExecutions'; import { AddWorkflowMetadata1695128658538 } from '../common/1695128658538-AddWorkflowMetadata'; -import { MigrateToTimestampTz1694091729095 } from './1694091729095-MigrateToTimestampTz'; import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections'; import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole'; -import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; import { DropRoleMapping1705429061930 } from '../common/1705429061930-DropRoleMapping'; import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus'; import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase'; import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess'; +import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable'; -import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; -import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { AddConstraintToExecutionMetadata1720101653148 } from '../common/1720101653148-AddConstraintToExecutionMetadata'; -import { FixExecutionMetadataSequence1721377157740 } from './1721377157740-FixExecutionMetadataSequence'; import { CreateInvalidAuthTokenTable1723627610222 } from '../common/1723627610222-CreateInvalidAuthTokenTable'; +import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { CreateAnnotationTables1724753530828 } from '../common/1724753530828-CreateExecutionAnnotationTables'; export const postgresMigrations: Migration[] = [ diff --git a/packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts b/packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts index 83923e4285452..12f9e50ba8591 100644 --- a/packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts +++ b/packages/cli/src/databases/migrations/sqlite/1646992772331-CreateUserManagement.ts @@ -1,6 +1,7 @@ -import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; import { v4 as uuid } from 'uuid'; +import type { InsertResult, MigrationContext, ReversibleMigration } from '@/databases/types'; + export class CreateUserManagement1646992772331 implements ReversibleMigration { async up({ queryRunner, tablePrefix, loadSurveyFromDisk }: MigrationContext) { await queryRunner.query( diff --git a/packages/cli/src/databases/migrations/sqlite/1690000000002-MigrateIntegerKeysToString.ts b/packages/cli/src/databases/migrations/sqlite/1690000000002-MigrateIntegerKeysToString.ts index b281c0dbdd8a9..99cbef5aac474 100644 --- a/packages/cli/src/databases/migrations/sqlite/1690000000002-MigrateIntegerKeysToString.ts +++ b/packages/cli/src/databases/migrations/sqlite/1690000000002-MigrateIntegerKeysToString.ts @@ -1,8 +1,9 @@ +import { GlobalConfig } from '@n8n/config'; import { statSync } from 'fs'; +import { InstanceSettings } from 'n8n-core'; import path from 'path'; import { Container } from 'typedi'; -import { InstanceSettings } from 'n8n-core'; -import { GlobalConfig } from '@n8n/config'; + import type { MigrationContext, IrreversibleMigration } from '@/databases/types'; export class MigrateIntegerKeysToString1690000000002 implements IrreversibleMigration { diff --git a/packages/cli/src/databases/migrations/sqlite/index.ts b/packages/cli/src/databases/migrations/sqlite/index.ts index 5696b77726d27..a1739ae4a4afc 100644 --- a/packages/cli/src/databases/migrations/sqlite/index.ts +++ b/packages/cli/src/databases/migrations/sqlite/index.ts @@ -1,63 +1,64 @@ import type { Migration } from '@/databases/types'; + import { InitialMigration1588102412422 } from './1588102412422-InitialMigration'; import { WebhookModel1592445003908 } from './1592445003908-WebhookModel'; import { CreateIndexStoppedAt1594825041918 } from './1594825041918-CreateIndexStoppedAt'; -import { AddWebhookId1611071044839 } from './1611071044839-AddWebhookId'; import { MakeStoppedAtNullable1607431743769 } from './1607431743769-MakeStoppedAtNullable'; +import { AddWebhookId1611071044839 } from './1611071044839-AddWebhookId'; import { CreateTagEntity1617213344594 } from './1617213344594-CreateTagEntity'; -import { UniqueWorkflowNames1620821879465 } from '../common/1620821879465-UniqueWorkflowNames'; import { AddWaitColumn1621707690587 } from './1621707690587-AddWaitColumn'; -import { UpdateWorkflowCredentials1630330987096 } from '../common/1630330987096-UpdateWorkflowCredentials'; import { AddExecutionEntityIndexes1644421939510 } from './1644421939510-AddExecutionEntityIndexes'; import { CreateUserManagement1646992772331 } from './1646992772331-CreateUserManagement'; import { LowerCaseUserEmail1648740597343 } from './1648740597343-LowerCaseUserEmail'; -import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { CommunityNodes1652254514001 } from './1652254514001-CommunityNodes'; +import { AddUserSettings1652367743993 } from './1652367743993-AddUserSettings'; import { AddAPIKeyColumn1652905585850 } from './1652905585850-AddAPIKeyColumn'; import { IntroducePinData1654089251344 } from './1654089251344-IntroducePinData'; -import { AddNodeIds1658930531669 } from '../common/1658930531669-AddNodeIds'; -import { AddJsonKeyPinData1659888469333 } from '../common/1659888469333-AddJsonKeyPinData'; import { CreateCredentialsUserRole1660062385367 } from './1660062385367-CreateCredentialsUserRole'; import { CreateWorkflowsEditorRole1663755770892 } from './1663755770892-CreateWorkflowsUserRole'; +import { WorkflowStatistics1664196174000 } from './1664196174000-WorkflowStatistics'; import { CreateCredentialUsageTable1665484192211 } from './1665484192211-CreateCredentialUsageTable'; import { RemoveCredentialUsageTable1665754637024 } from './1665754637024-RemoveCredentialUsageTable'; -import { AddWorkflowVersionIdColumn1669739707124 } from '../common/1669739707124-AddWorkflowVersionIdColumn'; -import { WorkflowStatistics1664196174000 } from './1664196174000-WorkflowStatistics'; import { AddTriggerCountColumn1669823906993 } from './1669823906993-AddTriggerCountColumn'; -import { RemoveWorkflowDataLoadedFlag1671726148419 } from '../common/1671726148419-RemoveWorkflowDataLoadedFlag'; import { MessageEventBusDestinations1671535397530 } from './1671535397530-MessageEventBusDestinations'; import { DeleteExecutionsWithWorkflows1673268682475 } from './1673268682475-DeleteExecutionsWithWorkflows'; -import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; -import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; import { AddStatusToExecutions1674138566000 } from './1674138566000-AddStatusToExecutions'; import { MigrateExecutionStatus1676996103000 } from './1676996103000-MigrateExecutionStatus'; import { UpdateRunningExecutionStatus1677237073720 } from './1677237073720-UpdateRunningExecutionStatus'; -import { CreateExecutionMetadataTable1679416281777 } from './1679416281777-CreateExecutionMetadataTable'; import { CreateVariables1677501636752 } from './1677501636752-CreateVariables'; +import { CreateExecutionMetadataTable1679416281777 } from './1679416281777-CreateExecutionMetadataTable'; import { AddUserActivatedProperty1681134145996 } from './1681134145996-AddUserActivatedProperty'; +import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; import { MigrateIntegerKeysToString1690000000002 } from './1690000000002-MigrateIntegerKeysToString'; import { SeparateExecutionData1690000000010 } from './1690000000010-SeparateExecutionData'; -import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup'; import { FixMissingIndicesFromStringIdMigration1690000000020 } from './1690000000020-FixMissingIndicesFromStringIdMigration'; import { RemoveResetPasswordColumns1690000000030 } from './1690000000030-RemoveResetPasswordColumns'; -import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex'; import { AddMfaColumns1690000000030 } from './1690000000040-AddMfaColumns'; +import { ExecutionSoftDelete1693491613982 } from './1693491613982-ExecutionSoftDelete'; +import { DropRoleMapping1705429061930 } from './1705429061930-DropRoleMapping'; +import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; +import { UniqueWorkflowNames1620821879465 } from '../common/1620821879465-UniqueWorkflowNames'; +import { UpdateWorkflowCredentials1630330987096 } from '../common/1630330987096-UpdateWorkflowCredentials'; +import { AddNodeIds1658930531669 } from '../common/1658930531669-AddNodeIds'; +import { AddJsonKeyPinData1659888469333 } from '../common/1659888469333-AddJsonKeyPinData'; +import { AddWorkflowVersionIdColumn1669739707124 } from '../common/1669739707124-AddWorkflowVersionIdColumn'; +import { RemoveWorkflowDataLoadedFlag1671726148419 } from '../common/1671726148419-RemoveWorkflowDataLoadedFlag'; +import { CreateLdapEntities1674509946020 } from '../common/1674509946020-CreateLdapEntities'; +import { PurgeInvalidWorkflowConnections1675940580449 } from '../common/1675940580449-PurgeInvalidWorkflowConnections'; +import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex'; import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable'; import { DisallowOrphanExecutions1693554410387 } from '../common/1693554410387-DisallowOrphanExecutions'; -import { ExecutionSoftDelete1693491613982 } from './1693491613982-ExecutionSoftDelete'; import { AddWorkflowMetadata1695128658538 } from '../common/1695128658538-AddWorkflowMetadata'; import { ModifyWorkflowHistoryNodesAndConnections1695829275184 } from '../common/1695829275184-ModifyWorkflowHistoryNodesAndConnections'; import { AddGlobalAdminRole1700571993961 } from '../common/1700571993961-AddGlobalAdminRole'; -import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; -import { DropRoleMapping1705429061930 } from './1705429061930-DropRoleMapping'; import { RemoveFailedExecutionStatus1711018413374 } from '../common/1711018413374-RemoveFailedExecutionStatus'; import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase'; import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess'; +import { CreateProject1714133768519 } from '../common/1714133768519-CreateProject'; import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable'; -import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting'; -import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { AddConstraintToExecutionMetadata1720101653148 } from '../common/1720101653148-AddConstraintToExecutionMetadata'; import { CreateInvalidAuthTokenTable1723627610222 } from '../common/1723627610222-CreateInvalidAuthTokenTable'; +import { RefactorExecutionIndices1723796243146 } from '../common/1723796243146-RefactorExecutionIndices'; import { CreateAnnotationTables1724753530828 } from '../common/1724753530828-CreateExecutionAnnotationTables'; const sqliteMigrations: Migration[] = [ 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 1ca3a9227dc58..ac45b71bc4576 100644 --- a/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/execution.repository.test.ts @@ -1,10 +1,10 @@ -import Container from 'typedi'; import { GlobalConfig } from '@n8n/config'; import type { SelectQueryBuilder } from '@n8n/typeorm'; import { Not, LessThanOrEqual } from '@n8n/typeorm'; +import { mock } from 'jest-mock-extended'; import { BinaryDataService } from 'n8n-core'; import { nanoid } from 'nanoid'; -import { mock } from 'jest-mock-extended'; +import Container from 'typedi'; import { ExecutionEntity } from '@/databases/entities/execution-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; diff --git a/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts b/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts index 8e67ed825f8bf..afaca2206f129 100644 --- a/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/shared-credentials.repository.test.ts @@ -1,11 +1,11 @@ -import { Container } from 'typedi'; +import { hasScope } from '@n8n/permissions'; import { In } from '@n8n/typeorm'; import { mock } from 'jest-mock-extended'; -import { hasScope } from '@n8n/permissions'; +import { Container } from 'typedi'; -import type { User } from '@/databases/entities/user'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { SharedCredentials } from '@/databases/entities/shared-credentials'; +import type { User } from '@/databases/entities/user'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { GLOBAL_MEMBER_SCOPES, GLOBAL_OWNER_SCOPES } from '@/permissions/global-roles'; import { mockEntityManager } from '@test/mocking'; diff --git a/packages/cli/src/databases/repositories/__tests__/workflow-statistics.test.ts b/packages/cli/src/databases/repositories/__tests__/workflow-statistics.test.ts index c37ce9810e6a1..202938e526d50 100644 --- a/packages/cli/src/databases/repositories/__tests__/workflow-statistics.test.ts +++ b/packages/cli/src/databases/repositories/__tests__/workflow-statistics.test.ts @@ -1,10 +1,9 @@ -import { Container } from 'typedi'; import { type InsertResult, QueryFailedError } from '@n8n/typeorm'; import { mock, mockClear } from 'jest-mock-extended'; +import { Container } from 'typedi'; import { StatisticsNames, WorkflowStatistics } from '@/databases/entities/workflow-statistics'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; - import { mockEntityManager } from '@test/mocking'; describe('insertWorkflowStatistics', () => { diff --git a/packages/cli/src/databases/repositories/annotation-tag-mapping.repository.ts b/packages/cli/src/databases/repositories/annotation-tag-mapping.repository.ts index b478348319819..c8c4a80d31013 100644 --- a/packages/cli/src/databases/repositories/annotation-tag-mapping.repository.ts +++ b/packages/cli/src/databases/repositories/annotation-tag-mapping.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping'; @Service() diff --git a/packages/cli/src/databases/repositories/annotation-tag.repository.ts b/packages/cli/src/databases/repositories/annotation-tag.repository.ts index bf15e5626b820..2f4b847ba6d4e 100644 --- a/packages/cli/src/databases/repositories/annotation-tag.repository.ts +++ b/packages/cli/src/databases/repositories/annotation-tag.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; @Service() diff --git a/packages/cli/src/databases/repositories/auth-identity.repository.ts b/packages/cli/src/databases/repositories/auth-identity.repository.ts index abe6a55bae2e3..349fe29cd5b41 100644 --- a/packages/cli/src/databases/repositories/auth-identity.repository.ts +++ b/packages/cli/src/databases/repositories/auth-identity.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { AuthIdentity } from '../entities/auth-identity'; @Service() diff --git a/packages/cli/src/databases/repositories/auth-provider-sync-history.repository.ts b/packages/cli/src/databases/repositories/auth-provider-sync-history.repository.ts index 03f9f96d491e5..d4c5d50b5a759 100644 --- a/packages/cli/src/databases/repositories/auth-provider-sync-history.repository.ts +++ b/packages/cli/src/databases/repositories/auth-provider-sync-history.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { AuthProviderSyncHistory } from '../entities/auth-provider-sync-history'; @Service() diff --git a/packages/cli/src/databases/repositories/auth-user.repository.ts b/packages/cli/src/databases/repositories/auth-user.repository.ts index 978ea458e6bd1..0d94fc9ba64b7 100644 --- a/packages/cli/src/databases/repositories/auth-user.repository.ts +++ b/packages/cli/src/databases/repositories/auth-user.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { AuthUser } from '../entities/auth-user'; @Service() diff --git a/packages/cli/src/databases/repositories/credentials.repository.ts b/packages/cli/src/databases/repositories/credentials.repository.ts index 77fb9ce97361f..4c62e30f637ed 100644 --- a/packages/cli/src/databases/repositories/credentials.repository.ts +++ b/packages/cli/src/databases/repositories/credentials.repository.ts @@ -1,12 +1,14 @@ -import { Service } from 'typedi'; +import type { Scope } from '@n8n/permissions'; import { DataSource, In, Repository, Like } from '@n8n/typeorm'; import type { FindManyOptions, FindOptionsWhere } from '@n8n/typeorm'; -import { CredentialsEntity } from '../entities/credentials-entity'; +import { Service } from 'typedi'; + import type { ListQuery } from '@/requests'; -import type { User } from '../entities/user'; -import type { Scope } from '@n8n/permissions'; import { RoleService } from '@/services/role.service'; +import { CredentialsEntity } from '../entities/credentials-entity'; +import type { User } from '../entities/user'; + @Service() export class CredentialsRepository extends Repository { constructor( diff --git a/packages/cli/src/databases/repositories/event-destinations.repository.ts b/packages/cli/src/databases/repositories/event-destinations.repository.ts index bc8368559f829..56a2ab0f9043f 100644 --- a/packages/cli/src/databases/repositories/event-destinations.repository.ts +++ b/packages/cli/src/databases/repositories/event-destinations.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { EventDestinations } from '../entities/event-destinations'; @Service() diff --git a/packages/cli/src/databases/repositories/execution-annotation.repository.ts b/packages/cli/src/databases/repositories/execution-annotation.repository.ts index 1b971031cc8f7..81d4917173559 100644 --- a/packages/cli/src/databases/repositories/execution-annotation.repository.ts +++ b/packages/cli/src/databases/repositories/execution-annotation.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; @Service() diff --git a/packages/cli/src/databases/repositories/execution-data.repository.ts b/packages/cli/src/databases/repositories/execution-data.repository.ts index 831ed478a3437..7f54a6f214f97 100644 --- a/packages/cli/src/databases/repositories/execution-data.repository.ts +++ b/packages/cli/src/databases/repositories/execution-data.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, In, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { ExecutionData } from '../entities/execution-data'; @Service() diff --git a/packages/cli/src/databases/repositories/execution-metadata.repository.ts b/packages/cli/src/databases/repositories/execution-metadata.repository.ts index 5eb48e2d242b8..efaf239c4afb5 100644 --- a/packages/cli/src/databases/repositories/execution-metadata.repository.ts +++ b/packages/cli/src/databases/repositories/execution-metadata.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { ExecutionMetadata } from '../entities/execution-metadata'; @Service() diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 711d2b73356ea..52c7fd65f36ac 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -1,5 +1,11 @@ -import { Service } from 'typedi'; -import pick from 'lodash/pick'; +import { GlobalConfig } from '@n8n/config'; +import type { + FindManyOptions, + FindOneOptions, + FindOperator, + FindOptionsWhere, + SelectQueryBuilder, +} from '@n8n/typeorm'; import { Brackets, DataSource, @@ -13,15 +19,8 @@ import { Repository, } from '@n8n/typeorm'; import { DateUtils } from '@n8n/typeorm/util/DateUtils'; -import type { - FindManyOptions, - FindOneOptions, - FindOperator, - FindOptionsWhere, - SelectQueryBuilder, -} from '@n8n/typeorm'; import { parse, stringify } from 'flatted'; -import { GlobalConfig } from '@n8n/config'; +import pick from 'lodash/pick'; import { BinaryDataService } from 'n8n-core'; import { ExecutionCancelledError, @@ -34,26 +33,27 @@ import type { ExecutionSummary, IRunExecutionData, } from 'n8n-workflow'; +import { Service } from 'typedi'; +import config from '@/config'; +import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; +import { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping'; +import { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; +import { PostgresLiveRowsRetrievalError } from '@/errors/postgres-live-rows-retrieval.error'; +import type { ExecutionSummaries } from '@/executions/execution.types'; import type { ExecutionPayload, IExecutionBase, IExecutionFlattedDb, IExecutionResponse, } from '@/interfaces'; +import { Logger } from '@/logger'; +import { separate } from '@/utils'; -import config from '@/config'; +import { ExecutionDataRepository } from './execution-data.repository'; import type { ExecutionData } from '../entities/execution-data'; import { ExecutionEntity } from '../entities/execution-entity'; import { ExecutionMetadata } from '../entities/execution-metadata'; -import { ExecutionDataRepository } from './execution-data.repository'; -import { Logger } from '@/logger'; -import type { ExecutionSummaries } from '@/executions/execution.types'; -import { PostgresLiveRowsRetrievalError } from '@/errors/postgres-live-rows-retrieval.error'; -import { separate } from '@/utils'; -import { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; -import { AnnotationTagMapping } from '@/databases/entities/annotation-tag-mapping'; -import { ExecutionAnnotation } from '@/databases/entities/execution-annotation'; export interface IGetExecutionsQueryFilter { id?: FindOperator | string; diff --git a/packages/cli/src/databases/repositories/installed-nodes.repository.ts b/packages/cli/src/databases/repositories/installed-nodes.repository.ts index e675331f853cc..880b4375cac93 100644 --- a/packages/cli/src/databases/repositories/installed-nodes.repository.ts +++ b/packages/cli/src/databases/repositories/installed-nodes.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { InstalledNodes } from '../entities/installed-nodes'; @Service() diff --git a/packages/cli/src/databases/repositories/installed-packages.repository.ts b/packages/cli/src/databases/repositories/installed-packages.repository.ts index bb1beae952459..50f9e7ad4fa2c 100644 --- a/packages/cli/src/databases/repositories/installed-packages.repository.ts +++ b/packages/cli/src/databases/repositories/installed-packages.repository.ts @@ -1,8 +1,9 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; -import { InstalledPackages } from '../entities/installed-packages'; -import { InstalledNodesRepository } from './installed-nodes.repository'; import type { PackageDirectoryLoader } from 'n8n-core'; +import { Service } from 'typedi'; + +import { InstalledNodesRepository } from './installed-nodes.repository'; +import { InstalledPackages } from '../entities/installed-packages'; @Service() export class InstalledPackagesRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/invalid-auth-token.repository.ts b/packages/cli/src/databases/repositories/invalid-auth-token.repository.ts index 716175fa169ce..94909b998df62 100644 --- a/packages/cli/src/databases/repositories/invalid-auth-token.repository.ts +++ b/packages/cli/src/databases/repositories/invalid-auth-token.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { InvalidAuthToken } from '../entities/invalid-auth-token'; @Service() diff --git a/packages/cli/src/databases/repositories/license-metrics.repository.ts b/packages/cli/src/databases/repositories/license-metrics.repository.ts index 5fdc1985b83bd..6be6ee0e7b2b9 100644 --- a/packages/cli/src/databases/repositories/license-metrics.repository.ts +++ b/packages/cli/src/databases/repositories/license-metrics.repository.ts @@ -1,6 +1,6 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { DataSource, Repository, Entity } from '@n8n/typeorm'; +import { Service } from 'typedi'; @Entity() export class LicenseMetrics {} diff --git a/packages/cli/src/databases/repositories/project-relation.repository.ts b/packages/cli/src/databases/repositories/project-relation.repository.ts index 999f6241f0b4c..8d8faba1ba557 100644 --- a/packages/cli/src/databases/repositories/project-relation.repository.ts +++ b/packages/cli/src/databases/repositories/project-relation.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, In, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { ProjectRelation, type ProjectRole } from '../entities/project-relation'; @Service() diff --git a/packages/cli/src/databases/repositories/project.repository.ts b/packages/cli/src/databases/repositories/project.repository.ts index ff7ec545bafcb..c67d4e94569d7 100644 --- a/packages/cli/src/databases/repositories/project.repository.ts +++ b/packages/cli/src/databases/repositories/project.repository.ts @@ -1,6 +1,7 @@ -import { Service } from 'typedi'; import type { EntityManager } from '@n8n/typeorm'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { Project } from '../entities/project'; @Service() diff --git a/packages/cli/src/databases/repositories/settings.repository.ts b/packages/cli/src/databases/repositories/settings.repository.ts index 635945e3a15ff..8d87fcffffb7b 100644 --- a/packages/cli/src/databases/repositories/settings.repository.ts +++ b/packages/cli/src/databases/repositories/settings.repository.ts @@ -1,9 +1,11 @@ -import { EXTERNAL_SECRETS_DB_KEY } from '@/external-secrets/constants'; -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; import { ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; -import { Settings } from '../entities/settings'; +import { Service } from 'typedi'; + import config from '@/config'; +import { EXTERNAL_SECRETS_DB_KEY } from '@/external-secrets/constants'; + +import { Settings } from '../entities/settings'; @Service() export class SettingsRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/shared-credentials.repository.ts b/packages/cli/src/databases/repositories/shared-credentials.repository.ts index b24d736fff0ef..516c546929ea3 100644 --- a/packages/cli/src/databases/repositories/shared-credentials.repository.ts +++ b/packages/cli/src/databases/repositories/shared-credentials.repository.ts @@ -1,12 +1,14 @@ -import { Service } from 'typedi'; +import type { Scope } from '@n8n/permissions'; import type { EntityManager, FindOptionsRelations, FindOptionsWhere } from '@n8n/typeorm'; import { DataSource, In, Not, Repository } from '@n8n/typeorm'; -import { type CredentialSharingRole, SharedCredentials } from '../entities/shared-credentials'; -import type { User } from '../entities/user'; +import { Service } from 'typedi'; + import { RoleService } from '@/services/role.service'; -import type { Scope } from '@n8n/permissions'; + import type { Project } from '../entities/project'; import type { ProjectRole } from '../entities/project-relation'; +import { type CredentialSharingRole, SharedCredentials } from '../entities/shared-credentials'; +import type { User } from '../entities/user'; @Service() export class SharedCredentialsRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/shared-workflow.repository.ts b/packages/cli/src/databases/repositories/shared-workflow.repository.ts index 37b47b8f1c968..31eef22e2adc7 100644 --- a/packages/cli/src/databases/repositories/shared-workflow.repository.ts +++ b/packages/cli/src/databases/repositories/shared-workflow.repository.ts @@ -1,11 +1,13 @@ -import { Service } from 'typedi'; +import type { Scope } from '@n8n/permissions'; import { DataSource, Repository, In, Not } from '@n8n/typeorm'; import type { EntityManager, FindManyOptions, FindOptionsWhere } from '@n8n/typeorm'; -import { SharedWorkflow, type WorkflowSharingRole } from '../entities/shared-workflow'; -import { type User } from '../entities/user'; -import type { Scope } from '@n8n/permissions'; +import { Service } from 'typedi'; + import { RoleService } from '@/services/role.service'; + import type { Project } from '../entities/project'; +import { SharedWorkflow, type WorkflowSharingRole } from '../entities/shared-workflow'; +import { type User } from '../entities/user'; @Service() export class SharedWorkflowRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/tag.repository.ts b/packages/cli/src/databases/repositories/tag.repository.ts index c4a36d77d223c..800fe225ae443 100644 --- a/packages/cli/src/databases/repositories/tag.repository.ts +++ b/packages/cli/src/databases/repositories/tag.repository.ts @@ -1,9 +1,10 @@ -import { Service } from 'typedi'; import type { EntityManager } from '@n8n/typeorm'; import { DataSource, In, Repository } from '@n8n/typeorm'; +import intersection from 'lodash/intersection'; +import { Service } from 'typedi'; + import { TagEntity } from '../entities/tag-entity'; import type { WorkflowEntity } from '../entities/workflow-entity'; -import intersection from 'lodash/intersection'; @Service() export class TagRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/user.repository.ts b/packages/cli/src/databases/repositories/user.repository.ts index 40bf42edeab07..61a4edffa5061 100644 --- a/packages/cli/src/databases/repositories/user.repository.ts +++ b/packages/cli/src/databases/repositories/user.repository.ts @@ -1,11 +1,12 @@ -import { Service } from 'typedi'; import type { DeepPartial, EntityManager, FindManyOptions } from '@n8n/typeorm'; import { DataSource, In, IsNull, Not, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import type { ListQuery } from '@/requests'; -import { type GlobalRole, User } from '../entities/user'; import { Project } from '../entities/project'; import { ProjectRelation } from '../entities/project-relation'; +import { type GlobalRole, User } from '../entities/user'; @Service() export class UserRepository extends Repository { diff --git a/packages/cli/src/databases/repositories/variables.repository.ts b/packages/cli/src/databases/repositories/variables.repository.ts index 1b6c4c7cc5734..2f2500250b2b7 100644 --- a/packages/cli/src/databases/repositories/variables.repository.ts +++ b/packages/cli/src/databases/repositories/variables.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { Variables } from '../entities/variables'; @Service() diff --git a/packages/cli/src/databases/repositories/webhook.repository.ts b/packages/cli/src/databases/repositories/webhook.repository.ts index 1ea710beec388..b89b9fba0f626 100644 --- a/packages/cli/src/databases/repositories/webhook.repository.ts +++ b/packages/cli/src/databases/repositories/webhook.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { WebhookEntity } from '../entities/webhook-entity'; @Service() diff --git a/packages/cli/src/databases/repositories/workflow-history.repository.ts b/packages/cli/src/databases/repositories/workflow-history.repository.ts index 3e44eb91d1986..ca791ebcb7c57 100644 --- a/packages/cli/src/databases/repositories/workflow-history.repository.ts +++ b/packages/cli/src/databases/repositories/workflow-history.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, LessThan, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { WorkflowHistory } from '../entities/workflow-history'; @Service() diff --git a/packages/cli/src/databases/repositories/workflow-statistics.repository.ts b/packages/cli/src/databases/repositories/workflow-statistics.repository.ts index 0b8f35f647293..c2ea18fe2c656 100644 --- a/packages/cli/src/databases/repositories/workflow-statistics.repository.ts +++ b/packages/cli/src/databases/repositories/workflow-statistics.repository.ts @@ -1,9 +1,11 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { DataSource, MoreThanOrEqual, QueryFailedError, Repository } from '@n8n/typeorm'; -import { StatisticsNames, WorkflowStatistics } from '../entities/workflow-statistics'; +import { Service } from 'typedi'; + import type { User } from '@/databases/entities/user'; +import { StatisticsNames, WorkflowStatistics } from '../entities/workflow-statistics'; + type StatisticsInsertResult = 'insert' | 'failed' | 'alreadyExists'; type StatisticsUpsertResult = StatisticsInsertResult | 'update'; diff --git a/packages/cli/src/databases/repositories/workflow-tag-mapping.repository.ts b/packages/cli/src/databases/repositories/workflow-tag-mapping.repository.ts index 43123023c81af..108affaf116a7 100644 --- a/packages/cli/src/databases/repositories/workflow-tag-mapping.repository.ts +++ b/packages/cli/src/databases/repositories/workflow-tag-mapping.repository.ts @@ -1,5 +1,6 @@ -import { Service } from 'typedi'; import { DataSource, Repository } from '@n8n/typeorm'; +import { Service } from 'typedi'; + import { WorkflowTagMapping } from '../entities/workflow-tag-mapping'; @Service() diff --git a/packages/cli/src/databases/repositories/workflow.repository.ts b/packages/cli/src/databases/repositories/workflow.repository.ts index fcebc5190b66f..0317124472720 100644 --- a/packages/cli/src/databases/repositories/workflow.repository.ts +++ b/packages/cli/src/databases/repositories/workflow.repository.ts @@ -1,4 +1,3 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { DataSource, @@ -11,11 +10,14 @@ import { type FindManyOptions, type FindOptionsRelations, } from '@n8n/typeorm'; +import { Service } from 'typedi'; + +import config from '@/config'; import type { ListQuery } from '@/requests'; import { isStringArray } from '@/utils'; -import config from '@/config'; -import { WorkflowEntity } from '../entities/workflow-entity'; + import { WebhookEntity } from '../entities/webhook-entity'; +import { WorkflowEntity } from '../entities/workflow-entity'; @Service() export class WorkflowRepository extends Repository { diff --git a/packages/cli/src/databases/subscribers/user-subscriber.ts b/packages/cli/src/databases/subscribers/user-subscriber.ts index 29aa387cad724..4bb2cc98d368b 100644 --- a/packages/cli/src/databases/subscribers/user-subscriber.ts +++ b/packages/cli/src/databases/subscribers/user-subscriber.ts @@ -1,7 +1,8 @@ -import { Container } from 'typedi'; import type { EntitySubscriberInterface, UpdateEvent } from '@n8n/typeorm'; import { EventSubscriber } from '@n8n/typeorm'; import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; +import { Container } from 'typedi'; + import { Logger } from '@/logger'; import { Project } from '../entities/project'; diff --git a/packages/cli/src/databases/types.ts b/packages/cli/src/databases/types.ts index 96a26e4712016..21bfdc025a29f 100644 --- a/packages/cli/src/databases/types.ts +++ b/packages/cli/src/databases/types.ts @@ -1,6 +1,8 @@ -import type { INodeTypes } from 'n8n-workflow'; import type { QueryRunner, ObjectLiteral } from '@n8n/typeorm'; +import type { INodeTypes } from 'n8n-workflow'; + import type { Logger } from '@/logger'; + import type { createSchemaBuilder } from './dsl'; export type DatabaseType = 'mariadb' | 'postgresdb' | 'mysqldb' | 'sqlite'; diff --git a/packages/cli/src/databases/utils/generators.ts b/packages/cli/src/databases/utils/generators.ts index 5c4a40cb77f90..3bc24712a203c 100644 --- a/packages/cli/src/databases/utils/generators.ts +++ b/packages/cli/src/databases/utils/generators.ts @@ -1,5 +1,6 @@ -import { customAlphabet } from 'nanoid'; import { ALPHABET } from 'n8n-workflow'; +import { customAlphabet } from 'nanoid'; + import type { N8nInstanceType } from '@/interfaces'; const nanoid = customAlphabet(ALPHABET, 16); diff --git a/packages/cli/src/databases/utils/migration-helpers.ts b/packages/cli/src/databases/utils/migration-helpers.ts index 072d7b3fd4dcf..9d29e3fbe5903 100644 --- a/packages/cli/src/databases/utils/migration-helpers.ts +++ b/packages/cli/src/databases/utils/migration-helpers.ts @@ -1,16 +1,16 @@ -import { Container } from 'typedi'; import { GlobalConfig } from '@n8n/config'; -import { readFileSync, rmSync } from 'fs'; -import { InstanceSettings } from 'n8n-core'; import type { ObjectLiteral } from '@n8n/typeorm'; import type { QueryRunner } from '@n8n/typeorm/query-runner/QueryRunner'; +import { readFileSync, rmSync } from 'fs'; +import { InstanceSettings } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { Container } from 'typedi'; import { inTest } from '@/constants'; -import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@/databases/types'; import { createSchemaBuilder } from '@/databases/dsl'; -import { NodeTypes } from '@/node-types'; +import type { BaseMigration, Migration, MigrationContext, MigrationFn } from '@/databases/types'; import { Logger } from '@/logger'; +import { NodeTypes } from '@/node-types'; const PERSONALIZATION_SURVEY_FILENAME = 'personalizationSurvey.json'; diff --git a/packages/cli/src/databases/utils/transformers.ts b/packages/cli/src/databases/utils/transformers.ts index a08440a8e81ef..a18d0cf633c13 100644 --- a/packages/cli/src/databases/utils/transformers.ts +++ b/packages/cli/src/databases/utils/transformers.ts @@ -1,7 +1,7 @@ -import { Container } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import type { ValueTransformer, FindOperator } from '@n8n/typeorm'; import { jsonParse } from 'n8n-workflow'; +import { Container } from 'typedi'; export const idStringifier = { from: (value?: number): string | undefined => value?.toString(), diff --git a/packages/cli/src/db.ts b/packages/cli/src/db.ts index 2645865d0bb18..13147b4106ac1 100644 --- a/packages/cli/src/db.ts +++ b/packages/cli/src/db.ts @@ -1,4 +1,3 @@ -import { Container } from 'typedi'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { EntityManager } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import @@ -8,11 +7,12 @@ import { ensureError, ErrorReporterProxy as ErrorReporter, } from 'n8n-workflow'; +import { Container } from 'typedi'; import { inTest } from '@/constants'; -import { wrapMigration } from '@/databases/utils/migration-helpers'; -import type { Migration } from '@/databases/types'; import { getConnectionOptions, arePostgresOptions } from '@/databases/config'; +import type { Migration } from '@/databases/types'; +import { wrapMigration } from '@/databases/utils/migration-helpers'; let connection: Connection; diff --git a/packages/cli/src/decorators/__tests__/controller.registry.test.ts b/packages/cli/src/decorators/__tests__/controller.registry.test.ts index 3a0f0b91d2d51..0d7b9de0b79b7 100644 --- a/packages/cli/src/decorators/__tests__/controller.registry.test.ts +++ b/packages/cli/src/decorators/__tests__/controller.registry.test.ts @@ -2,15 +2,15 @@ jest.mock('@/constants', () => ({ inProduction: true, })); +import type { GlobalConfig } from '@n8n/config'; import express from 'express'; -import { agent as testAgent } from 'supertest'; import { mock } from 'jest-mock-extended'; +import { agent as testAgent } from 'supertest'; -import { ControllerRegistry, Get, Licensed, RestController } from '@/decorators'; import type { AuthService } from '@/auth/auth.service'; +import { ControllerRegistry, Get, Licensed, RestController } from '@/decorators'; import type { License } from '@/license'; import type { SuperAgentTest } from '@test-integration/types'; -import type { GlobalConfig } from '@n8n/config'; describe('ControllerRegistry', () => { const license = mock(); diff --git a/packages/cli/src/decorators/__tests__/on-shutdown.test.ts b/packages/cli/src/decorators/__tests__/on-shutdown.test.ts index f8d11140cfb52..28e70dac47328 100644 --- a/packages/cli/src/decorators/__tests__/on-shutdown.test.ts +++ b/packages/cli/src/decorators/__tests__/on-shutdown.test.ts @@ -1,7 +1,8 @@ +import { mock } from 'jest-mock-extended'; import Container, { Service } from 'typedi'; + import { OnShutdown } from '@/decorators/on-shutdown'; import { ShutdownService } from '@/shutdown/shutdown.service'; -import { mock } from 'jest-mock-extended'; describe('OnShutdown', () => { let shutdownService: ShutdownService; diff --git a/packages/cli/src/decorators/controller.registry.ts b/packages/cli/src/decorators/controller.registry.ts index a550bef6eada9..7e8a17301d18c 100644 --- a/packages/cli/src/decorators/controller.registry.ts +++ b/packages/cli/src/decorators/controller.registry.ts @@ -1,17 +1,18 @@ -import { Container, Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { Router } from 'express'; import type { Application, Request, Response, RequestHandler } from 'express'; import { rateLimit as expressRateLimit } from 'express-rate-limit'; +import { Container, Service } from 'typedi'; import { AuthService } from '@/auth/auth.service'; -import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error'; import { inProduction, RESPONSE_ERROR_MESSAGES } from '@/constants'; +import { UnauthenticatedError } from '@/errors/response-errors/unauthenticated.error'; import type { BooleanLicenseFeature } from '@/interfaces'; import { License } from '@/license'; +import { userHasScope } from '@/permissions/check-access'; import type { AuthenticatedRequest } from '@/requests'; import { send } from '@/response-helper'; // TODO: move `ResponseHelper.send` to this file -import { userHasScope } from '@/permissions/check-access'; -import { GlobalConfig } from '@n8n/config'; + import type { AccessScope, Controller, diff --git a/packages/cli/src/decorators/licensed.ts b/packages/cli/src/decorators/licensed.ts index 10936562eb202..16403396c7863 100644 --- a/packages/cli/src/decorators/licensed.ts +++ b/packages/cli/src/decorators/licensed.ts @@ -1,4 +1,5 @@ import type { BooleanLicenseFeature } from '@/interfaces'; + import { getRouteMetadata } from './controller.registry'; import type { Controller } from './types'; diff --git a/packages/cli/src/decorators/on-shutdown.ts b/packages/cli/src/decorators/on-shutdown.ts index ec2d955fe6fa4..dbcb547d420de 100644 --- a/packages/cli/src/decorators/on-shutdown.ts +++ b/packages/cli/src/decorators/on-shutdown.ts @@ -1,7 +1,8 @@ -import { Container } from 'typedi'; import { ApplicationError } from 'n8n-workflow'; -import { type ServiceClass, ShutdownService } from '@/shutdown/shutdown.service'; +import { Container } from 'typedi'; + import { DEFAULT_SHUTDOWN_PRIORITY } from '@/constants'; +import { type ServiceClass, ShutdownService } from '@/shutdown/shutdown.service'; /** * Decorator that registers a method as a shutdown hook. The method will diff --git a/packages/cli/src/decorators/rest-controller.ts b/packages/cli/src/decorators/rest-controller.ts index 278504ad60756..d540f6a8ac41d 100644 --- a/packages/cli/src/decorators/rest-controller.ts +++ b/packages/cli/src/decorators/rest-controller.ts @@ -1,4 +1,5 @@ import { Service } from 'typedi'; + import { getControllerMetadata } from './controller.registry'; import type { Controller } from './types'; diff --git a/packages/cli/src/decorators/route.ts b/packages/cli/src/decorators/route.ts index 42ce97bc6e184..f221cbb84157b 100644 --- a/packages/cli/src/decorators/route.ts +++ b/packages/cli/src/decorators/route.ts @@ -1,6 +1,7 @@ import type { RequestHandler } from 'express'; -import type { Controller, Method, RateLimit } from './types'; + import { getRouteMetadata } from './controller.registry'; +import type { Controller, Method, RateLimit } from './types'; interface RouteOptions { middlewares?: RequestHandler[]; diff --git a/packages/cli/src/decorators/scoped.ts b/packages/cli/src/decorators/scoped.ts index 8a3f0b02a57e5..1a30fe3a69e14 100644 --- a/packages/cli/src/decorators/scoped.ts +++ b/packages/cli/src/decorators/scoped.ts @@ -1,4 +1,5 @@ import type { Scope } from '@n8n/permissions'; + import { getRouteMetadata } from './controller.registry'; import type { Controller } from './types'; diff --git a/packages/cli/src/decorators/types.ts b/packages/cli/src/decorators/types.ts index da531599a2b50..f18faf5ed5760 100644 --- a/packages/cli/src/decorators/types.ts +++ b/packages/cli/src/decorators/types.ts @@ -1,7 +1,8 @@ +import type { Scope } from '@n8n/permissions'; import type { RequestHandler } from 'express'; import type { Class } from 'n8n-core'; + import type { BooleanLicenseFeature } from '@/interfaces'; -import type { Scope } from '@n8n/permissions'; export type Method = 'get' | 'post' | 'put' | 'patch' | 'delete'; diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts b/packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts index 88096f8206b07..82f1000671085 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts +++ b/packages/cli/src/environments/source-control/__tests__/source-control-export.service.test.ts @@ -1,14 +1,15 @@ import mock from 'jest-mock-extended/lib/Mock'; -import { SourceControlExportService } from '../source-control-export.service.ee'; -import type { SourceControlledFile } from '../types/source-controlled-file'; import { Cipher, type InstanceSettings } from 'n8n-core'; +import { ApplicationError, deepCopy } from 'n8n-workflow'; +import Container from 'typedi'; + +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { SharedCredentials } from '@/databases/entities/shared-credentials'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { mockInstance } from '@test/mocking'; -import type { SharedCredentials } from '@/databases/entities/shared-credentials'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; -import Container from 'typedi'; -import { ApplicationError, deepCopy } from 'n8n-workflow'; +import { SourceControlExportService } from '../source-control-export.service.ee'; +import type { SourceControlledFile } from '../types/source-controlled-file'; // https://github.com/jestjs/jest/issues/4715 function deepSpyOn(object: O, methodName: M) { diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts b/packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts index a97e3e5b218e0..acdc2d9c8eaa5 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts +++ b/packages/cli/src/environments/source-control/__tests__/source-control-git.service.test.ts @@ -1,8 +1,10 @@ import { mock } from 'jest-mock-extended'; -import { SourceControlGitService } from '../source-control-git.service.ee'; import { simpleGit } from 'simple-git'; import type { SimpleGit } from 'simple-git'; + import type { User } from '@/databases/entities/user'; + +import { SourceControlGitService } from '../source-control-git.service.ee'; import type { SourceControlPreferences } from '../types/source-control-preferences'; const MOCK_BRANCHES = { diff --git a/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts b/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts index 3009101b5c3b0..508d1eb49a4bd 100644 --- a/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts +++ b/packages/cli/src/environments/source-control/__tests__/source-control-helper.ee.test.ts @@ -1,4 +1,12 @@ +import { constants as fsConstants, accessSync } from 'fs'; +import { InstanceSettings } from 'n8n-core'; +import path from 'path'; import Container from 'typedi'; + +import { + SOURCE_CONTROL_SSH_FOLDER, + SOURCE_CONTROL_GIT_FOLDER, +} from '@/environments/source-control/constants'; import { generateSshKeyPair, getRepoType, @@ -7,17 +15,10 @@ import { getTrackingInformationFromPullResult, sourceControlFoldersExistCheck, } from '@/environments/source-control/source-control-helper.ee'; -import { License } from '@/license'; import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; -import { InstanceSettings } from 'n8n-core'; -import path from 'path'; -import { - SOURCE_CONTROL_SSH_FOLDER, - SOURCE_CONTROL_GIT_FOLDER, -} from '@/environments/source-control/constants'; -import { constants as fsConstants, accessSync } from 'fs'; -import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; import type { SourceControlPreferences } from '@/environments/source-control/types/source-control-preferences'; +import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +import { License } from '@/license'; import { mockInstance } from '@test/mocking'; const pushResult: SourceControlledFile[] = [ diff --git a/packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts b/packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts index 24317ecbe16bd..2a8480561dad4 100644 --- a/packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts +++ b/packages/cli/src/environments/source-control/middleware/source-control-enabled-middleware.ee.ts @@ -1,5 +1,6 @@ import type { RequestHandler } from 'express'; import { Container } from 'typedi'; + import { isSourceControlLicensed } from '../source-control-helper.ee'; import { SourceControlPreferencesService } from '../source-control-preferences.service.ee'; diff --git a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts index 2be67ef41b3b3..6fb904b4a0f3f 100644 --- a/packages/cli/src/environments/source-control/source-control-export.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-export.service.ee.ts @@ -1,18 +1,24 @@ -import Container, { Service } from 'typedi'; +import { rmSync } from 'fs'; +import { writeFile as fsWriteFile, rm as fsRm } from 'fs/promises'; +import { Credentials, InstanceSettings } from 'n8n-core'; +import { ApplicationError, type ICredentialDataDecryptedObject } from 'n8n-workflow'; import path from 'path'; +import Container, { Service } from 'typedi'; + +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { TagRepository } from '@/databases/repositories/tag.repository'; +import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { Logger } from '@/logger'; + import { SOURCE_CONTROL_CREDENTIAL_EXPORT_FOLDER, SOURCE_CONTROL_GIT_FOLDER, SOURCE_CONTROL_TAGS_EXPORT_FILE, SOURCE_CONTROL_WORKFLOW_EXPORT_FOLDER, } from './constants'; -import { ApplicationError, type ICredentialDataDecryptedObject } from 'n8n-workflow'; -import { writeFile as fsWriteFile, rm as fsRm } from 'fs/promises'; -import { rmSync } from 'fs'; -import { Credentials, InstanceSettings } from 'n8n-core'; -import type { ExportableWorkflow } from './types/exportable-workflow'; -import type { ExportableCredential } from './types/exportable-credential'; -import type { ExportResult } from './types/export-result'; import { getCredentialExportPath, getVariablesPath, @@ -20,16 +26,12 @@ import { sourceControlFoldersExistCheck, stringContainsExpression, } from './source-control-helper.ee'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import type { ExportResult } from './types/export-result'; +import type { ExportableCredential } from './types/exportable-credential'; +import type { ExportableWorkflow } from './types/exportable-workflow'; +import type { ResourceOwner } from './types/resource-owner'; import type { SourceControlledFile } from './types/source-controlled-file'; import { VariablesService } from '../variables/variables.service.ee'; -import { TagRepository } from '@/databases/repositories/tag.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logger'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; -import type { ResourceOwner } from './types/resource-owner'; @Service() export class SourceControlExportService { diff --git a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts index a2201e3ad0873..14cdb9e81a023 100644 --- a/packages/cli/src/environments/source-control/source-control-git.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-git.service.ee.ts @@ -1,5 +1,5 @@ -import { Service } from 'typedi'; import { execSync } from 'child_process'; +import { ApplicationError } from 'n8n-workflow'; import path from 'path'; import type { CommitResult, @@ -11,7 +11,12 @@ import type { SimpleGitOptions, StatusResult, } from 'simple-git'; -import type { SourceControlPreferences } from './types/source-control-preferences'; +import { Service } from 'typedi'; + +import type { User } from '@/databases/entities/user'; +import { Logger } from '@/logger'; +import { OwnershipService } from '@/services/ownership.service'; + import { SOURCE_CONTROL_DEFAULT_BRANCH, SOURCE_CONTROL_DEFAULT_EMAIL, @@ -19,11 +24,8 @@ import { SOURCE_CONTROL_ORIGIN, } from './constants'; import { sourceControlFoldersExistCheck } from './source-control-helper.ee'; -import type { User } from '@/databases/entities/user'; -import { Logger } from '@/logger'; -import { ApplicationError } from 'n8n-workflow'; -import { OwnershipService } from '@/services/ownership.service'; import { SourceControlPreferencesService } from './source-control-preferences.service.ee'; +import type { SourceControlPreferences } from './types/source-control-preferences'; @Service() export class SourceControlGitService { diff --git a/packages/cli/src/environments/source-control/source-control-helper.ee.ts b/packages/cli/src/environments/source-control/source-control-helper.ee.ts index 738f4212f50e6..29393c5efe0f2 100644 --- a/packages/cli/src/environments/source-control/source-control-helper.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-helper.ee.ts @@ -1,17 +1,19 @@ -import { Container } from 'typedi'; -import { License } from '@/license'; import { generateKeyPairSync } from 'crypto'; -import type { KeyPair } from './types/key-pair'; import { constants as fsConstants, mkdirSync, accessSync } from 'fs'; +import path from 'path'; +import { Container } from 'typedi'; + +import { License } from '@/license'; +import { Logger } from '@/logger'; + import { SOURCE_CONTROL_GIT_KEY_COMMENT, SOURCE_CONTROL_TAGS_EXPORT_FILE, SOURCE_CONTROL_VARIABLES_EXPORT_FILE, } from './constants'; -import type { SourceControlledFile } from './types/source-controlled-file'; -import path from 'path'; +import type { KeyPair } from './types/key-pair'; import type { KeyPairType } from './types/key-pair-type'; -import { Logger } from '@/logger'; +import type { SourceControlledFile } from './types/source-controlled-file'; export function stringContainsExpression(testString: string): boolean { return /^=.*\{\{.*\}\}/.test(testString); diff --git a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts index 44d3de3ccbe33..bf69975e2b43b 100644 --- a/packages/cli/src/environments/source-control/source-control-import.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-import.service.ee.ts @@ -1,5 +1,32 @@ -import { Container, Service } from 'typedi'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In } from '@n8n/typeorm'; +import glob from 'fast-glob'; +import { readFile as fsReadFile } from 'fs/promises'; +import { Credentials, InstanceSettings } from 'n8n-core'; +import { ApplicationError, jsonParse, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; import path from 'path'; +import { Container, Service } from 'typedi'; + +import { ActiveWorkflowManager } from '@/active-workflow-manager'; +import type { Project } from '@/databases/entities/project'; +import { SharedCredentials } from '@/databases/entities/shared-credentials'; +import type { TagEntity } from '@/databases/entities/tag-entity'; +import type { Variables } from '@/databases/entities/variables'; +import type { WorkflowTagMapping } from '@/databases/entities/workflow-tag-mapping'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { TagRepository } from '@/databases/repositories/tag.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { VariablesRepository } from '@/databases/repositories/variables.repository'; +import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { IWorkflowToImport } from '@/interfaces'; +import { Logger } from '@/logger'; +import { isUniqueConstraintError } from '@/response-helper'; +import { assertNever } from '@/utils'; + import { SOURCE_CONTROL_CREDENTIAL_EXPORT_FOLDER, SOURCE_CONTROL_GIT_FOLDER, @@ -7,37 +34,12 @@ import { SOURCE_CONTROL_VARIABLES_EXPORT_FILE, SOURCE_CONTROL_WORKFLOW_EXPORT_FOLDER, } from './constants'; -import glob from 'fast-glob'; -import { ApplicationError, jsonParse, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; -import { readFile as fsReadFile } from 'fs/promises'; -import { Credentials, InstanceSettings } from 'n8n-core'; -import type { IWorkflowToImport } from '@/interfaces'; +import { getCredentialExportPath, getWorkflowExportPath } from './source-control-helper.ee'; import type { ExportableCredential } from './types/exportable-credential'; -import type { Variables } from '@/databases/entities/variables'; -import { SharedCredentials } from '@/databases/entities/shared-credentials'; -import type { WorkflowTagMapping } from '@/databases/entities/workflow-tag-mapping'; -import type { TagEntity } from '@/databases/entities/tag-entity'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In } from '@n8n/typeorm'; -import { isUniqueConstraintError } from '@/response-helper'; +import type { ResourceOwner } from './types/resource-owner'; import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id'; -import { getCredentialExportPath, getWorkflowExportPath } from './source-control-helper.ee'; import type { SourceControlledFile } from './types/source-controlled-file'; import { VariablesService } from '../variables/variables.service.ee'; -import { TagRepository } from '@/databases/repositories/tag.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Logger } from '@/logger'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; -import { VariablesRepository } from '@/databases/repositories/variables.repository'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import type { Project } from '@/databases/entities/project'; -import type { ResourceOwner } from './types/resource-owner'; -import { assertNever } from '@/utils'; -import { UserRepository } from '@/databases/repositories/user.repository'; @Service() export class SourceControlImportService { diff --git a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts index 8e69e8e72afcc..a99c5fb3e8b1c 100644 --- a/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control-preferences.service.ee.ts @@ -1,23 +1,25 @@ -import { writeFile, chmod, readFile } from 'node:fs/promises'; -import Container, { Service } from 'typedi'; -import { SourceControlPreferences } from './types/source-control-preferences'; import type { ValidationError } from 'class-validator'; import { validate } from 'class-validator'; import { rm as fsRm } from 'fs/promises'; -import { generateSshKeyPair, isSourceControlLicensed } from './source-control-helper.ee'; import { Cipher, InstanceSettings } from 'n8n-core'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { writeFile, chmod, readFile } from 'node:fs/promises'; +import path from 'path'; +import Container, { Service } from 'typedi'; + +import config from '@/config'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { Logger } from '@/logger'; + import { SOURCE_CONTROL_SSH_FOLDER, SOURCE_CONTROL_GIT_FOLDER, SOURCE_CONTROL_SSH_KEY_NAME, SOURCE_CONTROL_PREFERENCES_DB_KEY, } from './constants'; -import path from 'path'; +import { generateSshKeyPair, isSourceControlLicensed } from './source-control-helper.ee'; import type { KeyPairType } from './types/key-pair-type'; -import config from '@/config'; -import { Logger } from '@/logger'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { SourceControlPreferences } from './types/source-control-preferences'; @Service() export class SourceControlPreferencesService { diff --git a/packages/cli/src/environments/source-control/source-control.controller.ee.ts b/packages/cli/src/environments/source-control/source-control.controller.ee.ts index d927ee2a9bd00..7e41fd7cae1ea 100644 --- a/packages/cli/src/environments/source-control/source-control.controller.ee.ts +++ b/packages/cli/src/environments/source-control/source-control.controller.ee.ts @@ -1,21 +1,23 @@ -import type { PullResult } from 'simple-git'; import express from 'express'; +import type { PullResult } from 'simple-git'; + import { Get, Post, Patch, RestController, GlobalScope } from '@/decorators'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { EventService } from '@/events/event.service'; + +import { SOURCE_CONTROL_DEFAULT_BRANCH } from './constants'; import { sourceControlLicensedMiddleware, sourceControlLicensedAndEnabledMiddleware, } from './middleware/source-control-enabled-middleware.ee'; +import { getRepoType } from './source-control-helper.ee'; +import { SourceControlPreferencesService } from './source-control-preferences.service.ee'; import { SourceControlService } from './source-control.service.ee'; +import type { ImportResult } from './types/import-result'; import { SourceControlRequest } from './types/requests'; -import { SourceControlPreferencesService } from './source-control-preferences.service.ee'; +import { SourceControlGetStatus } from './types/source-control-get-status'; import type { SourceControlPreferences } from './types/source-control-preferences'; import type { SourceControlledFile } from './types/source-controlled-file'; -import { SOURCE_CONTROL_DEFAULT_BRANCH } from './constants'; -import type { ImportResult } from './types/import-result'; -import { EventService } from '@/events/event.service'; -import { getRepoType } from './source-control-helper.ee'; -import { SourceControlGetStatus } from './types/source-control-get-status'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; @RestController('/source-control') export class SourceControlController { diff --git a/packages/cli/src/environments/source-control/source-control.service.ee.ts b/packages/cli/src/environments/source-control/source-control.service.ee.ts index add002935ac42..11340a0e15206 100644 --- a/packages/cli/src/environments/source-control/source-control.service.ee.ts +++ b/packages/cli/src/environments/source-control/source-control.service.ee.ts @@ -1,5 +1,24 @@ -import { Service } from 'typedi'; +import { writeFileSync } from 'fs'; +import { ApplicationError } from 'n8n-workflow'; import path from 'path'; +import type { PushResult } from 'simple-git'; +import { Service } from 'typedi'; + +import type { TagEntity } from '@/databases/entities/tag-entity'; +import type { User } from '@/databases/entities/user'; +import type { Variables } from '@/databases/entities/variables'; +import { TagRepository } from '@/databases/repositories/tag.repository'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { EventService } from '@/events/event.service'; +import { Logger } from '@/logger'; + +import { + SOURCE_CONTROL_DEFAULT_EMAIL, + SOURCE_CONTROL_DEFAULT_NAME, + SOURCE_CONTROL_README, +} from './constants'; +import { SourceControlExportService } from './source-control-export.service.ee'; +import { SourceControlGitService } from './source-control-git.service.ee'; import { getTagsPath, getTrackingInformationFromPostPushResult, @@ -8,33 +27,16 @@ import { getVariablesPath, sourceControlFoldersExistCheck, } from './source-control-helper.ee'; -import type { SourceControlPreferences } from './types/source-control-preferences'; -import { - SOURCE_CONTROL_DEFAULT_EMAIL, - SOURCE_CONTROL_DEFAULT_NAME, - SOURCE_CONTROL_README, -} from './constants'; -import { SourceControlGitService } from './source-control-git.service.ee'; -import type { PushResult } from 'simple-git'; -import { SourceControlExportService } from './source-control-export.service.ee'; -import type { ImportResult } from './types/import-result'; -import type { SourceControlPushWorkFolder } from './types/source-control-push-work-folder'; -import type { SourceControllPullOptions } from './types/source-control-pull-work-folder'; -import type { SourceControlledFile } from './types/source-controlled-file'; -import { SourceControlPreferencesService } from './source-control-preferences.service.ee'; -import { writeFileSync } from 'fs'; import { SourceControlImportService } from './source-control-import.service.ee'; -import type { User } from '@/databases/entities/user'; +import { SourceControlPreferencesService } from './source-control-preferences.service.ee'; +import type { ExportableCredential } from './types/exportable-credential'; +import type { ImportResult } from './types/import-result'; import type { SourceControlGetStatus } from './types/source-control-get-status'; -import type { TagEntity } from '@/databases/entities/tag-entity'; -import type { Variables } from '@/databases/entities/variables'; +import type { SourceControlPreferences } from './types/source-control-preferences'; +import type { SourceControllPullOptions } from './types/source-control-pull-work-folder'; +import type { SourceControlPushWorkFolder } from './types/source-control-push-work-folder'; import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id'; -import type { ExportableCredential } from './types/exportable-credential'; -import { EventService } from '@/events/event.service'; -import { TagRepository } from '@/databases/repositories/tag.repository'; -import { Logger } from '@/logger'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { ApplicationError } from 'n8n-workflow'; +import type { SourceControlledFile } from './types/source-controlled-file'; @Service() export class SourceControlService { diff --git a/packages/cli/src/environments/source-control/types/exportable-credential.ts b/packages/cli/src/environments/source-control/types/exportable-credential.ts index a15f5b4890ec2..a15a8658b6ce2 100644 --- a/packages/cli/src/environments/source-control/types/exportable-credential.ts +++ b/packages/cli/src/environments/source-control/types/exportable-credential.ts @@ -1,4 +1,5 @@ import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; + import type { ResourceOwner } from './resource-owner'; export interface ExportableCredential { diff --git a/packages/cli/src/environments/source-control/types/exportable-workflow.ts b/packages/cli/src/environments/source-control/types/exportable-workflow.ts index 56cec13537d0f..f4e281d3d4e53 100644 --- a/packages/cli/src/environments/source-control/types/exportable-workflow.ts +++ b/packages/cli/src/environments/source-control/types/exportable-workflow.ts @@ -1,4 +1,5 @@ import type { INode, IConnections, IWorkflowSettings } from 'n8n-workflow'; + import type { ResourceOwner } from './resource-owner'; export interface ExportableWorkflow { diff --git a/packages/cli/src/environments/source-control/types/requests.ts b/packages/cli/src/environments/source-control/types/requests.ts index 5855b0af4ba04..4f5d583f40eac 100644 --- a/packages/cli/src/environments/source-control/types/requests.ts +++ b/packages/cli/src/environments/source-control/types/requests.ts @@ -1,15 +1,16 @@ import type { AuthenticatedRequest } from '@/requests'; -import type { SourceControlPreferences } from './source-control-preferences'; -import type { SourceControlSetBranch } from './source-control-set-branch'; + import type { SourceControlCommit } from './source-control-commit'; -import type { SourceControlStage } from './source-control-stage'; +import type { SourceControlDisconnect } from './source-control-disconnect'; +import type { SourceControlGenerateKeyPair } from './source-control-generate-key-pair'; +import type { SourceControlGetStatus } from './source-control-get-status'; +import type { SourceControlPreferences } from './source-control-preferences'; +import type { SourceControlPullWorkFolder } from './source-control-pull-work-folder'; import type { SourceControlPush } from './source-control-push'; import type { SourceControlPushWorkFolder } from './source-control-push-work-folder'; -import type { SourceControlPullWorkFolder } from './source-control-pull-work-folder'; -import type { SourceControlDisconnect } from './source-control-disconnect'; +import type { SourceControlSetBranch } from './source-control-set-branch'; import type { SourceControlSetReadOnly } from './source-control-set-read-only'; -import type { SourceControlGetStatus } from './source-control-get-status'; -import type { SourceControlGenerateKeyPair } from './source-control-generate-key-pair'; +import type { SourceControlStage } from './source-control-stage'; export declare namespace SourceControlRequest { type UpdatePreferences = AuthenticatedRequest<{}, {}, Partial, {}>; diff --git a/packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts b/packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts index 9f9093b432ba5..b5ec734b6e506 100644 --- a/packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts +++ b/packages/cli/src/environments/source-control/types/source-control-generate-key-pair.ts @@ -1,4 +1,5 @@ import { IsOptional, IsString } from 'class-validator'; + import { KeyPairType } from './key-pair-type'; export class SourceControlGenerateKeyPair { diff --git a/packages/cli/src/environments/source-control/types/source-control-preferences.ts b/packages/cli/src/environments/source-control/types/source-control-preferences.ts index ecda479ef6cda..3965ba404160f 100644 --- a/packages/cli/src/environments/source-control/types/source-control-preferences.ts +++ b/packages/cli/src/environments/source-control/types/source-control-preferences.ts @@ -1,4 +1,5 @@ import { IsBoolean, IsHexColor, IsOptional, IsString } from 'class-validator'; + import { KeyPairType } from './key-pair-type'; export class SourceControlPreferences { diff --git a/packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts b/packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts index 20299a013913d..55c8e178c486a 100644 --- a/packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts +++ b/packages/cli/src/environments/source-control/types/source-control-push-work-folder.ts @@ -1,4 +1,5 @@ import { IsBoolean, IsOptional, IsString } from 'class-validator'; + import type { SourceControlledFile } from './source-controlled-file'; export class SourceControlPushWorkFolder { diff --git a/packages/cli/src/environments/variables/environment-helpers.ts b/packages/cli/src/environments/variables/environment-helpers.ts index 9a3f2362f8c59..720d2f3a2392b 100644 --- a/packages/cli/src/environments/variables/environment-helpers.ts +++ b/packages/cli/src/environments/variables/environment-helpers.ts @@ -1,4 +1,5 @@ import { Container } from 'typedi'; + import { License } from '@/license'; export function isVariablesEnabled(): boolean { diff --git a/packages/cli/src/environments/variables/variables.controller.ee.ts b/packages/cli/src/environments/variables/variables.controller.ee.ts index d2b7f62b945ad..5da4221a3d56d 100644 --- a/packages/cli/src/environments/variables/variables.controller.ee.ts +++ b/packages/cli/src/environments/variables/variables.controller.ee.ts @@ -1,10 +1,11 @@ -import { VariablesRequest } from '@/requests'; import { Delete, Get, GlobalScope, Licensed, Patch, Post, RestController } from '@/decorators'; -import { VariablesService } from './variables.service.ee'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { VariableValidationError } from '@/errors/variable-validation.error'; import { VariableCountLimitReachedError } from '@/errors/variable-count-limit-reached.error'; +import { VariableValidationError } from '@/errors/variable-validation.error'; +import { VariablesRequest } from '@/requests'; + +import { VariablesService } from './variables.service.ee'; @RestController('/variables') export class VariablesController { diff --git a/packages/cli/src/environments/variables/variables.service.ee.ts b/packages/cli/src/environments/variables/variables.service.ee.ts index ad7b3cba9bca2..31cf725099b90 100644 --- a/packages/cli/src/environments/variables/variables.service.ee.ts +++ b/packages/cli/src/environments/variables/variables.service.ee.ts @@ -1,12 +1,14 @@ import { Container, Service } from 'typedi'; + import type { Variables } from '@/databases/entities/variables'; -import { generateNanoId } from '@/databases/utils/generators'; -import { canCreateNewVariable } from './environment-helpers'; -import { CacheService } from '@/services/cache/cache.service'; import { VariablesRepository } from '@/databases/repositories/variables.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import { VariableCountLimitReachedError } from '@/errors/variable-count-limit-reached.error'; import { VariableValidationError } from '@/errors/variable-validation.error'; import { EventService } from '@/events/event.service'; +import { CacheService } from '@/services/cache/cache.service'; + +import { canCreateNewVariable } from './environment-helpers'; @Service() export class VariablesService { diff --git a/packages/cli/src/error-reporting.ts b/packages/cli/src/error-reporting.ts index d211e4d15a9da..64a7696a77fde 100644 --- a/packages/cli/src/error-reporting.ts +++ b/packages/cli/src/error-reporting.ts @@ -1,8 +1,9 @@ -import { createHash } from 'crypto'; -import config from '@/config'; -import { ErrorReporterProxy, ApplicationError } from 'n8n-workflow'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { QueryFailedError } from '@n8n/typeorm'; +import { createHash } from 'crypto'; +import { ErrorReporterProxy, ApplicationError } from 'n8n-workflow'; + +import config from '@/config'; let initialized = false; diff --git a/packages/cli/src/errors/feature-not-licensed.error.ts b/packages/cli/src/errors/feature-not-licensed.error.ts index 1419501941575..a61015f2e419f 100644 --- a/packages/cli/src/errors/feature-not-licensed.error.ts +++ b/packages/cli/src/errors/feature-not-licensed.error.ts @@ -1,6 +1,7 @@ -import type { LICENSE_FEATURES } from '@/constants'; import { ApplicationError } from 'n8n-workflow'; +import type { LICENSE_FEATURES } from '@/constants'; + export class FeatureNotLicensedError extends ApplicationError { constructor(feature: (typeof LICENSE_FEATURES)[keyof typeof LICENSE_FEATURES]) { super( diff --git a/packages/cli/src/errors/subworkflow-policy-denial.error.ts b/packages/cli/src/errors/subworkflow-policy-denial.error.ts index 2d3169513062f..2e4b9255349db 100644 --- a/packages/cli/src/errors/subworkflow-policy-denial.error.ts +++ b/packages/cli/src/errors/subworkflow-policy-denial.error.ts @@ -1,7 +1,8 @@ import { WorkflowOperationError } from 'n8n-workflow'; -import type { Project } from '@/databases/entities/project'; import type { INode } from 'n8n-workflow'; +import type { Project } from '@/databases/entities/project'; + type Options = { /** ID of the subworkflow whose execution was denied. */ subworkflowId: string; diff --git a/packages/cli/src/errors/workflow-missing-id.error.ts b/packages/cli/src/errors/workflow-missing-id.error.ts index eaeba5452ff2d..f34a761244d0f 100644 --- a/packages/cli/src/errors/workflow-missing-id.error.ts +++ b/packages/cli/src/errors/workflow-missing-id.error.ts @@ -1,7 +1,8 @@ -import type { IWorkflowDb } from '@/interfaces'; import type { Workflow } from 'n8n-workflow'; import { ApplicationError } from 'n8n-workflow'; +import type { IWorkflowDb } from '@/interfaces'; + export class WorkflowMissingIdError extends ApplicationError { constructor(workflow: Workflow | IWorkflowDb) { super('Detected ID-less worklfow', { extra: { workflow } }); diff --git a/packages/cli/src/eventbus/event-bus.controller.ts b/packages/cli/src/eventbus/event-bus.controller.ts index d9922b482e80f..43603e935dd75 100644 --- a/packages/cli/src/eventbus/event-bus.controller.ts +++ b/packages/cli/src/eventbus/event-bus.controller.ts @@ -1,4 +1,3 @@ -import { eventNamesAll } from './event-message-classes'; import express from 'express'; import type { MessageEventBusDestinationWebhookOptions, @@ -7,9 +6,10 @@ import type { import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import { RestController, Get, Post, Delete, GlobalScope, Licensed } from '@/decorators'; -import { AuthenticatedRequest } from '@/requests'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { AuthenticatedRequest } from '@/requests'; +import { eventNamesAll } from './event-message-classes'; import { MessageEventBus } from './message-event-bus/message-event-bus'; import { isMessageEventBusDestinationSentryOptions, diff --git a/packages/cli/src/eventbus/event-message-classes/abstract-event-message-options.ts b/packages/cli/src/eventbus/event-message-classes/abstract-event-message-options.ts index 7c70aa9ee5ad3..dae747db43cea 100644 --- a/packages/cli/src/eventbus/event-message-classes/abstract-event-message-options.ts +++ b/packages/cli/src/eventbus/event-message-classes/abstract-event-message-options.ts @@ -1,5 +1,6 @@ import type { DateTime } from 'luxon'; import type { EventMessageTypeNames } from 'n8n-workflow'; + import type { EventNamesTypes } from '.'; import type { AbstractEventPayload } from './abstract-event-payload'; diff --git a/packages/cli/src/eventbus/event-message-classes/abstract-event-message.ts b/packages/cli/src/eventbus/event-message-classes/abstract-event-message.ts index e74ba8c06a40a..ac260b2c52472 100644 --- a/packages/cli/src/eventbus/event-message-classes/abstract-event-message.ts +++ b/packages/cli/src/eventbus/event-message-classes/abstract-event-message.ts @@ -2,9 +2,10 @@ import { DateTime } from 'luxon'; import type { EventMessageTypeNames, JsonObject } from 'n8n-workflow'; import { v4 as uuid } from 'uuid'; -import type { AbstractEventPayload } from './abstract-event-payload'; -import type { AbstractEventMessageOptions } from './abstract-event-message-options'; + import type { EventNamesTypes } from '.'; +import type { AbstractEventMessageOptions } from './abstract-event-message-options'; +import type { AbstractEventPayload } from './abstract-event-payload'; function modifyUnderscoredKeys( input: { [key: string]: any }, diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-ai-node.ts b/packages/cli/src/eventbus/event-message-classes/event-message-ai-node.ts index a59220fba9976..bdd3ae4fbdfd9 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-ai-node.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-ai-node.ts @@ -1,7 +1,8 @@ -import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { JsonObject } from 'n8n-workflow'; -import type { EventNamesAiNodesType } from '.'; import { EventMessageTypeNames } from 'n8n-workflow'; + +import type { EventNamesAiNodesType } from '.'; +import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { AbstractEventMessageOptions } from './abstract-event-message-options'; import type { AbstractEventPayload } from './abstract-event-payload'; diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-audit.ts b/packages/cli/src/eventbus/event-message-classes/event-message-audit.ts index 4ae0fa485d85b..d0f89f40cefff 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-audit.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-audit.ts @@ -1,9 +1,10 @@ -import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import { EventMessageTypeNames } from 'n8n-workflow'; import type { JsonObject, JsonValue } from 'n8n-workflow'; -import type { AbstractEventPayload } from './abstract-event-payload'; -import type { AbstractEventMessageOptions } from './abstract-event-message-options'; + import type { EventNamesAuditType } from '.'; +import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; +import type { AbstractEventMessageOptions } from './abstract-event-message-options'; +import type { AbstractEventPayload } from './abstract-event-payload'; // -------------------------------------- // EventMessage class for Audit events diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-execution.ts b/packages/cli/src/eventbus/event-message-classes/event-message-execution.ts index e311e5354fce7..ab19dab71a2ec 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-execution.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-execution.ts @@ -1,9 +1,10 @@ -import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { JsonObject } from 'n8n-workflow'; import { EventMessageTypeNames } from 'n8n-workflow'; + +import type { EventNamesExecutionType } from '.'; +import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { AbstractEventMessageOptions } from './abstract-event-message-options'; import type { AbstractEventPayload } from './abstract-event-payload'; -import type { EventNamesExecutionType } from '.'; export interface EventPayloadExecution extends AbstractEventPayload { executionId: string; diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-generic.ts b/packages/cli/src/eventbus/event-message-classes/event-message-generic.ts index 14d8bfb345e23..cb268f76c7d56 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-generic.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-generic.ts @@ -1,8 +1,9 @@ import type { JsonObject } from 'n8n-workflow'; import { EventMessageTypeNames } from 'n8n-workflow'; + import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; -import type { AbstractEventPayload } from './abstract-event-payload'; import type { AbstractEventMessageOptions } from './abstract-event-message-options'; +import type { AbstractEventPayload } from './abstract-event-payload'; export const eventMessageGenericDestinationTestEvent = 'n8n.destination.test'; diff --git a/packages/cli/src/eventbus/event-message-classes/event-message-node.ts b/packages/cli/src/eventbus/event-message-classes/event-message-node.ts index da36c2456cd78..2b0122a474b38 100644 --- a/packages/cli/src/eventbus/event-message-classes/event-message-node.ts +++ b/packages/cli/src/eventbus/event-message-classes/event-message-node.ts @@ -1,9 +1,10 @@ -import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { JsonObject } from 'n8n-workflow'; import { EventMessageTypeNames } from 'n8n-workflow'; + +import type { EventNamesNodeType } from '.'; +import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { AbstractEventMessageOptions } from './abstract-event-message-options'; import type { AbstractEventPayload } from './abstract-event-payload'; -import type { EventNamesNodeType } from '.'; // -------------------------------------- // EventMessage class for Node events 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 e4662e0ffcd14..4d94f3d2c147a 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,10 +1,12 @@ -import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; import type { IWorkflowBase, JsonObject } from 'n8n-workflow'; import { EventMessageTypeNames } from 'n8n-workflow'; -import type { AbstractEventMessageOptions } from './abstract-event-message-options'; -import type { AbstractEventPayload } from './abstract-event-payload'; + import type { IExecutionBase } from '@/interfaces'; + import type { EventNamesWorkflowType } from '.'; +import { AbstractEventMessage, isEventMessageOptionsWithType } from './abstract-event-message'; +import type { AbstractEventMessageOptions } from './abstract-event-message-options'; +import type { AbstractEventPayload } from './abstract-event-payload'; // -------------------------------------- // EventMessage class for Workflow events diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts index 544afdbeabafc..d901346d7e3b5 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-from-db.ts @@ -1,12 +1,14 @@ import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; +import { Container } from 'typedi'; + import type { EventDestinations } from '@/databases/entities/event-destinations'; -import type { MessageEventBus } from '../message-event-bus/message-event-bus'; -import type { MessageEventBusDestination } from './message-event-bus-destination.ee'; +import { Logger } from '@/logger'; + import { MessageEventBusDestinationSentry } from './message-event-bus-destination-sentry.ee'; import { MessageEventBusDestinationSyslog } from './message-event-bus-destination-syslog.ee'; import { MessageEventBusDestinationWebhook } from './message-event-bus-destination-webhook.ee'; -import { Container } from 'typedi'; -import { Logger } from '@/logger'; +import type { MessageEventBusDestination } from './message-event-bus-destination.ee'; +import type { MessageEventBus } from '../message-event-bus/message-event-bus'; export function messageEventBusDestinationFromDb( eventBusInstance: MessageEventBus, diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee.ts index d376d116102cf..5678cbb59c4f4 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee.ts @@ -1,14 +1,16 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import * as Sentry from '@sentry/node'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import type { MessageEventBusDestinationOptions, MessageEventBusDestinationSentryOptions, } from 'n8n-workflow'; -import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; + import { N8N_VERSION } from '@/constants'; + +import { MessageEventBusDestination } from './message-event-bus-destination.ee'; +import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; export const isMessageEventBusDestinationSentryOptions = ( diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts index a16718086d1b2..dc1727cb0ca11 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee.ts @@ -1,16 +1,17 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import syslog from 'syslog-client'; - import type { MessageEventBusDestinationOptions, MessageEventBusDestinationSyslogOptions, } from 'n8n-workflow'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; +import syslog from 'syslog-client'; +import Container from 'typedi'; + +import { Logger } from '@/logger'; + import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; -import Container from 'typedi'; -import { Logger } from '@/logger'; export const isMessageEventBusDestinationSyslogOptions = ( candidate: unknown, ): candidate is MessageEventBusDestinationSyslogOptions => { diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts index 01cffac93ae2a..f6a35f43292c6 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import axios from 'axios'; import type { AxiosRequestConfig, Method } from 'axios'; +import { Agent as HTTPSAgent } from 'https'; import { jsonParse, MessageEventBusDestinationTypeNames } from 'n8n-workflow'; import type { MessageEventBusDestinationOptions, @@ -11,12 +11,14 @@ import type { IWorkflowExecuteAdditionalData, MessageEventBusDestinationWebhookOptions, } from 'n8n-workflow'; +import Container from 'typedi'; + import { CredentialsHelper } from '@/credentials-helper'; -import { Agent as HTTPSAgent } from 'https'; +import * as SecretsHelpers from '@/external-secrets/external-secrets-helper.ee'; + +import { MessageEventBusDestination } from './message-event-bus-destination.ee'; import { eventMessageGenericDestinationTestEvent } from '../event-message-classes/event-message-generic'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; -import * as SecretsHelpers from '@/external-secrets/external-secrets-helper.ee'; -import Container from 'typedi'; export const isMessageEventBusDestinationWebhookOptions = ( candidate: unknown, diff --git a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts index e6b9552602efd..4d6725ff2c2ce 100644 --- a/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts +++ b/packages/cli/src/eventbus/message-event-bus-destination/message-event-bus-destination.ee.ts @@ -1,14 +1,16 @@ -import { v4 as uuid } from 'uuid'; -import { Container } from 'typedi'; import type { INodeCredentials, MessageEventBusDestinationOptions } from 'n8n-workflow'; import { MessageEventBusDestinationTypeNames } from 'n8n-workflow'; +import { Container } from 'typedi'; +import { v4 as uuid } from 'uuid'; + +import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; +import { License } from '@/license'; import { Logger } from '@/logger'; -import type { AbstractEventMessage } from '../event-message-classes/abstract-event-message'; + import type { EventMessageTypes } from '../event-message-classes'; +import type { AbstractEventMessage } from '../event-message-classes/abstract-event-message'; import type { EventMessageConfirmSource } from '../event-message-classes/event-message-confirm'; import type { MessageEventBus, MessageWithCallback } from '../message-event-bus/message-event-bus'; -import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; -import { License } from '@/license'; export abstract class MessageEventBusDestination implements MessageEventBusDestinationOptions { // Since you can't have static abstract functions - this just serves as a reminder that you need to implement these. Please. diff --git a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer-worker.ts b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer-worker.ts index 308d4508c1c5c..dce989b1c7c3a 100644 --- a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer-worker.ts +++ b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer-worker.ts @@ -1,6 +1,7 @@ import { appendFileSync, existsSync, rmSync, renameSync, openSync, closeSync } from 'fs'; import { stat } from 'fs/promises'; import { isMainThread, parentPort } from 'worker_threads'; + import type { MessageEventBusLogWriterOptions } from './message-event-bus-log-writer'; let logFileBasePath = ''; diff --git a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts index fd6eb1db38598..6b009f38e9bbe 100644 --- a/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts +++ b/packages/cli/src/eventbus/message-event-bus-writer/message-event-bus-log-writer.ts @@ -1,34 +1,36 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { isEventMessageOptions } from '../event-message-classes/abstract-event-message'; +import { GlobalConfig } from '@n8n/config'; +import { once as eventOnce } from 'events'; +import { createReadStream, existsSync, rmSync } from 'fs'; +import remove from 'lodash/remove'; import { InstanceSettings } from 'n8n-core'; +import { EventMessageTypeNames, jsonParse } from 'n8n-workflow'; import path, { parse } from 'path'; -import { Worker } from 'worker_threads'; -import { createReadStream, existsSync, rmSync } from 'fs'; import readline from 'readline'; -import remove from 'lodash/remove'; -import type { EventMessageGenericOptions } from '../event-message-classes/event-message-generic'; -import { EventMessageGeneric } from '../event-message-classes/event-message-generic'; +import Container from 'typedi'; +import { Worker } from 'worker_threads'; + +import { inTest } from '@/constants'; +import { Logger } from '@/logger'; + +import type { EventMessageTypes } from '../event-message-classes'; +import { isEventMessageOptions } from '../event-message-classes/abstract-event-message'; import type { AbstractEventMessageOptions } from '../event-message-classes/abstract-event-message-options'; -import type { EventMessageWorkflowOptions } from '../event-message-classes/event-message-workflow'; -import { EventMessageWorkflow } from '../event-message-classes/event-message-workflow'; -import { EventMessageTypeNames, jsonParse } from 'n8n-workflow'; import type { EventMessageAuditOptions } from '../event-message-classes/event-message-audit'; import { EventMessageAudit } from '../event-message-classes/event-message-audit'; -import type { EventMessageNodeOptions } from '../event-message-classes/event-message-node'; -import { EventMessageNode } from '../event-message-classes/event-message-node'; -import type { EventMessageReturnMode } from '../message-event-bus/message-event-bus'; -import type { EventMessageTypes } from '../event-message-classes'; import type { EventMessageConfirmSource } from '../event-message-classes/event-message-confirm'; import { EventMessageConfirm, isEventMessageConfirm, } from '../event-message-classes/event-message-confirm'; -import { once as eventOnce } from 'events'; -import { inTest } from '@/constants'; -import { Logger } from '@/logger'; -import Container from 'typedi'; -import { GlobalConfig } from '@n8n/config'; +import type { EventMessageGenericOptions } from '../event-message-classes/event-message-generic'; +import { EventMessageGeneric } from '../event-message-classes/event-message-generic'; +import type { EventMessageNodeOptions } from '../event-message-classes/event-message-node'; +import { EventMessageNode } from '../event-message-classes/event-message-node'; +import type { EventMessageWorkflowOptions } from '../event-message-classes/event-message-workflow'; +import { EventMessageWorkflow } from '../event-message-classes/event-message-workflow'; +import type { EventMessageReturnMode } from '../message-event-bus/message-event-bus'; interface MessageEventBusLogWriterConstructorOptions { logBaseName?: string; diff --git a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts index 1989b9f251a32..cf9a5854784b9 100644 --- a/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts +++ b/packages/cli/src/eventbus/message-event-bus/message-event-bus.ts @@ -1,4 +1,4 @@ -import { Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { DeleteResult } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import @@ -6,38 +6,38 @@ import { In } from '@n8n/typeorm'; import EventEmitter from 'events'; import uniqby from 'lodash/uniqBy'; import type { MessageEventBusDestinationOptions } from 'n8n-workflow'; +import { Service } from 'typedi'; import config from '@/config'; import { EventDestinationsRepository } from '@/databases/repositories/event-destinations.repository'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { OrchestrationService } from '@/services/orchestration.service'; +import { License } from '@/license'; import { Logger } from '@/logger'; +import { OrchestrationService } from '@/services/orchestration.service'; -import type { EventMessageTypes } from '../event-message-classes/'; -import type { MessageEventBusDestination } from '../message-event-bus-destination/message-event-bus-destination.ee'; -import { MessageEventBusLogWriter } from '../message-event-bus-writer/message-event-bus-log-writer'; -import { messageEventBusDestinationFromDb } from '../message-event-bus-destination/message-event-bus-destination-from-db'; -import type { EventMessageConfirmSource } from '../event-message-classes/event-message-confirm'; -import type { EventMessageAuditOptions } from '../event-message-classes/event-message-audit'; -import { EventMessageAudit } from '../event-message-classes/event-message-audit'; -import type { EventMessageWorkflowOptions } from '../event-message-classes/event-message-workflow'; -import { EventMessageWorkflow } from '../event-message-classes/event-message-workflow'; -import type { EventMessageNodeOptions } from '../event-message-classes/event-message-node'; -import { EventMessageNode } from '../event-message-classes/event-message-node'; -import { - EventMessageGeneric, - eventMessageGenericDestinationTestEvent, -} from '../event-message-classes/event-message-generic'; import { ExecutionRecoveryService } from '../../executions/execution-recovery.service'; +import type { EventMessageTypes } from '../event-message-classes/'; import { EventMessageAiNode, type EventMessageAiNodeOptions, } from '../event-message-classes/event-message-ai-node'; -import { License } from '@/license'; +import type { EventMessageAuditOptions } from '../event-message-classes/event-message-audit'; +import { EventMessageAudit } from '../event-message-classes/event-message-audit'; +import type { EventMessageConfirmSource } from '../event-message-classes/event-message-confirm'; import type { EventMessageExecutionOptions } from '../event-message-classes/event-message-execution'; import { EventMessageExecution } from '../event-message-classes/event-message-execution'; -import { GlobalConfig } from '@n8n/config'; +import { + EventMessageGeneric, + eventMessageGenericDestinationTestEvent, +} from '../event-message-classes/event-message-generic'; +import type { EventMessageNodeOptions } from '../event-message-classes/event-message-node'; +import { EventMessageNode } from '../event-message-classes/event-message-node'; +import type { EventMessageWorkflowOptions } from '../event-message-classes/event-message-workflow'; +import { EventMessageWorkflow } from '../event-message-classes/event-message-workflow'; +import { messageEventBusDestinationFromDb } from '../message-event-bus-destination/message-event-bus-destination-from-db'; +import type { MessageEventBusDestination } from '../message-event-bus-destination/message-event-bus-destination.ee'; +import { MessageEventBusLogWriter } from '../message-event-bus-writer/message-event-bus-log-writer'; export type EventMessageReturnMode = 'sent' | 'unsent' | 'all' | 'unfinished'; 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 b19ae0c9c77ed..d768218950d4c 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 @@ -1,10 +1,11 @@ import { mock } from 'jest-mock-extended'; -import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; -import { EventService } from '@/events/event.service'; import type { INode, IRun, IWorkflowBase } from 'n8n-workflow'; -import type { IWorkflowDb } from '@/interfaces'; + import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { EventService } from '@/events/event.service'; +import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; import type { RelayEventMap } from '@/events/relay-event-map'; +import type { IWorkflowDb } from '@/interfaces'; 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 93d134b5e4fb4..9a05835205515 100644 --- a/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts +++ b/packages/cli/src/events/__tests__/telemetry-event-relay.test.ts @@ -1,19 +1,20 @@ +import type { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; -import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; -import { EventService } from '@/events/event.service'; -import config from '@/config'; import type { IWorkflowBase } from 'n8n-workflow'; + +import config from '@/config'; +import { N8N_VERSION } from '@/constants'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import type { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import type { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { EventService } from '@/events/event.service'; +import type { RelayEventMap } from '@/events/relay-event-map'; +import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; import type { IWorkflowDb } from '@/interfaces'; -import type { Telemetry } from '@/telemetry'; import type { License } from '@/license'; -import type { GlobalConfig } from '@n8n/config'; -import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { NodeTypes } from '@/node-types'; -import type { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import type { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import type { RelayEventMap } from '@/events/relay-event-map'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { N8N_VERSION } from '@/constants'; +import type { Telemetry } from '@/telemetry'; const flushPromises = async () => await new Promise((resolve) => setImmediate(resolve)); diff --git a/packages/cli/src/events/event-relay.ts b/packages/cli/src/events/event-relay.ts index 1a8a17b8930f2..dde983884f9a1 100644 --- a/packages/cli/src/events/event-relay.ts +++ b/packages/cli/src/events/event-relay.ts @@ -1,7 +1,9 @@ -import { EventService } from './event.service'; import { Service } from 'typedi'; + import type { RelayEventMap } from '@/events/relay-event-map'; +import { EventService } from './event.service'; + @Service() export class EventRelay { constructor(readonly eventService: EventService) {} diff --git a/packages/cli/src/events/event.service.ts b/packages/cli/src/events/event.service.ts index f709f7519a8fa..10ba7666efed3 100644 --- a/packages/cli/src/events/event.service.ts +++ b/packages/cli/src/events/event.service.ts @@ -1,8 +1,10 @@ import { Service } from 'typedi'; + import { TypedEmitter } from '@/typed-emitter'; -import type { RelayEventMap } from './relay-event-map'; -import type { QueueMetricsEventMap } from './queue-metrics-event-map'; + import type { AiEventMap } from './ai-event-map'; +import type { QueueMetricsEventMap } from './queue-metrics-event-map'; +import type { RelayEventMap } from './relay-event-map'; type EventMap = RelayEventMap & QueueMetricsEventMap & AiEventMap; diff --git a/packages/cli/src/events/log-streaming-event-relay.ts b/packages/cli/src/events/log-streaming-event-relay.ts index 9d446139aeaad..788e5e50c42b7 100644 --- a/packages/cli/src/events/log-streaming-event-relay.ts +++ b/packages/cli/src/events/log-streaming-event-relay.ts @@ -1,9 +1,11 @@ +import type { IWorkflowBase } from 'n8n-workflow'; import { Service } from 'typedi'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; + import { Redactable } from '@/decorators/redactable'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { EventRelay } from '@/events/event-relay'; import type { RelayEventMap } from '@/events/relay-event-map'; -import type { IWorkflowBase } from 'n8n-workflow'; + import { EventService } from './event.service'; @Service() diff --git a/packages/cli/src/events/relay-event-map.ts b/packages/cli/src/events/relay-event-map.ts index 06f635d655131..cf2d5f9cfb46b 100644 --- a/packages/cli/src/events/relay-event-map.ts +++ b/packages/cli/src/events/relay-event-map.ts @@ -5,10 +5,12 @@ import type { IWorkflowBase, IWorkflowExecutionDataProcess, } from 'n8n-workflow'; -import type { IWorkflowDb } from '@/interfaces'; + +import type { AuthProviderType } from '@/databases/entities/auth-identity'; import type { ProjectRole } from '@/databases/entities/project-relation'; import type { GlobalRole } from '@/databases/entities/user'; -import type { AuthProviderType } from '@/databases/entities/auth-identity'; +import type { IWorkflowDb } from '@/interfaces'; + import type { AiEventMap } from './ai-event-map'; export type UserLike = { diff --git a/packages/cli/src/events/telemetry-event-relay.ts b/packages/cli/src/events/telemetry-event-relay.ts index 1113c76dc3349..1544ff85ec668 100644 --- a/packages/cli/src/events/telemetry-event-relay.ts +++ b/packages/cli/src/events/telemetry-event-relay.ts @@ -1,23 +1,25 @@ -import { Service } from 'typedi'; -import { EventService } from '@/events/event.service'; -import type { RelayEventMap } from '@/events/relay-event-map'; -import { Telemetry } from '../telemetry'; -import config from '@/config'; -import os from 'node:os'; -import { License } from '@/license'; import { GlobalConfig } from '@n8n/config'; -import { N8N_VERSION } from '@/constants'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { snakeCase } from 'change-case'; import type { ExecutionStatus, INodesGraphResult, ITelemetryTrackProperties } from 'n8n-workflow'; -import { get as pslGet } from 'psl'; import { TelemetryHelpers } from 'n8n-workflow'; -import { NodeTypes } from '@/node-types'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import os from 'node:os'; +import { get as pslGet } from 'psl'; +import { Service } from 'typedi'; + +import config from '@/config'; +import { N8N_VERSION } from '@/constants'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import type { IExecutionTrackProperties } from '@/interfaces'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { EventService } from '@/events/event.service'; +import type { RelayEventMap } from '@/events/relay-event-map'; import { determineFinalExecutionStatus } from '@/execution-lifecycle-hooks/shared/shared-hook-functions'; +import type { IExecutionTrackProperties } from '@/interfaces'; +import { License } from '@/license'; +import { NodeTypes } from '@/node-types'; + import { EventRelay } from './event-relay'; -import { snakeCase } from 'change-case'; +import { Telemetry } from '../telemetry'; @Service() export class TelemetryEventRelay extends EventRelay { diff --git a/packages/cli/src/execution-lifecycle-hooks/__tests__/restore-binary-data-id.test.ts b/packages/cli/src/execution-lifecycle-hooks/__tests__/restore-binary-data-id.test.ts index 58f0825ef7e31..f4f7a463bcdcb 100644 --- a/packages/cli/src/execution-lifecycle-hooks/__tests__/restore-binary-data-id.test.ts +++ b/packages/cli/src/execution-lifecycle-hooks/__tests__/restore-binary-data-id.test.ts @@ -1,9 +1,9 @@ -import { restoreBinaryDataId } from '@/execution-lifecycle-hooks/restore-binary-data-id'; import { BinaryDataService } from 'n8n-core'; -import { mockInstance } from '@test/mocking'; - import type { IRun } from 'n8n-workflow'; + import config from '@/config'; +import { restoreBinaryDataId } from '@/execution-lifecycle-hooks/restore-binary-data-id'; +import { mockInstance } from '@test/mocking'; function toIRun(item?: object) { return { diff --git a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts index 7c58590e355e7..80e620fb17870 100644 --- a/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts +++ b/packages/cli/src/execution-lifecycle-hooks/__tests__/save-execution-progress.test.ts @@ -1,15 +1,16 @@ -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { mockInstance } from '@test/mocking'; -import { Logger } from '@/logger'; -import { saveExecutionProgress } from '@/execution-lifecycle-hooks/save-execution-progress'; -import * as fnModule from '@/execution-lifecycle-hooks/to-save-settings'; import { ErrorReporterProxy, type IRunExecutionData, type ITaskData, type IWorkflowBase, } from 'n8n-workflow'; + +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { saveExecutionProgress } from '@/execution-lifecycle-hooks/save-execution-progress'; +import * as fnModule from '@/execution-lifecycle-hooks/to-save-settings'; import type { IExecutionResponse } from '@/interfaces'; +import { Logger } from '@/logger'; +import { mockInstance } from '@test/mocking'; mockInstance(Logger); diff --git a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts index d19a6e22a4ff0..31b045ade806f 100644 --- a/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts +++ b/packages/cli/src/execution-lifecycle-hooks/restore-binary-data-id.ts @@ -1,7 +1,8 @@ -import Container from 'typedi'; import { BinaryDataService } from 'n8n-core'; -import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; import type { BinaryData } from 'n8n-core'; +import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; +import Container from 'typedi'; + import config from '@/config'; import { Logger } from '@/logger'; diff --git a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts index 33b1d9308e00a..212990211f0af 100644 --- a/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts +++ b/packages/cli/src/execution-lifecycle-hooks/save-execution-progress.ts @@ -1,11 +1,10 @@ -import { Container } from 'typedi'; - import type { IRunExecutionData, ITaskData, IWorkflowBase } from 'n8n-workflow'; import { ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import { Container } from 'typedi'; -import { Logger } from '@/logger'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { toSaveSettings } from '@/execution-lifecycle-hooks/to-save-settings'; +import { Logger } from '@/logger'; export async function saveExecutionProgress( workflowData: IWorkflowBase, diff --git a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts index be8aef4cff620..d6d55e63e592f 100644 --- a/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts +++ b/packages/cli/src/execution-lifecycle-hooks/shared/shared-hook-functions.ts @@ -1,11 +1,12 @@ -import { Container } from 'typedi'; -import type { ExecutionStatus, IRun, IWorkflowBase } from 'n8n-workflow'; -import type { ExecutionPayload, IExecutionDb } from '@/interfaces'; import pick from 'lodash/pick'; -import { isWorkflowIdValid } from '@/utils'; +import type { ExecutionStatus, IRun, IWorkflowBase } from 'n8n-workflow'; +import { Container } from 'typedi'; + import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { ExecutionMetadataService } from '@/services/execution-metadata.service'; +import type { ExecutionPayload, IExecutionDb } from '@/interfaces'; import { Logger } from '@/logger'; +import { ExecutionMetadataService } from '@/services/execution-metadata.service'; +import { isWorkflowIdValid } from '@/utils'; export function determineFinalExecutionStatus(runData: IRun): ExecutionStatus { const workflowHasCrashed = runData.status === 'crashed'; diff --git a/packages/cli/src/execution-lifecycle-hooks/to-save-settings.ts b/packages/cli/src/execution-lifecycle-hooks/to-save-settings.ts index 4b4aac2b8561c..71d012a1d6f18 100644 --- a/packages/cli/src/execution-lifecycle-hooks/to-save-settings.ts +++ b/packages/cli/src/execution-lifecycle-hooks/to-save-settings.ts @@ -1,6 +1,7 @@ -import config from '@/config'; import type { IWorkflowSettings } from 'n8n-workflow'; +import config from '@/config'; + /** * Return whether a workflow execution is configured to be saved or not: * diff --git a/packages/cli/src/executions/__tests__/constants.ts b/packages/cli/src/executions/__tests__/constants.ts index ece7a0a3ff769..e2ab19bf62fd3 100644 --- a/packages/cli/src/executions/__tests__/constants.ts +++ b/packages/cli/src/executions/__tests__/constants.ts @@ -1,6 +1,7 @@ -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { NodeConnectionType } from 'n8n-workflow'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; + /** * Workflow producing an execution whose data will be truncated by an instance crash. */ diff --git a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts index 0a7d1cb9893ed..de7c27a8e8341 100644 --- a/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts +++ b/packages/cli/src/executions/__tests__/execution-recovery.service.test.ts @@ -1,26 +1,25 @@ -import Container from 'typedi'; import { stringify } from 'flatted'; -import { randomInt } from 'n8n-workflow'; +import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; +import { randomInt } from 'n8n-workflow'; +import Container from 'typedi'; -import { mockInstance } from '@test/mocking'; -import { createWorkflow } from '@test-integration/db/workflows'; -import { createExecution } from '@test-integration/db/executions'; -import * as testDb from '@test-integration/test-db'; - -import { mock } from 'jest-mock-extended'; -import { ExecutionRecoveryService } from '@/executions/execution-recovery.service'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Push } from '@/push'; import { ARTIFICIAL_TASK_DATA } from '@/constants'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { NodeCrashedError } from '@/errors/node-crashed.error'; import { WorkflowCrashedError } from '@/errors/workflow-crashed.error'; +import type { EventMessageTypes as EventMessage } from '@/eventbus/event-message-classes'; import { EventMessageNode } from '@/eventbus/event-message-classes/event-message-node'; +import { ExecutionRecoveryService } from '@/executions/execution-recovery.service'; +import { Push } from '@/push'; +import { mockInstance } from '@test/mocking'; +import { createExecution } from '@test-integration/db/executions'; +import { createWorkflow } from '@test-integration/db/workflows'; +import * as testDb from '@test-integration/test-db'; + import { IN_PROGRESS_EXECUTION_DATA, OOM_WORKFLOW } from './constants'; import { setupMessages } from './utils'; -import type { EventMessageTypes as EventMessage } from '@/eventbus/event-message-classes'; - describe('ExecutionRecoveryService', () => { const push = mockInstance(Push); const instanceSettings = new InstanceSettings(); diff --git a/packages/cli/src/executions/__tests__/execution.service.test.ts b/packages/cli/src/executions/__tests__/execution.service.test.ts index 253e91e6d521e..b91836578c853 100644 --- a/packages/cli/src/executions/__tests__/execution.service.test.ts +++ b/packages/cli/src/executions/__tests__/execution.service.test.ts @@ -1,17 +1,18 @@ import { mock } from 'jest-mock-extended'; import { WorkflowOperationError } from 'n8n-workflow'; + +import type { ActiveExecutions } from '@/active-executions'; +import type { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; import config from '@/config'; -import { ExecutionService } from '@/executions/execution.service'; +import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error'; import { MissingExecutionStopError } from '@/errors/missing-execution-stop.error'; -import type { ActiveExecutions } from '@/active-executions'; +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 { WaitTracker } from '@/wait-tracker'; -import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { ExecutionRequest } from '@/executions/execution.types'; -import type { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; import type { Job } from '@/scaling/scaling.types'; +import type { WaitTracker } from '@/wait-tracker'; import { mockInstance } from '@test/mocking'; describe('ExecutionService', () => { diff --git a/packages/cli/src/executions/__tests__/executions.controller.test.ts b/packages/cli/src/executions/__tests__/executions.controller.test.ts index acf619a9ea303..aea4c567e90f5 100644 --- a/packages/cli/src/executions/__tests__/executions.controller.test.ts +++ b/packages/cli/src/executions/__tests__/executions.controller.test.ts @@ -1,10 +1,11 @@ import { mock } from 'jest-mock-extended'; + +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { ExecutionsController } from '@/executions/executions.controller'; -import type { ExecutionRequest, ExecutionSummaries } from '@/executions/execution.types'; import type { ExecutionService } from '@/executions/execution.service'; +import type { ExecutionRequest, ExecutionSummaries } from '@/executions/execution.types'; +import { ExecutionsController } from '@/executions/executions.controller'; import type { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; describe('ExecutionsController', () => { const executionService = mock(); diff --git a/packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts b/packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts index d52d09b80cef8..8b3395b226165 100644 --- a/packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts +++ b/packages/cli/src/executions/__tests__/parse-range-query.middleware.test.ts @@ -1,8 +1,9 @@ -import { parseRangeQuery } from '@/executions/parse-range-query.middleware'; -import { mock } from 'jest-mock-extended'; import type { NextFunction } from 'express'; import type * as express from 'express'; +import { mock } from 'jest-mock-extended'; + import type { ExecutionRequest } from '@/executions/execution.types'; +import { parseRangeQuery } from '@/executions/parse-range-query.middleware'; describe('`parseRangeQuery` middleware', () => { const res = mock({ diff --git a/packages/cli/src/executions/execution-recovery.service.ts b/packages/cli/src/executions/execution-recovery.service.ts index ba4b79662bfe0..e1e6a1f180eeb 100644 --- a/packages/cli/src/executions/execution-recovery.service.ts +++ b/packages/cli/src/executions/execution-recovery.service.ts @@ -1,18 +1,20 @@ -import { Service } from 'typedi'; -import { Push } from '@/push'; -import { sleep } from 'n8n-workflow'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { getWorkflowHooksMain } from '@/workflow-execute-additional-data'; // @TODO: Dependency cycle import type { DateTime } from 'luxon'; -import type { IRun, ITaskData } from 'n8n-workflow'; import { InstanceSettings } from 'n8n-core'; -import type { EventMessageTypes } from '../eventbus/event-message-classes'; -import type { IExecutionResponse } from '@/interfaces'; +import { sleep } from 'n8n-workflow'; +import type { IRun, ITaskData } from 'n8n-workflow'; +import { Service } from 'typedi'; + +import { ARTIFICIAL_TASK_DATA } from '@/constants'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { NodeCrashedError } from '@/errors/node-crashed.error'; import { WorkflowCrashedError } from '@/errors/workflow-crashed.error'; -import { ARTIFICIAL_TASK_DATA } from '@/constants'; -import { Logger } from '@/logger'; import { EventService } from '@/events/event.service'; +import type { IExecutionResponse } from '@/interfaces'; +import { Logger } from '@/logger'; +import { Push } from '@/push'; +import { getWorkflowHooksMain } from '@/workflow-execute-additional-data'; // @TODO: Dependency cycle + +import type { EventMessageTypes } from '../eventbus/event-message-classes'; /** * Service for recovering key properties in executions. diff --git a/packages/cli/src/executions/execution.service.ee.ts b/packages/cli/src/executions/execution.service.ee.ts index bdca53efe9e52..cb4ae332edd38 100644 --- a/packages/cli/src/executions/execution.service.ee.ts +++ b/packages/cli/src/executions/execution.service.ee.ts @@ -1,10 +1,12 @@ +import { Service } from 'typedi'; + +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { IExecutionResponse, IExecutionFlattedResponse } from '@/interfaces'; +import type { WorkflowWithSharingsAndCredentials } from '@/workflows/workflows.types'; + import { ExecutionService } from './execution.service'; import type { ExecutionRequest } from './execution.types'; -import type { IExecutionResponse, IExecutionFlattedResponse } from '@/interfaces'; import { EnterpriseWorkflowService } from '../workflows/workflow.service.ee'; -import type { WorkflowWithSharingsAndCredentials } from '@/workflows/workflows.types'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { Service } from 'typedi'; @Service() export class EnterpriseExecutionsService { diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index 6d29d3d126246..a04c10e45f4e0 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -1,4 +1,3 @@ -import { Container, Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { validate as jsonSchemaValidate } from 'jsonschema'; import type { @@ -16,33 +15,36 @@ import { Workflow, WorkflowOperationError, } from 'n8n-workflow'; +import { Container, Service } from 'typedi'; + import { ActiveExecutions } from '@/active-executions'; +import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; +import config from '@/config'; +import type { User } from '@/databases/entities/user'; +import { AnnotationTagMappingRepository } from '@/databases/repositories/annotation-tag-mapping.repository'; +import { ExecutionAnnotationRepository } from '@/databases/repositories/execution-annotation.repository'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import type { IGetExecutionsQueryFilter } from '@/databases/repositories/execution.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error'; +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 { ExecutionPayload, IExecutionFlattedResponse, IExecutionResponse, IWorkflowDb, } from '@/interfaces'; -import { NodeTypes } from '@/node-types'; -import type { ExecutionRequest, ExecutionSummaries, StopResult } from './execution.types'; -import { WorkflowRunner } from '@/workflow-runner'; -import type { IGetExecutionsQueryFilter } from '@/databases/repositories/execution.repository'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { License } from '@/license'; import { Logger } from '@/logger'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import config from '@/config'; +import { NodeTypes } from '@/node-types'; import { WaitTracker } from '@/wait-tracker'; -import { MissingExecutionStopError } from '@/errors/missing-execution-stop.error'; -import { QueuedExecutionRetryError } from '@/errors/queued-execution-retry.error'; -import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; -import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error'; -import { License } from '@/license'; -import type { User } from '@/databases/entities/user'; +import { WorkflowRunner } from '@/workflow-runner'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; -import { AnnotationTagMappingRepository } from '@/databases/repositories/annotation-tag-mapping.repository'; -import { ExecutionAnnotationRepository } from '@/databases/repositories/execution-annotation.repository'; + +import type { ExecutionRequest, ExecutionSummaries, StopResult } from './execution.types'; export const schemaGetExecutionsQueryFilter = { $id: '/IGetExecutionsQueryFilter', diff --git a/packages/cli/src/executions/execution.types.ts b/packages/cli/src/executions/execution.types.ts index 57379622c287f..ba574199a0bf4 100644 --- a/packages/cli/src/executions/execution.types.ts +++ b/packages/cli/src/executions/execution.types.ts @@ -1,5 +1,3 @@ -import type { ExecutionEntity } from '@/databases/entities/execution-entity'; -import type { AuthenticatedRequest } from '@/requests'; import type { Scope } from '@n8n/permissions'; import type { AnnotationVote, @@ -9,6 +7,9 @@ import type { WorkflowExecuteMode, } from 'n8n-workflow'; +import type { ExecutionEntity } from '@/databases/entities/execution-entity'; +import type { AuthenticatedRequest } from '@/requests'; + export declare namespace ExecutionRequest { namespace QueryParams { type GetMany = { diff --git a/packages/cli/src/executions/executions.controller.ts b/packages/cli/src/executions/executions.controller.ts index 6979ff90d91bf..158242eb29edf 100644 --- a/packages/cli/src/executions/executions.controller.ts +++ b/packages/cli/src/executions/executions.controller.ts @@ -1,16 +1,18 @@ -import { ExecutionRequest, type ExecutionSummaries } from './execution.types'; -import { ExecutionService } from './execution.service'; -import { validateExecutionUpdatePayload } from './validation'; +import type { Scope } from '@n8n/permissions'; + +import type { User } from '@/databases/entities/user'; import { Get, Patch, Post, RestController } from '@/decorators'; -import { EnterpriseExecutionsService } from './execution.service.ee'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { License } from '@/license'; +import { isPositiveInteger } from '@/utils'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; + +import { ExecutionService } from './execution.service'; +import { EnterpriseExecutionsService } from './execution.service.ee'; +import { ExecutionRequest, type ExecutionSummaries } from './execution.types'; import { parseRangeQuery } from './parse-range-query.middleware'; -import type { User } from '@/databases/entities/user'; -import type { Scope } from '@n8n/permissions'; -import { isPositiveInteger } from '@/utils'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { validateExecutionUpdatePayload } from './validation'; @RestController('/executions') export class ExecutionsController { diff --git a/packages/cli/src/executions/parse-range-query.middleware.ts b/packages/cli/src/executions/parse-range-query.middleware.ts index b02b012c2464c..608fb1056f8ce 100644 --- a/packages/cli/src/executions/parse-range-query.middleware.ts +++ b/packages/cli/src/executions/parse-range-query.middleware.ts @@ -1,14 +1,16 @@ -import * as ResponseHelper from '@/response-helper'; import type { NextFunction, Response } from 'express'; -import type { ExecutionRequest } from './execution.types'; +import { validate } from 'jsonschema'; import type { JsonObject } from 'n8n-workflow'; import { ApplicationError, jsonParse } from 'n8n-workflow'; + +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import * as ResponseHelper from '@/response-helper'; + import { allowedExecutionsQueryFilterFields as ALLOWED_FILTER_FIELDS, schemaGetExecutionsQueryFilter as SCHEMA, } from './execution.service'; -import { validate } from 'jsonschema'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import type { ExecutionRequest } from './execution.types'; const isValid = (arg: JsonObject) => validate(arg, SCHEMA).valid; diff --git a/packages/cli/src/executions/validation.ts b/packages/cli/src/executions/validation.ts index 243c3c78b2c73..75071114a8c63 100644 --- a/packages/cli/src/executions/validation.ts +++ b/packages/cli/src/executions/validation.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; + import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import type { ExecutionRequest } from '@/executions/execution.types'; diff --git a/packages/cli/src/expression-evaluator.ts b/packages/cli/src/expression-evaluator.ts index 1b53f845dc1c5..9a91b4864f52d 100644 --- a/packages/cli/src/expression-evaluator.ts +++ b/packages/cli/src/expression-evaluator.ts @@ -1,6 +1,7 @@ -import config from '@/config'; import { ErrorReporterProxy, ExpressionEvaluatorProxy } from 'n8n-workflow'; +import config from '@/config'; + export const initExpressionEvaluator = () => { ExpressionEvaluatorProxy.setEvaluator(config.getEnv('expression.evaluator')); ExpressionEvaluatorProxy.setDifferEnabled(config.getEnv('expression.reportDifference')); diff --git a/packages/cli/src/external-hooks.ts b/packages/cli/src/external-hooks.ts index 00e0aa0388d48..764625fa23cd3 100644 --- a/packages/cli/src/external-hooks.ts +++ b/packages/cli/src/external-hooks.ts @@ -1,12 +1,13 @@ /* eslint-disable @typescript-eslint/no-var-requires */ +import { ApplicationError } from 'n8n-workflow'; import { Service } from 'typedi'; -import type { IExternalHooksFileData, IExternalHooksFunctions } from '@/interfaces'; + import config from '@/config'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { ApplicationError } from 'n8n-workflow'; +import type { IExternalHooksFileData, IExternalHooksFunctions } from '@/interfaces'; @Service() export class ExternalHooks { diff --git a/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts b/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts index c0ecdd9128bc3..97547ecf130ab 100644 --- a/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts +++ b/packages/cli/src/external-secrets/__tests__/external-secrets-manager.ee.test.ts @@ -1,18 +1,19 @@ -import { Container } from 'typedi'; +import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; +import { Container } from 'typedi'; + import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import type { ExternalSecretsSettings } from '@/interfaces'; -import { License } from '@/license'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { ExternalSecretsProviders } from '@/external-secrets/external-secrets-providers.ee'; -import { mockInstance } from '@test/mocking'; +import type { ExternalSecretsSettings } from '@/interfaces'; +import { License } from '@/license'; import { DummyProvider, ErrorProvider, FailedProvider, MockProviders, } from '@test/external-secrets/utils'; -import { mock } from 'jest-mock-extended'; +import { mockInstance } from '@test/mocking'; describe('External Secrets Manager', () => { const connectedDate = '2023-08-01T12:32:29.000Z'; diff --git a/packages/cli/src/external-secrets/external-secrets-helper.ee.ts b/packages/cli/src/external-secrets/external-secrets-helper.ee.ts index 85997d805e375..946badde421d1 100644 --- a/packages/cli/src/external-secrets/external-secrets-helper.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-helper.ee.ts @@ -1,7 +1,8 @@ -import { License } from '@/license'; import { GlobalConfig } from '@n8n/config'; import Container from 'typedi'; +import { License } from '@/license'; + export const updateIntervalTime = () => Container.get(GlobalConfig).externalSecrets.updateInterval * 1000; export const preferGet = () => Container.get(GlobalConfig).externalSecrets.preferGet; diff --git a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts index 9e5298bb49b4e..5ac8a5a1bf5b7 100644 --- a/packages/cli/src/external-secrets/external-secrets-manager.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-manager.ee.ts @@ -1,22 +1,21 @@ +import { Cipher } from 'n8n-core'; +import { jsonParse, type IDataObject, ApplicationError } from 'n8n-workflow'; +import Container, { Service } from 'typedi'; + import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { EventService } from '@/events/event.service'; import type { ExternalSecretsSettings, SecretsProvider, SecretsProviderSettings, } from '@/interfaces'; - -import { Cipher } from 'n8n-core'; -import Container, { Service } from 'typedi'; - +import { License } from '@/license'; import { Logger } from '@/logger'; +import { OrchestrationService } from '@/services/orchestration.service'; -import { jsonParse, type IDataObject, ApplicationError } from 'n8n-workflow'; import { EXTERNAL_SECRETS_INITIAL_BACKOFF, EXTERNAL_SECRETS_MAX_BACKOFF } from './constants'; -import { License } from '@/license'; -import { EventService } from '@/events/event.service'; import { updateIntervalTime } from './external-secrets-helper.ee'; import { ExternalSecretsProviders } from './external-secrets-providers.ee'; -import { OrchestrationService } from '@/services/orchestration.service'; @Service() export class ExternalSecretsManager { diff --git a/packages/cli/src/external-secrets/external-secrets-providers.ee.ts b/packages/cli/src/external-secrets/external-secrets-providers.ee.ts index b4e7396fced45..642c107603cd4 100644 --- a/packages/cli/src/external-secrets/external-secrets-providers.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets-providers.ee.ts @@ -1,10 +1,12 @@ -import type { SecretsProvider } from '@/interfaces'; import { Service } from 'typedi'; -import { InfisicalProvider } from './providers/infisical'; -import { VaultProvider } from './providers/vault'; + +import type { SecretsProvider } from '@/interfaces'; + import { AwsSecretsManager } from './providers/aws-secrets/aws-secrets-manager'; import { AzureKeyVault } from './providers/azure-key-vault/azure-key-vault'; import { GcpSecretsManager } from './providers/gcp-secrets-manager/gcp-secrets-manager'; +import { InfisicalProvider } from './providers/infisical'; +import { VaultProvider } from './providers/vault'; @Service() export class ExternalSecretsProviders { diff --git a/packages/cli/src/external-secrets/external-secrets.controller.ee.ts b/packages/cli/src/external-secrets/external-secrets.controller.ee.ts index 0b27d856dc3aa..7bcffe9c85ba7 100644 --- a/packages/cli/src/external-secrets/external-secrets.controller.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets.controller.ee.ts @@ -1,9 +1,11 @@ -import { Get, Post, RestController, GlobalScope } from '@/decorators'; -import { ExternalSecretsRequest } from '@/requests'; import { Response } from 'express'; -import { ExternalSecretsService } from './external-secrets.service.ee'; + +import { Get, Post, RestController, GlobalScope } from '@/decorators'; import { ExternalSecretsProviderNotFoundError } from '@/errors/external-secrets-provider-not-found.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { ExternalSecretsRequest } from '@/requests'; + +import { ExternalSecretsService } from './external-secrets.service.ee'; @RestController('/external-secrets') export class ExternalSecretsController { diff --git a/packages/cli/src/external-secrets/external-secrets.service.ee.ts b/packages/cli/src/external-secrets/external-secrets.service.ee.ts index d7ba686361489..aab3b2069a7af 100644 --- a/packages/cli/src/external-secrets/external-secrets.service.ee.ts +++ b/packages/cli/src/external-secrets/external-secrets.service.ee.ts @@ -1,11 +1,13 @@ -import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; -import type { SecretsProvider } from '@/interfaces'; -import type { ExternalSecretsRequest } from '@/requests'; import type { IDataObject } from 'n8n-workflow'; import { deepCopy } from 'n8n-workflow'; import Container, { Service } from 'typedi'; -import { ExternalSecretsManager } from './external-secrets-manager.ee'; + +import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; import { ExternalSecretsProviderNotFoundError } from '@/errors/external-secrets-provider-not-found.error'; +import type { SecretsProvider } from '@/interfaces'; +import type { ExternalSecretsRequest } from '@/requests'; + +import { ExternalSecretsManager } from './external-secrets-manager.ee'; @Service() export class ExternalSecretsService { diff --git a/packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts b/packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts index 8bacd6bbb9d21..4380db8c1b32d 100644 --- a/packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts +++ b/packages/cli/src/external-secrets/providers/__tests__/azure-key-vault.test.ts @@ -1,7 +1,8 @@ import { SecretClient } from '@azure/keyvault-secrets'; import type { KeyVaultSecret } from '@azure/keyvault-secrets'; -import { AzureKeyVault } from '../azure-key-vault/azure-key-vault'; import { mock } from 'jest-mock-extended'; + +import { AzureKeyVault } from '../azure-key-vault/azure-key-vault'; import type { AzureKeyVaultContext } from '../azure-key-vault/types'; jest.mock('@azure/identity'); diff --git a/packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts b/packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts index 40673041a760c..09798d0d3ab62 100644 --- a/packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts +++ b/packages/cli/src/external-secrets/providers/__tests__/gcp-secrets-manager.test.ts @@ -1,8 +1,9 @@ +import { SecretManagerServiceClient } from '@google-cloud/secret-manager'; +import type { google } from '@google-cloud/secret-manager/build/protos/protos'; import { mock } from 'jest-mock-extended'; + import { GcpSecretsManager } from '../gcp-secrets-manager/gcp-secrets-manager'; import type { GcpSecretsManagerContext } from '../gcp-secrets-manager/types'; -import { SecretManagerServiceClient } from '@google-cloud/secret-manager'; -import type { google } from '@google-cloud/secret-manager/build/protos/protos'; jest.mock('@google-cloud/secret-manager'); diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts index 0241f719bc8ec..e8b4c3cce2feb 100644 --- a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts +++ b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-client.ts @@ -1,7 +1,8 @@ -import axios from 'axios'; import * as aws4 from 'aws4'; -import type { AxiosRequestConfig } from 'axios'; import type { Request as Aws4Options } from 'aws4'; +import axios from 'axios'; +import type { AxiosRequestConfig } from 'axios'; + import type { AwsSecretsManagerContext, ConnectionTestResult, diff --git a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts index 3a310706dd33c..2c17aee5a6332 100644 --- a/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/aws-secrets/aws-secrets-manager.ts @@ -1,8 +1,10 @@ -import { AwsSecretsClient } from './aws-secrets-client'; +import type { INodeProperties } from 'n8n-workflow'; + import { UnknownAuthTypeError } from '@/errors/unknown-auth-type.error'; import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import type { INodeProperties } from 'n8n-workflow'; + +import { AwsSecretsClient } from './aws-secrets-client'; import type { AwsSecretsManagerContext } from './types'; export class AwsSecretsManager implements SecretsProvider { diff --git a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts index 0060d1900fd4f..c87c5e07d006d 100644 --- a/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts +++ b/packages/cli/src/external-secrets/providers/azure-key-vault/azure-key-vault.ts @@ -1,9 +1,11 @@ import { ClientSecretCredential } from '@azure/identity'; import { SecretClient } from '@azure/keyvault-secrets'; -import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; import type { INodeProperties } from 'n8n-workflow'; -import type { AzureKeyVaultContext } from './types'; + import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; +import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; + +import type { AzureKeyVaultContext } from './types'; export class AzureKeyVault implements SecretsProvider { name = 'azureKeyVault'; diff --git a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts index dae760fcc1449..c562139105447 100644 --- a/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts +++ b/packages/cli/src/external-secrets/providers/gcp-secrets-manager/gcp-secrets-manager.ts @@ -1,7 +1,9 @@ import { SecretManagerServiceClient as GcpClient } from '@google-cloud/secret-manager'; +import { jsonParse, type INodeProperties } from 'n8n-workflow'; + import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '@/external-secrets/constants'; import type { SecretsProvider, SecretsProviderState } from '@/interfaces'; -import { jsonParse, type INodeProperties } from 'n8n-workflow'; + import type { GcpSecretsManagerContext, GcpSecretAccountKey, diff --git a/packages/cli/src/external-secrets/providers/infisical.ts b/packages/cli/src/external-secrets/providers/infisical.ts index 7a2a01e712b2e..e74ef921b76ff 100644 --- a/packages/cli/src/external-secrets/providers/infisical.ts +++ b/packages/cli/src/external-secrets/providers/infisical.ts @@ -1,8 +1,10 @@ -import type { SecretsProvider, SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; import InfisicalClient from 'infisical-node'; -import { populateClientWorkspaceConfigsHelper } from 'infisical-node/lib/helpers/key'; import { getServiceTokenData } from 'infisical-node/lib/api/serviceTokenData'; +import { populateClientWorkspaceConfigsHelper } from 'infisical-node/lib/helpers/key'; import { ApplicationError, type IDataObject, type INodeProperties } from 'n8n-workflow'; + +import type { SecretsProvider, SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; + import { EXTERNAL_SECRETS_NAME_REGEX } from '../constants'; export interface InfisicalSettings { diff --git a/packages/cli/src/external-secrets/providers/vault.ts b/packages/cli/src/external-secrets/providers/vault.ts index d0baf6b1e3f94..e325e699354c6 100644 --- a/packages/cli/src/external-secrets/providers/vault.ts +++ b/packages/cli/src/external-secrets/providers/vault.ts @@ -1,12 +1,14 @@ -import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; -import { SecretsProvider } from '@/interfaces'; -import type { IDataObject, INodeProperties } from 'n8n-workflow'; import type { AxiosInstance, AxiosResponse } from 'axios'; import axios from 'axios'; +import type { IDataObject, INodeProperties } from 'n8n-workflow'; +import { Container } from 'typedi'; + +import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; +import { SecretsProvider } from '@/interfaces'; import { Logger } from '@/logger'; + import { DOCS_HELP_NOTICE, EXTERNAL_SECRETS_NAME_REGEX } from '../constants'; import { preferGet } from '../external-secrets-helper.ee'; -import { Container } from 'typedi'; type VaultAuthMethod = 'token' | 'usernameAndPassword' | 'appRole'; diff --git a/packages/cli/src/generic-helpers.ts b/packages/cli/src/generic-helpers.ts index 7010e0d4dcb6e..272cdb433f5e7 100644 --- a/packages/cli/src/generic-helpers.ts +++ b/packages/cli/src/generic-helpers.ts @@ -1,16 +1,18 @@ import { validate } from 'class-validator'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; + import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { TagEntity } from '@/databases/entities/tag-entity'; import type { User } from '@/databases/entities/user'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { UserRoleChangePayload, UserSettingsUpdatePayload, UserUpdatePayload, } from '@/requests'; -import { BadRequestError } from './errors/response-errors/bad-request.error'; + import type { PersonalizationSurveyAnswersV4 } from './controllers/survey-answers.dto'; +import { BadRequestError } from './errors/response-errors/bad-request.error'; export async function validateEntity( entity: diff --git a/packages/cli/src/interfaces.ts b/packages/cli/src/interfaces.ts index beb3c75497207..7e6eb1584d044 100644 --- a/packages/cli/src/interfaces.ts +++ b/packages/cli/src/interfaces.ts @@ -1,4 +1,6 @@ +import type { Scope } from '@n8n/permissions'; import type { Application } from 'express'; +import type { WorkflowExecute } from 'n8n-core'; import type { ExecutionError, ICredentialDataDecryptedObject, @@ -23,13 +25,9 @@ import type { IWorkflowExecutionDataProcess, IUser, } from 'n8n-workflow'; - -import type { ActiveWorkflowManager } from '@/active-workflow-manager'; - -import type { WorkflowExecute } from 'n8n-core'; - import type PCancelable from 'p-cancelable'; +import type { ActiveWorkflowManager } from '@/active-workflow-manager'; import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; import type { AuthProviderType } from '@/databases/entities/auth-identity'; import type { SharedCredentials } from '@/databases/entities/shared-credentials'; @@ -39,11 +37,11 @@ import type { CredentialsRepository } from '@/databases/repositories/credentials import type { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { UserRepository } from '@/databases/repositories/user.repository'; import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { ExternalHooks } from './external-hooks'; + import type { LICENSE_FEATURES, LICENSE_QUOTAS } from './constants'; -import type { WorkflowWithSharingsAndCredentials } from './workflows/workflows.types'; +import type { ExternalHooks } from './external-hooks'; import type { RunningJobSummary } from './scaling/scaling.types'; -import type { Scope } from '@n8n/permissions'; +import type { WorkflowWithSharingsAndCredentials } from './workflows/workflows.types'; export interface ICredentialsTypeData { [key: string]: CredentialLoadingDetails; diff --git a/packages/cli/src/ldap/__tests__/helpers.test.ts b/packages/cli/src/ldap/__tests__/helpers.test.ts index 4295ac6f6f879..5d38c58e1a521 100644 --- a/packages/cli/src/ldap/__tests__/helpers.test.ts +++ b/packages/cli/src/ldap/__tests__/helpers.test.ts @@ -1,9 +1,9 @@ -import { UserRepository } from '@/databases/repositories/user.repository'; -import { mockInstance } from '@test/mocking'; -import * as helpers from '@/ldap/helpers.ee'; import { AuthIdentity } from '@/databases/entities/auth-identity'; import { User } from '@/databases/entities/user'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { generateNanoId } from '@/databases/utils/generators'; +import * as helpers from '@/ldap/helpers.ee'; +import { mockInstance } from '@test/mocking'; const userRepository = mockInstance(UserRepository); diff --git a/packages/cli/src/ldap/helpers.ee.ts b/packages/cli/src/ldap/helpers.ee.ts index d5eec5c5b1bd9..7af09170548d3 100644 --- a/packages/cli/src/ldap/helpers.ee.ts +++ b/packages/cli/src/ldap/helpers.ee.ts @@ -1,14 +1,18 @@ +import { validate } from 'jsonschema'; import type { Entry as LdapUser } from 'ldapts'; import { Filter } from 'ldapts/filters/Filter'; -import { Container } from 'typedi'; -import { validate } from 'jsonschema'; import { randomString } from 'n8n-workflow'; +import { Container } from 'typedi'; -import * as Db from '@/db'; import config from '@/config'; -import { User } from '@/databases/entities/user'; import { AuthIdentity } from '@/databases/entities/auth-identity'; import type { AuthProviderSyncHistory } from '@/databases/entities/auth-provider-sync-history'; +import { User } from '@/databases/entities/user'; +import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; +import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import * as Db from '@/db'; +import { License } from '@/license'; import { BINARY_AD_ATTRIBUTES, @@ -17,10 +21,6 @@ import { LDAP_LOGIN_LABEL, } from './constants'; import type { ConnectionSecurity, LdapConfig } from './types'; -import { License } from '@/license'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository'; -import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; /** * Check whether the LDAP feature is disabled in the instance diff --git a/packages/cli/src/ldap/ldap.controller.ee.ts b/packages/cli/src/ldap/ldap.controller.ee.ts index 7a56d8049d9ca..c951b6d41d19c 100644 --- a/packages/cli/src/ldap/ldap.controller.ee.ts +++ b/packages/cli/src/ldap/ldap.controller.ee.ts @@ -1,12 +1,13 @@ import pick from 'lodash/pick'; + import { Get, Post, Put, RestController, GlobalScope } from '@/decorators'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { EventService } from '@/events/event.service'; import { NON_SENSIBLE_LDAP_CONFIG_PROPERTIES } from './constants'; import { getLdapSynchronizations } from './helpers.ee'; -import { LdapConfiguration } from './types'; import { LdapService } from './ldap.service.ee'; -import { EventService } from '@/events/event.service'; +import { LdapConfiguration } from './types'; @RestController('/ldap') export class LdapController { diff --git a/packages/cli/src/ldap/ldap.service.ee.ts b/packages/cli/src/ldap/ldap.service.ee.ts index 7eba59191d2d7..84c79c7651cc5 100644 --- a/packages/cli/src/ldap/ldap.service.ee.ts +++ b/packages/cli/src/ldap/ldap.service.ee.ts @@ -1,20 +1,20 @@ -import { Service } from 'typedi'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { QueryFailedError } from '@n8n/typeorm'; import type { Entry as LdapUser, ClientOptions } from 'ldapts'; import { Client } from 'ldapts'; -import type { ConnectionOptions } from 'tls'; -import { ApplicationError, jsonParse } from 'n8n-workflow'; import { Cipher } from 'n8n-core'; +import { ApplicationError, jsonParse } from 'n8n-workflow'; +import type { ConnectionOptions } from 'tls'; +import { Service } from 'typedi'; import config from '@/config'; -import type { User } from '@/databases/entities/user'; import type { RunningMode, SyncStatus } from '@/databases/entities/auth-provider-sync-history'; +import type { User } from '@/databases/entities/user'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { Logger } from '@/logger'; - import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import { EventService } from '@/events/event.service'; +import { Logger } from '@/logger'; import { getCurrentAuthenticationMethod, isEmailCurrentAuthenticationMethod, @@ -22,7 +22,12 @@ import { setCurrentAuthenticationMethod, } from '@/sso/sso-helpers'; -import type { LdapConfig } from './types'; +import { + BINARY_AD_ATTRIBUTES, + LDAP_FEATURE_NAME, + LDAP_LOGIN_ENABLED, + LDAP_LOGIN_LABEL, +} from './constants'; import { createFilter, deleteAllLdapIdentities, @@ -38,13 +43,7 @@ import { saveLdapSynchronization, validateLdapConfigurationSchema, } from './helpers.ee'; -import { - BINARY_AD_ATTRIBUTES, - LDAP_FEATURE_NAME, - LDAP_LOGIN_ENABLED, - LDAP_LOGIN_LABEL, -} from './constants'; -import { EventService } from '@/events/event.service'; +import type { LdapConfig } from './types'; @Service() export class LdapService { diff --git a/packages/cli/src/license.ts b/packages/cli/src/license.ts index 21ef6c577ff38..6e4ced8751f05 100644 --- a/packages/cli/src/license.ts +++ b/packages/cli/src/license.ts @@ -2,8 +2,14 @@ import type { TEntitlement, TFeatures, TLicenseBlock } from '@n8n_io/license-sdk import { LicenseManager } from '@n8n_io/license-sdk'; import { InstanceSettings, ObjectStoreService } from 'n8n-core'; import Container, { Service } from 'typedi'; -import { Logger } from '@/logger'; + import config from '@/config'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { OnShutdown } from '@/decorators/on-shutdown'; +import { Logger } from '@/logger'; +import { LicenseMetricsService } from '@/metrics/license-metrics.service'; +import { OrchestrationService } from '@/services/orchestration.service'; + import { LICENSE_FEATURES, LICENSE_QUOTAS, @@ -11,13 +17,9 @@ import { SETTINGS_LICENSE_CERT_KEY, UNLIMITED_LICENSE_QUOTA, } from './constants'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { BooleanLicenseFeature, N8nInstanceType, NumericLicenseFeature } from './interfaces'; import type { RedisServicePubSubPublisher } from './services/redis/redis-service-pub-sub-publisher'; import { RedisService } from './services/redis.service'; -import { OrchestrationService } from '@/services/orchestration.service'; -import { OnShutdown } from '@/decorators/on-shutdown'; -import { LicenseMetricsService } from '@/metrics/license-metrics.service'; type FeatureReturnType = Partial< { diff --git a/packages/cli/src/license/__tests__/license.service.test.ts b/packages/cli/src/license/__tests__/license.service.test.ts index 8a730f01926ba..5fe4d6c69209e 100644 --- a/packages/cli/src/license/__tests__/license.service.test.ts +++ b/packages/cli/src/license/__tests__/license.service.test.ts @@ -1,10 +1,11 @@ -import { LicenseErrors, LicenseService } from '@/license/license.service'; -import type { License } from '@/license'; -import type { EventService } from '@/events/event.service'; -import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { TEntitlement } from '@n8n_io/license-sdk'; import { mock } from 'jest-mock-extended'; + +import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import type { EventService } from '@/events/event.service'; +import type { License } from '@/license'; +import { LicenseErrors, LicenseService } from '@/license/license.service'; describe('LicenseService', () => { const license = mock(); diff --git a/packages/cli/src/license/license.controller.ts b/packages/cli/src/license/license.controller.ts index 945f3650ea340..e1644046bb395 100644 --- a/packages/cli/src/license/license.controller.ts +++ b/packages/cli/src/license/license.controller.ts @@ -1,8 +1,10 @@ +import type { AxiosError } from 'axios'; + import { Get, Post, RestController, GlobalScope } from '@/decorators'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { AuthenticatedRequest, LicenseRequest } from '@/requests'; + import { LicenseService } from './license.service'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import type { AxiosError } from 'axios'; @RestController('/license') export class LicenseController { diff --git a/packages/cli/src/license/license.service.ts b/packages/cli/src/license/license.service.ts index 178e8b1bf2e0d..d92c181f8dc3f 100644 --- a/packages/cli/src/license/license.service.ts +++ b/packages/cli/src/license/license.service.ts @@ -1,12 +1,12 @@ -import { Service } from 'typedi'; import axios from 'axios'; +import { Service } from 'typedi'; -import { Logger } from '@/logger'; -import { License } from '@/license'; -import { EventService } from '@/events/event.service'; import type { User } from '@/databases/entities/user'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { EventService } from '@/events/event.service'; +import { License } from '@/license'; +import { Logger } from '@/logger'; import { UrlService } from '@/services/url.service'; type LicenseError = Error & { errorId?: keyof typeof LicenseErrors }; diff --git a/packages/cli/src/load-nodes-and-credentials.ts b/packages/cli/src/load-nodes-and-credentials.ts index eb6c55fa5dd7e..500f5d20289d1 100644 --- a/packages/cli/src/load-nodes-and-credentials.ts +++ b/packages/cli/src/load-nodes-and-credentials.ts @@ -1,8 +1,6 @@ +import { GlobalConfig } from '@n8n/config'; import glob from 'fast-glob'; -import { Container, Service } from 'typedi'; -import path from 'path'; import fsPromises from 'fs/promises'; - import type { Class, DirectoryLoader, Types } from 'n8n-core'; import { CUSTOM_EXTENSION_ENV, @@ -19,6 +17,8 @@ import type { ICredentialTypeData, } from 'n8n-workflow'; import { NodeHelpers, ApplicationError, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import path from 'path'; +import { Container, Service } from 'typedi'; import { CUSTOM_API_CALL_KEY, @@ -28,7 +28,6 @@ import { inE2ETests, } from '@/constants'; import { Logger } from '@/logger'; -import { GlobalConfig } from '@n8n/config'; interface LoadedNodesAndCredentials { nodes: INodeTypeData; diff --git a/packages/cli/src/logger.ts b/packages/cli/src/logger.ts index 4e105b33043da..7a24bdbf28fb7 100644 --- a/packages/cli/src/logger.ts +++ b/packages/cli/src/logger.ts @@ -1,10 +1,9 @@ -import { Service } from 'typedi'; -import winston from 'winston'; import callsites from 'callsites'; -import { inspect } from 'util'; -import { basename } from 'path'; - import { LoggerProxy, type IDataObject, LOG_LEVELS } from 'n8n-workflow'; +import { basename } from 'path'; +import { Service } from 'typedi'; +import { inspect } from 'util'; +import winston from 'winston'; import config from '@/config'; diff --git a/packages/cli/src/metrics/__tests__/license-metrics.service.test.ts b/packages/cli/src/metrics/__tests__/license-metrics.service.test.ts index 2abf766a7b396..ec123a3f01754 100644 --- a/packages/cli/src/metrics/__tests__/license-metrics.service.test.ts +++ b/packages/cli/src/metrics/__tests__/license-metrics.service.test.ts @@ -1,7 +1,8 @@ import { mock } from 'jest-mock-extended'; -import { LicenseMetricsService } from '@/metrics/license-metrics.service'; -import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; + import type { LicenseMetricsRepository } from '@/databases/repositories/license-metrics.repository'; +import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { LicenseMetricsService } from '@/metrics/license-metrics.service'; describe('LicenseMetricsService', () => { const workflowRepository = mock(); diff --git a/packages/cli/src/metrics/__tests__/prometheus-metrics.service.test.ts b/packages/cli/src/metrics/__tests__/prometheus-metrics.service.test.ts index dd79de956ef42..f9e8558990a4f 100644 --- a/packages/cli/src/metrics/__tests__/prometheus-metrics.service.test.ts +++ b/packages/cli/src/metrics/__tests__/prometheus-metrics.service.test.ts @@ -1,13 +1,15 @@ -import config from '@/config'; -import promClient from 'prom-client'; +import { GlobalConfig } from '@n8n/config'; +import type express from 'express'; import promBundle from 'express-prom-bundle'; import { mock } from 'jest-mock-extended'; -import { PrometheusMetricsService } from '../prometheus-metrics.service'; -import type express from 'express'; +import promClient from 'prom-client'; + +import config from '@/config'; import type { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import { mockInstance } from '@test/mocking'; -import { GlobalConfig } from '@n8n/config'; import type { EventService } from '@/events/event.service'; +import { mockInstance } from '@test/mocking'; + +import { PrometheusMetricsService } from '../prometheus-metrics.service'; const mockMiddleware = ( _req: express.Request, diff --git a/packages/cli/src/metrics/license-metrics.service.ts b/packages/cli/src/metrics/license-metrics.service.ts index 14ac6a3df2a7e..ba546b3cc0168 100644 --- a/packages/cli/src/metrics/license-metrics.service.ts +++ b/packages/cli/src/metrics/license-metrics.service.ts @@ -1,5 +1,6 @@ -import { LicenseMetricsRepository } from '@/databases/repositories/license-metrics.repository'; import { Service } from 'typedi'; + +import { LicenseMetricsRepository } from '@/databases/repositories/license-metrics.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; @Service() diff --git a/packages/cli/src/metrics/prometheus-metrics.service.ts b/packages/cli/src/metrics/prometheus-metrics.service.ts index 3646f172f183b..11b353437a98a 100644 --- a/packages/cli/src/metrics/prometheus-metrics.service.ts +++ b/packages/cli/src/metrics/prometheus-metrics.service.ts @@ -1,18 +1,19 @@ -import { N8N_VERSION } from '@/constants'; +import { GlobalConfig } from '@n8n/config'; import type express from 'express'; import promBundle from 'express-prom-bundle'; +import { EventMessageTypeNames } from 'n8n-workflow'; import promClient, { type Counter, type Gauge } from 'prom-client'; import semverParse from 'semver/functions/parse'; import { Service } from 'typedi'; -import { CacheService } from '@/services/cache/cache.service'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import { EventMessageTypeNames } from 'n8n-workflow'; +import config from '@/config'; +import { N8N_VERSION } from '@/constants'; import type { EventMessageTypes } from '@/eventbus'; -import type { Includes, MetricCategory, MetricLabel } from './types'; -import { GlobalConfig } from '@n8n/config'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { EventService } from '@/events/event.service'; -import config from '@/config'; +import { CacheService } from '@/services/cache/cache.service'; + +import type { Includes, MetricCategory, MetricLabel } from './types'; @Service() export class PrometheusMetricsService { diff --git a/packages/cli/src/mfa/helpers.ts b/packages/cli/src/mfa/helpers.ts index e03c7c00e06eb..d08ed98c16894 100644 --- a/packages/cli/src/mfa/helpers.ts +++ b/packages/cli/src/mfa/helpers.ts @@ -1,8 +1,10 @@ import Container from 'typedi'; + import config from '@/config'; -import { MFA_FEATURE_ENABLED } from './constants'; import { UserRepository } from '@/databases/repositories/user.repository'; +import { MFA_FEATURE_ENABLED } from './constants'; + export const isMfaFeatureEnabled = () => config.get(MFA_FEATURE_ENABLED); const isMfaFeatureDisabled = () => !isMfaFeatureEnabled(); diff --git a/packages/cli/src/mfa/mfa.service.ts b/packages/cli/src/mfa/mfa.service.ts index 2e490ec127288..5f730b7bf18d6 100644 --- a/packages/cli/src/mfa/mfa.service.ts +++ b/packages/cli/src/mfa/mfa.service.ts @@ -1,10 +1,12 @@ -import { v4 as uuid } from 'uuid'; -import { Service } from 'typedi'; import { Cipher } from 'n8n-core'; +import { Service } from 'typedi'; +import { v4 as uuid } from 'uuid'; + import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; -import { TOTPService } from './totp.service'; import { InvalidMfaCodeError } from '@/errors/response-errors/invalid-mfa-code.error'; +import { TOTPService } from './totp.service'; + @Service() export class MfaService { constructor( diff --git a/packages/cli/src/middlewares/body-parser.ts b/packages/cli/src/middlewares/body-parser.ts index 5efe388e6f1e1..59327ea080e0e 100644 --- a/packages/cli/src/middlewares/body-parser.ts +++ b/packages/cli/src/middlewares/body-parser.ts @@ -1,14 +1,15 @@ -import getRawBody from 'raw-body'; -import { type Readable } from 'stream'; -import { createGunzip, createInflate } from 'zlib'; +import { GlobalConfig } from '@n8n/config'; import type { Request, RequestHandler } from 'express'; -import { parse as parseQueryString } from 'querystring'; -import { Parser as XmlParser } from 'xml2js'; import { parseIncomingMessage } from 'n8n-core'; import { jsonParse } from 'n8n-workflow'; -import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; -import { GlobalConfig } from '@n8n/config'; +import { parse as parseQueryString } from 'querystring'; +import getRawBody from 'raw-body'; +import { type Readable } from 'stream'; import Container from 'typedi'; +import { Parser as XmlParser } from 'xml2js'; +import { createGunzip, createInflate } from 'zlib'; + +import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; const xmlParser = new XmlParser({ async: true, diff --git a/packages/cli/src/middlewares/list-query/__tests__/list-query.test.ts b/packages/cli/src/middlewares/list-query/__tests__/list-query.test.ts index b6ee124dfac4e..0e77792a43d5e 100644 --- a/packages/cli/src/middlewares/list-query/__tests__/list-query.test.ts +++ b/packages/cli/src/middlewares/list-query/__tests__/list-query.test.ts @@ -1,9 +1,10 @@ +import type { Response, NextFunction } from 'express'; + import { filterListQueryMiddleware } from '@/middlewares/list-query/filter'; -import { selectListQueryMiddleware } from '@/middlewares/list-query/select'; import { paginationListQueryMiddleware } from '@/middlewares/list-query/pagination'; -import * as ResponseHelper from '@/response-helper'; +import { selectListQueryMiddleware } from '@/middlewares/list-query/select'; import type { ListQuery } from '@/requests'; -import type { Response, NextFunction } from 'express'; +import * as ResponseHelper from '@/response-helper'; describe('List query middleware', () => { let mockReq: ListQuery.Request; diff --git a/packages/cli/src/middlewares/list-query/dtos/base.filter.dto.ts b/packages/cli/src/middlewares/list-query/dtos/base.filter.dto.ts index 2a67be55bde67..678cb86981ccb 100644 --- a/packages/cli/src/middlewares/list-query/dtos/base.filter.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/base.filter.dto.ts @@ -1,8 +1,9 @@ -import { isObjectLiteral } from '@/utils'; import { plainToInstance, instanceToPlain } from 'class-transformer'; import { validate } from 'class-validator'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { isObjectLiteral } from '@/utils'; + export class BaseFilter { protected static async toFilter(rawFilter: string, Filter: typeof BaseFilter) { const dto = jsonParse(rawFilter, { errorMessage: 'Failed to parse filter JSON' }); diff --git a/packages/cli/src/middlewares/list-query/dtos/base.select.dto.ts b/packages/cli/src/middlewares/list-query/dtos/base.select.dto.ts index 20b85094ce722..9a8cb395f0694 100644 --- a/packages/cli/src/middlewares/list-query/dtos/base.select.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/base.select.dto.ts @@ -1,6 +1,7 @@ -import { isStringArray } from '@/utils'; import { ApplicationError, jsonParse } from 'n8n-workflow'; +import { isStringArray } from '@/utils'; + export class BaseSelect { static selectableFields: Set; diff --git a/packages/cli/src/middlewares/list-query/dtos/credentials.filter.dto.ts b/packages/cli/src/middlewares/list-query/dtos/credentials.filter.dto.ts index 191799b15711f..b0d0078ed60ef 100644 --- a/packages/cli/src/middlewares/list-query/dtos/credentials.filter.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/credentials.filter.dto.ts @@ -1,5 +1,6 @@ -import { IsOptional, IsString } from 'class-validator'; import { Expose } from 'class-transformer'; +import { IsOptional, IsString } from 'class-validator'; + import { BaseFilter } from './base.filter.dto'; export class CredentialsFilter extends BaseFilter { diff --git a/packages/cli/src/middlewares/list-query/dtos/pagination.dto.ts b/packages/cli/src/middlewares/list-query/dtos/pagination.dto.ts index 1a837d159ce51..a48a79e31db11 100644 --- a/packages/cli/src/middlewares/list-query/dtos/pagination.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/pagination.dto.ts @@ -1,6 +1,7 @@ -import { isIntegerString } from '@/utils'; import { ApplicationError } from 'n8n-workflow'; +import { isIntegerString } from '@/utils'; + export class Pagination { static fromString(rawTake: string, rawSkip: string) { if (!isIntegerString(rawTake)) { diff --git a/packages/cli/src/middlewares/list-query/dtos/user.filter.dto.ts b/packages/cli/src/middlewares/list-query/dtos/user.filter.dto.ts index 82f124c8e9795..473f0782ed951 100644 --- a/packages/cli/src/middlewares/list-query/dtos/user.filter.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/user.filter.dto.ts @@ -1,5 +1,6 @@ -import { IsOptional, IsString, IsBoolean } from 'class-validator'; import { Expose } from 'class-transformer'; +import { IsOptional, IsString, IsBoolean } from 'class-validator'; + import { BaseFilter } from './base.filter.dto'; export class UserFilter extends BaseFilter { diff --git a/packages/cli/src/middlewares/list-query/dtos/workflow.filter.dto.ts b/packages/cli/src/middlewares/list-query/dtos/workflow.filter.dto.ts index d608589f00b32..28e4106c8faca 100644 --- a/packages/cli/src/middlewares/list-query/dtos/workflow.filter.dto.ts +++ b/packages/cli/src/middlewares/list-query/dtos/workflow.filter.dto.ts @@ -1,5 +1,5 @@ -import { IsOptional, IsString, IsBoolean, IsArray } from 'class-validator'; import { Expose } from 'class-transformer'; +import { IsOptional, IsString, IsBoolean, IsArray } from 'class-validator'; import { BaseFilter } from './base.filter.dto'; diff --git a/packages/cli/src/middlewares/list-query/filter.ts b/packages/cli/src/middlewares/list-query/filter.ts index b3216308eaa2a..9522238b2e8eb 100644 --- a/packages/cli/src/middlewares/list-query/filter.ts +++ b/packages/cli/src/middlewares/list-query/filter.ts @@ -1,11 +1,12 @@ +import type { NextFunction, Response } from 'express'; + +import type { ListQuery } from '@/requests'; import * as ResponseHelper from '@/response-helper'; -import { WorkflowFilter } from './dtos/workflow.filter.dto'; -import { CredentialsFilter } from './dtos/credentials.filter.dto'; -import { UserFilter } from './dtos/user.filter.dto'; import { toError } from '@/utils'; -import type { NextFunction, Response } from 'express'; -import type { ListQuery } from '@/requests'; +import { CredentialsFilter } from './dtos/credentials.filter.dto'; +import { UserFilter } from './dtos/user.filter.dto'; +import { WorkflowFilter } from './dtos/workflow.filter.dto'; export const filterListQueryMiddleware = async ( req: ListQuery.Request, diff --git a/packages/cli/src/middlewares/list-query/index.ts b/packages/cli/src/middlewares/list-query/index.ts index 524dcb268e96d..a766b43bd08da 100644 --- a/packages/cli/src/middlewares/list-query/index.ts +++ b/packages/cli/src/middlewares/list-query/index.ts @@ -1,8 +1,10 @@ +import type { NextFunction, Response } from 'express'; + +import type { ListQuery } from '@/requests'; + import { filterListQueryMiddleware } from './filter'; -import { selectListQueryMiddleware } from './select'; import { paginationListQueryMiddleware } from './pagination'; -import type { ListQuery } from '@/requests'; -import type { NextFunction, Response } from 'express'; +import { selectListQueryMiddleware } from './select'; export type ListQueryMiddleware = ( req: ListQuery.Request, diff --git a/packages/cli/src/middlewares/list-query/pagination.ts b/packages/cli/src/middlewares/list-query/pagination.ts index e9595a24c483a..8823cf8572763 100644 --- a/packages/cli/src/middlewares/list-query/pagination.ts +++ b/packages/cli/src/middlewares/list-query/pagination.ts @@ -1,10 +1,12 @@ -import { toError } from '@/utils'; -import * as ResponseHelper from '@/response-helper'; -import { Pagination } from './dtos/pagination.dto'; -import type { ListQuery } from '@/requests'; import type { RequestHandler } from 'express'; import { ApplicationError } from 'n8n-workflow'; +import type { ListQuery } from '@/requests'; +import * as ResponseHelper from '@/response-helper'; +import { toError } from '@/utils'; + +import { Pagination } from './dtos/pagination.dto'; + export const paginationListQueryMiddleware: RequestHandler = ( req: ListQuery.Request, res, diff --git a/packages/cli/src/middlewares/list-query/select.ts b/packages/cli/src/middlewares/list-query/select.ts index 35e6f17cd96f3..7eb2de0d3771d 100644 --- a/packages/cli/src/middlewares/list-query/select.ts +++ b/packages/cli/src/middlewares/list-query/select.ts @@ -1,11 +1,12 @@ -import { WorkflowSelect } from './dtos/workflow.select.dto'; -import { UserSelect } from './dtos/user.select.dto'; -import { CredentialsSelect } from './dtos/credentials.select.dto'; +import type { RequestHandler } from 'express'; + +import type { ListQuery } from '@/requests'; import * as ResponseHelper from '@/response-helper'; import { toError } from '@/utils'; -import type { RequestHandler } from 'express'; -import type { ListQuery } from '@/requests'; +import { CredentialsSelect } from './dtos/credentials.select.dto'; +import { UserSelect } from './dtos/user.select.dto'; +import { WorkflowSelect } from './dtos/workflow.select.dto'; export const selectListQueryMiddleware: RequestHandler = (req: ListQuery.Request, res, next) => { const { select: rawSelect } = req.query; diff --git a/packages/cli/src/node-types.ts b/packages/cli/src/node-types.ts index baf828ac37706..84b406001eecd 100644 --- a/packages/cli/src/node-types.ts +++ b/packages/cli/src/node-types.ts @@ -1,3 +1,5 @@ +import type { Dirent } from 'fs'; +import { readdir } from 'fs/promises'; import { loadClassInIsolation } from 'n8n-core'; import type { INodeType, @@ -7,12 +9,11 @@ import type { LoadedClass, } from 'n8n-workflow'; import { ApplicationError, NodeHelpers } from 'n8n-workflow'; -import { Service } from 'typedi'; -import { LoadNodesAndCredentials } from './load-nodes-and-credentials'; import { join, dirname } from 'path'; -import { readdir } from 'fs/promises'; -import type { Dirent } from 'fs'; +import { Service } from 'typedi'; + import { UnrecognizedNodeTypeError } from './errors/unrecognized-node-type.error'; +import { LoadNodesAndCredentials } from './load-nodes-and-credentials'; @Service() export class NodeTypes implements INodeTypes { diff --git a/packages/cli/src/permissions/check-access.ts b/packages/cli/src/permissions/check-access.ts index f29a1e95d2ae9..deea44ca99958 100644 --- a/packages/cli/src/permissions/check-access.ts +++ b/packages/cli/src/permissions/check-access.ts @@ -1,14 +1,14 @@ -import { Container } from 'typedi'; +import type { Scope } from '@n8n/permissions'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { ApplicationError } from 'n8n-workflow'; +import { Container } from 'typedi'; -import { RoleService } from '@/services/role.service'; +import type { User } from '@/databases/entities/user'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import type { User } from '@/databases/entities/user'; -import type { Scope } from '@n8n/permissions'; -import { ApplicationError } from 'n8n-workflow'; +import { RoleService } from '@/services/role.service'; export const userHasScope = async ( user: User, diff --git a/packages/cli/src/posthog/__tests__/posthog.test.ts b/packages/cli/src/posthog/__tests__/posthog.test.ts index f1604f7253df1..f2869afcbf6af 100644 --- a/packages/cli/src/posthog/__tests__/posthog.test.ts +++ b/packages/cli/src/posthog/__tests__/posthog.test.ts @@ -1,7 +1,8 @@ -import { PostHog } from 'posthog-node'; import { InstanceSettings } from 'n8n-core'; -import { PostHogClient } from '@/posthog'; +import { PostHog } from 'posthog-node'; + import config from '@/config'; +import { PostHogClient } from '@/posthog'; import { mockInstance } from '@test/mocking'; jest.mock('posthog-node'); diff --git a/packages/cli/src/posthog/index.ts b/packages/cli/src/posthog/index.ts index 63289f8e4be5b..08a501f0fcf3b 100644 --- a/packages/cli/src/posthog/index.ts +++ b/packages/cli/src/posthog/index.ts @@ -1,7 +1,8 @@ -import { Service } from 'typedi'; -import type { PostHog } from 'posthog-node'; -import type { FeatureFlags, ITelemetryTrackProperties } from 'n8n-workflow'; import { InstanceSettings } from 'n8n-core'; +import type { FeatureFlags, ITelemetryTrackProperties } from 'n8n-workflow'; +import type { PostHog } from 'posthog-node'; +import { Service } from 'typedi'; + import config from '@/config'; import type { PublicUser } from '@/interfaces'; diff --git a/packages/cli/src/public-api/index.ts b/packages/cli/src/public-api/index.ts index 0d16f9d214f1a..c240a3efa3400 100644 --- a/packages/cli/src/public-api/index.ts +++ b/packages/cli/src/public-api/index.ts @@ -1,21 +1,20 @@ -import { Container } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import type { Router } from 'express'; import express from 'express'; +import type { HttpError } from 'express-openapi-validator/dist/framework/types'; import fs from 'fs/promises'; +import type { OpenAPIV3 } from 'openapi-types'; import path from 'path'; - +import type { JsonObject } from 'swagger-ui-express'; +import { Container } from 'typedi'; import validator from 'validator'; import YAML from 'yamljs'; -import type { HttpError } from 'express-openapi-validator/dist/framework/types'; -import type { OpenAPIV3 } from 'openapi-types'; -import type { JsonObject } from 'swagger-ui-express'; -import { License } from '@/license'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { UrlService } from '@/services/url.service'; -import type { AuthenticatedRequest } from '@/requests'; -import { GlobalConfig } from '@n8n/config'; import { EventService } from '@/events/event.service'; +import { License } from '@/license'; +import type { AuthenticatedRequest } from '@/requests'; +import { UrlService } from '@/services/url.service'; async function createApiRouter( version: string, diff --git a/packages/cli/src/public-api/types.ts b/packages/cli/src/public-api/types.ts index 6eaa567485405..b69acff8d9992 100644 --- a/packages/cli/src/public-api/types.ts +++ b/packages/cli/src/public-api/types.ts @@ -1,9 +1,9 @@ import type { ExecutionStatus, ICredentialDataDecryptedObject } from 'n8n-workflow'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { TagEntity } from '@/databases/entities/tag-entity'; -import type { Risk } from '@/security-audit/types'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { AuthlessRequest, AuthenticatedRequest } from '@/requests'; +import type { Risk } from '@/security-audit/types'; export type PaginatedRequest = AuthenticatedRequest< {}, diff --git a/packages/cli/src/public-api/v1/handlers/audit/audit.handler.ts b/packages/cli/src/public-api/v1/handlers/audit/audit.handler.ts index 3c1121711bf29..eb611d9ba5664 100644 --- a/packages/cli/src/public-api/v1/handlers/audit/audit.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/audit/audit.handler.ts @@ -1,8 +1,9 @@ -import { globalScope } from '@/public-api/v1/shared/middlewares/global.middleware'; import type { Response } from 'express'; -import type { AuditRequest } from '@/public-api/types'; import Container from 'typedi'; +import type { AuditRequest } from '@/public-api/types'; +import { globalScope } from '@/public-api/v1/shared/middlewares/global.middleware'; + export = { generateAudit: [ globalScope('securityAudit:generate'), diff --git a/packages/cli/src/public-api/v1/handlers/credentials/credentials.handler.ts b/packages/cli/src/public-api/v1/handlers/credentials/credentials.handler.ts index 16d3c0e9c961c..2a0cbe3895736 100644 --- a/packages/cli/src/public-api/v1/handlers/credentials/credentials.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/credentials/credentials.handler.ts @@ -1,13 +1,14 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ import type express from 'express'; +import { Container } from 'typedi'; +import { z } from 'zod'; -import { CredentialsHelper } from '@/credentials-helper'; import { CredentialTypes } from '@/credential-types'; +import { EnterpriseCredentialsService } from '@/credentials/credentials.service.ee'; +import { CredentialsHelper } from '@/credentials-helper'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; -import type { CredentialTypeRequest, CredentialRequest } from '../../../types'; -import { projectScope } from '../../shared/middlewares/global.middleware'; -import { validCredentialsProperties, validCredentialType } from './credentials.middleware'; +import { validCredentialsProperties, validCredentialType } from './credentials.middleware'; import { createCredential, encryptCredential, @@ -18,9 +19,8 @@ import { saveCredential, toJsonSchema, } from './credentials.service'; -import { Container } from 'typedi'; -import { z } from 'zod'; -import { EnterpriseCredentialsService } from '@/credentials/credentials.service.ee'; +import type { CredentialTypeRequest, CredentialRequest } from '../../../types'; +import { projectScope } from '../../shared/middlewares/global.middleware'; export = { createCredential: [ diff --git a/packages/cli/src/public-api/v1/handlers/credentials/credentials.middleware.ts b/packages/cli/src/public-api/v1/handlers/credentials/credentials.middleware.ts index 8583c866b8fe0..59ebb7b6d0627 100644 --- a/packages/cli/src/public-api/v1/handlers/credentials/credentials.middleware.ts +++ b/packages/cli/src/public-api/v1/handlers/credentials/credentials.middleware.ts @@ -2,12 +2,13 @@ import type express from 'express'; import { validate } from 'jsonschema'; +import { Container } from 'typedi'; -import { CredentialsHelper } from '@/credentials-helper'; import { CredentialTypes } from '@/credential-types'; -import type { CredentialRequest } from '../../../types'; +import { CredentialsHelper } from '@/credentials-helper'; + import { toJsonSchema } from './credentials.service'; -import { Container } from 'typedi'; +import type { CredentialRequest } from '../../../types'; export const validCredentialType = ( req: CredentialRequest.Create, 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 11bcbd9c54e02..2477ef928f807 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 @@ -5,19 +5,21 @@ import type { INodeProperties, INodePropertyOptions, } from 'n8n-workflow'; -import * as Db from '@/db'; -import type { ICredentialsDb } from '@/interfaces'; +import { Container } from 'typedi'; + import { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { SharedCredentials } from '@/databases/entities/shared-credentials'; import type { User } from '@/databases/entities/user'; -import { ExternalHooks } from '@/external-hooks'; -import type { IDependency, IJsonSchema } from '../../../types'; -import type { CredentialRequest } from '@/requests'; -import { Container } from 'typedi'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +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 { IDependency, IJsonSchema } from '../../../types'; export async function getCredentials(credentialId: string): Promise { return await Container.get(CredentialsRepository).findOneBy({ id: credentialId }); diff --git a/packages/cli/src/public-api/v1/handlers/executions/executions.handler.ts b/packages/cli/src/public-api/v1/handlers/executions/executions.handler.ts index 4dc0a9a69bf4d..896a4f2d0dcef 100644 --- a/packages/cli/src/public-api/v1/handlers/executions/executions.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/executions/executions.handler.ts @@ -1,15 +1,16 @@ import type express from 'express'; -import { Container } from 'typedi'; import { replaceCircularReferences } from 'n8n-workflow'; +import { Container } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; -import { validCursor } from '../../shared/middlewares/global.middleware'; +import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { EventService } from '@/events/event.service'; + import type { ExecutionRequest } from '../../../types'; -import { getSharedWorkflowIds } from '../workflows/workflows.service'; +import { validCursor } from '../../shared/middlewares/global.middleware'; import { encodeNextCursor } from '../../shared/services/pagination.service'; -import { EventService } from '@/events/event.service'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; +import { getSharedWorkflowIds } from '../workflows/workflows.service'; export = { deleteExecution: [ diff --git a/packages/cli/src/public-api/v1/handlers/projects/projects.handler.ts b/packages/cli/src/public-api/v1/handlers/projects/projects.handler.ts index caf9727a118f3..ea7220f7880d4 100644 --- a/packages/cli/src/public-api/v1/handlers/projects/projects.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/projects/projects.handler.ts @@ -1,10 +1,12 @@ -import { globalScope, isLicensed, validCursor } from '../../shared/middlewares/global.middleware'; import type { Response } from 'express'; -import type { ProjectRequest } from '@/requests'; -import type { PaginatedRequest } from '@/public-api/types'; import Container from 'typedi'; + import { ProjectController } from '@/controllers/project.controller'; import { ProjectRepository } from '@/databases/repositories/project.repository'; +import type { PaginatedRequest } from '@/public-api/types'; +import type { ProjectRequest } from '@/requests'; + +import { globalScope, isLicensed, validCursor } from '../../shared/middlewares/global.middleware'; import { encodeNextCursor } from '../../shared/services/pagination.service'; type Create = ProjectRequest.Create; diff --git a/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts b/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts index 330701f59cad0..fdcb2f16baabf 100644 --- a/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/source-control/source-control.handler.ts @@ -1,17 +1,19 @@ import type express from 'express'; -import { Container } from 'typedi'; import type { StatusResult } from 'simple-git'; -import type { PublicSourceControlRequest } from '../../../types'; -import { globalScope } from '../../shared/middlewares/global.middleware'; -import type { ImportResult } from '@/environments/source-control/types/import-result'; -import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; -import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; +import { Container } from 'typedi'; + import { getTrackingInformationFromPullResult, isSourceControlLicensed, } from '@/environments/source-control/source-control-helper.ee'; +import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; +import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; +import type { ImportResult } from '@/environments/source-control/types/import-result'; import { EventService } from '@/events/event.service'; +import type { PublicSourceControlRequest } from '../../../types'; +import { globalScope } from '../../shared/middlewares/global.middleware'; + export = { pull: [ globalScope('sourceControl:pull'), diff --git a/packages/cli/src/public-api/v1/handlers/tags/tags.handler.ts b/packages/cli/src/public-api/v1/handlers/tags/tags.handler.ts index b17dcfc4c9a90..daf5d78414e28 100644 --- a/packages/cli/src/public-api/v1/handlers/tags/tags.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/tags/tags.handler.ts @@ -1,16 +1,16 @@ +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import type { FindManyOptions } from '@n8n/typeorm'; import type express from 'express'; +import { Container } from 'typedi'; import type { TagEntity } from '@/databases/entities/tag-entity'; -import { globalScope, validCursor } from '../../shared/middlewares/global.middleware'; -import type { TagRequest } from '../../../types'; -import { encodeNextCursor } from '../../shared/services/pagination.service'; - -import { Container } from 'typedi'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import type { FindManyOptions } from '@n8n/typeorm'; import { TagRepository } from '@/databases/repositories/tag.repository'; import { TagService } from '@/services/tag.service'; +import type { TagRequest } from '../../../types'; +import { globalScope, validCursor } from '../../shared/middlewares/global.middleware'; +import { encodeNextCursor } from '../../shared/services/pagination.service'; + export = { createTag: [ globalScope('tag:create'), diff --git a/packages/cli/src/public-api/v1/handlers/users/users.handler.ee.ts b/packages/cli/src/public-api/v1/handlers/users/users.handler.ee.ts index ecff06013a3d6..e933d12901a0a 100644 --- a/packages/cli/src/public-api/v1/handlers/users/users.handler.ee.ts +++ b/packages/cli/src/public-api/v1/handlers/users/users.handler.ee.ts @@ -1,21 +1,21 @@ import type express from 'express'; +import type { Response } from 'express'; import { Container } from 'typedi'; -import { clean, getAllUsersAndCount, getUser } from './users.service.ee'; +import { InvitationController } from '@/controllers/invitation.controller'; +import { UsersController } from '@/controllers/users.controller'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { EventService } from '@/events/event.service'; +import type { UserRequest } from '@/requests'; -import { encodeNextCursor } from '../../shared/services/pagination.service'; +import { clean, getAllUsersAndCount, getUser } from './users.service.ee'; import { globalScope, isLicensed, validCursor, validLicenseWithUserQuota, } from '../../shared/middlewares/global.middleware'; -import type { UserRequest } from '@/requests'; -import { EventService } from '@/events/event.service'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import type { Response } from 'express'; -import { InvitationController } from '@/controllers/invitation.controller'; -import { UsersController } from '@/controllers/users.controller'; +import { encodeNextCursor } from '../../shared/services/pagination.service'; type Create = UserRequest.Invite; type Delete = UserRequest.Delete; diff --git a/packages/cli/src/public-api/v1/handlers/users/users.service.ee.ts b/packages/cli/src/public-api/v1/handlers/users/users.service.ee.ts index 263224e4d1da5..f4e1b868787c5 100644 --- a/packages/cli/src/public-api/v1/handlers/users/users.service.ee.ts +++ b/packages/cli/src/public-api/v1/handlers/users/users.service.ee.ts @@ -1,10 +1,11 @@ -import { Container } from 'typedi'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import type { User } from '@/databases/entities/user'; -import pick from 'lodash/pick'; -import { validate as uuidValidate } from 'uuid'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import pick from 'lodash/pick'; +import { Container } from 'typedi'; +import { validate as uuidValidate } from 'uuid'; + +import type { User } from '@/databases/entities/user'; +import { UserRepository } from '@/databases/repositories/user.repository'; export async function getUser(data: { withIdentifier: string; diff --git a/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts b/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts index 50e35fb076a2d..65fb1daab5653 100644 --- a/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts @@ -1,11 +1,13 @@ +import type { Response } from 'express'; import Container from 'typedi'; + import { VariablesRepository } from '@/databases/repositories/variables.repository'; import { VariablesController } from '@/environments/variables/variables.controller.ee'; +import type { PaginatedRequest } from '@/public-api/types'; +import type { VariablesRequest } from '@/requests'; + import { globalScope, isLicensed, validCursor } from '../../shared/middlewares/global.middleware'; import { encodeNextCursor } from '../../shared/services/pagination.service'; -import type { Response } from 'express'; -import type { VariablesRequest } from '@/requests'; -import type { PaginatedRequest } from '@/public-api/types'; type Create = VariablesRequest.Create; type Delete = VariablesRequest.Delete; diff --git a/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts b/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts index ef582815cea99..f46b177c61171 100644 --- a/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts +++ b/packages/cli/src/public-api/v1/handlers/workflows/workflows.handler.ts @@ -1,20 +1,26 @@ -import type express from 'express'; - -import { Container } from 'typedi'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { FindOptionsWhere } from '@n8n/typeorm'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In, Like, QueryFailedError } from '@n8n/typeorm'; +import type express from 'express'; +import { Container } from 'typedi'; import { v4 as uuid } from 'uuid'; +import { z } from 'zod'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { TagRepository } from '@/databases/repositories/tag.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; import { addNodeIds, replaceInvalidCredentials } from '@/workflow-helpers'; -import type { WorkflowRequest } from '../../../types'; -import { projectScope, validCursor } from '../../shared/middlewares/global.middleware'; -import { encodeNextCursor } from '../../shared/services/pagination.service'; +import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; +import { WorkflowService } from '@/workflows/workflow.service'; +import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; + import { getWorkflowById, setWorkflowAsActive, @@ -25,15 +31,9 @@ import { getWorkflowTags, updateTags, } from './workflows.service'; -import { WorkflowService } from '@/workflows/workflow.service'; -import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { TagRepository } from '@/databases/repositories/tag.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { EventService } from '@/events/event.service'; -import { z } from 'zod'; -import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; +import type { WorkflowRequest } from '../../../types'; +import { projectScope, validCursor } from '../../shared/middlewares/global.middleware'; +import { encodeNextCursor } from '../../shared/services/pagination.service'; export = { createWorkflow: [ diff --git a/packages/cli/src/public-api/v1/handlers/workflows/workflows.service.ts b/packages/cli/src/public-api/v1/handlers/workflows/workflows.service.ts index c16c362d0ff17..f4a2d38156dab 100644 --- a/packages/cli/src/public-api/v1/handlers/workflows/workflows.service.ts +++ b/packages/cli/src/public-api/v1/handlers/workflows/workflows.service.ts @@ -1,17 +1,18 @@ +import type { Scope } from '@n8n/permissions'; import { Container } from 'typedi'; -import * as Db from '@/db'; + +import config from '@/config'; +import type { Project } from '@/databases/entities/project'; +import { SharedWorkflow, type WorkflowSharingRole } from '@/databases/entities/shared-workflow'; import type { User } from '@/databases/entities/user'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { WorkflowTagMapping } from '@/databases/entities/workflow-tag-mapping'; -import { SharedWorkflow, type WorkflowSharingRole } from '@/databases/entities/shared-workflow'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import type { Project } from '@/databases/entities/project'; import { TagRepository } from '@/databases/repositories/tag.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import * as Db from '@/db'; import { License } from '@/license'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; -import type { Scope } from '@n8n/permissions'; -import config from '@/config'; function insertIf(condition: boolean, elements: string[]): string[] { return condition ? elements : []; diff --git a/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts b/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts index dcba76ec55754..8a49a48093c2d 100644 --- a/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts +++ b/packages/cli/src/public-api/v1/shared/middlewares/global.middleware.ts @@ -1,16 +1,16 @@ /* eslint-disable @typescript-eslint/no-invalid-void-type */ +import type { Scope } from '@n8n/permissions'; import type express from 'express'; import { Container } from 'typedi'; +import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; +import type { BooleanLicenseFeature } from '@/interfaces'; import { License } from '@/license'; +import { userHasScope } from '@/permissions/check-access'; import type { AuthenticatedRequest } from '@/requests'; import type { PaginatedRequest } from '../../../types'; import { decodeCursor } from '../services/pagination.service'; -import type { Scope } from '@n8n/permissions'; -import { userHasScope } from '@/permissions/check-access'; -import type { BooleanLicenseFeature } from '@/interfaces'; -import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; const UNLIMITED_USERS_QUOTA = -1; diff --git a/packages/cli/src/public-api/v1/shared/services/pagination.service.ts b/packages/cli/src/public-api/v1/shared/services/pagination.service.ts index 086a8676b9a7e..96aa77b0883ef 100644 --- a/packages/cli/src/public-api/v1/shared/services/pagination.service.ts +++ b/packages/cli/src/public-api/v1/shared/services/pagination.service.ts @@ -1,4 +1,5 @@ import { jsonParse } from 'n8n-workflow'; + import type { CursorPagination, OffsetPagination, diff --git a/packages/cli/src/push/__tests__/index.test.ts b/packages/cli/src/push/__tests__/index.test.ts index 02bc428fdb2be..6230c63397243 100644 --- a/packages/cli/src/push/__tests__/index.test.ts +++ b/packages/cli/src/push/__tests__/index.test.ts @@ -1,14 +1,13 @@ -import type { WebSocket } from 'ws'; import { mock } from 'jest-mock-extended'; +import type { WebSocket } from 'ws'; import config from '@/config'; import type { User } from '@/databases/entities/user'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { Push } from '@/push'; import { SSEPush } from '@/push/sse.push'; -import { WebSocketPush } from '@/push/websocket.push'; import type { WebSocketPushRequest, SSEPushRequest } from '@/push/types'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; - +import { WebSocketPush } from '@/push/websocket.push'; import { mockInstance } from '@test/mocking'; jest.unmock('@/push'); diff --git a/packages/cli/src/push/__tests__/websocket.push.test.ts b/packages/cli/src/push/__tests__/websocket.push.test.ts index 158264827c114..b7f3fa38a0f56 100644 --- a/packages/cli/src/push/__tests__/websocket.push.test.ts +++ b/packages/cli/src/push/__tests__/websocket.push.test.ts @@ -1,13 +1,12 @@ -import { Container } from 'typedi'; import { EventEmitter } from 'events'; +import { Container } from 'typedi'; import type WebSocket from 'ws'; -import { WebSocketPush } from '@/push/websocket.push'; -import { Logger } from '@/logger'; +import type { User } from '@/databases/entities/user'; import type { PushDataExecutionRecovered } from '@/interfaces'; - +import { Logger } from '@/logger'; +import { WebSocketPush } from '@/push/websocket.push'; import { mockInstance } from '@test/mocking'; -import type { User } from '@/databases/entities/user'; jest.useFakeTimers(); diff --git a/packages/cli/src/push/abstract.push.ts b/packages/cli/src/push/abstract.push.ts index 20b43283de477..43febacb5ede1 100644 --- a/packages/cli/src/push/abstract.push.ts +++ b/packages/cli/src/push/abstract.push.ts @@ -1,9 +1,10 @@ import { assert, jsonStringify } from 'n8n-workflow'; + +import type { User } from '@/databases/entities/user'; import type { IPushDataType } from '@/interfaces'; import type { Logger } from '@/logger'; -import type { User } from '@/databases/entities/user'; -import { TypedEmitter } from '@/typed-emitter'; import type { OnPushMessage } from '@/push/types'; +import { TypedEmitter } from '@/typed-emitter'; export interface AbstractPushEvents { message: OnPushMessage; diff --git a/packages/cli/src/push/index.ts b/packages/cli/src/push/index.ts index b01e085cec289..840462d9a6e54 100644 --- a/packages/cli/src/push/index.ts +++ b/packages/cli/src/push/index.ts @@ -1,23 +1,23 @@ +import type { Application } from 'express'; import { ServerResponse } from 'http'; import type { Server } from 'http'; import type { Socket } from 'net'; -import type { Application } from 'express'; -import { Server as WSServer } from 'ws'; -import { parse as parseUrl } from 'url'; import { Container, Service } from 'typedi'; +import { parse as parseUrl } from 'url'; +import { Server as WSServer } from 'ws'; +import { AuthService } from '@/auth/auth.service'; import config from '@/config'; +import type { User } from '@/databases/entities/user'; import { OnShutdown } from '@/decorators/on-shutdown'; -import { AuthService } from '@/auth/auth.service'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import type { IPushDataType } from '@/interfaces'; import { OrchestrationService } from '@/services/orchestration.service'; +import { TypedEmitter } from '@/typed-emitter'; import { SSEPush } from './sse.push'; -import { WebSocketPush } from './websocket.push'; import type { OnPushMessage, PushResponse, SSEPushRequest, WebSocketPushRequest } from './types'; -import { TypedEmitter } from '@/typed-emitter'; -import type { User } from '@/databases/entities/user'; +import { WebSocketPush } from './websocket.push'; type PushEvents = { editorUiConnected: string; diff --git a/packages/cli/src/push/sse.push.ts b/packages/cli/src/push/sse.push.ts index e78134eac367b..96af003b4bbb2 100644 --- a/packages/cli/src/push/sse.push.ts +++ b/packages/cli/src/push/sse.push.ts @@ -1,11 +1,11 @@ -import SSEChannel from 'sse-channel'; import { Service } from 'typedi'; +import type { User } from '@/databases/entities/user'; import { Logger } from '@/logger'; +import SSEChannel from 'sse-channel'; import { AbstractPush } from './abstract.push'; import type { PushRequest, PushResponse } from './types'; -import type { User } from '@/databases/entities/user'; type Connection = { req: PushRequest; res: PushResponse }; diff --git a/packages/cli/src/push/types.ts b/packages/cli/src/push/types.ts index 0a9d6f5b6cad9..db9121eecc88f 100644 --- a/packages/cli/src/push/types.ts +++ b/packages/cli/src/push/types.ts @@ -1,8 +1,8 @@ import type { Response } from 'express'; import type { WebSocket } from 'ws'; -import type { AuthenticatedRequest } from '@/requests'; import type { User } from '@/databases/entities/user'; +import type { AuthenticatedRequest } from '@/requests'; // TODO: move all push related types here diff --git a/packages/cli/src/push/websocket.push.ts b/packages/cli/src/push/websocket.push.ts index 79ef00fffb1b1..013663cab6d1e 100644 --- a/packages/cli/src/push/websocket.push.ts +++ b/packages/cli/src/push/websocket.push.ts @@ -1,9 +1,11 @@ -import type WebSocket from 'ws'; +import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; import { Service } from 'typedi'; +import type WebSocket from 'ws'; + +import type { User } from '@/databases/entities/user'; import { Logger } from '@/logger'; + import { AbstractPush } from './abstract.push'; -import type { User } from '@/databases/entities/user'; -import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; function heartbeat(this: WebSocket) { this.isAlive = true; diff --git a/packages/cli/src/requests.ts b/packages/cli/src/requests.ts index a6afe6afaf6c5..11990f63ba924 100644 --- a/packages/cli/src/requests.ts +++ b/packages/cli/src/requests.ts @@ -1,3 +1,7 @@ +import type { Scope } from '@n8n/permissions'; +import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; +import { Expose } from 'class-transformer'; +import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, Length } from 'class-validator'; import type express from 'express'; import type { BannerName, @@ -12,22 +16,19 @@ import type { IUser, } from 'n8n-workflow'; -import { Expose } from 'class-transformer'; -import { IsBoolean, IsEmail, IsIn, IsOptional, IsString, Length } from 'class-validator'; -import { NoXss } from '@/validators/no-xss.validator'; -import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/interfaces'; +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { Project, ProjectType } from '@/databases/entities/project'; import { AssignableRole } from '@/databases/entities/user'; import type { GlobalRole, User } from '@/databases/entities/user'; import type { Variables } from '@/databases/entities/variables'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { WorkflowHistory } from '@/databases/entities/workflow-history'; -import type { Project, ProjectType } from '@/databases/entities/project'; +import type { PublicUser, SecretsProvider, SecretsProviderState } from '@/interfaces'; +import { NoUrl } from '@/validators/no-url.validator'; +import { NoXss } from '@/validators/no-xss.validator'; + import type { ProjectRole } from './databases/entities/project-relation'; -import type { Scope } from '@n8n/permissions'; import type { ScopesField } from './services/role.service'; -import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; -import { NoUrl } from '@/validators/no-url.validator'; export class UserUpdatePayload implements Pick { @Expose() diff --git a/packages/cli/src/response-helper.ts b/packages/cli/src/response-helper.ts index aebef56f0c8be..c9f7270d5f37f 100644 --- a/packages/cli/src/response-helper.ts +++ b/packages/cli/src/response-helper.ts @@ -1,16 +1,17 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import type { Request, Response } from 'express'; -import picocolors from 'picocolors'; import { ErrorReporterProxy as ErrorReporter, FORM_TRIGGER_PATH_IDENTIFIER, NodeApiError, } from 'n8n-workflow'; import { Readable } from 'node:stream'; +import picocolors from 'picocolors'; +import Container from 'typedi'; import { inDevelopment } from '@/constants'; + import { ResponseError } from './errors/response-errors/abstract/response.error'; -import Container from 'typedi'; import { Logger } from './logger'; export function sendSuccessResponse( diff --git a/packages/cli/src/scaling/__tests__/scaling.service.test.ts b/packages/cli/src/scaling/__tests__/scaling.service.test.ts index 9fe36a36370c8..8a95042697cb0 100644 --- a/packages/cli/src/scaling/__tests__/scaling.service.test.ts +++ b/packages/cli/src/scaling/__tests__/scaling.service.test.ts @@ -1,16 +1,18 @@ -import { mock } from 'jest-mock-extended'; -import { ScalingService } from '../scaling.service'; -import { JOB_TYPE_NAME, QUEUE_NAME } from '../constants'; -import config from '@/config'; -import * as BullModule from 'bull'; -import type { Job, JobData, JobOptions, JobQueue } from '../scaling.types'; -import { ApplicationError } from 'n8n-workflow'; -import { mockInstance } from '@test/mocking'; import { GlobalConfig } from '@n8n/config'; +import * as BullModule from 'bull'; +import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; -import type { OrchestrationService } from '@/services/orchestration.service'; +import { ApplicationError } from 'n8n-workflow'; import Container from 'typedi'; + +import config from '@/config'; +import type { OrchestrationService } from '@/services/orchestration.service'; +import { mockInstance } from '@test/mocking'; + +import { JOB_TYPE_NAME, QUEUE_NAME } from '../constants'; import type { JobProcessor } from '../job-processor'; +import { ScalingService } from '../scaling.service'; +import type { Job, JobData, JobOptions, JobQueue } from '../scaling.types'; const queue = mock({ client: { ping: jest.fn() }, diff --git a/packages/cli/src/scaling/job-processor.ts b/packages/cli/src/scaling/job-processor.ts index 7804a6d6c85fe..317c849e287ea 100644 --- a/packages/cli/src/scaling/job-processor.ts +++ b/packages/cli/src/scaling/job-processor.ts @@ -1,15 +1,17 @@ -import { Service } from 'typedi'; -import { BINARY_ENCODING, ApplicationError, Workflow } from 'n8n-workflow'; import { WorkflowExecute } from 'n8n-core'; -import { Logger } from '@/logger'; +import { BINARY_ENCODING, ApplicationError, Workflow } from 'n8n-workflow'; +import type { ExecutionStatus, IExecuteResponsePromiseData, IRun } from 'n8n-workflow'; +import type PCancelable from 'p-cancelable'; +import { Service } from 'typedi'; + import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import { Logger } from '@/logger'; import { NodeTypes } from '@/node-types'; -import type { ExecutionStatus, IExecuteResponsePromiseData, IRun } from 'n8n-workflow'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; + import type { Job, JobId, JobResult, RunningJob, RunningJobSummary } from './scaling.types'; -import type PCancelable from 'p-cancelable'; /** * Responsible for processing jobs from the queue, i.e. running enqueued executions. diff --git a/packages/cli/src/scaling/scaling.service.ts b/packages/cli/src/scaling/scaling.service.ts index 77d5323b0f89b..2aa06a691ba43 100644 --- a/packages/cli/src/scaling/scaling.service.ts +++ b/packages/cli/src/scaling/scaling.service.ts @@ -1,11 +1,19 @@ -import Container, { Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; +import { InstanceSettings } from 'n8n-core'; import { ApplicationError, BINARY_ENCODING, sleep, jsonStringify } from 'n8n-workflow'; +import type { IExecuteResponsePromiseData } from 'n8n-workflow'; +import Container, { Service } from 'typedi'; + import { ActiveExecutions } from '@/active-executions'; import config from '@/config'; -import { Logger } from '@/logger'; -import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; import { HIGHEST_SHUTDOWN_PRIORITY, Time } from '@/constants'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; +import { MaxStalledCountError } from '@/errors/max-stalled-count.error'; +import { EventService } from '@/events/event.service'; +import { Logger } from '@/logger'; +import { OrchestrationService } from '@/services/orchestration.service'; + import { JOB_TYPE_NAME, QUEUE_NAME } from './constants'; import { JobProcessor } from './job-processor'; import type { @@ -18,12 +26,6 @@ import type { QueueRecoveryContext, PubSubMessage, } from './scaling.types'; -import type { IExecuteResponsePromiseData } from 'n8n-workflow'; -import { GlobalConfig } from '@n8n/config'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { InstanceSettings } from 'n8n-core'; -import { OrchestrationService } from '@/services/orchestration.service'; -import { EventService } from '@/events/event.service'; @Service() export class ScalingService { diff --git a/packages/cli/src/scaling/scaling.types.ts b/packages/cli/src/scaling/scaling.types.ts index 2599cf594bd1e..9bd6c5d2aefb2 100644 --- a/packages/cli/src/scaling/scaling.types.ts +++ b/packages/cli/src/scaling/scaling.types.ts @@ -1,3 +1,4 @@ +import type Bull from 'bull'; import type { ExecutionError, ExecutionStatus, @@ -5,7 +6,6 @@ import type { IRun, WorkflowExecuteMode as WorkflowExecutionMode, } from 'n8n-workflow'; -import type Bull from 'bull'; import type PCancelable from 'p-cancelable'; export type JobQueue = Bull.Queue; diff --git a/packages/cli/src/secrets-helpers.ts b/packages/cli/src/secrets-helpers.ts index 082c3ea97d1a6..88a75ae3daa07 100644 --- a/packages/cli/src/secrets-helpers.ts +++ b/packages/cli/src/secrets-helpers.ts @@ -1,5 +1,6 @@ import type { SecretsHelpersBase } from 'n8n-workflow'; import { Service } from 'typedi'; + import { ExternalSecretsManager } from './external-secrets/external-secrets-manager.ee'; @Service() diff --git a/packages/cli/src/security-audit/risk-reporters/credentials-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/credentials-risk-reporter.ts index f5ae3860f6c01..ab7873e80813f 100644 --- a/packages/cli/src/security-audit/risk-reporters/credentials-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/credentials-risk-reporter.ts @@ -1,12 +1,13 @@ -import { Service } from 'typedi'; import type { IWorkflowBase } from 'n8n-workflow'; +import { Service } from 'typedi'; + import config from '@/config'; -import { CREDENTIALS_REPORT } from '@/security-audit/constants'; -import type { RiskReporter, Risk } from '@/security-audit/types'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { CREDENTIALS_REPORT } from '@/security-audit/constants'; +import type { RiskReporter, Risk } from '@/security-audit/types'; @Service() export class CredentialsRiskReporter implements RiskReporter { diff --git a/packages/cli/src/security-audit/risk-reporters/database-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/database-risk-reporter.ts index dd537f71823a0..9dad0829aec94 100644 --- a/packages/cli/src/security-audit/risk-reporters/database-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/database-risk-reporter.ts @@ -1,13 +1,14 @@ -import { toFlaggedNode } from '@/security-audit/utils'; +import { Service } from 'typedi'; + +import type { WorkflowEntity as Workflow } from '@/databases/entities/workflow-entity'; import { SQL_NODE_TYPES, DATABASE_REPORT, DB_QUERY_PARAMS_DOCS_URL, SQL_NODE_TYPES_WITH_QUERY_PARAMS, } from '@/security-audit/constants'; -import type { WorkflowEntity as Workflow } from '@/databases/entities/workflow-entity'; import type { RiskReporter, Risk } from '@/security-audit/types'; -import { Service } from 'typedi'; +import { toFlaggedNode } from '@/security-audit/utils'; @Service() export class DatabaseRiskReporter implements RiskReporter { diff --git a/packages/cli/src/security-audit/risk-reporters/filesystem-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/filesystem-risk-reporter.ts index 621611e052db2..645e6f8684aed 100644 --- a/packages/cli/src/security-audit/risk-reporters/filesystem-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/filesystem-risk-reporter.ts @@ -1,8 +1,9 @@ -import { getNodeTypes } from '@/security-audit/utils'; -import { FILESYSTEM_INTERACTION_NODE_TYPES, FILESYSTEM_REPORT } from '@/security-audit/constants'; +import { Service } from 'typedi'; + import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { FILESYSTEM_INTERACTION_NODE_TYPES, FILESYSTEM_REPORT } from '@/security-audit/constants'; import type { RiskReporter, Risk } from '@/security-audit/types'; -import { Service } from 'typedi'; +import { getNodeTypes } from '@/security-audit/utils'; @Service() export class FilesystemRiskReporter implements RiskReporter { diff --git a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts index 9d96f18331a66..4792bf8b6a940 100644 --- a/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/instance-risk-reporter.ts @@ -1,21 +1,22 @@ +import { GlobalConfig } from '@n8n/config'; import axios from 'axios'; -import { Service } from 'typedi'; import { InstanceSettings } from 'n8n-core'; +import { Service } from 'typedi'; + import config from '@/config'; -import { toFlaggedNode } from '@/security-audit/utils'; -import { separate } from '@/utils'; +import { getN8nPackageJson, inDevelopment } from '@/constants'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { Logger } from '@/logger'; +import { isApiEnabled } from '@/public-api'; import { ENV_VARS_DOCS_URL, INSTANCE_REPORT, WEBHOOK_NODE_TYPE, WEBHOOK_VALIDATOR_NODE_TYPES, } from '@/security-audit/constants'; -import { getN8nPackageJson, inDevelopment } from '@/constants'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { RiskReporter, Risk, n8n } from '@/security-audit/types'; -import { isApiEnabled } from '@/public-api'; -import { Logger } from '@/logger'; -import { GlobalConfig } from '@n8n/config'; +import { toFlaggedNode } from '@/security-audit/utils'; +import { separate } from '@/utils'; @Service() export class InstanceRiskReporter implements RiskReporter { diff --git a/packages/cli/src/security-audit/risk-reporters/nodes-risk-reporter.ts b/packages/cli/src/security-audit/risk-reporters/nodes-risk-reporter.ts index 109879c12ab60..4908ff9329543 100644 --- a/packages/cli/src/security-audit/risk-reporters/nodes-risk-reporter.ts +++ b/packages/cli/src/security-audit/risk-reporters/nodes-risk-reporter.ts @@ -1,8 +1,10 @@ -import * as path from 'path'; +import { GlobalConfig } from '@n8n/config'; import glob from 'fast-glob'; +import * as path from 'path'; import { Service } from 'typedi'; + +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { getNodeTypes } from '@/security-audit/utils'; import { OFFICIAL_RISKY_NODE_TYPES, ENV_VARS_DOCS_URL, @@ -10,10 +12,9 @@ import { COMMUNITY_NODES_RISKS_URL, NPM_PACKAGE_URL, } from '@/security-audit/constants'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { Risk, RiskReporter } from '@/security-audit/types'; +import { getNodeTypes } from '@/security-audit/utils'; import { CommunityPackagesService } from '@/services/community-packages.service'; -import { GlobalConfig } from '@n8n/config'; @Service() export class NodesRiskReporter implements RiskReporter { diff --git a/packages/cli/src/security-audit/security-audit.service.ts b/packages/cli/src/security-audit/security-audit.service.ts index 3c27f647bcc64..19582450c4761 100644 --- a/packages/cli/src/security-audit/security-audit.service.ts +++ b/packages/cli/src/security-audit/security-audit.service.ts @@ -2,10 +2,9 @@ import Container, { Service } from 'typedi'; import config from '@/config'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; - import { RISK_CATEGORIES } from '@/security-audit/constants'; -import { toReportTitle } from '@/security-audit/utils'; import type { Risk, RiskReporter } from '@/security-audit/types'; +import { toReportTitle } from '@/security-audit/utils'; @Service() export class SecurityAuditService { diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.ts index 82e12b0386c4f..e7d1eaabfb47e 100644 --- a/packages/cli/src/server.ts +++ b/packages/cli/src/server.ts @@ -1,16 +1,16 @@ -import { Container, Service } from 'typedi'; import { exec as callbackExec } from 'child_process'; -import { resolve } from 'path'; -import { access as fsAccess } from 'fs/promises'; -import { promisify } from 'util'; import cookieParser from 'cookie-parser'; import express from 'express'; +import { access as fsAccess } from 'fs/promises'; import helmet from 'helmet'; import { InstanceSettings } from 'n8n-core'; import type { IN8nUISettings } from 'n8n-workflow'; +import { resolve } from 'path'; +import { Container, Service } from 'typedi'; +import { promisify } from 'util'; +import { AbstractServer } from '@/abstract-server'; import config from '@/config'; - import { CLI_DIR, EDITOR_UI_DIST_DIR, @@ -20,22 +20,21 @@ import { N8N_VERSION, Time, } from '@/constants'; -import type { APIRequest } from '@/requests'; +import { CredentialsOverwrites } from '@/credentials-overwrites'; import { ControllerRegistry } from '@/decorators'; -import { isApiEnabled, loadPublicApiVersions } from '@/public-api'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; import type { ICredentialsOverwrite } from '@/interfaces'; -import { CredentialsOverwrites } from '@/credentials-overwrites'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import * as ResponseHelper from '@/response-helper'; -import { setupPushServer, setupPushHandler, Push } from '@/push'; import { isLdapEnabled } from '@/ldap/helpers.ee'; -import { AbstractServer } from '@/abstract-server'; -import { PostHogClient } from '@/posthog'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { handleMfaDisable, isMfaFeatureEnabled } from '@/mfa/helpers'; +import { PostHogClient } from '@/posthog'; +import { isApiEnabled, loadPublicApiVersions } from '@/public-api'; +import { setupPushServer, setupPushHandler, Push } from '@/push'; +import type { APIRequest } from '@/requests'; +import * as ResponseHelper from '@/response-helper'; import type { FrontendService } from '@/services/frontend.service'; import { OrchestrationService } from '@/services/orchestration.service'; -import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; import '@/controllers/active-workflows.controller'; import '@/controllers/annotation-tags.controller'; diff --git a/packages/cli/src/services/__tests__/active-workflows.service.test.ts b/packages/cli/src/services/__tests__/active-workflows.service.test.ts index 8fa36b808a39f..788ef3fb6847f 100644 --- a/packages/cli/src/services/__tests__/active-workflows.service.test.ts +++ b/packages/cli/src/services/__tests__/active-workflows.service.test.ts @@ -1,11 +1,12 @@ +import { mock } from 'jest-mock-extended'; + import type { ActivationErrorsService } from '@/activation-errors.service'; import type { User } from '@/databases/entities/user'; +import { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { ActiveWorkflowsService } from '@/services/active-workflows.service'; -import { mock } from 'jest-mock-extended'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ActiveWorkflowsService } from '@/services/active-workflows.service'; describe('ActiveWorkflowsService', () => { const user = mock(); diff --git a/packages/cli/src/services/__tests__/community-packages.service.test.ts b/packages/cli/src/services/__tests__/community-packages.service.test.ts index f30ff372a67fd..df4591cd08afc 100644 --- a/packages/cli/src/services/__tests__/community-packages.service.test.ts +++ b/packages/cli/src/services/__tests__/community-packages.service.test.ts @@ -1,11 +1,11 @@ +import type { GlobalConfig } from '@n8n/config'; +import axios from 'axios'; import { exec } from 'child_process'; import { access as fsAccess, mkdir as fsMkdir } from 'fs/promises'; -import axios from 'axios'; import { mocked } from 'jest-mock'; import { mock } from 'jest-mock-extended'; -import type { GlobalConfig } from '@n8n/config'; -import type { PublicInstalledPackage } from 'n8n-workflow'; import type { PackageDirectoryLoader } from 'n8n-core'; +import type { PublicInstalledPackage } from 'n8n-workflow'; import { NODE_PACKAGE_PREFIX, @@ -13,15 +13,14 @@ import { NPM_PACKAGE_STATUS_GOOD, RESPONSE_ERROR_MESSAGES, } from '@/constants'; +import { InstalledNodes } from '@/databases/entities/installed-nodes'; import { InstalledPackages } from '@/databases/entities/installed-packages'; -import type { CommunityPackages } from '@/interfaces'; -import { CommunityPackagesService } from '@/services/community-packages.service'; import { InstalledNodesRepository } from '@/databases/repositories/installed-nodes.repository'; import { InstalledPackagesRepository } from '@/databases/repositories/installed-packages.repository'; -import { InstalledNodes } from '@/databases/entities/installed-nodes'; -import type { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import type { CommunityPackages } from '@/interfaces'; import type { License } from '@/license'; - +import type { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { CommunityPackagesService } from '@/services/community-packages.service'; import { mockInstance } from '@test/mocking'; import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '@test-integration/constants'; import { randomName } from '@test-integration/random'; diff --git a/packages/cli/src/services/__tests__/credentials-tester.service.test.ts b/packages/cli/src/services/__tests__/credentials-tester.service.test.ts index e9f98c7a8b015..4da925c532d2d 100644 --- a/packages/cli/src/services/__tests__/credentials-tester.service.test.ts +++ b/packages/cli/src/services/__tests__/credentials-tester.service.test.ts @@ -1,8 +1,9 @@ -import { CredentialsTester } from '@/services/credentials-tester.service'; import mock from 'jest-mock-extended/lib/Mock'; -import type { CredentialTypes } from '@/credential-types'; import type { ICredentialType, INodeType } from 'n8n-workflow'; + +import type { CredentialTypes } from '@/credential-types'; import type { NodeTypes } from '@/node-types'; +import { CredentialsTester } from '@/services/credentials-tester.service'; describe('CredentialsTester', () => { const credentialTypes = mock(); diff --git a/packages/cli/src/services/__tests__/execution-metadata.service.test.ts b/packages/cli/src/services/__tests__/execution-metadata.service.test.ts index 16919b681a7cf..4b713d6872cf4 100644 --- a/packages/cli/src/services/__tests__/execution-metadata.service.test.ts +++ b/packages/cli/src/services/__tests__/execution-metadata.service.test.ts @@ -1,4 +1,5 @@ import { Container } from 'typedi'; + import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; import { ExecutionMetadataService } from '@/services/execution-metadata.service'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/services/__tests__/hooks.service.test.ts b/packages/cli/src/services/__tests__/hooks.service.test.ts index 76bade847415c..f195981cf0d85 100644 --- a/packages/cli/src/services/__tests__/hooks.service.test.ts +++ b/packages/cli/src/services/__tests__/hooks.service.test.ts @@ -1,18 +1,18 @@ +import RudderStack from '@rudderstack/rudder-sdk-node'; import type { Response } from 'express'; import { mock } from 'jest-mock-extended'; +import type { AuthService } from '@/auth/auth.service'; import type { AuthUser } from '@/databases/entities/auth-user'; +import type { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; import type { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import type { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { UserRepository } from '@/databases/repositories/user.repository'; import type { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { AuthService } from '@/auth/auth.service'; -import type { UserService } from '@/services/user.service'; -import { HooksService } from '@/services/hooks.service'; import type { Invitation } from '@/interfaces'; import type { AuthenticatedRequest } from '@/requests'; -import type { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; -import RudderStack from '@rudderstack/rudder-sdk-node'; +import { HooksService } from '@/services/hooks.service'; +import type { UserService } from '@/services/user.service'; jest.mock('@rudderstack/rudder-sdk-node'); diff --git a/packages/cli/src/services/__tests__/jwt.service.test.ts b/packages/cli/src/services/__tests__/jwt.service.test.ts index 74dd5cd51b45b..6e6e744fb9b69 100644 --- a/packages/cli/src/services/__tests__/jwt.service.test.ts +++ b/packages/cli/src/services/__tests__/jwt.service.test.ts @@ -1,6 +1,7 @@ +import { mock } from 'jest-mock-extended'; import jwt from 'jsonwebtoken'; import type { InstanceSettings } from 'n8n-core'; -import { mock } from 'jest-mock-extended'; + import config from '@/config'; import { JwtService } from '@/services/jwt.service'; diff --git a/packages/cli/src/services/__tests__/naming.service.test.ts b/packages/cli/src/services/__tests__/naming.service.test.ts index 6b8702c05a2b3..8027b04709612 100644 --- a/packages/cli/src/services/__tests__/naming.service.test.ts +++ b/packages/cli/src/services/__tests__/naming.service.test.ts @@ -1,9 +1,9 @@ -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { mockInstance } from '@test/mocking'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { NamingService } from '@/services/naming.service'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import { mockInstance } from '@test/mocking'; describe('NamingService', () => { const workflowRepository = mockInstance(WorkflowRepository); diff --git a/packages/cli/src/services/__tests__/orchestration.service.test.ts b/packages/cli/src/services/__tests__/orchestration.service.test.ts index 5cb10c6598890..3ec7e4cf78116 100644 --- a/packages/cli/src/services/__tests__/orchestration.service.test.ts +++ b/packages/cli/src/services/__tests__/orchestration.service.test.ts @@ -1,23 +1,24 @@ -import Container from 'typedi'; import type Redis from 'ioredis'; import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; import type { WorkflowActivateMode } from 'n8n-workflow'; +import Container from 'typedi'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; -import { OrchestrationService } from '@/services/orchestration.service'; -import type { RedisServiceWorkerResponseObject } from '@/services/redis/redis-service-commands'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import { RedisService } from '@/services/redis.service'; -import { handleWorkerResponseMessageMain } from '@/services/orchestration/main/handle-worker-response-message-main'; -import { handleCommandMessageMain } from '@/services/orchestration/main/handle-command-message-main'; -import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service'; -import * as helpers from '@/services/orchestration/helpers'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { Push } from '@/push'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { mockInstance } from '@test/mocking'; +import * as helpers from '@/services/orchestration/helpers'; +import { handleCommandMessageMain } from '@/services/orchestration/main/handle-command-message-main'; +import { handleWorkerResponseMessageMain } from '@/services/orchestration/main/handle-worker-response-message-main'; +import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service'; +import { OrchestrationService } from '@/services/orchestration.service'; import { RedisClientService } from '@/services/redis/redis-client.service'; +import type { RedisServiceWorkerResponseObject } from '@/services/redis/redis-service-commands'; +import { RedisService } from '@/services/redis.service'; +import { mockInstance } from '@test/mocking'; + import type { MainResponseReceivedHandlerOptions } from '../orchestration/main/types'; const instanceSettings = Container.get(InstanceSettings); diff --git a/packages/cli/src/services/__tests__/ownership.service.test.ts b/packages/cli/src/services/__tests__/ownership.service.test.ts index 03b5c2fb146ce..ee6922dd76d01 100644 --- a/packages/cli/src/services/__tests__/ownership.service.test.ts +++ b/packages/cli/src/services/__tests__/ownership.service.test.ts @@ -1,16 +1,17 @@ -import { OwnershipService } from '@/services/ownership.service'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { mock } from 'jest-mock-extended'; + +import { Project } from '@/databases/entities/project'; +import { ProjectRelation } from '@/databases/entities/project-relation'; +import type { SharedCredentials } from '@/databases/entities/shared-credentials'; import { SharedWorkflow } from '@/databases/entities/shared-workflow'; import { User } from '@/databases/entities/user'; -import type { SharedCredentials } from '@/databases/entities/shared-credentials'; -import { mockInstance } from '@test/mocking'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { mock } from 'jest-mock-extended'; -import { Project } from '@/databases/entities/project'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import { ProjectRelation } from '@/databases/entities/project-relation'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { OwnershipService } from '@/services/ownership.service'; import { mockCredential, mockProject } from '@test/mock-objects'; +import { mockInstance } from '@test/mocking'; describe('OwnershipService', () => { const userRepository = mockInstance(UserRepository); diff --git a/packages/cli/src/services/__tests__/password.utility.test.ts b/packages/cli/src/services/__tests__/password.utility.test.ts index 3cab55ae48f57..48be7588c2b7b 100644 --- a/packages/cli/src/services/__tests__/password.utility.test.ts +++ b/packages/cli/src/services/__tests__/password.utility.test.ts @@ -1,6 +1,7 @@ -import { PasswordUtility } from '@/services/password.utility'; import Container from 'typedi'; +import { PasswordUtility } from '@/services/password.utility'; + function toComponents(hash: string) { const BCRYPT_HASH_REGEX = /^\$(?.{2})\$(?\d{2})\$(?.{22})(?.{31})$/; diff --git a/packages/cli/src/services/__tests__/redis.service.test.ts b/packages/cli/src/services/__tests__/redis.service.test.ts index 1e282e6df1990..9990b58d6a247 100644 --- a/packages/cli/src/services/__tests__/redis.service.test.ts +++ b/packages/cli/src/services/__tests__/redis.service.test.ts @@ -1,6 +1,7 @@ import Container from 'typedi'; -import { Logger } from '@/logger'; + import config from '@/config'; +import { Logger } from '@/logger'; import { RedisService } from '@/services/redis.service'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/services/__tests__/user.service.test.ts b/packages/cli/src/services/__tests__/user.service.test.ts index d2da4aac45889..084ea3b4ba0f0 100644 --- a/packages/cli/src/services/__tests__/user.service.test.ts +++ b/packages/cli/src/services/__tests__/user.service.test.ts @@ -1,12 +1,12 @@ +import { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; import { v4 as uuid } from 'uuid'; import { User } from '@/databases/entities/user'; -import { UserService } from '@/services/user.service'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { UrlService } from '@/services/url.service'; +import { UserService } from '@/services/user.service'; import { mockInstance } from '@test/mocking'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { GlobalConfig } from '@n8n/config'; describe('UserService', () => { const globalConfig = mockInstance(GlobalConfig, { diff --git a/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts b/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts index 0afb5de438e64..a8d73cbffff7c 100644 --- a/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts +++ b/packages/cli/src/services/__tests__/workflow-statistics.service.test.ts @@ -1,6 +1,4 @@ -import { Container } from 'typedi'; import { GlobalConfig } from '@n8n/config'; -import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; import { QueryFailedError, type DataSource, @@ -9,17 +7,19 @@ import { } from '@n8n/typeorm'; import { mocked } from 'jest-mock'; import { mock } from 'jest-mock-extended'; +import type { IRun, WorkflowExecuteMode } from 'n8n-workflow'; +import { Container } from 'typedi'; import config from '@/config'; +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; import type { WorkflowStatistics } from '@/databases/entities/workflow-statistics'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; -import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; -import { UserService } from '@/services/user.service'; +import type { EventService } from '@/events/event.service'; import { OwnershipService } from '@/services/ownership.service'; +import { UserService } from '@/services/user.service'; +import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; import { mockInstance } from '@test/mocking'; -import type { Project } from '@/databases/entities/project'; -import type { EventService } from '@/events/event.service'; describe('WorkflowStatisticsService', () => { const fakeUser = mock({ id: 'abcde-fghij' }); diff --git a/packages/cli/src/services/access.service.ts b/packages/cli/src/services/access.service.ts index cc3580768f6e8..49ac7bfe23589 100644 --- a/packages/cli/src/services/access.service.ts +++ b/packages/cli/src/services/access.service.ts @@ -1,8 +1,9 @@ +import type { Workflow } from 'n8n-workflow'; import { Service } from 'typedi'; + +import type { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import type { User } from '@/databases/entities/user'; -import type { Workflow } from 'n8n-workflow'; /** * Responsible for checking whether a user has access to a resource. diff --git a/packages/cli/src/services/active-workflows.service.ts b/packages/cli/src/services/active-workflows.service.ts index 6c6671faadb93..f2aaf9293dbe3 100644 --- a/packages/cli/src/services/active-workflows.service.ts +++ b/packages/cli/src/services/active-workflows.service.ts @@ -1,9 +1,9 @@ import { Service } from 'typedi'; +import { ActivationErrorsService } from '@/activation-errors.service'; import type { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { ActivationErrorsService } from '@/activation-errors.service'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { Logger } from '@/logger'; diff --git a/packages/cli/src/services/ai-assistant.service.ts b/packages/cli/src/services/ai-assistant.service.ts index 62c4778cfb590..77234165c1c09 100644 --- a/packages/cli/src/services/ai-assistant.service.ts +++ b/packages/cli/src/services/ai-assistant.service.ts @@ -1,12 +1,14 @@ -import { Service } from 'typedi'; import type { AiAssistantSDK } from '@n8n_io/ai-assistant-sdk'; import { AiAssistantClient } from '@n8n_io/ai-assistant-sdk'; import { assert, type IUser } from 'n8n-workflow'; -import { License } from '../license'; -import { N8N_VERSION } from '../constants'; +import { Service } from 'typedi'; +import type { Response } from 'undici'; + import config from '@/config'; import type { AiAssistantRequest } from '@/requests'; -import type { Response } from 'undici'; + +import { N8N_VERSION } from '../constants'; +import { License } from '../license'; @Service() export class AiAssistantService { diff --git a/packages/cli/src/services/annotation-tag.service.ts b/packages/cli/src/services/annotation-tag.service.ts index 7b28b399822af..27c93041b569c 100644 --- a/packages/cli/src/services/annotation-tag.service.ts +++ b/packages/cli/src/services/annotation-tag.service.ts @@ -1,8 +1,9 @@ import { Service } from 'typedi'; -import { validateEntity } from '@/generic-helpers'; -import type { IAnnotationTagDb, IAnnotationTagWithCountDb } from '@/interfaces'; + import type { AnnotationTagEntity } from '@/databases/entities/annotation-tag-entity'; import { AnnotationTagRepository } from '@/databases/repositories/annotation-tag.repository'; +import { validateEntity } from '@/generic-helpers'; +import type { IAnnotationTagDb, IAnnotationTagWithCountDb } from '@/interfaces'; type GetAllResult = T extends { withUsageCount: true } ? IAnnotationTagWithCountDb[] diff --git a/packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts b/packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts index b094f3e0d0f08..d515aae5bec71 100644 --- a/packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts +++ b/packages/cli/src/services/cache/__tests__/cache-mock.service.test.ts @@ -1,5 +1,6 @@ -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; +import Container from 'typedi'; + import { CacheService } from '@/services/cache/cache.service'; const cacheService = Container.get(CacheService); diff --git a/packages/cli/src/services/cache/__tests__/cache.service.test.ts b/packages/cli/src/services/cache/__tests__/cache.service.test.ts index 5c024b2903cc7..e87e46984be15 100644 --- a/packages/cli/src/services/cache/__tests__/cache.service.test.ts +++ b/packages/cli/src/services/cache/__tests__/cache.service.test.ts @@ -1,9 +1,10 @@ -import { CacheService } from '@/services/cache/cache.service'; -import config from '@/config'; -import { sleep } from 'n8n-workflow'; import { GlobalConfig } from '@n8n/config'; +import { sleep } from 'n8n-workflow'; import Container from 'typedi'; +import config from '@/config'; +import { CacheService } from '@/services/cache/cache.service'; + jest.mock('ioredis', () => { const Redis = require('ioredis-mock'); diff --git a/packages/cli/src/services/cache/cache.service.ts b/packages/cli/src/services/cache/cache.service.ts index 04d019530e400..3fe674b4b3709 100644 --- a/packages/cli/src/services/cache/cache.service.ts +++ b/packages/cli/src/services/cache/cache.service.ts @@ -1,19 +1,19 @@ -import Container, { Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { caching } from 'cache-manager'; import { ApplicationError, jsonStringify } from 'n8n-workflow'; +import Container, { Service } from 'typedi'; import config from '@/config'; -import { UncacheableValueError } from '@/errors/cache-errors/uncacheable-value.error'; +import { TIME } from '@/constants'; import { MalformedRefreshValueError } from '@/errors/cache-errors/malformed-refresh-value.error'; +import { UncacheableValueError } from '@/errors/cache-errors/uncacheable-value.error'; import type { TaggedRedisCache, TaggedMemoryCache, MaybeHash, Hash, } from '@/services/cache/cache.types'; -import { TIME } from '@/constants'; import { TypedEmitter } from '@/typed-emitter'; -import { GlobalConfig } from '@n8n/config'; type CacheEvents = { 'metrics.cache.hit': never; diff --git a/packages/cli/src/services/cache/cache.types.ts b/packages/cli/src/services/cache/cache.types.ts index f598e22494446..8a798d355d0c8 100644 --- a/packages/cli/src/services/cache/cache.types.ts +++ b/packages/cli/src/services/cache/cache.types.ts @@ -1,4 +1,5 @@ import type { MemoryCache } from 'cache-manager'; + import type { RedisCache } from '@/services/cache/redis.cache-manager'; export type TaggedRedisCache = RedisCache & { kind: 'redis' }; diff --git a/packages/cli/src/services/cache/redis.cache-manager.ts b/packages/cli/src/services/cache/redis.cache-manager.ts index 429e0d93c0619..4014f051c0342 100644 --- a/packages/cli/src/services/cache/redis.cache-manager.ts +++ b/packages/cli/src/services/cache/redis.cache-manager.ts @@ -2,9 +2,9 @@ * Based on https://github.com/node-cache-manager/node-cache-manager-ioredis-yet */ +import type { Cache, Store, Config } from 'cache-manager'; import Redis from 'ioredis'; import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'; -import type { Cache, Store, Config } from 'cache-manager'; import { ApplicationError, jsonParse } from 'n8n-workflow'; export class NoCacheableError implements Error { diff --git a/packages/cli/src/services/community-packages.service.ts b/packages/cli/src/services/community-packages.service.ts index 828179bb286c9..500518ae02525 100644 --- a/packages/cli/src/services/community-packages.service.ts +++ b/packages/cli/src/services/community-packages.service.ts @@ -1,18 +1,13 @@ +import { GlobalConfig } from '@n8n/config'; +import axios from 'axios'; import { exec } from 'child_process'; import { access as fsAccess, mkdir as fsMkdir } from 'fs/promises'; - -import { Service } from 'typedi'; -import { promisify } from 'util'; -import axios from 'axios'; - -import { GlobalConfig } from '@n8n/config'; -import { ApplicationError, type PublicInstalledPackage } from 'n8n-workflow'; import { InstanceSettings } from 'n8n-core'; import type { PackageDirectoryLoader } from 'n8n-core'; +import { ApplicationError, type PublicInstalledPackage } from 'n8n-workflow'; +import { Service } from 'typedi'; +import { promisify } from 'util'; -import { toError } from '@/utils'; -import { InstalledPackagesRepository } from '@/databases/repositories/installed-packages.repository'; -import type { InstalledPackages } from '@/databases/entities/installed-packages'; import { LICENSE_FEATURES, NODE_PACKAGE_PREFIX, @@ -21,12 +16,16 @@ import { RESPONSE_ERROR_MESSAGES, UNKNOWN_FAILURE_REASON, } from '@/constants'; +import type { InstalledPackages } from '@/databases/entities/installed-packages'; +import { InstalledPackagesRepository } from '@/databases/repositories/installed-packages.repository'; import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import type { CommunityPackages } from '@/interfaces'; +import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { Logger } from '@/logger'; +import { toError } from '@/utils'; + import { OrchestrationService } from './orchestration.service'; -import { License } from '@/license'; const DEFAULT_REGISTRY = 'https://registry.npmjs.org'; diff --git a/packages/cli/src/services/credentials-tester.service.ts b/packages/cli/src/services/credentials-tester.service.ts index 6337066c5f51c..b66d4a474f3b3 100644 --- a/packages/cli/src/services/credentials-tester.service.ts +++ b/packages/cli/src/services/credentials-tester.service.ts @@ -3,10 +3,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-call */ -import { Service } from 'typedi'; -import { NodeExecuteFunctions } from 'n8n-core'; import get from 'lodash/get'; - +import { NodeExecuteFunctions } from 'n8n-core'; import type { ICredentialsDecrypted, ICredentialTestFunction, @@ -33,15 +31,17 @@ import { ErrorReporterProxy as ErrorReporter, ApplicationError, } from 'n8n-workflow'; +import { Service } from 'typedi'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import { CredentialTypes } from '@/credential-types'; import type { User } from '@/databases/entities/user'; +import { Logger } from '@/logger'; import { NodeTypes } from '@/node-types'; -import { CredentialTypes } from '@/credential-types'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; + import { RESPONSE_ERROR_MESSAGES } from '../constants'; -import { isObjectLiteral } from '../utils'; -import { Logger } from '@/logger'; import { CredentialsHelper } from '../credentials-helper'; +import { isObjectLiteral } from '../utils'; const { OAUTH2_CREDENTIAL_TEST_SUCCEEDED, OAUTH2_CREDENTIAL_TEST_FAILED } = RESPONSE_ERROR_MESSAGES; diff --git a/packages/cli/src/services/cta.service.ts b/packages/cli/src/services/cta.service.ts index 6aee3aad57559..221674cfa7a52 100644 --- a/packages/cli/src/services/cta.service.ts +++ b/packages/cli/src/services/cta.service.ts @@ -1,6 +1,7 @@ import { Service } from 'typedi'; -import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; + import type { User } from '@/databases/entities/user'; +import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; @Service() export class CtaService { diff --git a/packages/cli/src/services/curl.service.ts b/packages/cli/src/services/curl.service.ts index 01c32868638a2..8875fd982820d 100644 --- a/packages/cli/src/services/curl.service.ts +++ b/packages/cli/src/services/curl.service.ts @@ -1,8 +1,9 @@ -import { Service } from 'typedi'; -import curlconverter from 'curlconverter'; import get from 'lodash/get'; import type { IDataObject } from 'n8n-workflow'; import { jsonParse } from 'n8n-workflow'; +import { Service } from 'typedi'; + +import curlconverter from 'curlconverter'; interface CurlJson { url: string; diff --git a/packages/cli/src/services/dynamic-node-parameters.service.ts b/packages/cli/src/services/dynamic-node-parameters.service.ts index d69f7893730b1..7a641e84a6a9c 100644 --- a/packages/cli/src/services/dynamic-node-parameters.service.ts +++ b/packages/cli/src/services/dynamic-node-parameters.service.ts @@ -1,4 +1,4 @@ -import { Service } from 'typedi'; +import { NodeExecuteFunctions } from 'n8n-core'; import type { ILoadOptions, ILoadOptionsFunctions, @@ -19,7 +19,8 @@ import type { IDataObject, } from 'n8n-workflow'; import { Workflow, RoutingNode, ApplicationError } from 'n8n-workflow'; -import { NodeExecuteFunctions } from 'n8n-core'; +import { Service } from 'typedi'; + import { NodeTypes } from '@/node-types'; @Service() diff --git a/packages/cli/src/services/execution-metadata.service.ts b/packages/cli/src/services/execution-metadata.service.ts index c5867660622ff..b88b68f12f2c0 100644 --- a/packages/cli/src/services/execution-metadata.service.ts +++ b/packages/cli/src/services/execution-metadata.service.ts @@ -1,6 +1,7 @@ import { Service } from 'typedi'; -import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; + import type { ExecutionMetadata } from '@/databases/entities/execution-metadata'; +import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; @Service() export class ExecutionMetadataService { diff --git a/packages/cli/src/services/frontend.service.ts b/packages/cli/src/services/frontend.service.ts index 97406cca94e6e..8459642a5bb0d 100644 --- a/packages/cli/src/services/frontend.service.ts +++ b/packages/cli/src/services/frontend.service.ts @@ -1,38 +1,39 @@ -import fs from 'node:fs'; -import { Container, Service } from 'typedi'; -import uniq from 'lodash/uniq'; +import { GlobalConfig } from '@n8n/config'; import { createWriteStream } from 'fs'; import { mkdir } from 'fs/promises'; -import path from 'path'; -import { GlobalConfig } from '@n8n/config'; +import uniq from 'lodash/uniq'; +import { InstanceSettings } from 'n8n-core'; import type { ICredentialType, IN8nUISettings, INodeTypeBaseDescription, ITelemetrySettings, } from 'n8n-workflow'; -import { InstanceSettings } from 'n8n-core'; +import fs from 'node:fs'; +import path from 'path'; +import { Container, Service } from 'typedi'; import config from '@/config'; import { LICENSE_FEATURES } from '@/constants'; -import { CredentialsOverwrites } from '@/credentials-overwrites'; import { CredentialTypes } from '@/credential-types'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { License } from '@/license'; -import { getCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { CredentialsOverwrites } from '@/credentials-overwrites'; +import { getVariablesLimit } from '@/environments/variables/environment-helpers'; +import { EventService } from '@/events/event.service'; import { getLdapLoginLabel } from '@/ldap/helpers.ee'; +import { License } from '@/license'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { Logger } from '@/logger'; +import { isApiEnabled } from '@/public-api'; +import type { CommunityPackagesService } from '@/services/community-packages.service'; import { getSamlLoginLabel } from '@/sso/saml/saml-helpers'; -import { getVariablesLimit } from '@/environments/variables/environment-helpers'; +import { getCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { UserManagementMailer } from '@/user-management/email'; import { getWorkflowHistoryLicensePruneTime, getWorkflowHistoryPruneTime, } from '@/workflows/workflow-history/workflow-history-helper.ee'; -import { UserManagementMailer } from '@/user-management/email'; -import type { CommunityPackagesService } from '@/services/community-packages.service'; -import { Logger } from '@/logger'; + import { UrlService } from './url.service'; -import { EventService } from '@/events/event.service'; -import { isApiEnabled } from '@/public-api'; @Service() export class FrontendService { diff --git a/packages/cli/src/services/hooks.service.ts b/packages/cli/src/services/hooks.service.ts index 69493c53c5144..19b2f8deb879c 100644 --- a/packages/cli/src/services/hooks.service.ts +++ b/packages/cli/src/services/hooks.service.ts @@ -1,24 +1,24 @@ -import { Service } from 'typedi'; -import type { NextFunction, Response } from 'express'; -import type { QueryDeepPartialEntity } from '@n8n/typeorm/query-builder/QueryPartialEntity'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import type { FindManyOptions, FindOneOptions, FindOptionsWhere } from '@n8n/typeorm'; +import type { QueryDeepPartialEntity } from '@n8n/typeorm/query-builder/QueryPartialEntity'; +import RudderStack, { type constructorOptions } from '@rudderstack/rudder-sdk-node'; +import type { NextFunction, Response } from 'express'; +import { Service } from 'typedi'; import { AuthService } from '@/auth/auth.service'; import type { AuthUser } from '@/databases/entities/auth-user'; +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { Settings } from '@/databases/entities/settings'; import type { User } from '@/databases/entities/user'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; -import type { Settings } from '@/databases/entities/settings'; -import { UserService } from '@/services/user.service'; -import type { AuthenticatedRequest } from '@/requests'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { Invitation } from '@/interfaces'; -import RudderStack, { type constructorOptions } from '@rudderstack/rudder-sdk-node'; +import type { AuthenticatedRequest } from '@/requests'; +import { UserService } from '@/services/user.service'; /** * Exposes functionality to be used by the cloud BE hooks. diff --git a/packages/cli/src/services/import.service.ts b/packages/cli/src/services/import.service.ts index c295fd45e2402..5691fc941cd54 100644 --- a/packages/cli/src/services/import.service.ts +++ b/packages/cli/src/services/import.service.ts @@ -1,18 +1,18 @@ +import { type INode, type INodeCredentialsDetails } from 'n8n-workflow'; import { Service } from 'typedi'; import { v4 as uuid } from 'uuid'; -import { type INode, type INodeCredentialsDetails } from 'n8n-workflow'; -import { Logger } from '@/logger'; -import * as Db from '@/db'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { TagRepository } from '@/databases/repositories/tag.repository'; -import { SharedWorkflow } from '@/databases/entities/shared-workflow'; -import { replaceInvalidCredentials } from '@/workflow-helpers'; import { Project } from '@/databases/entities/project'; +import { SharedWorkflow } from '@/databases/entities/shared-workflow'; +import type { TagEntity } from '@/databases/entities/tag-entity'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { WorkflowTagMapping } from '@/databases/entities/workflow-tag-mapping'; -import type { TagEntity } from '@/databases/entities/tag-entity'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { TagRepository } from '@/databases/repositories/tag.repository'; +import * as Db from '@/db'; import type { ICredentialsDb } from '@/interfaces'; +import { Logger } from '@/logger'; +import { replaceInvalidCredentials } from '@/workflow-helpers'; @Service() export class ImportService { diff --git a/packages/cli/src/services/jwt.service.ts b/packages/cli/src/services/jwt.service.ts index bcc2cdcbadb9c..8058de10dd283 100644 --- a/packages/cli/src/services/jwt.service.ts +++ b/packages/cli/src/services/jwt.service.ts @@ -1,7 +1,8 @@ -import { Service } from 'typedi'; import { createHash } from 'crypto'; import jwt from 'jsonwebtoken'; import { InstanceSettings } from 'n8n-core'; +import { Service } from 'typedi'; + import config from '@/config'; @Service() diff --git a/packages/cli/src/services/naming.service.ts b/packages/cli/src/services/naming.service.ts index 4244f114ded55..a715b2b360ed3 100644 --- a/packages/cli/src/services/naming.service.ts +++ b/packages/cli/src/services/naming.service.ts @@ -1,6 +1,7 @@ import { Service } from 'typedi'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; + import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; @Service() export class NamingService { diff --git a/packages/cli/src/services/orchestration.handler.base.service.ts b/packages/cli/src/services/orchestration.handler.base.service.ts index 054ca3de2318f..d2f0a2de5d555 100644 --- a/packages/cli/src/services/orchestration.handler.base.service.ts +++ b/packages/cli/src/services/orchestration.handler.base.service.ts @@ -1,8 +1,9 @@ import Container from 'typedi'; -import { RedisService } from './redis.service'; -import type { RedisServicePubSubSubscriber } from './redis/redis-service-pub-sub-subscriber'; -import type { WorkerCommandReceivedHandlerOptions } from './orchestration/worker/types'; + import type { MainResponseReceivedHandlerOptions } from './orchestration/main/types'; +import type { WorkerCommandReceivedHandlerOptions } from './orchestration/worker/types'; +import type { RedisServicePubSubSubscriber } from './redis/redis-service-pub-sub-subscriber'; +import { RedisService } from './redis.service'; export abstract class OrchestrationHandlerService { protected initialized = false; diff --git a/packages/cli/src/services/orchestration.service.ts b/packages/cli/src/services/orchestration.service.ts index a81803d478f1a..d1e4b37ef7c42 100644 --- a/packages/cli/src/services/orchestration.service.ts +++ b/packages/cli/src/services/orchestration.service.ts @@ -1,13 +1,14 @@ +import { InstanceSettings } from 'n8n-core'; +import type { WorkflowActivateMode } from 'n8n-workflow'; import { Service } from 'typedi'; -import { Logger } from '@/logger'; + import config from '@/config'; -import type { RedisServicePubSubPublisher } from './redis/redis-service-pub-sub-publisher'; -import type { RedisServiceBaseCommand, RedisServiceCommand } from './redis/redis-service-commands'; +import { Logger } from '@/logger'; -import { RedisService } from './redis.service'; import { MultiMainSetup } from './orchestration/main/multi-main-setup.ee'; -import type { WorkflowActivateMode } from 'n8n-workflow'; -import { InstanceSettings } from 'n8n-core'; +import type { RedisServiceBaseCommand, RedisServiceCommand } from './redis/redis-service-commands'; +import type { RedisServicePubSubPublisher } from './redis/redis-service-pub-sub-publisher'; +import { RedisService } from './redis.service'; @Service() export class OrchestrationService { diff --git a/packages/cli/src/services/orchestration/helpers.ts b/packages/cli/src/services/orchestration/helpers.ts index 7301ae1bef271..a6f313ecfff9f 100644 --- a/packages/cli/src/services/orchestration/helpers.ts +++ b/packages/cli/src/services/orchestration/helpers.ts @@ -1,9 +1,11 @@ -import { Container } from 'typedi'; import { jsonParse } from 'n8n-workflow'; +import * as os from 'os'; +import { Container } from 'typedi'; + import { Logger } from '@/logger'; -import type { RedisServiceCommandObject } from '../redis/redis-service-commands'; + import { COMMAND_REDIS_CHANNEL } from '../redis/redis-constants'; -import * as os from 'os'; +import type { RedisServiceCommandObject } from '../redis/redis-service-commands'; export interface RedisServiceCommandLastReceived { [date: string]: Date; diff --git a/packages/cli/src/services/orchestration/main/handle-command-message-main.ts b/packages/cli/src/services/orchestration/main/handle-command-message-main.ts index 18930aa0c8182..9193e344bb236 100644 --- a/packages/cli/src/services/orchestration/main/handle-command-message-main.ts +++ b/packages/cli/src/services/orchestration/main/handle-command-message-main.ts @@ -1,16 +1,18 @@ import { Container } from 'typedi'; -import { debounceMessageReceiver, messageToRedisServiceCommandObject } from '../helpers'; + +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { License } from '@/license'; import { Logger } from '@/logger'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; import { Push } from '@/push'; -import { TestWebhooks } from '@/webhooks/test-webhooks'; -import { OrchestrationService } from '@/services/orchestration.service'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { CommunityPackagesService } from '@/services/community-packages.service'; +import { OrchestrationService } from '@/services/orchestration.service'; +import { TestWebhooks } from '@/webhooks/test-webhooks'; + +import { debounceMessageReceiver, messageToRedisServiceCommandObject } from '../helpers'; // eslint-disable-next-line complexity export async function handleCommandMessageMain(messageString: string) { diff --git a/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts b/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts index b54dc956b20ad..fd1c402aca487 100644 --- a/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts +++ b/packages/cli/src/services/orchestration/main/handle-worker-response-message-main.ts @@ -1,10 +1,12 @@ import { jsonParse } from 'n8n-workflow'; import Container from 'typedi'; + import { Logger } from '@/logger'; -import { Push } from '../../../push'; -import type { RedisServiceWorkerResponseObject } from '../../redis/redis-service-commands'; import { WORKER_RESPONSE_REDIS_CHANNEL } from '@/services/redis/redis-constants'; + import type { MainResponseReceivedHandlerOptions } from './types'; +import { Push } from '../../../push'; +import type { RedisServiceWorkerResponseObject } from '../../redis/redis-service-commands'; export async function handleWorkerResponseMessageMain( messageString: string, diff --git a/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts b/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts index 3e1098350b0e6..bdc3ab53160aa 100644 --- a/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts +++ b/packages/cli/src/services/orchestration/main/multi-main-setup.ee.ts @@ -1,11 +1,12 @@ -import config from '@/config'; -import { Service } from 'typedi'; -import { TIME } from '@/constants'; import { InstanceSettings } from 'n8n-core'; import { ErrorReporterProxy as EventReporter } from 'n8n-workflow'; +import { Service } from 'typedi'; + +import config from '@/config'; +import { TIME } from '@/constants'; import { Logger } from '@/logger'; -import { RedisServicePubSubPublisher } from '@/services/redis/redis-service-pub-sub-publisher'; import { RedisClientService } from '@/services/redis/redis-client.service'; +import { RedisServicePubSubPublisher } from '@/services/redis/redis-service-pub-sub-publisher'; import { TypedEmitter } from '@/typed-emitter'; type MultiMainEvents = { diff --git a/packages/cli/src/services/orchestration/main/orchestration.handler.main.service.ts b/packages/cli/src/services/orchestration/main/orchestration.handler.main.service.ts index 1b9a64006c8a1..fc08146aa073e 100644 --- a/packages/cli/src/services/orchestration/main/orchestration.handler.main.service.ts +++ b/packages/cli/src/services/orchestration/main/orchestration.handler.main.service.ts @@ -1,9 +1,10 @@ import { Service } from 'typedi'; -import { COMMAND_REDIS_CHANNEL, WORKER_RESPONSE_REDIS_CHANNEL } from '../../redis/redis-constants'; -import { handleWorkerResponseMessageMain } from './handle-worker-response-message-main'; + import { handleCommandMessageMain } from './handle-command-message-main'; -import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; +import { handleWorkerResponseMessageMain } from './handle-worker-response-message-main'; import type { MainResponseReceivedHandlerOptions } from './types'; +import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; +import { COMMAND_REDIS_CHANNEL, WORKER_RESPONSE_REDIS_CHANNEL } from '../../redis/redis-constants'; @Service() export class OrchestrationHandlerMainService extends OrchestrationHandlerService { diff --git a/packages/cli/src/services/orchestration/webhook/handle-command-message-webhook.ts b/packages/cli/src/services/orchestration/webhook/handle-command-message-webhook.ts index 9a5b9b739a0c6..8a695059570df 100644 --- a/packages/cli/src/services/orchestration/webhook/handle-command-message-webhook.ts +++ b/packages/cli/src/services/orchestration/webhook/handle-command-message-webhook.ts @@ -1,12 +1,14 @@ -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; -import { License } from '@/license'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import Container from 'typedi'; import { Logger } from 'winston'; -import { messageToRedisServiceCommandObject, debounceMessageReceiver } from '../helpers'; + import config from '@/config'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { License } from '@/license'; import { CommunityPackagesService } from '@/services/community-packages.service'; +import { messageToRedisServiceCommandObject, debounceMessageReceiver } from '../helpers'; + export async function handleCommandMessageWebhook(messageString: string) { const queueModeId = config.getEnv('redis.queueModeId'); const isMainInstance = config.getEnv('generic.instanceType') === 'main'; diff --git a/packages/cli/src/services/orchestration/webhook/orchestration.handler.webhook.service.ts b/packages/cli/src/services/orchestration/webhook/orchestration.handler.webhook.service.ts index 398a93de3d024..d1c778697d86f 100644 --- a/packages/cli/src/services/orchestration/webhook/orchestration.handler.webhook.service.ts +++ b/packages/cli/src/services/orchestration/webhook/orchestration.handler.webhook.service.ts @@ -1,7 +1,8 @@ import { Service } from 'typedi'; -import { COMMAND_REDIS_CHANNEL } from '../../redis/redis-constants'; -import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; + import { handleCommandMessageWebhook } from './handle-command-message-webhook'; +import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; +import { COMMAND_REDIS_CHANNEL } from '../../redis/redis-constants'; @Service() export class OrchestrationHandlerWebhookService extends OrchestrationHandlerService { diff --git a/packages/cli/src/services/orchestration/webhook/orchestration.webhook.service.ts b/packages/cli/src/services/orchestration/webhook/orchestration.webhook.service.ts index 9e97078348eeb..84ba61a9046d4 100644 --- a/packages/cli/src/services/orchestration/webhook/orchestration.webhook.service.ts +++ b/packages/cli/src/services/orchestration/webhook/orchestration.webhook.service.ts @@ -1,7 +1,9 @@ import { Service } from 'typedi'; -import { OrchestrationService } from '../../orchestration.service'; + import config from '@/config'; +import { OrchestrationService } from '../../orchestration.service'; + @Service() export class OrchestrationWebhookService extends OrchestrationService { sanityCheck(): boolean { diff --git a/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts b/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts index 8b680068a6f9b..bdeabe78d4712 100644 --- a/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts +++ b/packages/cli/src/services/orchestration/worker/handle-command-message-worker.ts @@ -1,16 +1,18 @@ import { jsonParse } from 'n8n-workflow'; -import Container from 'typedi'; -import type { RedisServiceCommandObject } from '@/services/redis/redis-service-commands'; -import { COMMAND_REDIS_CHANNEL } from '@/services/redis/redis-constants'; import * as os from 'os'; -import { License } from '@/license'; +import Container from 'typedi'; + +import { N8N_VERSION } from '@/constants'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; -import { debounceMessageReceiver, getOsCpuString } from '../helpers'; -import type { WorkerCommandReceivedHandlerOptions } from './types'; +import { License } from '@/license'; import { Logger } from '@/logger'; -import { N8N_VERSION } from '@/constants'; import { CommunityPackagesService } from '@/services/community-packages.service'; +import { COMMAND_REDIS_CHANNEL } from '@/services/redis/redis-constants'; +import type { RedisServiceCommandObject } from '@/services/redis/redis-service-commands'; + +import type { WorkerCommandReceivedHandlerOptions } from './types'; +import { debounceMessageReceiver, getOsCpuString } from '../helpers'; export function getWorkerCommandReceivedHandler(options: WorkerCommandReceivedHandlerOptions) { // eslint-disable-next-line complexity diff --git a/packages/cli/src/services/orchestration/worker/orchestration.handler.worker.service.ts b/packages/cli/src/services/orchestration/worker/orchestration.handler.worker.service.ts index f9c028d875284..3e91ca1655d57 100644 --- a/packages/cli/src/services/orchestration/worker/orchestration.handler.worker.service.ts +++ b/packages/cli/src/services/orchestration/worker/orchestration.handler.worker.service.ts @@ -1,7 +1,8 @@ import { Service } from 'typedi'; -import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; + import { getWorkerCommandReceivedHandler } from './handle-command-message-worker'; import type { WorkerCommandReceivedHandlerOptions } from './types'; +import { OrchestrationHandlerService } from '../../orchestration.handler.base.service'; @Service() export class OrchestrationHandlerWorkerService extends OrchestrationHandlerService { diff --git a/packages/cli/src/services/orchestration/worker/orchestration.worker.service.ts b/packages/cli/src/services/orchestration/worker/orchestration.worker.service.ts index fc5bb931ea09b..ae000fd501473 100644 --- a/packages/cli/src/services/orchestration/worker/orchestration.worker.service.ts +++ b/packages/cli/src/services/orchestration/worker/orchestration.worker.service.ts @@ -1,7 +1,9 @@ import { Service } from 'typedi'; -import { OrchestrationService } from '../../orchestration.service'; + import config from '@/config'; +import { OrchestrationService } from '../../orchestration.service'; + @Service() export class OrchestrationWorkerService extends OrchestrationService { sanityCheck(): boolean { diff --git a/packages/cli/src/services/orchestration/worker/types.ts b/packages/cli/src/services/orchestration/worker/types.ts index e54490b447fad..5c3db2bbe4615 100644 --- a/packages/cli/src/services/orchestration/worker/types.ts +++ b/packages/cli/src/services/orchestration/worker/types.ts @@ -1,7 +1,9 @@ import type { ExecutionStatus, WorkflowExecuteMode } from 'n8n-workflow'; -import type { RedisServicePubSubPublisher } from '../../redis/redis-service-pub-sub-publisher'; + import type { RunningJobSummary } from '@/scaling/scaling.types'; +import type { RedisServicePubSubPublisher } from '../../redis/redis-service-pub-sub-publisher'; + export interface WorkerCommandReceivedHandlerOptions { queueModeId: string; redisPublisher: RedisServicePubSubPublisher; diff --git a/packages/cli/src/services/ownership.service.ts b/packages/cli/src/services/ownership.service.ts index e7363c9a6a059..65e83e53eb495 100644 --- a/packages/cli/src/services/ownership.service.ts +++ b/packages/cli/src/services/ownership.service.ts @@ -1,12 +1,13 @@ import { Service } from 'typedi'; -import { CacheService } from '@/services/cache/cache.service'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import type { ListQuery } from '@/requests'; + import type { Project } from '@/databases/entities/project'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import type { User } from '@/databases/entities/user'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import type { ListQuery } from '@/requests'; +import { CacheService } from '@/services/cache/cache.service'; @Service() export class OwnershipService { diff --git a/packages/cli/src/services/password.utility.ts b/packages/cli/src/services/password.utility.ts index 8c8c3aaf1964c..9719db44bb09f 100644 --- a/packages/cli/src/services/password.utility.ts +++ b/packages/cli/src/services/password.utility.ts @@ -1,10 +1,11 @@ -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { Service as Utility } from 'typedi'; import { compare, hash } from 'bcryptjs'; +import { Service as Utility } from 'typedi'; + import { MAX_PASSWORD_CHAR_LENGTH as maxLength, MIN_PASSWORD_CHAR_LENGTH as minLength, } from '@/constants'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; const SALT_ROUNDS = 10; diff --git a/packages/cli/src/services/project.service.ts b/packages/cli/src/services/project.service.ts index 795311baccbfb..d78e3a07e1d8a 100644 --- a/packages/cli/src/services/project.service.ts +++ b/packages/cli/src/services/project.service.ts @@ -1,25 +1,27 @@ +import { type Scope } from '@n8n/permissions'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import type { FindOptionsWhere, EntityManager } from '@n8n/typeorm'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In, Not } from '@n8n/typeorm'; +import { ApplicationError } from 'n8n-workflow'; +import Container, { Service } from 'typedi'; + +import { UNLIMITED_LICENSE_QUOTA } from '@/constants'; import { Project, type ProjectType } from '@/databases/entities/project'; import { ProjectRelation } from '@/databases/entities/project-relation'; import type { ProjectRole } from '@/databases/entities/project-relation'; import type { User } from '@/databases/entities/user'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import type { FindOptionsWhere, EntityManager } from '@n8n/typeorm'; -import Container, { Service } from 'typedi'; -import { type Scope } from '@n8n/permissions'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In, Not } from '@n8n/typeorm'; -import { RoleService } from './role.service'; -import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { CacheService } from './cache/cache.service'; +import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { License } from '@/license'; -import { UNLIMITED_LICENSE_QUOTA } from '@/constants'; -import { ApplicationError } from 'n8n-workflow'; + +import { CacheService } from './cache/cache.service'; +import { RoleService } from './role.service'; export class TeamProjectOverQuotaError extends ApplicationError { constructor(limit: number) { diff --git a/packages/cli/src/services/pruning.service.ts b/packages/cli/src/services/pruning.service.ts index f3977478b9c65..d541e5898c7da 100644 --- a/packages/cli/src/services/pruning.service.ts +++ b/packages/cli/src/services/pruning.service.ts @@ -1,11 +1,13 @@ -import { Service } from 'typedi'; import { BinaryDataService, InstanceSettings } from 'n8n-core'; -import { inTest, TIME } from '@/constants'; +import { jsonStringify } from 'n8n-workflow'; +import { Service } from 'typedi'; + import config from '@/config'; +import { inTest, TIME } from '@/constants'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logger'; -import { jsonStringify } from 'n8n-workflow'; import { OnShutdown } from '@/decorators/on-shutdown'; +import { Logger } from '@/logger'; + import { OrchestrationService } from './orchestration.service'; @Service() diff --git a/packages/cli/src/services/redis.service.ts b/packages/cli/src/services/redis.service.ts index d3c0beb87a53b..22692f3637edd 100644 --- a/packages/cli/src/services/redis.service.ts +++ b/packages/cli/src/services/redis.service.ts @@ -1,6 +1,7 @@ import { Service } from 'typedi'; -import { RedisServicePubSubSubscriber } from './redis/redis-service-pub-sub-subscriber'; + import { RedisServicePubSubPublisher } from './redis/redis-service-pub-sub-publisher'; +import { RedisServicePubSubSubscriber } from './redis/redis-service-pub-sub-subscriber'; /* * This is a convenience service that provides access to all the Redis clients. diff --git a/packages/cli/src/services/redis/redis-client.service.ts b/packages/cli/src/services/redis/redis-client.service.ts index 822392708631b..30bad8b631c0a 100644 --- a/packages/cli/src/services/redis/redis-client.service.ts +++ b/packages/cli/src/services/redis/redis-client.service.ts @@ -1,8 +1,9 @@ -import { Service } from 'typedi'; -import { Logger } from '@/logger'; +import { GlobalConfig } from '@n8n/config'; import ioRedis from 'ioredis'; import type { Cluster, RedisOptions } from 'ioredis'; -import { GlobalConfig } from '@n8n/config'; +import { Service } from 'typedi'; + +import { Logger } from '@/logger'; import type { RedisClientType } from './redis.types'; diff --git a/packages/cli/src/services/redis/redis-service-base-classes.ts b/packages/cli/src/services/redis/redis-service-base-classes.ts index d31044bb5c213..d652ef10c54ec 100644 --- a/packages/cli/src/services/redis/redis-service-base-classes.ts +++ b/packages/cli/src/services/redis/redis-service-base-classes.ts @@ -1,8 +1,10 @@ import type Redis from 'ioredis'; import type { Cluster } from 'ioredis'; import { Service } from 'typedi'; + import config from '@/config'; import { Logger } from '@/logger'; + import { RedisClientService } from './redis-client.service'; import type { RedisClientType } from './redis.types'; diff --git a/packages/cli/src/services/redis/redis-service-pub-sub-publisher.ts b/packages/cli/src/services/redis/redis-service-pub-sub-publisher.ts index bfcb8cc0ac6e7..367591b4cdafa 100644 --- a/packages/cli/src/services/redis/redis-service-pub-sub-publisher.ts +++ b/packages/cli/src/services/redis/redis-service-pub-sub-publisher.ts @@ -1,10 +1,11 @@ import { Service } from 'typedi'; + import { COMMAND_REDIS_CHANNEL, WORKER_RESPONSE_REDIS_CHANNEL } from './redis-constants'; +import { RedisServiceBaseSender } from './redis-service-base-classes'; import type { RedisServiceCommandObject, RedisServiceWorkerResponseObject, } from './redis-service-commands'; -import { RedisServiceBaseSender } from './redis-service-base-classes'; @Service() export class RedisServicePubSubPublisher extends RedisServiceBaseSender { diff --git a/packages/cli/src/services/redis/redis-service-pub-sub-subscriber.ts b/packages/cli/src/services/redis/redis-service-pub-sub-subscriber.ts index c6ff27c249121..52bc0b225f688 100644 --- a/packages/cli/src/services/redis/redis-service-pub-sub-subscriber.ts +++ b/packages/cli/src/services/redis/redis-service-pub-sub-subscriber.ts @@ -1,4 +1,5 @@ import { Service } from 'typedi'; + import { COMMAND_REDIS_CHANNEL, WORKER_RESPONSE_REDIS_CHANNEL } from './redis-constants'; import { RedisServiceBaseReceiver } from './redis-service-base-classes'; diff --git a/packages/cli/src/services/role.service.ts b/packages/cli/src/services/role.service.ts index 6d5e8575205c3..97adbbfb7d908 100644 --- a/packages/cli/src/services/role.service.ts +++ b/packages/cli/src/services/role.service.ts @@ -1,3 +1,8 @@ +import { combineScopes, type Resource, type Scope } from '@n8n/permissions'; +import { ApplicationError } from 'n8n-workflow'; +import { Service } from 'typedi'; + +import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { ProjectRelation, ProjectRole } from '@/databases/entities/project-relation'; import type { CredentialSharingRole, @@ -5,6 +10,7 @@ import type { } from '@/databases/entities/shared-credentials'; import type { SharedWorkflow, WorkflowSharingRole } from '@/databases/entities/shared-workflow'; import type { GlobalRole, User } from '@/databases/entities/user'; +import { License } from '@/license'; import { GLOBAL_ADMIN_SCOPES, GLOBAL_MEMBER_SCOPES, @@ -23,11 +29,6 @@ import { WORKFLOW_SHARING_OWNER_SCOPES, } from '@/permissions/resource-roles'; import type { ListQuery } from '@/requests'; -import { combineScopes, type Resource, type Scope } from '@n8n/permissions'; -import { Service } from 'typedi'; -import { ApplicationError } from 'n8n-workflow'; -import { License } from '@/license'; -import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; export type RoleNamespace = 'global' | 'project' | 'credential' | 'workflow'; diff --git a/packages/cli/src/services/tag.service.ts b/packages/cli/src/services/tag.service.ts index 2ddd3dd899e9f..7ed3feebffdb3 100644 --- a/packages/cli/src/services/tag.service.ts +++ b/packages/cli/src/services/tag.service.ts @@ -1,9 +1,10 @@ -import { TagRepository } from '@/databases/repositories/tag.repository'; import { Service } from 'typedi'; -import { validateEntity } from '@/generic-helpers'; -import type { ITagWithCountDb } from '@/interfaces'; + 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'; type GetAllResult = T extends { withUsageCount: true } ? ITagWithCountDb[] : TagEntity[]; diff --git a/packages/cli/src/services/url.service.ts b/packages/cli/src/services/url.service.ts index 8c0e1948fc971..43b53f28ad054 100644 --- a/packages/cli/src/services/url.service.ts +++ b/packages/cli/src/services/url.service.ts @@ -1,6 +1,7 @@ +import { GlobalConfig } from '@n8n/config'; import { Service } from 'typedi'; + import config from '@/config'; -import { GlobalConfig } from '@n8n/config'; @Service() export class UrlService { diff --git a/packages/cli/src/services/user-onboarding.service.ts b/packages/cli/src/services/user-onboarding.service.ts index ff929e93daf38..5e92830a8783a 100644 --- a/packages/cli/src/services/user-onboarding.service.ts +++ b/packages/cli/src/services/user-onboarding.service.ts @@ -1,6 +1,6 @@ -import { Service } from 'typedi'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { Service } from 'typedi'; import type { User } from '@/databases/entities/user'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; diff --git a/packages/cli/src/services/user.service.ts b/packages/cli/src/services/user.service.ts index 17d3b40b0784c..259a30666ce87 100644 --- a/packages/cli/src/services/user.service.ts +++ b/packages/cli/src/services/user.service.ts @@ -1,17 +1,17 @@ -import { Service } from 'typedi'; import type { IUserSettings } from 'n8n-workflow'; import { ApplicationError, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import { Service } from 'typedi'; import type { User, AssignableRole } 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 { PostHogClient } from '@/posthog'; import { Logger } from '@/logger'; -import { UserManagementMailer } from '@/user-management/email'; -import { UrlService } from '@/services/url.service'; +import type { PostHogClient } from '@/posthog'; import type { UserRequest } from '@/requests'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; -import { EventService } from '@/events/event.service'; +import { UrlService } from '@/services/url.service'; +import { UserManagementMailer } from '@/user-management/email'; @Service() export class UserService { diff --git a/packages/cli/src/services/workflow-statistics.service.ts b/packages/cli/src/services/workflow-statistics.service.ts index ca93ecf989636..42c6d14638e25 100644 --- a/packages/cli/src/services/workflow-statistics.service.ts +++ b/packages/cli/src/services/workflow-statistics.service.ts @@ -1,12 +1,14 @@ -import { Service } from 'typedi'; import type { INode, IRun, IWorkflowBase } from 'n8n-workflow'; +import { Service } from 'typedi'; + import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; -import { UserService } from '@/services/user.service'; +import { EventService } from '@/events/event.service'; import { Logger } from '@/logger'; -import { OwnershipService } from './ownership.service'; +import { UserService } from '@/services/user.service'; import { TypedEmitter } from '@/typed-emitter'; -import { EventService } from '@/events/event.service'; + +import { OwnershipService } from './ownership.service'; type WorkflowStatisticsEvents = { nodeFetchedData: { workflowId: string; node: INode }; diff --git a/packages/cli/src/shutdown/__tests__/shutdown.service.test.ts b/packages/cli/src/shutdown/__tests__/shutdown.service.test.ts index 16f37b38281e1..9c2f5b4887fbe 100644 --- a/packages/cli/src/shutdown/__tests__/shutdown.service.test.ts +++ b/packages/cli/src/shutdown/__tests__/shutdown.service.test.ts @@ -1,8 +1,9 @@ -import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; import { mock } from 'jest-mock-extended'; +import { ApplicationError, ErrorReporterProxy } from 'n8n-workflow'; +import Container from 'typedi'; + import type { ServiceClass } from '@/shutdown/shutdown.service'; import { ShutdownService } from '@/shutdown/shutdown.service'; -import Container from 'typedi'; class MockComponent { onShutdown() {} diff --git a/packages/cli/src/shutdown/shutdown.service.ts b/packages/cli/src/shutdown/shutdown.service.ts index f3927ec309a10..8e2c1f3884b15 100644 --- a/packages/cli/src/shutdown/shutdown.service.ts +++ b/packages/cli/src/shutdown/shutdown.service.ts @@ -1,8 +1,9 @@ -import { Container, Service } from 'typedi'; -import { ApplicationError, ErrorReporterProxy, assert } from 'n8n-workflow'; import type { Class } from 'n8n-core'; -import { Logger } from '@/logger'; +import { ApplicationError, ErrorReporterProxy, assert } from 'n8n-workflow'; +import { Container, Service } from 'typedi'; + import { LOWEST_SHUTDOWN_PRIORITY, HIGHEST_SHUTDOWN_PRIORITY } from '@/constants'; +import { Logger } from '@/logger'; type HandlerFn = () => Promise | void; export type ServiceClass = Class>; diff --git a/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts b/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts index c1ea30993ae82..76ae2e4d50500 100644 --- a/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml-helpers.test.ts @@ -1,11 +1,11 @@ +import type { AuthIdentity } from '@/databases/entities/auth-identity'; import { User } from '@/databases/entities/user'; +import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { generateNanoId } from '@/databases/utils/generators'; import * as helpers from '@/sso/saml/saml-helpers'; import type { SamlUserAttributes } from '@/sso/saml/types/saml-user-attributes'; import { mockInstance } from '@test/mocking'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import type { AuthIdentity } from '@/databases/entities/auth-identity'; -import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; const userRepository = mockInstance(UserRepository); mockInstance(AuthIdentityRepository); diff --git a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts index 9821c89637a38..418f29c688544 100644 --- a/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts +++ b/packages/cli/src/sso/saml/__tests__/saml.service.ee.test.ts @@ -1,11 +1,12 @@ -import { mock } from 'jest-mock-extended'; import type express from 'express'; -import { SamlService } from '@/sso/saml/saml.service.ee'; -import { mockInstance } from '@test/mocking'; -import { UrlService } from '@/services/url.service'; -import { Logger } from '@/logger'; +import { mock } from 'jest-mock-extended'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; + +import { Logger } from '@/logger'; +import { UrlService } from '@/services/url.service'; import * as samlHelpers from '@/sso/saml/saml-helpers'; +import { SamlService } from '@/sso/saml/saml.service.ee'; +import { mockInstance } from '@test/mocking'; describe('SamlService', () => { const logger = mockInstance(Logger); diff --git a/packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts b/packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts index e0bf2b1b01c1c..749dbf7b98f01 100644 --- a/packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts +++ b/packages/cli/src/sso/saml/middleware/saml-enabled-middleware.ts @@ -1,4 +1,5 @@ import type { RequestHandler } from 'express'; + import { isSamlLicensed, isSamlLicensedAndEnabled } from '../saml-helpers'; export const samlLicensedAndEnabledMiddleware: RequestHandler = (_, res, next) => { diff --git a/packages/cli/src/sso/saml/routes/saml.controller.ee.ts b/packages/cli/src/sso/saml/routes/saml.controller.ee.ts index 621d03bec1c7e..77c8c192917b1 100644 --- a/packages/cli/src/sso/saml/routes/saml.controller.ee.ts +++ b/packages/cli/src/sso/saml/routes/saml.controller.ee.ts @@ -1,33 +1,33 @@ -import express from 'express'; import { validate } from 'class-validator'; +import express from 'express'; +import querystring from 'querystring'; import type { PostBindingContext } from 'samlify/types/src/entity'; import url from 'url'; -import { Get, Post, RestController, GlobalScope } from '@/decorators'; import { AuthService } from '@/auth/auth.service'; -import { AuthenticatedRequest } from '@/requests'; -import querystring from 'querystring'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { Get, Post, RestController, GlobalScope } from '@/decorators'; import { AuthError } from '@/errors/response-errors/auth.error'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { EventService } from '@/events/event.service'; +import { AuthenticatedRequest } from '@/requests'; import { UrlService } from '@/services/url.service'; +import { + samlLicensedAndEnabledMiddleware, + samlLicensedMiddleware, +} from '../middleware/saml-enabled-middleware'; +import { isConnectionTestRequest, isSamlLicensedAndEnabled } from '../saml-helpers'; +import { SamlService } from '../saml.service.ee'; import { getServiceProviderConfigTestReturnUrl, getServiceProviderEntityId, getServiceProviderReturnUrl, } from '../service-provider.ee'; -import { getSamlConnectionTestSuccessView } from '../views/saml-connection-test-success'; -import { getSamlConnectionTestFailedView } from '../views/saml-connection-test-failed'; -import { isConnectionTestRequest, isSamlLicensedAndEnabled } from '../saml-helpers'; import type { SamlLoginBinding } from '../types'; -import { - samlLicensedAndEnabledMiddleware, - samlLicensedMiddleware, -} from '../middleware/saml-enabled-middleware'; -import { SamlService } from '../saml.service.ee'; import { SamlConfiguration } from '../types/requests'; import { getInitSSOFormView } from '../views/init-sso-post'; -import { EventService } from '@/events/event.service'; +import { getSamlConnectionTestFailedView } from '../views/saml-connection-test-failed'; +import { getSamlConnectionTestSuccessView } from '../views/saml-connection-test-success'; @RestController('/sso/saml') export class SamlController { diff --git a/packages/cli/src/sso/saml/saml-helpers.ts b/packages/cli/src/sso/saml/saml-helpers.ts index b6150343cfbf3..996e17b359832 100644 --- a/packages/cli/src/sso/saml/saml-helpers.ts +++ b/packages/cli/src/sso/saml/saml-helpers.ts @@ -1,29 +1,29 @@ -import { Container } from 'typedi'; -import type { FlowResult } from 'samlify/types/src/flow'; import { randomString } from 'n8n-workflow'; +import type { FlowResult } from 'samlify/types/src/flow'; +import { Container } from 'typedi'; import config from '@/config'; import { AuthIdentity } from '@/databases/entities/auth-identity'; import type { User } from '@/databases/entities/user'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { License } from '@/license'; import { PasswordUtility } from '@/services/password.utility'; +import { SAML_LOGIN_ENABLED, SAML_LOGIN_LABEL } from './constants'; +import { getServiceProviderConfigTestReturnUrl } from './service-provider.ee'; +import type { SamlConfiguration } from './types/requests'; +import type { SamlAttributeMapping } from './types/saml-attribute-mapping'; import type { SamlPreferences } from './types/saml-preferences'; import type { SamlUserAttributes } from './types/saml-user-attributes'; -import type { SamlAttributeMapping } from './types/saml-attribute-mapping'; -import { SAML_LOGIN_ENABLED, SAML_LOGIN_LABEL } from './constants'; import { getCurrentAuthenticationMethod, isEmailCurrentAuthenticationMethod, isSamlCurrentAuthenticationMethod, setCurrentAuthenticationMethod, } from '../sso-helpers'; -import { getServiceProviderConfigTestReturnUrl } from './service-provider.ee'; -import type { SamlConfiguration } from './types/requests'; /** * Check whether the SAML feature is licensed and enabled in the instance diff --git a/packages/cli/src/sso/saml/saml-validator.ts b/packages/cli/src/sso/saml/saml-validator.ts index 8e1e9dc328450..6705320bee5f1 100644 --- a/packages/cli/src/sso/saml/saml-validator.ts +++ b/packages/cli/src/sso/saml/saml-validator.ts @@ -1,5 +1,6 @@ import { Container } from 'typedi'; import type { XMLFileInfo } from 'xmllint-wasm'; + import { Logger } from '@/logger'; let xml: XMLFileInfo; diff --git a/packages/cli/src/sso/saml/saml.service.ee.ts b/packages/cli/src/sso/saml/saml.service.ee.ts index 8fd63c2c1be42..f30fa6ff8e887 100644 --- a/packages/cli/src/sso/saml/saml.service.ee.ts +++ b/packages/cli/src/sso/saml/saml.service.ee.ts @@ -1,14 +1,21 @@ +import axios from 'axios'; import type express from 'express'; -import Container, { Service } from 'typedi'; -import type { User } from '@/databases/entities/user'; +import https from 'https'; import { ApplicationError, jsonParse } from 'n8n-workflow'; -import { getServiceProviderInstance } from './service-provider.ee'; -import type { SamlUserAttributes } from './types/saml-user-attributes'; -import { isSsoJustInTimeProvisioningEnabled } from '../sso-helpers'; -import type { SamlPreferences } from './types/saml-preferences'; -import { SAML_PREFERENCES_DB_KEY } from './constants'; import type { IdentityProviderInstance, ServiceProviderInstance } from 'samlify'; import type { BindingContext, PostBindingContext } from 'samlify/types/src/entity'; +import Container, { Service } from 'typedi'; + +import type { Settings } from '@/databases/entities/settings'; +import type { User } from '@/databases/entities/user'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { AuthError } from '@/errors/response-errors/auth.error'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { Logger } from '@/logger'; +import { UrlService } from '@/services/url.service'; + +import { SAML_PREFERENCES_DB_KEY } from './constants'; import { createUserFromSamlAttributes, getMappedSamlAttributesFromFlowResult, @@ -19,17 +26,12 @@ import { setSamlLoginLabel, updateUserFromSamlAttributes, } from './saml-helpers'; -import type { Settings } from '@/databases/entities/settings'; -import axios from 'axios'; -import https from 'https'; -import type { SamlLoginBinding } from './types'; import { validateMetadata, validateResponse } from './saml-validator'; -import { Logger } from '@/logger'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { AuthError } from '@/errors/response-errors/auth.error'; -import { UrlService } from '@/services/url.service'; +import { getServiceProviderInstance } from './service-provider.ee'; +import type { SamlLoginBinding } from './types'; +import type { SamlPreferences } from './types/saml-preferences'; +import type { SamlUserAttributes } from './types/saml-user-attributes'; +import { isSsoJustInTimeProvisioningEnabled } from '../sso-helpers'; @Service() export class SamlService { diff --git a/packages/cli/src/sso/saml/service-provider.ee.ts b/packages/cli/src/sso/saml/service-provider.ee.ts index 4630f7c01a888..2e6511df09004 100644 --- a/packages/cli/src/sso/saml/service-provider.ee.ts +++ b/packages/cli/src/sso/saml/service-provider.ee.ts @@ -1,6 +1,8 @@ -import { Container } from 'typedi'; import type { ServiceProviderInstance } from 'samlify'; +import { Container } from 'typedi'; + import { UrlService } from '@/services/url.service'; + import type { SamlPreferences } from './types/saml-preferences'; let serviceProviderInstance: ServiceProviderInstance | undefined; diff --git a/packages/cli/src/sso/saml/types/requests.ts b/packages/cli/src/sso/saml/types/requests.ts index c333c8c36114f..69fb89a1ebec9 100644 --- a/packages/cli/src/sso/saml/types/requests.ts +++ b/packages/cli/src/sso/saml/types/requests.ts @@ -1,4 +1,5 @@ import type { AuthenticatedRequest, AuthlessRequest } from '@/requests'; + import type { SamlPreferences } from './saml-preferences'; export declare namespace SamlConfiguration { diff --git a/packages/cli/src/sso/saml/types/saml-preferences.ts b/packages/cli/src/sso/saml/types/saml-preferences.ts index 6f4fc696ca835..1231684360a55 100644 --- a/packages/cli/src/sso/saml/types/saml-preferences.ts +++ b/packages/cli/src/sso/saml/types/saml-preferences.ts @@ -1,5 +1,6 @@ import { IsBoolean, IsObject, IsOptional, IsString } from 'class-validator'; import { SignatureConfig } from 'samlify/types/src/types'; + import { SamlLoginBinding } from '.'; import { SamlAttributeMapping } from './saml-attribute-mapping'; diff --git a/packages/cli/src/sso/sso-helpers.ts b/packages/cli/src/sso/sso-helpers.ts index b736785aa91a5..925c7a1eb19e3 100644 --- a/packages/cli/src/sso/sso-helpers.ts +++ b/packages/cli/src/sso/sso-helpers.ts @@ -1,7 +1,8 @@ +import Container from 'typedi'; + import config from '@/config'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; import type { AuthProviderType } from '@/databases/entities/auth-identity'; -import Container from 'typedi'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; /** * Only one authentication method can be active at a time. This function sets the current authentication method diff --git a/packages/cli/src/subworkflows/__tests__/subworkflow-policy-checker.test.ts b/packages/cli/src/subworkflows/__tests__/subworkflow-policy-checker.test.ts index 55d240c45abd2..d63c3825cdf68 100644 --- a/packages/cli/src/subworkflows/__tests__/subworkflow-policy-checker.test.ts +++ b/packages/cli/src/subworkflows/__tests__/subworkflow-policy-checker.test.ts @@ -1,21 +1,22 @@ -import { v4 as uuid } from 'uuid'; -import type { INode, Workflow } from 'n8n-workflow'; -import type { Project } from '@/databases/entities/project'; -import { OwnershipService } from '@/services/ownership.service'; -import { mockInstance } from '@test/mocking'; +import type { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; -import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker.service'; +import type { INode, Workflow } from 'n8n-workflow'; +import { v4 as uuid } from 'uuid'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { License } from '@/license'; -import type { GlobalConfig } from '@n8n/config'; -import type { AccessService } from '@/services/access.service'; +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { SUBWORKFLOW_DENIAL_BASE_DESCRIPTION, SubworkflowPolicyDenialError, } from '@/errors/subworkflow-policy-denial.error'; +import type { License } from '@/license'; +import type { AccessService } from '@/services/access.service'; +import { OwnershipService } from '@/services/ownership.service'; import type { UrlService } from '@/services/url.service'; +import { mockInstance } from '@test/mocking'; + +import { SubworkflowPolicyChecker } from '../subworkflow-policy-checker.service'; describe('SubworkflowPolicyChecker', () => { const ownershipService = mockInstance(OwnershipService); diff --git a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts index 33e6e58f76f91..52450ffbb544e 100644 --- a/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts +++ b/packages/cli/src/subworkflows/subworkflow-policy-checker.service.ts @@ -1,13 +1,14 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; -import { Logger } from '@/logger'; -import { License } from '@/license'; -import { OwnershipService } from '@/services/ownership.service'; import { type Workflow, type INode, type WorkflowSettings } from 'n8n-workflow'; +import { strict as assert } from 'node:assert'; +import { Service } from 'typedi'; + +import type { Project } from '@/databases/entities/project'; import { SubworkflowPolicyDenialError } from '@/errors/subworkflow-policy-denial.error'; +import { License } from '@/license'; +import { Logger } from '@/logger'; import { AccessService } from '@/services/access.service'; -import type { Project } from '@/databases/entities/project'; -import { strict as assert } from 'node:assert'; +import { OwnershipService } from '@/services/ownership.service'; import { UrlService } from '@/services/url.service'; type Policy = WorkflowSettings.CallerPolicy; diff --git a/packages/cli/src/telemetry/__tests__/telemetry.test.ts b/packages/cli/src/telemetry/__tests__/telemetry.test.ts index ca30c86ec4ade..3851e4523a1f1 100644 --- a/packages/cli/src/telemetry/__tests__/telemetry.test.ts +++ b/packages/cli/src/telemetry/__tests__/telemetry.test.ts @@ -1,9 +1,10 @@ import type RudderStack from '@rudderstack/rudder-sdk-node'; -import { Telemetry } from '@/telemetry'; -import config from '@/config'; -import { PostHogClient } from '@/posthog'; import { mock } from 'jest-mock-extended'; import { InstanceSettings } from 'n8n-core'; + +import config from '@/config'; +import { PostHogClient } from '@/posthog'; +import { Telemetry } from '@/telemetry'; import { mockInstance } from '@test/mocking'; jest.unmock('@/telemetry'); diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index 8aeede7968c00..8ffca478c1a49 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -1,21 +1,22 @@ -import axios from 'axios'; import type RudderStack from '@rudderstack/rudder-sdk-node'; -import { PostHogClient } from '@/posthog'; -import { Container, Service } from 'typedi'; -import type { ITelemetryTrackProperties } from 'n8n-workflow'; +import axios from 'axios'; import { InstanceSettings } from 'n8n-core'; +import type { ITelemetryTrackProperties } from 'n8n-workflow'; +import { Container, Service } from 'typedi'; import config from '@/config'; -import type { IExecutionTrackProperties } from '@/interfaces'; -import { Logger } from '@/logger'; -import { License } from '@/license'; import { LOWEST_SHUTDOWN_PRIORITY, N8N_VERSION } from '@/constants'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; -import { UserRepository } from '@/databases/repositories/user.repository'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { OnShutdown } from '@/decorators/on-shutdown'; +import type { IExecutionTrackProperties } from '@/interfaces'; +import { License } from '@/license'; +import { Logger } from '@/logger'; +import { PostHogClient } from '@/posthog'; + +import { SourceControlPreferencesService } from '../environments/source-control/source-control-preferences.service.ee'; type ExecutionTrackDataKey = 'manual_error' | 'manual_success' | 'prod_error' | 'prod_success'; diff --git a/packages/cli/src/typed-emitter.ts b/packages/cli/src/typed-emitter.ts index 176aa9584c907..403c90dfa20fb 100644 --- a/packages/cli/src/typed-emitter.ts +++ b/packages/cli/src/typed-emitter.ts @@ -1,5 +1,5 @@ -import { EventEmitter } from 'node:events'; import debounce from 'lodash/debounce'; +import { EventEmitter } from 'node:events'; type Payloads = { [E in keyof ListenerMap]: unknown; diff --git a/packages/cli/src/user-management/email/__tests__/user-management-mailer.test.ts b/packages/cli/src/user-management/email/__tests__/user-management-mailer.test.ts index 77529d6808bf7..04fcc2b81cbfd 100644 --- a/packages/cli/src/user-management/email/__tests__/user-management-mailer.test.ts +++ b/packages/cli/src/user-management/email/__tests__/user-management-mailer.test.ts @@ -1,8 +1,8 @@ import type { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; -import type { InviteEmailData, PasswordResetData } from '@/user-management/email/interfaces'; import type { UrlService } from '@/services/url.service'; +import type { InviteEmailData, PasswordResetData } from '@/user-management/email/interfaces'; import { NodeMailer } from '@/user-management/email/node-mailer'; import { UserManagementMailer } from '@/user-management/email/user-management-mailer'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/user-management/email/node-mailer.ts b/packages/cli/src/user-management/email/node-mailer.ts index e172699d05f50..cfc7247546509 100644 --- a/packages/cli/src/user-management/email/node-mailer.ts +++ b/packages/cli/src/user-management/email/node-mailer.ts @@ -1,13 +1,14 @@ -import { Service } from 'typedi'; -import path from 'node:path'; +import { GlobalConfig } from '@n8n/config'; import { pick } from 'lodash'; +import { ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import path from 'node:path'; import type { Transporter } from 'nodemailer'; import { createTransport } from 'nodemailer'; import type SMTPConnection from 'nodemailer/lib/smtp-connection'; -import { GlobalConfig } from '@n8n/config'; -import { ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; +import { Service } from 'typedi'; import { Logger } from '@/logger'; + import type { MailData, SendEmailResult } from './interfaces'; @Service() diff --git a/packages/cli/src/user-management/email/user-management-mailer.ts b/packages/cli/src/user-management/email/user-management-mailer.ts index 40ec991f76bde..6703354f07226 100644 --- a/packages/cli/src/user-management/email/user-management-mailer.ts +++ b/packages/cli/src/user-management/email/user-management-mailer.ts @@ -1,22 +1,22 @@ -import { Container, Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { existsSync } from 'fs'; import { readFile } from 'fs/promises'; import Handlebars from 'handlebars'; import { join as pathJoin } from 'path'; -import { GlobalConfig } from '@n8n/config'; +import { Container, Service } from 'typedi'; +import { inTest } from '@/constants'; import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { UserRepository } from '@/databases/repositories/user.repository'; +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { EventService } from '@/events/event.service'; import { Logger } from '@/logger'; import { UrlService } from '@/services/url.service'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; import { toError } from '@/utils'; import type { InviteEmailData, PasswordResetData, SendEmailResult } from './interfaces'; import { NodeMailer } from './node-mailer'; -import { inTest } from '@/constants'; type Template = HandlebarsTemplateDelegate; type TemplateName = diff --git a/packages/cli/src/user-management/permission-checker.ts b/packages/cli/src/user-management/permission-checker.ts index ec0dc2802a7be..c93d2acf91cb4 100644 --- a/packages/cli/src/user-management/permission-checker.ts +++ b/packages/cli/src/user-management/permission-checker.ts @@ -1,9 +1,9 @@ -import { Service } from 'typedi'; import type { INode } from 'n8n-workflow'; import { CredentialAccessError, NodeOperationError } from 'n8n-workflow'; +import { Service } from 'typedi'; -import { OwnershipService } from '@/services/ownership.service'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { OwnershipService } from '@/services/ownership.service'; import { ProjectService } from '@/services/project.service'; @Service() diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index 407aa49559469..ff172de181a18 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -1,5 +1,6 @@ import { CliWorkflowOperationError, SubworkflowOperationError } from 'n8n-workflow'; import type { INode } from 'n8n-workflow'; + import { STARTING_NODES } from '@/constants'; /** diff --git a/packages/cli/src/validators/__tests__/no-url.validator.test.ts b/packages/cli/src/validators/__tests__/no-url.validator.test.ts index dafba595efcab..82a0281cc2545 100644 --- a/packages/cli/src/validators/__tests__/no-url.validator.test.ts +++ b/packages/cli/src/validators/__tests__/no-url.validator.test.ts @@ -1,6 +1,7 @@ -import { NoUrl } from '../no-url.validator'; import { validate } from 'class-validator'; +import { NoUrl } from '../no-url.validator'; + describe('NoUrl', () => { class Entity { @NoUrl() diff --git a/packages/cli/src/validators/__tests__/no-xss.validator.test.ts b/packages/cli/src/validators/__tests__/no-xss.validator.test.ts index 75eaeb90723a3..34457cd13ebef 100644 --- a/packages/cli/src/validators/__tests__/no-xss.validator.test.ts +++ b/packages/cli/src/validators/__tests__/no-xss.validator.test.ts @@ -1,6 +1,7 @@ -import { NoXss } from '../no-xss.validator'; import { validate } from 'class-validator'; +import { NoXss } from '../no-xss.validator'; + describe('NoXss', () => { class Entity { @NoXss() diff --git a/packages/cli/src/validators/no-xss.validator.ts b/packages/cli/src/validators/no-xss.validator.ts index 69960c39dd2d8..0171cba070acc 100644 --- a/packages/cli/src/validators/no-xss.validator.ts +++ b/packages/cli/src/validators/no-xss.validator.ts @@ -1,6 +1,6 @@ -import xss from 'xss'; import type { ValidationOptions, ValidatorConstraintInterface } from 'class-validator'; import { registerDecorator, ValidatorConstraint } from 'class-validator'; +import xss from 'xss'; @ValidatorConstraint({ name: 'NoXss', async: false }) class NoXssConstraint implements ValidatorConstraintInterface { diff --git a/packages/cli/src/wait-tracker.ts b/packages/cli/src/wait-tracker.ts index b30c0012b4385..7792cf5285df6 100644 --- a/packages/cli/src/wait-tracker.ts +++ b/packages/cli/src/wait-tracker.ts @@ -4,11 +4,12 @@ import { type IWorkflowExecutionDataProcess, } from 'n8n-workflow'; import { Service } from 'typedi'; -import { WorkflowRunner } from '@/workflow-runner'; + import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { OwnershipService } from '@/services/ownership.service'; import { Logger } from '@/logger'; import { OrchestrationService } from '@/services/orchestration.service'; +import { OwnershipService } from '@/services/ownership.service'; +import { WorkflowRunner } from '@/workflow-runner'; @Service() export class WaitTracker { diff --git a/packages/cli/src/webhooks/__tests__/test-webhook-registrations.service.test.ts b/packages/cli/src/webhooks/__tests__/test-webhook-registrations.service.test.ts index 95502e3611e7c..0642a5eaa54fb 100644 --- a/packages/cli/src/webhooks/__tests__/test-webhook-registrations.service.test.ts +++ b/packages/cli/src/webhooks/__tests__/test-webhook-registrations.service.test.ts @@ -1,8 +1,9 @@ +import { mock } from 'jest-mock-extended'; + import type { CacheService } from '@/services/cache/cache.service'; import type { OrchestrationService } from '@/services/orchestration.service'; import type { TestWebhookRegistration } from '@/webhooks/test-webhook-registrations.service'; import { TestWebhookRegistrationsService } from '@/webhooks/test-webhook-registrations.service'; -import { mock } from 'jest-mock-extended'; describe('TestWebhookRegistrationsService', () => { const cacheService = mock(); diff --git a/packages/cli/src/webhooks/__tests__/test-webhooks.test.ts b/packages/cli/src/webhooks/__tests__/test-webhooks.test.ts index f1fa5338fcec4..d9228bcb0d39c 100644 --- a/packages/cli/src/webhooks/__tests__/test-webhooks.test.ts +++ b/packages/cli/src/webhooks/__tests__/test-webhooks.test.ts @@ -1,21 +1,20 @@ +import type * as express from 'express'; import { mock } from 'jest-mock-extended'; -import { TestWebhooks } from '@/webhooks/test-webhooks'; -import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; +import type { IWebhookData, IWorkflowExecuteAdditionalData, Workflow } from 'n8n-workflow'; import { v4 as uuid } from 'uuid'; + import { generateNanoId } from '@/databases/utils/generators'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import * as WebhookHelpers from '@/webhooks/webhook-helpers'; -import type * as express from 'express'; - +import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; import type { IWorkflowDb } from '@/interfaces'; -import type { IWebhookData, IWorkflowExecuteAdditionalData, Workflow } from 'n8n-workflow'; import type { TestWebhookRegistrationsService, TestWebhookRegistration, } from '@/webhooks/test-webhook-registrations.service'; - -import * as AdditionalData from '@/workflow-execute-additional-data'; +import { TestWebhooks } from '@/webhooks/test-webhooks'; +import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import type { WebhookRequest } from '@/webhooks/webhook.types'; +import * as AdditionalData from '@/workflow-execute-additional-data'; jest.mock('@/workflow-execute-additional-data'); diff --git a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts index 221476672af9e..7a8dd8b854a9f 100644 --- a/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts +++ b/packages/cli/src/webhooks/__tests__/waiting-webhooks.test.ts @@ -1,10 +1,11 @@ +import type express from 'express'; import { mock } from 'jest-mock-extended'; -import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; + +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 express from 'express'; -import type { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; import type { WaitingWebhookRequest } from '@/webhooks/webhook.types'; describe('WaitingWebhooks', () => { diff --git a/packages/cli/src/webhooks/__tests__/webhook-request-handler.test.ts b/packages/cli/src/webhooks/__tests__/webhook-request-handler.test.ts index c807c6c4d9ed0..f740a9c726c64 100644 --- a/packages/cli/src/webhooks/__tests__/webhook-request-handler.test.ts +++ b/packages/cli/src/webhooks/__tests__/webhook-request-handler.test.ts @@ -3,14 +3,14 @@ import { mock } from 'jest-mock-extended'; import { randomString } from 'n8n-workflow'; import type { IHttpRequestMethods } from 'n8n-workflow'; +import { ResponseError } from '@/errors/response-errors/abstract/response.error'; +import { createWebhookHandlerFor } from '@/webhooks/webhook-request-handler'; import type { IWebhookManager, IWebhookResponseCallbackData, WebhookOptionsRequest, WebhookRequest, } from '@/webhooks/webhook.types'; -import { createWebhookHandlerFor } from '@/webhooks/webhook-request-handler'; -import { ResponseError } from '@/errors/response-errors/abstract/response.error'; describe('WebhookRequestHandler', () => { const webhookManager = mock>(); diff --git a/packages/cli/src/webhooks/__tests__/webhook.service.test.ts b/packages/cli/src/webhooks/__tests__/webhook.service.test.ts index 6a970aa5832a0..534c36bca0878 100644 --- a/packages/cli/src/webhooks/__tests__/webhook.service.test.ts +++ b/packages/cli/src/webhooks/__tests__/webhook.service.test.ts @@ -1,9 +1,10 @@ import { v4 as uuid } from 'uuid'; + import config from '@/config'; +import { WebhookEntity } from '@/databases/entities/webhook-entity'; import { WebhookRepository } from '@/databases/repositories/webhook.repository'; import { CacheService } from '@/services/cache/cache.service'; import { WebhookService } from '@/webhooks/webhook.service'; -import { WebhookEntity } from '@/databases/entities/webhook-entity'; import { mockInstance } from '@test/mocking'; const createWebhook = (method: string, path: string, webhookId?: string, pathSegments?: number) => diff --git a/packages/cli/src/webhooks/live-webhooks.ts b/packages/cli/src/webhooks/live-webhooks.ts index f0736a221ebeb..e9314060d7880 100644 --- a/packages/cli/src/webhooks/live-webhooks.ts +++ b/packages/cli/src/webhooks/live-webhooks.ts @@ -1,23 +1,24 @@ -import { Service } from 'typedi'; import type { Response } from 'express'; import { Workflow, NodeHelpers } from 'n8n-workflow'; import type { INode, IWebhookData, IHttpRequestMethods } from 'n8n-workflow'; +import { Service } from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; +import { Logger } from '@/logger'; +import { NodeTypes } from '@/node-types'; +import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +import { WebhookService } from '@/webhooks/webhook.service'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; + import type { IWebhookResponseCallbackData, IWebhookManager, WebhookAccessControlOptions, WebhookRequest, } from './webhook.types'; -import { Logger } from '@/logger'; -import { NodeTypes } from '@/node-types'; -import { WebhookService } from '@/webhooks/webhook.service'; -import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; -import * as WebhookHelpers from '@/webhooks/webhook-helpers'; -import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; /** * Service for handling the execution of live webhooks, i.e. webhooks diff --git a/packages/cli/src/webhooks/test-webhook-registrations.service.ts b/packages/cli/src/webhooks/test-webhook-registrations.service.ts index 5bc046c67fa16..6a3e205f58964 100644 --- a/packages/cli/src/webhooks/test-webhook-registrations.service.ts +++ b/packages/cli/src/webhooks/test-webhook-registrations.service.ts @@ -1,8 +1,9 @@ -import { Service } from 'typedi'; -import { CacheService } from '@/services/cache/cache.service'; import type { IWebhookData } from 'n8n-workflow'; -import type { IWorkflowDb } from '@/interfaces'; +import { Service } from 'typedi'; + import { TEST_WEBHOOK_TIMEOUT, TEST_WEBHOOK_TIMEOUT_BUFFER } from '@/constants'; +import type { IWorkflowDb } from '@/interfaces'; +import { CacheService } from '@/services/cache/cache.service'; import { OrchestrationService } from '@/services/orchestration.service'; export type TestWebhookRegistration = { diff --git a/packages/cli/src/webhooks/test-webhooks.ts b/packages/cli/src/webhooks/test-webhooks.ts index 3ed6f86271e40..21511d4843879 100644 --- a/packages/cli/src/webhooks/test-webhooks.ts +++ b/packages/cli/src/webhooks/test-webhooks.ts @@ -1,5 +1,5 @@ import type express from 'express'; -import { Service } from 'typedi'; +import * as NodeExecuteFunctions from 'n8n-core'; import { WebhookPathTakenError, Workflow } from 'n8n-workflow'; import type { IWebhookData, @@ -7,26 +7,28 @@ import type { IHttpRequestMethods, IRunData, } from 'n8n-workflow'; -import type { - IWebhookResponseCallbackData, - IWebhookManager, - WebhookAccessControlOptions, - WebhookRequest, -} from './webhook.types'; -import { Push } from '@/push'; -import { NodeTypes } from '@/node-types'; -import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +import { Service } from 'typedi'; + import { TEST_WEBHOOK_TIMEOUT } from '@/constants'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { WorkflowMissingIdError } from '@/errors/workflow-missing-id.error'; import { WebhookNotFoundError } from '@/errors/response-errors/webhook-not-found.error'; -import * as NodeExecuteFunctions from 'n8n-core'; +import { WorkflowMissingIdError } from '@/errors/workflow-missing-id.error'; +import type { IWorkflowDb } from '@/interfaces'; +import { NodeTypes } from '@/node-types'; +import { Push } from '@/push'; +import { OrchestrationService } from '@/services/orchestration.service'; import { removeTrailingSlash } from '@/utils'; import type { TestWebhookRegistration } from '@/webhooks/test-webhook-registrations.service'; import { TestWebhookRegistrationsService } from '@/webhooks/test-webhook-registrations.service'; -import { OrchestrationService } from '@/services/orchestration.service'; +import * as WebhookHelpers from '@/webhooks/webhook-helpers'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; -import type { IWorkflowDb } from '@/interfaces'; + +import type { + IWebhookResponseCallbackData, + IWebhookManager, + WebhookAccessControlOptions, + WebhookRequest, +} from './webhook.types'; /** * Service for handling the execution of webhooks of manual executions diff --git a/packages/cli/src/webhooks/waiting-webhooks.ts b/packages/cli/src/webhooks/waiting-webhooks.ts index cfba81a91d6ad..6493fde9819d1 100644 --- a/packages/cli/src/webhooks/waiting-webhooks.ts +++ b/packages/cli/src/webhooks/waiting-webhooks.ts @@ -1,20 +1,21 @@ +import type express from 'express'; import { NodeHelpers, Workflow } from 'n8n-workflow'; import { Service } from 'typedi'; -import type express from 'express'; -import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +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, IWorkflowDb } from '@/interfaces'; +import { Logger } from '@/logger'; import { NodeTypes } from '@/node-types'; +import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; + import type { IWebhookResponseCallbackData, IWebhookManager, WaitingWebhookRequest, } from './webhook.types'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { Logger } from '@/logger'; -import { ConflictError } from '@/errors/response-errors/conflict.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import type { IExecutionResponse, IWorkflowDb } from '@/interfaces'; /** * Service for handling the execution of webhooks of Wait nodes that use the diff --git a/packages/cli/src/webhooks/webhook-helpers.ts b/packages/cli/src/webhooks/webhook-helpers.ts index 8b79bcae65e27..03b39d4417b70 100644 --- a/packages/cli/src/webhooks/webhook-helpers.ts +++ b/packages/cli/src/webhooks/webhook-helpers.ts @@ -7,13 +7,9 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import type express from 'express'; -import { Container } from 'typedi'; -import get from 'lodash/get'; -import { finished } from 'stream/promises'; import formidable from 'formidable'; - +import get from 'lodash/get'; import { BinaryDataService, NodeExecuteFunctions } from 'n8n-core'; - import type { IBinaryData, IBinaryKeyData, @@ -40,21 +36,24 @@ import { ErrorReporterProxy as ErrorReporter, NodeHelpers, } from 'n8n-workflow'; +import { finished } from 'stream/promises'; +import { Container } from 'typedi'; -import type { IWebhookResponseCallbackData, WebhookRequest } from './webhook.types'; -import * as WorkflowHelpers from '@/workflow-helpers'; -import { WorkflowRunner } from '@/workflow-runner'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; import { ActiveExecutions } from '@/active-executions'; -import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; -import { OwnershipService } from '@/services/ownership.service'; -import { parseBody } from '@/middlewares'; -import { Logger } from '@/logger'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import type { Project } from '@/databases/entities/project'; import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { UnprocessableRequestError } from '@/errors/response-errors/unprocessable.error'; -import type { Project } from '@/databases/entities/project'; import type { IExecutionDb, IWorkflowDb } from '@/interfaces'; +import { Logger } from '@/logger'; +import { parseBody } from '@/middlewares'; +import { OwnershipService } from '@/services/ownership.service'; +import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import * as WorkflowHelpers from '@/workflow-helpers'; +import { WorkflowRunner } from '@/workflow-runner'; + +import type { IWebhookResponseCallbackData, WebhookRequest } from './webhook.types'; /** * Returns all the webhooks which should be created for the given workflow diff --git a/packages/cli/src/webhooks/webhook-request-handler.ts b/packages/cli/src/webhooks/webhook-request-handler.ts index a495873a68a0f..96cf6da745516 100644 --- a/packages/cli/src/webhooks/webhook-request-handler.ts +++ b/packages/cli/src/webhooks/webhook-request-handler.ts @@ -1,11 +1,12 @@ import type express from 'express'; import type { IHttpRequestMethods } from 'n8n-workflow'; + +import * as ResponseHelper from '@/response-helper'; import type { IWebhookManager, WebhookOptionsRequest, WebhookRequest, } from '@/webhooks/webhook.types'; -import * as ResponseHelper from '@/response-helper'; const WEBHOOK_METHODS: IHttpRequestMethods[] = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT']; diff --git a/packages/cli/src/webhooks/webhook-server.ts b/packages/cli/src/webhooks/webhook-server.ts index bb00510e5601e..d54f39f2cf642 100644 --- a/packages/cli/src/webhooks/webhook-server.ts +++ b/packages/cli/src/webhooks/webhook-server.ts @@ -1,4 +1,5 @@ import { Service } from 'typedi'; + import { AbstractServer } from '@/abstract-server'; @Service() diff --git a/packages/cli/src/webhooks/webhook.service.ts b/packages/cli/src/webhooks/webhook.service.ts index 3d7e75871db64..8e72f0abf969e 100644 --- a/packages/cli/src/webhooks/webhook.service.ts +++ b/packages/cli/src/webhooks/webhook.service.ts @@ -1,8 +1,9 @@ -import { WebhookRepository } from '@/databases/repositories/webhook.repository'; +import type { IHttpRequestMethods } from 'n8n-workflow'; import { Service } from 'typedi'; -import { CacheService } from '@/services/cache/cache.service'; + import type { WebhookEntity } from '@/databases/entities/webhook-entity'; -import type { IHttpRequestMethods } from 'n8n-workflow'; +import { WebhookRepository } from '@/databases/repositories/webhook.repository'; +import { CacheService } from '@/services/cache/cache.service'; type Method = NonNullable; diff --git a/packages/cli/src/workflow-execute-additional-data.ts b/packages/cli/src/workflow-execute-additional-data.ts index 959363377b041..41409ac1c2631 100644 --- a/packages/cli/src/workflow-execute-additional-data.ts +++ b/packages/cli/src/workflow-execute-additional-data.ts @@ -3,8 +3,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ +import { GlobalConfig } from '@n8n/config'; import { WorkflowExecute } from 'n8n-core'; - import type { IDataObject, IExecuteData, @@ -33,11 +33,12 @@ import { Workflow, WorkflowHooks, } from 'n8n-workflow'; - import { Container } from 'typedi'; -import config from '@/config'; + import { ActiveExecutions } from '@/active-executions'; +import config from '@/config'; import { CredentialsHelper } from '@/credentials-helper'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExternalHooks } from '@/external-hooks'; import type { IPushDataExecutionFinished, @@ -48,30 +49,29 @@ import type { } from '@/interfaces'; import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; -import * as WorkflowHelpers from '@/workflow-helpers'; -import { findSubworkflowStart, isWorkflowIdValid } from '@/utils'; -import { PermissionChecker } from './user-management/permission-checker'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowStatisticsService } from '@/services/workflow-statistics.service'; -import { SecretsHelper } from './secrets-helpers'; -import { OwnershipService } from './services/ownership.service'; +import { findSubworkflowStart, isWorkflowIdValid } from '@/utils'; +import * as WorkflowHelpers from '@/workflow-helpers'; + +import { WorkflowRepository } from './databases/repositories/workflow.repository'; +import type { AiEventMap, AiEventPayload } from './events/ai-event-map'; +import { EventService } from './events/event.service'; +import { restoreBinaryDataId } from './execution-lifecycle-hooks/restore-binary-data-id'; +import { saveExecutionProgress } from './execution-lifecycle-hooks/save-execution-progress'; import { determineFinalExecutionStatus, prepareExecutionDataForDbUpdate, updateExistingExecution, } from './execution-lifecycle-hooks/shared/shared-hook-functions'; -import { restoreBinaryDataId } from './execution-lifecycle-hooks/restore-binary-data-id'; import { toSaveSettings } from './execution-lifecycle-hooks/to-save-settings'; import { Logger } from './logger'; -import { saveExecutionProgress } from './execution-lifecycle-hooks/save-execution-progress'; -import { WorkflowStaticDataService } from './workflows/workflow-static-data.service'; -import { WorkflowRepository } from './databases/repositories/workflow.repository'; +import { SecretsHelper } from './secrets-helpers'; +import { OwnershipService } from './services/ownership.service'; import { UrlService } from './services/url.service'; -import { WorkflowExecutionService } from './workflows/workflow-execution.service'; -import type { AiEventMap, AiEventPayload } from './events/ai-event-map'; -import { EventService } from './events/event.service'; -import { GlobalConfig } from '@n8n/config'; import { SubworkflowPolicyChecker } from './subworkflows/subworkflow-policy-checker.service'; +import { PermissionChecker } from './user-management/permission-checker'; +import { WorkflowExecutionService } from './workflows/workflow-execution.service'; +import { WorkflowStaticDataService } from './workflows/workflow-static-data.service'; export function objectToError(errorObject: unknown, workflow: Workflow): Error { // TODO: Expand with other error types diff --git a/packages/cli/src/workflow-helpers.ts b/packages/cli/src/workflow-helpers.ts index 917e91a401fd2..7cbce6b8a2751 100644 --- a/packages/cli/src/workflow-helpers.ts +++ b/packages/cli/src/workflow-helpers.ts @@ -1,5 +1,3 @@ -import { Container } from 'typedi'; -import { v4 as uuid } from 'uuid'; import type { IDataObject, INode, @@ -13,6 +11,8 @@ import type { NodeOperationError, IWorkflowExecutionDataProcess, } from 'n8n-workflow'; +import { Container } from 'typedi'; +import { v4 as uuid } from 'uuid'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; diff --git a/packages/cli/src/workflow-runner.ts b/packages/cli/src/workflow-runner.ts index e9735ed62ace3..a10646ac0b19b 100644 --- a/packages/cli/src/workflow-runner.ts +++ b/packages/cli/src/workflow-runner.ts @@ -2,9 +2,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-shadow */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ -import { Container, Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { WorkflowExecute } from 'n8n-core'; - import type { ExecutionError, IDeferredPromise, @@ -20,25 +19,25 @@ import { ExecutionCancelledError, Workflow, } from 'n8n-workflow'; - import PCancelable from 'p-cancelable'; +import { Container, Service } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; import config from '@/config'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExternalHooks } from '@/external-hooks'; import type { IExecutionResponse } from '@/interfaces'; +import { Logger } from '@/logger'; import { NodeTypes } from '@/node-types'; -import type { Job, JobData, JobResult } from '@/scaling/scaling.types'; import type { ScalingService } from '@/scaling/scaling.service'; -import * as WorkflowHelpers from '@/workflow-helpers'; +import type { Job, JobData, JobResult } from '@/scaling/scaling.types'; +import { PermissionChecker } from '@/user-management/permission-checker'; import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import * as WorkflowHelpers from '@/workflow-helpers'; import { generateFailedExecutionFromError } from '@/workflow-helpers'; -import { PermissionChecker } from '@/user-management/permission-checker'; -import { Logger } from '@/logger'; import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; + import { EventService } from './events/event.service'; -import { GlobalConfig } from '@n8n/config'; @Service() export class WorkflowRunner { diff --git a/packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts b/packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts index 5a75653275dec..35228dcfd4206 100644 --- a/packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts +++ b/packages/cli/src/workflows/__tests__/workflow-execution.service.test.ts @@ -1,10 +1,10 @@ -import type { INode } from 'n8n-workflow'; import { mock } from 'jest-mock-extended'; +import type { INode } from 'n8n-workflow'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { IWorkflowDb } from '@/interfaces'; -import { WorkflowExecutionService } from '@/workflows/workflow-execution.service'; import type { WorkflowRunner } from '@/workflow-runner'; +import { WorkflowExecutionService } from '@/workflows/workflow-execution.service'; const webhookNode: INode = { name: 'Webhook', diff --git a/packages/cli/src/workflows/workflow-execution.service.ts b/packages/cli/src/workflows/workflow-execution.service.ts index 2376eb34e34c3..87a78f4b5e183 100644 --- a/packages/cli/src/workflows/workflow-execution.service.ts +++ b/packages/cli/src/workflows/workflow-execution.service.ts @@ -1,4 +1,4 @@ -import { Service } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import type { IDeferredPromise, IExecuteData, @@ -16,21 +16,21 @@ import { Workflow, ErrorReporterProxy as ErrorReporter, } from 'n8n-workflow'; +import { Service } from 'typedi'; +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import * as WorkflowHelpers from '@/workflow-helpers'; -import type { WorkflowRequest } from '@/workflows/workflow.request'; import type { ExecutionPayload, IWorkflowDb, IWorkflowErrorData } from '@/interfaces'; -import { NodeTypes } from '@/node-types'; -import { WorkflowRunner } from '@/workflow-runner'; -import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; -import { TestWebhooks } from '@/webhooks/test-webhooks'; import { Logger } from '@/logger'; -import type { Project } from '@/databases/entities/project'; -import { GlobalConfig } from '@n8n/config'; +import { NodeTypes } from '@/node-types'; import { SubworkflowPolicyChecker } from '@/subworkflows/subworkflow-policy-checker.service'; +import { TestWebhooks } from '@/webhooks/test-webhooks'; +import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data'; +import * as WorkflowHelpers from '@/workflow-helpers'; +import { WorkflowRunner } from '@/workflow-runner'; +import type { WorkflowRequest } from '@/workflows/workflow.request'; @Service() export class WorkflowExecutionService { diff --git a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts index a4b7a70abfed0..ce3927f73066b 100644 --- a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts +++ b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history-helper.ee.test.ts @@ -1,5 +1,5 @@ -import { License } from '@/license'; import config from '@/config'; +import { License } from '@/license'; import { getWorkflowHistoryPruneTime } from '@/workflows/workflow-history/workflow-history-helper.ee'; import { mockInstance } from '@test/mocking'; diff --git a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts index 038e25d25726f..8bc54318bf70c 100644 --- a/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts +++ b/packages/cli/src/workflows/workflow-history/__tests__/workflow-history.service.ee.test.ts @@ -1,9 +1,10 @@ import { mockClear } from 'jest-mock-extended'; + import { User } from '@/databases/entities/user'; -import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; +import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { Logger } from '@/logger'; +import { WorkflowHistoryService } from '@/workflows/workflow-history/workflow-history.service.ee'; import { mockInstance } from '@test/mocking'; import { getWorkflow } from '@test-integration/workflow'; diff --git a/packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts index 27da19b7da9d5..11363a45bc0a8 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history-helper.ee.ts @@ -1,7 +1,8 @@ -import { License } from '@/license'; -import config from '@/config'; import Container from 'typedi'; +import config from '@/config'; +import { License } from '@/license'; + export function isWorkflowHistoryLicensed() { const license = Container.get(License); return license.isWorkflowHistoryLicensed(); diff --git a/packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts index 56aec86777e10..e710637441b2f 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history-manager.ee.ts @@ -1,6 +1,8 @@ -import { Service } from 'typedi'; import { DateTime } from 'luxon'; +import { Service } from 'typedi'; + import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; + import { WORKFLOW_HISTORY_PRUNE_INTERVAL } from './constants'; import { getWorkflowHistoryPruneTime, diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts index dd900375545bf..144a92d8f6fd1 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history.controller.ee.ts @@ -1,13 +1,14 @@ -import { RestController, Get, Middleware } from '@/decorators'; -import { WorkflowHistoryRequest } from '@/requests'; -import { WorkflowHistoryService } from './workflow-history.service.ee'; import { Request, Response, NextFunction } from 'express'; -import { isWorkflowHistoryEnabled, isWorkflowHistoryLicensed } from './workflow-history-helper.ee'; -import { paginationListQueryMiddleware } from '@/middlewares/list-query/pagination'; +import { RestController, Get, Middleware } from '@/decorators'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; import { SharedWorkflowNotFoundError } from '@/errors/shared-workflow-not-found.error'; import { WorkflowHistoryVersionNotFoundError } from '@/errors/workflow-history-version-not-found.error'; +import { paginationListQueryMiddleware } from '@/middlewares/list-query/pagination'; +import { WorkflowHistoryRequest } from '@/requests'; + +import { isWorkflowHistoryEnabled, isWorkflowHistoryLicensed } from './workflow-history-helper.ee'; +import { WorkflowHistoryService } from './workflow-history.service.ee'; const DEFAULT_TAKE = 20; diff --git a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts index 7b28d28f3546d..7d40c38ec0f42 100644 --- a/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts +++ b/packages/cli/src/workflows/workflow-history/workflow-history.service.ee.ts @@ -1,13 +1,15 @@ +import { Service } from 'typedi'; + import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import type { WorkflowHistory } from '@/databases/entities/workflow-history'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { Service } from 'typedi'; -import { isWorkflowHistoryEnabled } from './workflow-history-helper.ee'; -import { Logger } from '@/logger'; import { SharedWorkflowNotFoundError } from '@/errors/shared-workflow-not-found.error'; import { WorkflowHistoryVersionNotFoundError } from '@/errors/workflow-history-version-not-found.error'; +import { Logger } from '@/logger'; + +import { isWorkflowHistoryEnabled } from './workflow-history-helper.ee'; @Service() export class WorkflowHistoryService { diff --git a/packages/cli/src/workflows/workflow-sharing.service.ts b/packages/cli/src/workflows/workflow-sharing.service.ts index b4db7879fd35d..280c553a5ea9f 100644 --- a/packages/cli/src/workflows/workflow-sharing.service.ts +++ b/packages/cli/src/workflows/workflow-sharing.service.ts @@ -1,14 +1,14 @@ -import { Service } from 'typedi'; +import type { Scope } from '@n8n/permissions'; // eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import import { In } from '@n8n/typeorm'; +import { Service } from 'typedi'; -import type { User } from '@/databases/entities/user'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { RoleService } from '@/services/role.service'; -import type { Scope } from '@n8n/permissions'; import type { ProjectRole } from '@/databases/entities/project-relation'; import type { WorkflowSharingRole } from '@/databases/entities/shared-workflow'; +import type { User } from '@/databases/entities/user'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { RoleService } from '@/services/role.service'; @Service() export class WorkflowSharingService { diff --git a/packages/cli/src/workflows/workflow-static-data.service.ts b/packages/cli/src/workflows/workflow-static-data.service.ts index d7e2cf423a625..f639345a1cbd8 100644 --- a/packages/cli/src/workflows/workflow-static-data.service.ts +++ b/packages/cli/src/workflows/workflow-static-data.service.ts @@ -1,8 +1,9 @@ -import { Service } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { type IDataObject, type Workflow, ErrorReporterProxy as ErrorReporter } from 'n8n-workflow'; -import { Logger } from '@/logger'; +import { Service } from 'typedi'; + import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { Logger } from '@/logger'; import { isWorkflowIdValid } from '@/utils'; @Service() diff --git a/packages/cli/src/workflows/workflow.request.ts b/packages/cli/src/workflows/workflow.request.ts index d58daf0a4d244..d05b5c1dabb20 100644 --- a/packages/cli/src/workflows/workflow.request.ts +++ b/packages/cli/src/workflows/workflow.request.ts @@ -1,6 +1,7 @@ +import type { INode, IConnections, IWorkflowSettings, IRunData, StartNodeData } from 'n8n-workflow'; + import type { IWorkflowDb } from '@/interfaces'; import type { AuthenticatedRequest, ListQuery } from '@/requests'; -import type { INode, IConnections, IWorkflowSettings, IRunData, StartNodeData } from 'n8n-workflow'; export declare namespace WorkflowRequest { type CreateUpdatePayload = Partial<{ diff --git a/packages/cli/src/workflows/workflow.service.ee.ts b/packages/cli/src/workflows/workflow.service.ee.ts index f5f45ef3afd12..5456ac62681bd 100644 --- a/packages/cli/src/workflows/workflow.service.ee.ts +++ b/packages/cli/src/workflows/workflow.service.ee.ts @@ -1,29 +1,30 @@ -import { Service } from 'typedi'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In, type EntityManager } from '@n8n/typeorm'; import omit from 'lodash/omit'; import { ApplicationError, NodeOperationError, WorkflowActivationError } from 'n8n-workflow'; +import { Service } from 'typedi'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; +import { CredentialsService } from '@/credentials/credentials.service'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import { Project } from '@/databases/entities/project'; +import { SharedWorkflow } from '@/databases/entities/shared-workflow'; import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { CredentialsService } from '@/credentials/credentials.service'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { BadRequestError } from '@/errors/response-errors/bad-request.error'; import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflow.error'; import { Logger } from '@/logger'; +import { OwnershipService } from '@/services/ownership.service'; +import { ProjectService } from '@/services/project.service'; + import type { WorkflowWithSharingsAndCredentials, WorkflowWithSharingsMetaDataAndCredentials, } from './workflows.types'; -import { OwnershipService } from '@/services/ownership.service'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In, type EntityManager } from '@n8n/typeorm'; -import { Project } from '@/databases/entities/project'; -import { ProjectService } from '@/services/project.service'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { TransferWorkflowError } from '@/errors/response-errors/transfer-workflow.error'; -import { SharedWorkflow } from '@/databases/entities/shared-workflow'; @Service() export class EnterpriseWorkflowService { diff --git a/packages/cli/src/workflows/workflow.service.ts b/packages/cli/src/workflows/workflow.service.ts index dfa8e3275d970..03ab425a247f6 100644 --- a/packages/cli/src/workflows/workflow.service.ts +++ b/packages/cli/src/workflows/workflow.service.ts @@ -1,39 +1,40 @@ -import { Service } from 'typedi'; -import { NodeApiError } from 'n8n-workflow'; -import pick from 'lodash/pick'; +import type { Scope } from '@n8n/permissions'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import type { EntityManager } from '@n8n/typeorm'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In } from '@n8n/typeorm'; import omit from 'lodash/omit'; -import { v4 as uuid } from 'uuid'; +import pick from 'lodash/pick'; import { BinaryDataService } from 'n8n-core'; +import { NodeApiError } from 'n8n-workflow'; +import { Service } from 'typedi'; +import { v4 as uuid } from 'uuid'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; +import { SharedWorkflow } from '@/databases/entities/shared-workflow'; import type { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import * as WorkflowHelpers from '@/workflow-helpers'; -import { validateEntity } from '@/generic-helpers'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import { hasSharing, type ListQuery } from '@/requests'; -import { TagService } from '@/services/tag.service'; -import { OwnershipService } from '@/services/ownership.service'; -import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; +import { validateEntity } from '@/generic-helpers'; import { Logger } from '@/logger'; +import { hasSharing, type ListQuery } from '@/requests'; import { OrchestrationService } from '@/services/orchestration.service'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { OwnershipService } from '@/services/ownership.service'; +import { ProjectService } from '@/services/project.service'; import { RoleService } from '@/services/role.service'; +import { TagService } from '@/services/tag.service'; +import * as WorkflowHelpers from '@/workflow-helpers'; + +import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; import { WorkflowSharingService } from './workflow-sharing.service'; -import { ProjectService } from '@/services/project.service'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import type { Scope } from '@n8n/permissions'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import type { EntityManager } from '@n8n/typeorm'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In } from '@n8n/typeorm'; -import { SharedWorkflow } from '@/databases/entities/shared-workflow'; -import { EventService } from '@/events/event.service'; @Service() export class WorkflowService { diff --git a/packages/cli/src/workflows/workflows.controller.ts b/packages/cli/src/workflows/workflows.controller.ts index a8e8052f031d1..797797e386ca0 100644 --- a/packages/cli/src/workflows/workflows.controller.ts +++ b/packages/cli/src/workflows/workflows.controller.ts @@ -1,48 +1,49 @@ +import { GlobalConfig } from '@n8n/config'; +// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import +import { In, type FindOptionsRelations } from '@n8n/typeorm'; +import axios from 'axios'; import express from 'express'; +import { ApplicationError } from 'n8n-workflow'; import { v4 as uuid } from 'uuid'; -import axios from 'axios'; +import { z } from 'zod'; -import * as Db from '@/db'; -import * as ResponseHelper from '@/response-helper'; -import * as WorkflowHelpers from '@/workflow-helpers'; -import type { IWorkflowResponse } from '@/interfaces'; import config from '@/config'; -import { Delete, Get, Patch, Post, ProjectScope, Put, RestController } from '@/decorators'; +import type { Project } from '@/databases/entities/project'; import { SharedWorkflow } from '@/databases/entities/shared-workflow'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { TagRepository } from '@/databases/repositories/tag.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { validateEntity } from '@/generic-helpers'; +import * as Db from '@/db'; +import { Delete, Get, Patch, Post, ProjectScope, Put, RestController } from '@/decorators'; +import { BadRequestError } from '@/errors/response-errors/bad-request.error'; +import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; +import { InternalServerError } from '@/errors/response-errors/internal-server.error'; +import { NotFoundError } from '@/errors/response-errors/not-found.error'; +import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import { WorkflowService } from './workflow.service'; +import { validateEntity } from '@/generic-helpers'; +import type { IWorkflowResponse } from '@/interfaces'; import { License } from '@/license'; -import * as utils from '@/utils'; -import { listQueryMiddleware } from '@/middlewares'; -import { TagService } from '@/services/tag.service'; -import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; import { Logger } from '@/logger'; -import { BadRequestError } from '@/errors/response-errors/bad-request.error'; -import { NotFoundError } from '@/errors/response-errors/not-found.error'; -import { InternalServerError } from '@/errors/response-errors/internal-server.error'; -import { ForbiddenError } from '@/errors/response-errors/forbidden.error'; +import { listQueryMiddleware } from '@/middlewares'; +import * as ResponseHelper from '@/response-helper'; import { NamingService } from '@/services/naming.service'; +import { ProjectService } from '@/services/project.service'; +import { TagService } from '@/services/tag.service'; import { UserOnboardingService } from '@/services/user-onboarding.service'; -import { CredentialsService } from '../credentials/credentials.service'; +import { UserManagementMailer } from '@/user-management/email'; +import * as utils from '@/utils'; +import * as WorkflowHelpers from '@/workflow-helpers'; + +import { WorkflowExecutionService } from './workflow-execution.service'; +import { WorkflowHistoryService } from './workflow-history/workflow-history.service.ee'; import { WorkflowRequest } from './workflow.request'; +import { WorkflowService } from './workflow.service'; import { EnterpriseWorkflowService } from './workflow.service.ee'; -import { WorkflowExecutionService } from './workflow-execution.service'; -import { UserManagementMailer } from '@/user-management/email'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { ProjectService } from '@/services/project.service'; -import { ApplicationError } from 'n8n-workflow'; -// eslint-disable-next-line n8n-local-rules/misplaced-n8n-typeorm-import -import { In, type FindOptionsRelations } from '@n8n/typeorm'; -import type { Project } from '@/databases/entities/project'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import { z } from 'zod'; -import { EventService } from '@/events/event.service'; -import { GlobalConfig } from '@n8n/config'; +import { CredentialsService } from '../credentials/credentials.service'; @RestController('/workflows') export class WorkflowsController { diff --git a/packages/cli/test/integration/activation-errors.service.test.ts b/packages/cli/test/integration/activation-errors.service.test.ts index 37dfcc2e08937..6f84e3066a989 100644 --- a/packages/cli/test/integration/activation-errors.service.test.ts +++ b/packages/cli/test/integration/activation-errors.service.test.ts @@ -1,6 +1,7 @@ +import { GlobalConfig } from '@n8n/config'; + import { ActivationErrorsService } from '@/activation-errors.service'; import { CacheService } from '@/services/cache/cache.service'; -import { GlobalConfig } from '@n8n/config'; import { mockInstance } from '@test/mocking'; describe('ActivationErrorsService', () => { diff --git a/packages/cli/test/integration/active-workflow-manager.test.ts b/packages/cli/test/integration/active-workflow-manager.test.ts index 13e1f5d37b137..d5d471ba6072a 100644 --- a/packages/cli/test/integration/active-workflow-manager.test.ts +++ b/packages/cli/test/integration/active-workflow-manager.test.ts @@ -1,27 +1,27 @@ -import { Container } from 'typedi'; import { mock } from 'jest-mock-extended'; import { NodeApiError, NodeOperationError, Workflow } from 'n8n-workflow'; import type { IWebhookData, WorkflowActivateMode } from 'n8n-workflow'; +import { Container } from 'typedi'; import { ActiveExecutions } from '@/active-executions'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; +import type { WebhookEntity } from '@/databases/entities/webhook-entity'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ExecutionService } from '@/executions/execution.service'; import { ExternalHooks } from '@/external-hooks'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; import { SecretsHelper } from '@/secrets-helpers'; -import { WebhookService } from '@/webhooks/webhook.service'; import * as WebhookHelpers from '@/webhooks/webhook-helpers'; +import { WebhookService } from '@/webhooks/webhook.service'; import * as AdditionalData from '@/workflow-execute-additional-data'; -import type { WebhookEntity } from '@/databases/entities/webhook-entity'; -import { NodeTypes } from '@/node-types'; -import { ExecutionService } from '@/executions/execution.service'; import { WorkflowService } from '@/workflows/workflow.service'; -import { mockInstance } from '../shared/mocking'; -import * as testDb from './shared/test-db'; import { createOwner } from './shared/db/users'; import { createWorkflow } from './shared/db/workflows'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import * as testDb from './shared/test-db'; +import { mockInstance } from '../shared/mocking'; mockInstance(ActiveExecutions); mockInstance(Push); diff --git a/packages/cli/test/integration/auth.api.test.ts b/packages/cli/test/integration/auth.api.test.ts index a41bca3dbdcca..2880526668f30 100644 --- a/packages/cli/test/integration/auth.api.test.ts +++ b/packages/cli/test/integration/auth.api.test.ts @@ -8,11 +8,11 @@ import { UserRepository } from '@/databases/repositories/user.repository'; import { MfaService } from '@/mfa/mfa.service'; import { LOGGED_OUT_RESPONSE_BODY } from './shared/constants'; +import { createUser, createUserShell } from './shared/db/users'; import { randomValidPassword } from './shared/random'; import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; -import { createUser, createUserShell } from './shared/db/users'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; let owner: User; let authOwnerAgent: SuperAgentTest; diff --git a/packages/cli/test/integration/auth.mw.test.ts b/packages/cli/test/integration/auth.mw.test.ts index 262bea38fe9da..66f88159e1c52 100644 --- a/packages/cli/test/integration/auth.mw.test.ts +++ b/packages/cli/test/integration/auth.mw.test.ts @@ -1,9 +1,9 @@ import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import * as utils from './shared/utils/'; import { createUser } from './shared/db/users'; -import { mockInstance } from '../shared/mocking'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; +import { mockInstance } from '../shared/mocking'; describe('Auth Middleware', () => { mockInstance(ActiveWorkflowManager); diff --git a/packages/cli/test/integration/binary-data.api.test.ts b/packages/cli/test/integration/binary-data.api.test.ts index bfa5522948a0c..b98f6a525d1dc 100644 --- a/packages/cli/test/integration/binary-data.api.test.ts +++ b/packages/cli/test/integration/binary-data.api.test.ts @@ -1,11 +1,11 @@ +import { BinaryDataService, FileNotFoundError } from 'n8n-core'; import fsp from 'node:fs/promises'; import { Readable } from 'node:stream'; -import { BinaryDataService, FileNotFoundError } from 'n8n-core'; -import { mockInstance } from '../shared/mocking'; -import { setupTestServer } from './shared/utils'; import { createOwner } from './shared/db/users'; import type { SuperAgentTest } from './shared/types'; +import { setupTestServer } from './shared/utils'; +import { mockInstance } from '../shared/mocking'; jest.mock('fs/promises'); diff --git a/packages/cli/test/integration/collaboration/collaboration.service.test.ts b/packages/cli/test/integration/collaboration/collaboration.service.test.ts index 33f7d81607d64..a90424de8788e 100644 --- a/packages/cli/test/integration/collaboration/collaboration.service.test.ts +++ b/packages/cli/test/integration/collaboration/collaboration.service.test.ts @@ -1,20 +1,19 @@ -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; +import Container from 'typedi'; -import type { User } from '@/databases/entities/user'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { CollaborationService } from '@/collaboration/collaboration.service'; -import { Push } from '@/push'; -import { CacheService } from '@/services/cache/cache.service'; import type { WorkflowClosedMessage, WorkflowOpenedMessage, } from '@/collaboration/collaboration.message'; - +import { CollaborationService } from '@/collaboration/collaboration.service'; +import type { User } from '@/databases/entities/user'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { Push } from '@/push'; +import { CacheService } from '@/services/cache/cache.service'; import { mockInstance } from '@test/mocking'; -import * as testDb from '@test-integration/test-db'; -import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows'; import { createMember, createOwner } from '@test-integration/db/users'; +import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows'; +import * as testDb from '@test-integration/test-db'; describe('CollaborationService', () => { mockInstance(Push, new Push(mock())); diff --git a/packages/cli/test/integration/commands/credentials.cmd.test.ts b/packages/cli/test/integration/commands/credentials.cmd.test.ts index 2c2c7df7e2fb9..d8f85a611f047 100644 --- a/packages/cli/test/integration/commands/credentials.cmd.test.ts +++ b/packages/cli/test/integration/commands/credentials.cmd.test.ts @@ -2,13 +2,13 @@ import { nanoid } from 'nanoid'; import { ImportCredentialsCommand } from '@/commands/import/credentials'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; - import { setupTestCommand } from '@test-integration/utils/test-command'; + import { mockInstance } from '../../shared/mocking'; -import * as testDb from '../shared/test-db'; import { getAllCredentials, getAllSharedCredentials } from '../shared/db/credentials'; -import { createMember, createOwner } from '../shared/db/users'; import { getPersonalProject } from '../shared/db/projects'; +import { createMember, createOwner } from '../shared/db/users'; +import * as testDb from '../shared/test-db'; mockInstance(LoadNodesAndCredentials); const command = setupTestCommand(ImportCredentialsCommand); diff --git a/packages/cli/test/integration/commands/import.cmd.test.ts b/packages/cli/test/integration/commands/import.cmd.test.ts index 5a41b505aa9dd..3d1b352b4ce9b 100644 --- a/packages/cli/test/integration/commands/import.cmd.test.ts +++ b/packages/cli/test/integration/commands/import.cmd.test.ts @@ -2,13 +2,13 @@ import { nanoid } from 'nanoid'; import { ImportWorkflowsCommand } from '@/commands/import/workflow'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; - import { setupTestCommand } from '@test-integration/utils/test-command'; + import { mockInstance } from '../../shared/mocking'; -import * as testDb from '../shared/test-db'; -import { getAllSharedWorkflows, getAllWorkflows } from '../shared/db/workflows'; -import { createMember, createOwner } from '../shared/db/users'; import { getPersonalProject } from '../shared/db/projects'; +import { createMember, createOwner } from '../shared/db/users'; +import { getAllSharedWorkflows, getAllWorkflows } from '../shared/db/workflows'; +import * as testDb from '../shared/test-db'; mockInstance(LoadNodesAndCredentials); const command = setupTestCommand(ImportWorkflowsCommand); diff --git a/packages/cli/test/integration/commands/ldap/reset.test.ts b/packages/cli/test/integration/commands/ldap/reset.test.ts index a8965885d719c..ef0ab2c0d6e60 100644 --- a/packages/cli/test/integration/commands/ldap/reset.test.ts +++ b/packages/cli/test/integration/commands/ldap/reset.test.ts @@ -1,26 +1,26 @@ +import { EntityNotFoundError } from '@n8n/typeorm'; import { Container } from 'typedi'; import { v4 as uuid } from 'uuid'; -import { EntityNotFoundError } from '@n8n/typeorm'; import { Reset } from '@/commands/ldap/reset'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { getLdapSynchronizations, saveLdapSynchronization } from '@/ldap/helpers.ee'; import { LdapService } from '@/ldap/ldap.service.ee'; +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { Push } from '@/push'; import { Telemetry } from '@/telemetry'; - import { setupTestCommand } from '@test-integration/utils/test-command'; + import { mockInstance } from '../../../shared/mocking'; +import { saveCredential } from '../../shared/db/credentials'; +import { createTeamProject, findProject, getPersonalProject } from '../../shared/db/projects'; import { createLdapUser, createMember, getUserById } from '../../shared/db/users'; import { createWorkflow } from '../../shared/db/workflows'; -import { randomCredentialPayload } from '../../shared/random'; -import { saveCredential } from '../../shared/db/credentials'; import { createLdapConfig } from '../../shared/ldap'; -import { createTeamProject, findProject, getPersonalProject } from '../../shared/db/projects'; +import { randomCredentialPayload } from '../../shared/random'; mockInstance(Telemetry); diff --git a/packages/cli/test/integration/commands/license.cmd.test.ts b/packages/cli/test/integration/commands/license.cmd.test.ts index 4dba8d163f629..363d2feae61c0 100644 --- a/packages/cli/test/integration/commands/license.cmd.test.ts +++ b/packages/cli/test/integration/commands/license.cmd.test.ts @@ -1,13 +1,13 @@ import { Container } from 'typedi'; -import { setupTestCommand } from '@test-integration/utils/test-command'; -import { mockInstance } from '../../shared/mocking'; - import { ClearLicenseCommand } from '@/commands/license/clear'; import { SETTINGS_LICENSE_CERT_KEY } from '@/constants'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { setupTestCommand } from '@test-integration/utils/test-command'; + +import { mockInstance } from '../../shared/mocking'; mockInstance(LoadNodesAndCredentials); const license = mockInstance(License); diff --git a/packages/cli/test/integration/commands/reset.cmd.test.ts b/packages/cli/test/integration/commands/reset.cmd.test.ts index fdd23557f0f43..58e8e344e5933 100644 --- a/packages/cli/test/integration/commands/reset.cmd.test.ts +++ b/packages/cli/test/integration/commands/reset.cmd.test.ts @@ -1,23 +1,23 @@ import { Container } from 'typedi'; import { Reset } from '@/commands/user-management/reset'; -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; -import { NodeTypes } from '@/node-types'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; - +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { NodeTypes } from '@/node-types'; import { setupTestCommand } from '@test-integration/utils/test-command'; + import { mockInstance } from '../../shared/mocking'; -import * as testDb from '../shared/test-db'; +import { encryptCredentialData, saveCredential } from '../shared/db/credentials'; +import { getPersonalProject } from '../shared/db/projects'; import { createMember, createUser } from '../shared/db/users'; import { createWorkflow } from '../shared/db/workflows'; -import { getPersonalProject } from '../shared/db/projects'; -import { encryptCredentialData, saveCredential } from '../shared/db/credentials'; import { randomCredentialPayload } from '../shared/random'; +import * as testDb from '../shared/test-db'; mockInstance(LoadNodesAndCredentials); mockInstance(NodeTypes); diff --git a/packages/cli/test/integration/commands/update/workflow.test.ts b/packages/cli/test/integration/commands/update/workflow.test.ts index 76fb81175974c..1152eadfbf789 100644 --- a/packages/cli/test/integration/commands/update/workflow.test.ts +++ b/packages/cli/test/integration/commands/update/workflow.test.ts @@ -1,10 +1,10 @@ -import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { UpdateWorkflowCommand } from '@/commands/update/workflow'; - +import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { setupTestCommand } from '@test-integration/utils/test-command'; -import * as testDb from '../../shared/test-db'; -import { createWorkflowWithTrigger, getAllWorkflows } from '../../shared/db/workflows'; + import { mockInstance } from '../../../shared/mocking'; +import { createWorkflowWithTrigger, getAllWorkflows } from '../../shared/db/workflows'; +import * as testDb from '../../shared/test-db'; mockInstance(LoadNodesAndCredentials); const command = setupTestCommand(UpdateWorkflowCommand); diff --git a/packages/cli/test/integration/commands/worker.cmd.test.ts b/packages/cli/test/integration/commands/worker.cmd.test.ts index 7876a8a38c00c..679eb8c892c9f 100644 --- a/packages/cli/test/integration/commands/worker.cmd.test.ts +++ b/packages/cli/test/integration/commands/worker.cmd.test.ts @@ -2,18 +2,18 @@ import { BinaryDataService } from 'n8n-core'; import { Worker } from '@/commands/worker'; import config from '@/config'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; +import { ExternalHooks } from '@/external-hooks'; +import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { License } from '@/license'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; +import { ScalingService } from '@/scaling/scaling.service'; import { OrchestrationHandlerWorkerService } from '@/services/orchestration/worker/orchestration.handler.worker.service'; import { OrchestrationWorkerService } from '@/services/orchestration/worker/orchestration.worker.service'; -import { License } from '@/license'; -import { ExternalHooks } from '@/external-hooks'; -import { ScalingService } from '@/scaling/scaling.service'; - import { setupTestCommand } from '@test-integration/utils/test-command'; + import { mockInstance } from '../../shared/mocking'; -import { LogStreamingEventRelay } from '@/events/log-streaming-event-relay'; config.set('executions.mode', 'queue'); config.set('binaryDataManager.availableModes', 'filesystem'); diff --git a/packages/cli/test/integration/community-packages.api.test.ts b/packages/cli/test/integration/community-packages.api.test.ts index 0fa722c5e59cf..895fc6dbbb4cb 100644 --- a/packages/cli/test/integration/community-packages.api.test.ts +++ b/packages/cli/test/integration/community-packages.api.test.ts @@ -1,15 +1,15 @@ import path from 'path'; -import type { InstalledPackages } from '@/databases/entities/installed-packages'; import type { InstalledNodes } from '@/databases/entities/installed-nodes'; +import type { InstalledPackages } from '@/databases/entities/installed-packages'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { CommunityPackagesService } from '@/services/community-packages.service'; -import { mockInstance } from '../shared/mocking'; import { COMMUNITY_PACKAGE_VERSION } from './shared/constants'; -import { setupTestServer, mockPackage, mockNode, mockPackageName } from './shared/utils'; import { createOwner } from './shared/db/users'; import type { SuperAgentTest } from './shared/types'; +import { setupTestServer, mockPackage, mockNode, mockPackageName } from './shared/utils'; +import { mockInstance } from '../shared/mocking'; const communityPackagesService = mockInstance(CommunityPackagesService, { hasMissingPackages: false, diff --git a/packages/cli/test/integration/controllers/dynamic-node-parameters.controller.test.ts b/packages/cli/test/integration/controllers/dynamic-node-parameters.controller.test.ts index bf2f83037ed89..8f7436fc7598a 100644 --- a/packages/cli/test/integration/controllers/dynamic-node-parameters.controller.test.ts +++ b/packages/cli/test/integration/controllers/dynamic-node-parameters.controller.test.ts @@ -1,16 +1,16 @@ +import { mock } from 'jest-mock-extended'; import type { INodeListSearchResult, IWorkflowExecuteAdditionalData, ResourceMapperFields, } from 'n8n-workflow'; -import { mock } from 'jest-mock-extended'; import { DynamicNodeParametersService } from '@/services/dynamic-node-parameters.service'; import * as AdditionalData from '@/workflow-execute-additional-data'; import { createOwner } from '../shared/db/users'; -import { setupTestServer } from '../shared/utils'; import type { SuperAgentTest } from '../shared/types'; +import { setupTestServer } from '../shared/utils'; describe('DynamicNodeParametersController', () => { const testServer = setupTestServer({ endpointGroups: ['dynamic-node-parameters'] }); diff --git a/packages/cli/test/integration/controllers/invitation/assertions.ts b/packages/cli/test/integration/controllers/invitation/assertions.ts index cc4848e0e2b09..3e24a532229fe 100644 --- a/packages/cli/test/integration/controllers/invitation/assertions.ts +++ b/packages/cli/test/integration/controllers/invitation/assertions.ts @@ -1,5 +1,7 @@ import validator from 'validator'; + import type { User } from '@/databases/entities/user'; + import type { UserInvitationResult } from '../../shared/utils/users'; export function assertReturnedUserProps(user: User) { diff --git a/packages/cli/test/integration/controllers/invitation/invitation.controller.integration.test.ts b/packages/cli/test/integration/controllers/invitation/invitation.controller.integration.test.ts index a4816a32a04df..48663e1ef3838 100644 --- a/packages/cli/test/integration/controllers/invitation/invitation.controller.integration.test.ts +++ b/packages/cli/test/integration/controllers/invitation/invitation.controller.integration.test.ts @@ -1,30 +1,29 @@ -import Container from 'typedi'; import { Not } from '@n8n/typeorm'; +import Container from 'typedi'; + +import type { User } from '@/databases/entities/user'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { EventService } from '@/events/event.service'; import { ExternalHooks } from '@/external-hooks'; -import { UserManagementMailer } from '@/user-management/email'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { PasswordUtility } from '@/services/password.utility'; +import { UserManagementMailer } from '@/user-management/email'; +import { + assertReturnedUserProps, + assertStoredUserProps, + assertUserInviteResult, +} from './assertions'; +import { mockInstance } from '../../../shared/mocking'; +import { createMember, createOwner, createUserShell } from '../../shared/db/users'; import { randomEmail, randomInvalidPassword, randomName, randomValidPassword, } from '../../shared/random'; -import { createMember, createOwner, createUserShell } from '../../shared/db/users'; -import { mockInstance } from '../../../shared/mocking'; import * as utils from '../../shared/utils'; - -import { - assertReturnedUserProps, - assertStoredUserProps, - assertUserInviteResult, -} from './assertions'; - -import type { User } from '@/databases/entities/user'; import type { UserInvitationResult } from '../../shared/utils/users'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; describe('InvitationController', () => { const mailer = mockInstance(UserManagementMailer); diff --git a/packages/cli/test/integration/controllers/oauth/oauth2.api.test.ts b/packages/cli/test/integration/controllers/oauth/oauth2.api.test.ts index 35137673793b2..6712b4f231294 100644 --- a/packages/cli/test/integration/controllers/oauth/oauth2.api.test.ts +++ b/packages/cli/test/integration/controllers/oauth/oauth2.api.test.ts @@ -1,18 +1,17 @@ -import { Container } from 'typedi'; import { response as Response } from 'express'; import nock from 'nock'; import { parse as parseQs } from 'querystring'; +import { Container } from 'typedi'; +import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller'; +import { CredentialsHelper } from '@/credentials-helper'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; import type { User } from '@/databases/entities/user'; -import { CredentialsHelper } from '@/credentials-helper'; -import { OAuth2CredentialController } from '@/controllers/oauth/oauth2-credential.controller'; - -import { createOwner } from '@test-integration/db/users'; import { saveCredential } from '@test-integration/db/credentials'; +import { createOwner } from '@test-integration/db/users'; import * as testDb from '@test-integration/test-db'; -import { setupTestServer } from '@test-integration/utils'; import type { SuperAgentTest } from '@test-integration/types'; +import { setupTestServer } from '@test-integration/utils'; describe('OAuth2 API', () => { const testServer = setupTestServer({ endpointGroups: ['oauth2'] }); diff --git a/packages/cli/test/integration/credentials-helper.test.ts b/packages/cli/test/integration/credentials-helper.test.ts index 7686e75840e8f..b3cb15555b3e0 100644 --- a/packages/cli/test/integration/credentials-helper.test.ts +++ b/packages/cli/test/integration/credentials-helper.test.ts @@ -1,12 +1,13 @@ import Container from 'typedi'; -import * as testDb from './shared/test-db'; import { CredentialsHelper } from '@/credentials-helper'; -import { createOwner, createAdmin, createMember } from './shared/db/users'; import type { User } from '@/databases/entities/user'; + import { saveCredential } from './shared/db/credentials'; -import { randomCredentialPayload } from './shared/random'; import { createTeamProject, linkUserToProject } from './shared/db/projects'; +import { createOwner, createAdmin, createMember } from './shared/db/users'; +import { randomCredentialPayload } from './shared/random'; +import * as testDb from './shared/test-db'; let credentialHelper: CredentialsHelper; let owner: User; diff --git a/packages/cli/test/integration/credentials/credentials.api.ee.test.ts b/packages/cli/test/integration/credentials/credentials.api.ee.test.ts index ef89f4576741b..b1c0bfab75755 100644 --- a/packages/cli/test/integration/credentials/credentials.api.ee.test.ts +++ b/packages/cli/test/integration/credentials/credentials.api.ee.test.ts @@ -1,25 +1,24 @@ -import { Container } from 'typedi'; import { In } from '@n8n/typeorm'; +import { Container } from 'typedi'; import config from '@/config'; -import type { ListQuery } from '@/requests'; +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; -import type { Project } from '@/databases/entities/project'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import type { ListQuery } from '@/requests'; import { ProjectService } from '@/services/project.service'; import { UserManagementMailer } from '@/user-management/email'; +import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows'; -import { randomCredentialPayload } from '../shared/random'; -import * as testDb from '../shared/test-db'; -import type { SaveCredentialFunction } from '../shared/types'; -import * as utils from '../shared/utils'; +import { mockInstance } from '../../shared/mocking'; import { affixRoleToSaveCredential, getCredentialSharings, shareCredentialWithProjects, shareCredentialWithUsers, } from '../shared/db/credentials'; +import { createTeamProject, linkUserToProject } from '../shared/db/projects'; import { createAdmin, createManyUsers, @@ -27,10 +26,11 @@ import { createUser, createUserShell, } from '../shared/db/users'; +import { randomCredentialPayload } from '../shared/random'; +import * as testDb from '../shared/test-db'; +import type { SaveCredentialFunction } from '../shared/types'; import type { SuperAgentTest } from '../shared/types'; -import { mockInstance } from '../../shared/mocking'; -import { createTeamProject, linkUserToProject } from '../shared/db/projects'; -import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows'; +import * as utils from '../shared/utils'; const testServer = utils.setupTestServer({ endpointGroups: ['credentials'], diff --git a/packages/cli/test/integration/credentials/credentials.api.test.ts b/packages/cli/test/integration/credentials/credentials.api.test.ts index 71ed1d8cfbeb1..5f40850e599f7 100644 --- a/packages/cli/test/integration/credentials/credentials.api.test.ts +++ b/packages/cli/test/integration/credentials/credentials.api.test.ts @@ -1,31 +1,31 @@ -import { Container } from 'typedi'; -import type { Scope } from '@sentry/node'; import { GlobalConfig } from '@n8n/config'; +import type { Scope } from '@sentry/node'; import { Credentials } from 'n8n-core'; import { randomString } from 'n8n-workflow'; +import { Container } from 'typedi'; -import type { ListQuery } from '@/requests'; -import type { User } from '@/databases/entities/user'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import type { Project } from '@/databases/entities/project'; +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 { ListQuery } from '@/requests'; -import * as testDb from '../shared/test-db'; -import { setupTestServer } from '../shared/utils'; -import { - randomCredentialPayload as payload, - randomCredentialPayload, - randomName, -} from '../shared/random'; import { saveCredential, shareCredentialWithProjects, shareCredentialWithUsers, } from '../shared/db/credentials'; -import { createManyUsers, createMember, createOwner } from '../shared/db/users'; import { createTeamProject, linkUserToProject } from '../shared/db/projects'; +import { createManyUsers, createMember, createOwner } from '../shared/db/users'; +import { + randomCredentialPayload as payload, + randomCredentialPayload, + randomName, +} from '../shared/random'; +import * as testDb from '../shared/test-db'; import type { SuperAgentTest } from '../shared/types'; +import { setupTestServer } from '../shared/utils'; const { any } = expect; diff --git a/packages/cli/test/integration/credentials/credentials.service.test.ts b/packages/cli/test/integration/credentials/credentials.service.test.ts index bc2d1935700cf..ecfafada3fad1 100644 --- a/packages/cli/test/integration/credentials/credentials.service.test.ts +++ b/packages/cli/test/integration/credentials/credentials.service.test.ts @@ -1,13 +1,15 @@ -import type { User } from '@/databases/entities/user'; +import Container from 'typedi'; + +import { CredentialsService } from '@/credentials/credentials.service'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { User } from '@/databases/entities/user'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { createTeamProject, linkUserToProject } from '@test-integration/db/projects'; + import { saveCredential, shareCredentialWithUsers } from '../shared/db/credentials'; import { createMember } from '../shared/db/users'; import { randomCredentialPayload } from '../shared/random'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import Container from 'typedi'; -import { CredentialsService } from '@/credentials/credentials.service'; import * as testDb from '../shared/test-db'; -import { createTeamProject, linkUserToProject } from '@test-integration/db/projects'; const credentialPayload = randomCredentialPayload(); let memberWhoOwnsCredential: User; diff --git a/packages/cli/test/integration/cta.service.test.ts b/packages/cli/test/integration/cta.service.test.ts index c1e4109b4e903..68c1f24c5f4e5 100644 --- a/packages/cli/test/integration/cta.service.test.ts +++ b/packages/cli/test/integration/cta.service.test.ts @@ -1,11 +1,13 @@ import Container from 'typedi'; -import * as testDb from './shared/test-db'; + +import type { User } from '@/databases/entities/user'; +import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { CtaService } from '@/services/cta.service'; + import { createUser } from './shared/db/users'; -import { createManyWorkflows } from './shared/db/workflows'; -import type { User } from '@/databases/entities/user'; import { createWorkflowStatisticsItem } from './shared/db/workflow-statistics'; -import { StatisticsNames } from '@/databases/entities/workflow-statistics'; +import { createManyWorkflows } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; describe('CtaService', () => { let ctaService: CtaService; diff --git a/packages/cli/test/integration/database/repositories/execution.repository.test.ts b/packages/cli/test/integration/database/repositories/execution.repository.test.ts index ade7254216d62..52884bd3e625f 100644 --- a/packages/cli/test/integration/database/repositories/execution.repository.test.ts +++ b/packages/cli/test/integration/database/repositories/execution.repository.test.ts @@ -1,8 +1,10 @@ import Container from 'typedi'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; + import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository'; -import * as testDb from '../../shared/test-db'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; + import { createWorkflow } from '../../shared/db/workflows'; +import * as testDb from '../../shared/test-db'; describe('ExecutionRepository', () => { beforeAll(async () => { diff --git a/packages/cli/test/integration/database/repositories/project.repository.test.ts b/packages/cli/test/integration/database/repositories/project.repository.test.ts index 8986b2ed3d092..cc494fd5425f2 100644 --- a/packages/cli/test/integration/database/repositories/project.repository.test.ts +++ b/packages/cli/test/integration/database/repositories/project.repository.test.ts @@ -1,12 +1,14 @@ -import Container from 'typedi'; -import { createMember, createOwner } from '../../shared/db/users'; -import * as testDb from '../../shared/test-db'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import { EntityNotFoundError } from '@n8n/typeorm'; -import { createTeamProject } from '../../shared/db/projects'; +import Container from 'typedi'; + import { AuthIdentity } from '@/databases/entities/auth-identity'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; +import { createTeamProject } from '../../shared/db/projects'; +import { createMember, createOwner } from '../../shared/db/users'; +import * as testDb from '../../shared/test-db'; + describe('ProjectRepository', () => { beforeAll(async () => { await testDb.init(); diff --git a/packages/cli/test/integration/database/repositories/workflow.repository.test.ts b/packages/cli/test/integration/database/repositories/workflow.repository.test.ts index 5c64ad3fc0c71..acff2cbce9738 100644 --- a/packages/cli/test/integration/database/repositories/workflow.repository.test.ts +++ b/packages/cli/test/integration/database/repositories/workflow.repository.test.ts @@ -2,12 +2,12 @@ import Container from 'typedi'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import * as testDb from '../../shared/test-db'; import { createWorkflowWithTrigger, createWorkflow, getAllWorkflows, } from '../../shared/db/workflows'; +import * as testDb from '../../shared/test-db'; describe('WorkflowRepository', () => { beforeAll(async () => { diff --git a/packages/cli/test/integration/debug.controller.test.ts b/packages/cli/test/integration/debug.controller.test.ts index 891b23c52fc38..723edea58ab33 100644 --- a/packages/cli/test/integration/debug.controller.test.ts +++ b/packages/cli/test/integration/debug.controller.test.ts @@ -1,15 +1,15 @@ -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { generateNanoId } from '@/databases/utils/generators'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { OrchestrationService } from '@/services/orchestration.service'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import { MultiMainSetup } from '@/services/orchestration/main/multi-main-setup.ee'; +import { OrchestrationService } from '@/services/orchestration.service'; -import { mockInstance } from '../shared/mocking'; -import { randomName } from './shared/random'; -import { setupTestServer } from './shared/utils'; import { createOwner } from './shared/db/users'; +import { randomName } from './shared/random'; import type { SuperAgentTest } from './shared/types'; +import { setupTestServer } from './shared/utils'; +import { mockInstance } from '../shared/mocking'; describe('DebugController', () => { const workflowRepository = mockInstance(WorkflowRepository); diff --git a/packages/cli/test/integration/environments/source-control-import.service.test.ts b/packages/cli/test/integration/environments/source-control-import.service.test.ts index 4f6d78bcf6c4f..78732a99bcd17 100644 --- a/packages/cli/test/integration/environments/source-control-import.service.test.ts +++ b/packages/cli/test/integration/environments/source-control-import.service.test.ts @@ -1,23 +1,24 @@ -import fsp from 'node:fs/promises'; -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; -import * as utils from 'n8n-workflow'; import { Cipher } from 'n8n-core'; -import { nanoid } from 'nanoid'; import type { InstanceSettings } from 'n8n-core'; +import * as utils from 'n8n-workflow'; +import { nanoid } from 'nanoid'; +import fsp from 'node:fs/promises'; +import Container from 'typedi'; -import * as testDb from '../shared/test-db'; -import { SourceControlImportService } from '@/environments/source-control/source-control-import.service.ee'; -import { createMember, getGlobalOwner } from '../shared/db/users'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { mockInstance } from '../../shared/mocking'; -import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +import { SourceControlImportService } from '@/environments/source-control/source-control-import.service.ee'; import type { ExportableCredential } from '@/environments/source-control/types/exportable-credential'; -import { createTeamProject, getPersonalProject } from '../shared/db/projects'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; +import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; + +import { mockInstance } from '../../shared/mocking'; import { saveCredential } from '../shared/db/credentials'; +import { createTeamProject, getPersonalProject } from '../shared/db/projects'; +import { createMember, getGlobalOwner } from '../shared/db/users'; import { randomCredentialPayload } from '../shared/random'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import * as testDb from '../shared/test-db'; describe('SourceControlImportService', () => { let service: SourceControlImportService; diff --git a/packages/cli/test/integration/environments/source-control.test.ts b/packages/cli/test/integration/environments/source-control.test.ts index 2ee20160a8a32..f983b899aaf76 100644 --- a/packages/cli/test/integration/environments/source-control.test.ts +++ b/packages/cli/test/integration/environments/source-control.test.ts @@ -1,16 +1,16 @@ import { Container } from 'typedi'; -import type { User } from '@/databases/entities/user'; import config from '@/config'; +import type { User } from '@/databases/entities/user'; import { SourceControlPreferencesService } from '@/environments/source-control/source-control-preferences.service.ee'; import { SourceControlService } from '@/environments/source-control/source-control.service.ee'; import type { SourceControlledFile } from '@/environments/source-control/types/source-controlled-file'; +import { Telemetry } from '@/telemetry'; +import { mockInstance } from '@test/mocking'; -import * as utils from '../shared/utils'; import { createUser } from '../shared/db/users'; import type { SuperAgentTest } from '../shared/types'; -import { mockInstance } from '@test/mocking'; -import { Telemetry } from '@/telemetry'; +import * as utils from '../shared/utils'; let authOwnerAgent: SuperAgentTest; let owner: User; diff --git a/packages/cli/test/integration/eventbus.ee.test.ts b/packages/cli/test/integration/eventbus.ee.test.ts index 9af3e0702df0c..9b12cc53d549d 100644 --- a/packages/cli/test/integration/eventbus.ee.test.ts +++ b/packages/cli/test/integration/eventbus.ee.test.ts @@ -1,7 +1,4 @@ -import { Container } from 'typedi'; import axios from 'axios'; -import syslog from 'syslog-client'; -import { v4 as uuid } from 'uuid'; import type { MessageEventBusDestinationSentryOptions, MessageEventBusDestinationSyslogOptions, @@ -12,21 +9,24 @@ import { defaultMessageEventBusDestinationSyslogOptions, defaultMessageEventBusDestinationWebhookOptions, } from 'n8n-workflow'; +import syslog from 'syslog-client'; +import { Container } from 'typedi'; +import { v4 as uuid } from 'uuid'; import type { User } from '@/databases/entities/user'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import type { EventNamesTypes } from '@/eventbus/event-message-classes'; +import { EventMessageAudit } from '@/eventbus/event-message-classes/event-message-audit'; import { EventMessageGeneric } from '@/eventbus/event-message-classes/event-message-generic'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; +import type { MessageEventBusDestinationSentry } from '@/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee'; import type { MessageEventBusDestinationSyslog } from '@/eventbus/message-event-bus-destination/message-event-bus-destination-syslog.ee'; import type { MessageEventBusDestinationWebhook } from '@/eventbus/message-event-bus-destination/message-event-bus-destination-webhook.ee'; -import type { MessageEventBusDestinationSentry } from '@/eventbus/message-event-bus-destination/message-event-bus-destination-sentry.ee'; -import { EventMessageAudit } from '@/eventbus/event-message-classes/event-message-audit'; -import type { EventNamesTypes } from '@/eventbus/event-message-classes'; import { ExecutionRecoveryService } from '@/executions/execution-recovery.service'; -import * as utils from './shared/utils'; import { createUser } from './shared/db/users'; -import { mockInstance } from '../shared/mocking'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils'; +import { mockInstance } from '../shared/mocking'; jest.unmock('@/eventbus/message-event-bus/message-event-bus'); jest.mock('axios'); diff --git a/packages/cli/test/integration/eventbus.test.ts b/packages/cli/test/integration/eventbus.test.ts index 4ac70b7c3f7fd..b4e80dfde929e 100644 --- a/packages/cli/test/integration/eventbus.test.ts +++ b/packages/cli/test/integration/eventbus.test.ts @@ -2,10 +2,10 @@ import type { User } from '@/databases/entities/user'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { ExecutionRecoveryService } from '@/executions/execution-recovery.service'; -import * as utils from './shared/utils/'; import { createUser } from './shared/db/users'; -import { mockInstance } from '../shared/mocking'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; +import { mockInstance } from '../shared/mocking'; /** * NOTE: due to issues with mocking the MessageEventBus in multiple tests running in parallel, diff --git a/packages/cli/test/integration/execution.service.integration.test.ts b/packages/cli/test/integration/execution.service.integration.test.ts index 72240c33d5461..05061e536e7f2 100644 --- a/packages/cli/test/integration/execution.service.integration.test.ts +++ b/packages/cli/test/integration/execution.service.integration.test.ts @@ -1,13 +1,15 @@ -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { ExecutionService } from '@/executions/execution.service'; import { mock } from 'jest-mock-extended'; import Container from 'typedi'; -import { createWorkflow } from './shared/db/workflows'; -import { annotateExecution, createAnnotationTags, createExecution } from './shared/db/executions'; -import * as testDb from './shared/test-db'; + +import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { ExecutionService } from '@/executions/execution.service'; import type { ExecutionSummaries } from '@/executions/execution.types'; -import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; + +import { annotateExecution, createAnnotationTags, createExecution } from './shared/db/executions'; +import { createWorkflow } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; describe('ExecutionService', () => { let executionService: ExecutionService; diff --git a/packages/cli/test/integration/executions.controller.test.ts b/packages/cli/test/integration/executions.controller.test.ts index ab02a5047ecb7..341c7364e51e2 100644 --- a/packages/cli/test/integration/executions.controller.test.ts +++ b/packages/cli/test/integration/executions.controller.test.ts @@ -1,16 +1,15 @@ +import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; import type { User } from '@/databases/entities/user'; +import { WaitTracker } from '@/wait-tracker'; import { createSuccessfulExecution, getAllExecutions } from './shared/db/executions'; +import { createTeamProject, linkUserToProject } from './shared/db/projects'; import { createMember, createOwner } from './shared/db/users'; import { createWorkflow, shareWorkflowWithUsers } from './shared/db/workflows'; import * as testDb from './shared/test-db'; import { setupTestServer } from './shared/utils'; import { mockInstance } from '../shared/mocking'; -import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; -import { WaitTracker } from '@/wait-tracker'; -import { createTeamProject, linkUserToProject } from './shared/db/projects'; - mockInstance(WaitTracker); mockInstance(ConcurrencyControlService, { // @ts-expect-error Private property diff --git a/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts b/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts index 0cf6a27f798cd..b3560b92621c0 100644 --- a/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts +++ b/packages/cli/test/integration/external-secrets/external-secrets.api.test.ts @@ -1,27 +1,27 @@ -import { Container } from 'typedi'; +import { mock } from 'jest-mock-extended'; import { Cipher } from 'n8n-core'; import { jsonParse, type IDataObject } from 'n8n-workflow'; -import { mock } from 'jest-mock-extended'; +import { Container } from 'typedi'; -import { License } from '@/license'; -import type { ExternalSecretsSettings, SecretsProviderState } from '@/interfaces'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { ExternalSecretsProviders } from '@/external-secrets/external-secrets-providers.ee'; import config from '@/config'; -import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; import { CREDENTIAL_BLANKING_VALUE } from '@/constants'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import type { EventService } from '@/events/event.service'; +import { ExternalSecretsManager } from '@/external-secrets/external-secrets-manager.ee'; +import { ExternalSecretsProviders } from '@/external-secrets/external-secrets-providers.ee'; +import type { ExternalSecretsSettings, SecretsProviderState } from '@/interfaces'; +import { License } from '@/license'; -import { mockInstance } from '../../shared/mocking'; -import { setupTestServer } from '../shared/utils'; -import { createOwner, createUser } from '../shared/db/users'; import { DummyProvider, FailedProvider, MockProviders, TestFailProvider, } from '../../shared/external-secrets/utils'; +import { mockInstance } from '../../shared/mocking'; +import { createOwner, createUser } from '../shared/db/users'; import type { SuperAgentTest } from '../shared/types'; -import type { EventService } from '@/events/event.service'; +import { setupTestServer } from '../shared/utils'; let authOwnerAgent: SuperAgentTest; let authMemberAgent: SuperAgentTest; diff --git a/packages/cli/test/integration/healthcheck.controller.test.ts b/packages/cli/test/integration/healthcheck.controller.test.ts index 61a8f164bb18b..b98be04eaf2b9 100644 --- a/packages/cli/test/integration/healthcheck.controller.test.ts +++ b/packages/cli/test/integration/healthcheck.controller.test.ts @@ -1,6 +1,7 @@ -import * as testDb from './shared/test-db'; import { setupTestServer } from '@test-integration/utils'; +import * as testDb from './shared/test-db'; + const testServer = setupTestServer({ endpointGroups: ['health'] }); describe('HealthcheckController', () => { diff --git a/packages/cli/test/integration/import.service.test.ts b/packages/cli/test/integration/import.service.test.ts index b55a8533659ab..39cadde676b1f 100644 --- a/packages/cli/test/integration/import.service.test.ts +++ b/packages/cli/test/integration/import.service.test.ts @@ -1,17 +1,18 @@ -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; -import { v4 as uuid } from 'uuid'; import type { INode } from 'n8n-workflow'; +import Container from 'typedi'; +import { v4 as uuid } from 'uuid'; +import type { Project } from '@/databases/entities/project'; +import { TagEntity } from '@/databases/entities/tag-entity'; +import type { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { TagRepository } from '@/databases/repositories/tag.repository'; -import { ImportService } from '@/services/import.service'; -import { TagEntity } from '@/databases/entities/tag-entity'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { ImportService } from '@/services/import.service'; -import * as testDb from './shared/test-db'; -import { mockInstance } from '../shared/mocking'; +import { getPersonalProject } from './shared/db/projects'; import { createMember, createOwner } from './shared/db/users'; import { createWorkflow, @@ -19,10 +20,8 @@ import { getWorkflowById, newWorkflow, } from './shared/db/workflows'; - -import type { User } from '@/databases/entities/user'; -import type { Project } from '@/databases/entities/project'; -import { getPersonalProject } from './shared/db/projects'; +import * as testDb from './shared/test-db'; +import { mockInstance } from '../shared/mocking'; describe('ImportService', () => { let importService: ImportService; diff --git a/packages/cli/test/integration/ldap/ldap.api.test.ts b/packages/cli/test/integration/ldap/ldap.api.test.ts index f30889492bb26..17573f49f59bb 100644 --- a/packages/cli/test/integration/ldap/ldap.api.test.ts +++ b/packages/cli/test/integration/ldap/ldap.api.test.ts @@ -1,24 +1,24 @@ -import { Container } from 'typedi'; -import type { Entry as LdapUser } from 'ldapts'; import { Not } from '@n8n/typeorm'; +import type { Entry as LdapUser } from 'ldapts'; import { Cipher } from 'n8n-core'; +import { Container } from 'typedi'; import config from '@/config'; import type { User } from '@/databases/entities/user'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { AuthProviderSyncHistoryRepository } from '@/databases/repositories/auth-provider-sync-history.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { LDAP_DEFAULT_CONFIGURATION } from '@/ldap/constants'; -import { LdapService } from '@/ldap/ldap.service.ee'; import { saveLdapSynchronization } from '@/ldap/helpers.ee'; +import { LdapService } from '@/ldap/ldap.service.ee'; import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; import { randomEmail, randomName, uniqueId } from './../shared/random'; -import * as testDb from '../shared/test-db'; -import * as utils from '../shared/utils/'; -import { createLdapUser, createUser, getAllUsers, getLdapIdentities } from '../shared/db/users'; import { getPersonalProject } from '../shared/db/projects'; +import { createLdapUser, createUser, getAllUsers, getLdapIdentities } from '../shared/db/users'; import { createLdapConfig, defaultLdapConfig } from '../shared/ldap'; +import * as testDb from '../shared/test-db'; import type { SuperAgentTest } from '../shared/types'; +import * as utils from '../shared/utils/'; jest.mock('@/telemetry'); diff --git a/packages/cli/test/integration/license-metrics.repository.test.ts b/packages/cli/test/integration/license-metrics.repository.test.ts index 4fbad50ca4f8e..5396b4681f8e2 100644 --- a/packages/cli/test/integration/license-metrics.repository.test.ts +++ b/packages/cli/test/integration/license-metrics.repository.test.ts @@ -1,11 +1,13 @@ +import Container from 'typedi'; + +import { StatisticsNames } from '@/databases/entities/workflow-statistics'; import { LicenseMetricsRepository } from '@/databases/repositories/license-metrics.repository'; +import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; + +import { createManyCredentials } from './shared/db/credentials'; import { createAdmin, createMember, createOwner, createUser } from './shared/db/users'; -import * as testDb from './shared/test-db'; -import Container from 'typedi'; import { createManyWorkflows } from './shared/db/workflows'; -import { createManyCredentials } from './shared/db/credentials'; -import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; -import { StatisticsNames } from '@/databases/entities/workflow-statistics'; +import * as testDb from './shared/test-db'; describe('LicenseMetricsRepository', () => { let licenseMetricsRepository: LicenseMetricsRepository; diff --git a/packages/cli/test/integration/license.api.test.ts b/packages/cli/test/integration/license.api.test.ts index d20476831d747..ff40a699eaafc 100644 --- a/packages/cli/test/integration/license.api.test.ts +++ b/packages/cli/test/integration/license.api.test.ts @@ -1,14 +1,15 @@ import nock from 'nock'; + import config from '@/config'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import type { User } from '@/databases/entities/user'; import type { ILicensePostResponse, ILicenseReadResponse } from '@/interfaces'; import { License } from '@/license'; -import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; import { createUserShell } from './shared/db/users'; +import * as testDb from './shared/test-db'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; const MOCK_SERVER_URL = 'https://server.com/v1'; const MOCK_RENEW_OFFSET = 259200; diff --git a/packages/cli/test/integration/me.api.test.ts b/packages/cli/test/integration/me.api.test.ts index 72ecb09b32aa1..df9b7c48b6f70 100644 --- a/packages/cli/test/integration/me.api.test.ts +++ b/packages/cli/test/integration/me.api.test.ts @@ -1,20 +1,20 @@ -import { Container } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { IsNull } from '@n8n/typeorm'; +import type { IPersonalizationSurveyAnswersV4 } from 'n8n-workflow'; +import { Container } from 'typedi'; import validator from 'validator'; import type { User } from '@/databases/entities/user'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { UserRepository } from '@/databases/repositories/user.repository'; +import { mockInstance } from '@test/mocking'; import { SUCCESS_RESPONSE_BODY } from './shared/constants'; +import { addApiKey, createOwner, createUser, createUserShell } from './shared/db/users'; import { randomApiKey, randomEmail, randomName, randomValidPassword } from './shared/random'; import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; -import { addApiKey, createOwner, createUser, createUserShell } from './shared/db/users'; import type { SuperAgentTest } from './shared/types'; -import { mockInstance } from '@test/mocking'; -import { GlobalConfig } from '@n8n/config'; -import type { IPersonalizationSurveyAnswersV4 } from 'n8n-workflow'; +import * as utils from './shared/utils/'; const testServer = utils.setupTestServer({ endpointGroups: ['me'] }); diff --git a/packages/cli/test/integration/mfa/mfa.api.test.ts b/packages/cli/test/integration/mfa/mfa.api.test.ts index 296009c04d8ca..0062f87e8937e 100644 --- a/packages/cli/test/integration/mfa/mfa.api.test.ts +++ b/packages/cli/test/integration/mfa/mfa.api.test.ts @@ -1,5 +1,5 @@ -import Container from 'typedi'; import { randomInt, randomString } from 'n8n-workflow'; +import Container from 'typedi'; import { AuthService } from '@/auth/auth.service'; import config from '@/config'; @@ -7,10 +7,10 @@ import type { User } from '@/databases/entities/user'; import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; import { TOTPService } from '@/mfa/totp.service'; +import { createUser, createUserWithMfaEnabled } from '../shared/db/users'; +import { randomValidPassword, uniqueId } from '../shared/random'; import * as testDb from '../shared/test-db'; import * as utils from '../shared/utils'; -import { randomValidPassword, uniqueId } from '../shared/random'; -import { createUser, createUserWithMfaEnabled } from '../shared/db/users'; jest.mock('@/telemetry'); diff --git a/packages/cli/test/integration/middlewares/body-parser.test.ts b/packages/cli/test/integration/middlewares/body-parser.test.ts index 00163e05bbf67..a3381fe9e8408 100644 --- a/packages/cli/test/integration/middlewares/body-parser.test.ts +++ b/packages/cli/test/integration/middlewares/body-parser.test.ts @@ -1,7 +1,8 @@ -import { createServer } from 'http'; -import { gzipSync, deflateSync } from 'zlib'; import type { Request, Response } from 'express'; +import { createServer } from 'http'; import request from 'supertest'; +import { gzipSync, deflateSync } from 'zlib'; + import { rawBodyReader, bodyParser } from '@/middlewares/body-parser'; describe('bodyParser', () => { diff --git a/packages/cli/test/integration/owner.api.test.ts b/packages/cli/test/integration/owner.api.test.ts index 43a469b5f899a..fe5284ffbed6a 100644 --- a/packages/cli/test/integration/owner.api.test.ts +++ b/packages/cli/test/integration/owner.api.test.ts @@ -5,6 +5,7 @@ import config from '@/config'; import type { User } from '@/databases/entities/user'; import { UserRepository } from '@/databases/repositories/user.repository'; +import { createUserShell } from './shared/db/users'; import { randomEmail, randomInvalidPassword, @@ -13,7 +14,6 @@ import { } from './shared/random'; import * as testDb from './shared/test-db'; import * as utils from './shared/utils/'; -import { createUserShell } from './shared/db/users'; const testServer = utils.setupTestServer({ endpointGroups: ['owner'] }); diff --git a/packages/cli/test/integration/password-reset.api.test.ts b/packages/cli/test/integration/password-reset.api.test.ts index 7689ba9b793d7..89d66c3f21b6e 100644 --- a/packages/cli/test/integration/password-reset.api.test.ts +++ b/packages/cli/test/integration/password-reset.api.test.ts @@ -1,22 +1,21 @@ -import { v4 as uuid } from 'uuid'; import { compare } from 'bcryptjs'; -import { Container } from 'typedi'; import { mock } from 'jest-mock-extended'; import { randomString } from 'n8n-workflow'; +import { Container } from 'typedi'; +import { v4 as uuid } from 'uuid'; import { AuthService } from '@/auth/auth.service'; -import { License } from '@/license'; import config from '@/config'; import type { User } from '@/databases/entities/user'; -import { setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { ExternalHooks } from '@/external-hooks'; +import { License } from '@/license'; import { JwtService } from '@/services/jwt.service'; -import { UserManagementMailer } from '@/user-management/email'; -import { UserRepository } from '@/databases/repositories/user.repository'; import { PasswordUtility } from '@/services/password.utility'; +import { setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; +import { UserManagementMailer } from '@/user-management/email'; -import { mockInstance } from '../shared/mocking'; -import { getAuthToken, setupTestServer } from './shared/utils'; +import { createUser } from './shared/db/users'; import { randomEmail, randomInvalidPassword, @@ -24,7 +23,8 @@ import { randomValidPassword, } from './shared/random'; import * as testDb from './shared/test-db'; -import { createUser } from './shared/db/users'; +import { getAuthToken, setupTestServer } from './shared/utils'; +import { mockInstance } from '../shared/mocking'; config.set('userManagement.jwtSecret', randomString(5, 10)); diff --git a/packages/cli/test/integration/permission-checker.test.ts b/packages/cli/test/integration/permission-checker.test.ts index b64d840bf1fe1..e746ec29f7c58 100644 --- a/packages/cli/test/integration/permission-checker.test.ts +++ b/packages/cli/test/integration/permission-checker.test.ts @@ -1,26 +1,27 @@ -import { v4 as uuid } from 'uuid'; -import { Container } from 'typedi'; import type { INode, INodeTypeData } from 'n8n-workflow'; import { randomInt } from 'n8n-workflow'; +import { Container } from 'typedi'; +import { v4 as uuid } from 'uuid'; + +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { NodeTypes } from '@/node-types'; import { OwnershipService } from '@/services/ownership.service'; import { PermissionChecker } from '@/user-management/permission-checker'; -import { mockInstance } from '../shared/mocking'; +import { affixRoleToSaveCredential } from './shared/db/credentials'; +import { getPersonalProject } from './shared/db/projects'; +import { createOwner, createUser } from './shared/db/users'; import { randomCredentialPayload as randomCred } from './shared/random'; import * as testDb from './shared/test-db'; import type { SaveCredentialFunction } from './shared/types'; -import { affixRoleToSaveCredential } from './shared/db/credentials'; -import { createOwner, createUser } from './shared/db/users'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import { getPersonalProject } from './shared/db/projects'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { Project } from '@/databases/entities/project'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { mockInstance } from '../shared/mocking'; const ownershipService = mockInstance(OwnershipService); diff --git a/packages/cli/test/integration/project.api.test.ts b/packages/cli/test/integration/project.api.test.ts index 7b405749a39fd..14707ad7643c9 100644 --- a/packages/cli/test/integration/project.api.test.ts +++ b/packages/cli/test/integration/project.api.test.ts @@ -1,35 +1,37 @@ -import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; -import { createMember, createOwner, createUser } from './shared/db/users'; -import { - createTeamProject, - linkUserToProject, - getPersonalProject, - findProject, - getProjectRelations, -} from './shared/db/projects'; +import type { Scope } from '@n8n/permissions'; +import { EntityNotFoundError } from '@n8n/typeorm'; import Container from 'typedi'; + +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import type { Project } from '@/databases/entities/project'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; import type { ProjectRole } from '@/databases/entities/project-relation'; -import { EntityNotFoundError } from '@n8n/typeorm'; -import { createWorkflow, shareWorkflowWithProjects } from './shared/db/workflows'; +import type { GlobalRole } from '@/databases/entities/user'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { getWorkflowById } from '@/public-api/v1/handlers/workflows/workflows.service'; +import { CacheService } from '@/services/cache/cache.service'; +import { RoleService } from '@/services/role.service'; + import { getCredentialById, saveCredential, shareCredentialWithProjects, } from './shared/db/credentials'; +import { + createTeamProject, + linkUserToProject, + getPersonalProject, + findProject, + getProjectRelations, +} from './shared/db/projects'; +import { createMember, createOwner, createUser } from './shared/db/users'; +import { createWorkflow, shareWorkflowWithProjects } from './shared/db/workflows'; import { randomCredentialPayload } from './shared/random'; -import { getWorkflowById } from '@/public-api/v1/handlers/workflows/workflows.service'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; -import type { GlobalRole } from '@/databases/entities/user'; -import type { Scope } from '@n8n/permissions'; -import { CacheService } from '@/services/cache/cache.service'; +import * as testDb from './shared/test-db'; +import * as utils from './shared/utils/'; import { mockInstance } from '../shared/mocking'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { RoleService } from '@/services/role.service'; const testServer = utils.setupTestServer({ endpointGroups: ['project'], diff --git a/packages/cli/test/integration/project.service.integration.test.ts b/packages/cli/test/integration/project.service.integration.test.ts index ccb5b8865bcef..5d425d17eeffc 100644 --- a/packages/cli/test/integration/project.service.integration.test.ts +++ b/packages/cli/test/integration/project.service.integration.test.ts @@ -1,10 +1,12 @@ import Container from 'typedi'; -import { ProjectService } from '@/services/project.service'; -import * as testDb from './shared/test-db'; + import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; +import { ProjectService } from '@/services/project.service'; + +import { linkUserToProject, createTeamProject } from './shared/db/projects'; import { createUser } from './shared/db/users'; import { createWorkflow } from './shared/db/workflows'; -import { linkUserToProject, createTeamProject } from './shared/db/projects'; +import * as testDb from './shared/test-db'; describe('ProjectService', () => { let projectService: ProjectService; diff --git a/packages/cli/test/integration/prometheus-metrics.test.ts b/packages/cli/test/integration/prometheus-metrics.test.ts index c863950e4880b..2a13d2f09175a 100644 --- a/packages/cli/test/integration/prometheus-metrics.test.ts +++ b/packages/cli/test/integration/prometheus-metrics.test.ts @@ -1,13 +1,14 @@ -import { Container } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import { parse as semverParse } from 'semver'; import request, { type Response } from 'supertest'; +import { Container } from 'typedi'; +import config from '@/config'; import { N8N_VERSION } from '@/constants'; +import { EventService } from '@/events/event.service'; import { PrometheusMetricsService } from '@/metrics/prometheus-metrics.service'; + import { setupTestServer } from './shared/utils'; -import { GlobalConfig } from '@n8n/config'; -import config from '@/config'; -import { EventService } from '@/events/event.service'; jest.unmock('@/eventbus/message-event-bus/message-event-bus'); diff --git a/packages/cli/test/integration/pruning.service.test.ts b/packages/cli/test/integration/pruning.service.test.ts index 36ec15e490419..990d0aec3ae0e 100644 --- a/packages/cli/test/integration/pruning.service.test.ts +++ b/packages/cli/test/integration/pruning.service.test.ts @@ -1,24 +1,24 @@ -import config from '@/config'; +import { mock } from 'jest-mock-extended'; import { BinaryDataService, InstanceSettings } from 'n8n-core'; import type { ExecutionStatus } from 'n8n-workflow'; import Container from 'typedi'; -import * as testDb from './shared/test-db'; +import config from '@/config'; +import { TIME } from '@/constants'; import type { ExecutionEntity } from '@/databases/entities/execution-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { TIME } from '@/constants'; -import { PruningService } from '@/services/pruning.service'; import { Logger } from '@/logger'; +import { PruningService } from '@/services/pruning.service'; -import { mockInstance } from '../shared/mocking'; -import { createWorkflow } from './shared/db/workflows'; import { annotateExecution, createExecution, createSuccessfulExecution, } from './shared/db/executions'; -import { mock } from 'jest-mock-extended'; +import { createWorkflow } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; +import { mockInstance } from '../shared/mocking'; describe('softDeleteOnPruningCycle()', () => { let pruningService: PruningService; diff --git a/packages/cli/test/integration/public-api/credentials.test.ts b/packages/cli/test/integration/public-api/credentials.test.ts index 08812bf6888af..7323de391eb0d 100644 --- a/packages/cli/test/integration/public-api/credentials.test.ts +++ b/packages/cli/test/integration/public-api/credentials.test.ts @@ -1,18 +1,18 @@ -import { Container } from 'typedi'; import { randomString } from 'n8n-workflow'; +import { Container } from 'typedi'; import type { User } from '@/databases/entities/user'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; +import { createTeamProject } from '@test-integration/db/projects'; -import { randomApiKey, randomName } from '../shared/random'; -import * as utils from '../shared/utils/'; -import type { CredentialPayload, SaveCredentialFunction } from '../shared/types'; -import * as testDb from '../shared/test-db'; import { affixRoleToSaveCredential, createCredentials } from '../shared/db/credentials'; import { addApiKey, createUser, createUserShell } from '../shared/db/users'; +import { randomApiKey, randomName } from '../shared/random'; +import * as testDb from '../shared/test-db'; +import type { CredentialPayload, SaveCredentialFunction } from '../shared/types'; import type { SuperAgentTest } from '../shared/types'; -import { createTeamProject } from '@test-integration/db/projects'; +import * as utils from '../shared/utils/'; let owner: User; let member: User; diff --git a/packages/cli/test/integration/public-api/executions.test.ts b/packages/cli/test/integration/public-api/executions.test.ts index fd597baf838a8..019f69adc5d99 100644 --- a/packages/cli/test/integration/public-api/executions.test.ts +++ b/packages/cli/test/integration/public-api/executions.test.ts @@ -1,15 +1,10 @@ -import type { User } from '@/databases/entities/user'; import type { ActiveWorkflowManager } from '@/active-workflow-manager'; +import type { ExecutionEntity } from '@/databases/entities/execution-entity'; +import type { User } from '@/databases/entities/user'; +import { Telemetry } from '@/telemetry'; +import { mockInstance } from '@test/mocking'; +import { createTeamProject } from '@test-integration/db/projects'; -import { randomApiKey } from '../shared/random'; -import * as utils from '../shared/utils/'; -import * as testDb from '../shared/test-db'; -import { createUser } from '../shared/db/users'; -import { - createManyWorkflows, - createWorkflow, - shareWorkflowWithUsers, -} from '../shared/db/workflows'; import { createErrorExecution, createExecution, @@ -17,11 +12,16 @@ import { createSuccessfulExecution, createWaitingExecution, } from '../shared/db/executions'; +import { createUser } from '../shared/db/users'; +import { + createManyWorkflows, + createWorkflow, + shareWorkflowWithUsers, +} from '../shared/db/workflows'; +import { randomApiKey } from '../shared/random'; +import * as testDb from '../shared/test-db'; import type { SuperAgentTest } from '../shared/types'; -import { mockInstance } from '@test/mocking'; -import { Telemetry } from '@/telemetry'; -import { createTeamProject } from '@test-integration/db/projects'; -import type { ExecutionEntity } from '@/databases/entities/execution-entity'; +import * as utils from '../shared/utils/'; let owner: User; let user1: User; diff --git a/packages/cli/test/integration/public-api/projects.test.ts b/packages/cli/test/integration/public-api/projects.test.ts index 0f6dc160b3041..2bc8e9346bd1d 100644 --- a/packages/cli/test/integration/public-api/projects.test.ts +++ b/packages/cli/test/integration/public-api/projects.test.ts @@ -1,10 +1,11 @@ -import { setupTestServer } from '@test-integration/utils'; -import { createMember, createOwner } from '@test-integration/db/users'; -import * as testDb from '../shared/test-db'; import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; -import { createTeamProject, getProjectByNameOrFail } from '@test-integration/db/projects'; -import { mockInstance } from '@test/mocking'; import { Telemetry } from '@/telemetry'; +import { mockInstance } from '@test/mocking'; +import { createTeamProject, getProjectByNameOrFail } from '@test-integration/db/projects'; +import { createMember, createOwner } from '@test-integration/db/users'; +import { setupTestServer } from '@test-integration/utils'; + +import * as testDb from '../shared/test-db'; describe('Projects in Public API', () => { const testServer = setupTestServer({ endpointGroups: ['publicApi'] }); diff --git a/packages/cli/test/integration/public-api/tags.test.ts b/packages/cli/test/integration/public-api/tags.test.ts index 754aa4e7f1712..776d79d368577 100644 --- a/packages/cli/test/integration/public-api/tags.test.ts +++ b/packages/cli/test/integration/public-api/tags.test.ts @@ -1,13 +1,14 @@ import { Container } from 'typedi'; + import type { User } from '@/databases/entities/user'; import { TagRepository } from '@/databases/repositories/tag.repository'; +import { createTag } from '../shared/db/tags'; +import { createUser } from '../shared/db/users'; import { randomApiKey } from '../shared/random'; -import * as utils from '../shared/utils/'; import * as testDb from '../shared/test-db'; -import { createUser } from '../shared/db/users'; -import { createTag } from '../shared/db/tags'; import type { SuperAgentTest } from '../shared/types'; +import * as utils from '../shared/utils/'; let owner: User; let member: User; diff --git a/packages/cli/test/integration/public-api/users.ee.test.ts b/packages/cli/test/integration/public-api/users.ee.test.ts index e3aca89ec2366..04649403d9be0 100644 --- a/packages/cli/test/integration/public-api/users.ee.test.ts +++ b/packages/cli/test/integration/public-api/users.ee.test.ts @@ -1,16 +1,16 @@ -import validator from 'validator'; import { v4 as uuid } from 'uuid'; +import validator from 'validator'; +import type { User } from '@/databases/entities/user'; import { License } from '@/license'; +import { createTeamProject, linkUserToProject } from '@test-integration/db/projects'; import { mockInstance } from '../../shared/mocking'; +import { createOwner, createUser, createUserShell } from '../shared/db/users'; import { randomApiKey } from '../shared/random'; -import * as utils from '../shared/utils/'; import * as testDb from '../shared/test-db'; -import { createOwner, createUser, createUserShell } from '../shared/db/users'; import type { SuperAgentTest } from '../shared/types'; -import { createTeamProject, linkUserToProject } from '@test-integration/db/projects'; -import type { User } from '@/databases/entities/user'; +import * as utils from '../shared/utils/'; mockInstance(License, { getUsersLimit: jest.fn().mockReturnValue(-1), diff --git a/packages/cli/test/integration/public-api/users.test.ts b/packages/cli/test/integration/public-api/users.test.ts index 7a68d8ddc37f1..f1e74684b44b5 100644 --- a/packages/cli/test/integration/public-api/users.test.ts +++ b/packages/cli/test/integration/public-api/users.test.ts @@ -1,9 +1,10 @@ +import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; +import { Telemetry } from '@/telemetry'; +import { mockInstance } from '@test/mocking'; +import { createMember, createOwner, getUserById } from '@test-integration/db/users'; import { setupTestServer } from '@test-integration/utils'; + import * as testDb from '../shared/test-db'; -import { createMember, createOwner, getUserById } from '@test-integration/db/users'; -import { mockInstance } from '@test/mocking'; -import { Telemetry } from '@/telemetry'; -import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; describe('Users in Public API', () => { const testServer = setupTestServer({ endpointGroups: ['publicApi'] }); diff --git a/packages/cli/test/integration/public-api/variables.test.ts b/packages/cli/test/integration/public-api/variables.test.ts index 2d0db72e37e36..c7f6ba341cbc1 100644 --- a/packages/cli/test/integration/public-api/variables.test.ts +++ b/packages/cli/test/integration/public-api/variables.test.ts @@ -1,8 +1,9 @@ -import { setupTestServer } from '@test-integration/utils'; +import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; import { createOwner } from '@test-integration/db/users'; import { createVariable, getVariableOrFail } from '@test-integration/db/variables'; +import { setupTestServer } from '@test-integration/utils'; + import * as testDb from '../shared/test-db'; -import { FeatureNotLicensedError } from '@/errors/feature-not-licensed.error'; describe('Variables in Public API', () => { const testServer = setupTestServer({ endpointGroups: ['publicApi'] }); diff --git a/packages/cli/test/integration/public-api/workflows.test.ts b/packages/cli/test/integration/public-api/workflows.test.ts index fcdb15f5eecd7..5bb661eaa3b9e 100644 --- a/packages/cli/test/integration/public-api/workflows.test.ts +++ b/packages/cli/test/integration/public-api/workflows.test.ts @@ -1,28 +1,28 @@ -import { Container } from 'typedi'; import type { INode } from 'n8n-workflow'; +import { Container } from 'typedi'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; import { STARTING_NODES } from '@/constants'; +import type { Project } from '@/databases/entities/project'; import type { TagEntity } from '@/databases/entities/tag-entity'; import type { User } from '@/databases/entities/user'; -import type { Project } from '@/databases/entities/project'; import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; import { ExecutionService } from '@/executions/execution.service'; +import { ProjectService } from '@/services/project.service'; +import { Telemetry } from '@/telemetry'; +import { createTeamProject } from '@test-integration/db/projects'; -import { randomApiKey } from '../shared/random'; -import * as utils from '../shared/utils/'; -import * as testDb from '../shared/test-db'; +import { mockInstance } from '../../shared/mocking'; +import { createTag } from '../shared/db/tags'; import { createUser } from '../shared/db/users'; import { createWorkflow, createWorkflowWithTrigger } from '../shared/db/workflows'; -import { createTag } from '../shared/db/tags'; -import { mockInstance } from '../../shared/mocking'; +import { randomApiKey } from '../shared/random'; +import * as testDb from '../shared/test-db'; import type { SuperAgentTest } from '../shared/types'; -import { Telemetry } from '@/telemetry'; -import { ProjectService } from '@/services/project.service'; -import { createTeamProject } from '@test-integration/db/projects'; +import * as utils from '../shared/utils/'; mockInstance(Telemetry); diff --git a/packages/cli/test/integration/role.api.test.ts b/packages/cli/test/integration/role.api.test.ts index a25dc2b131d16..ad961c2565d2b 100644 --- a/packages/cli/test/integration/role.api.test.ts +++ b/packages/cli/test/integration/role.api.test.ts @@ -1,15 +1,15 @@ -import { Container } from 'typedi'; import type { Scope } from '@n8n/permissions'; +import { Container } from 'typedi'; -import type { GlobalRole } from '@/databases/entities/user'; import type { ProjectRole } from '@/databases/entities/project-relation'; import type { CredentialSharingRole } from '@/databases/entities/shared-credentials'; import type { WorkflowSharingRole } from '@/databases/entities/shared-workflow'; +import type { GlobalRole } from '@/databases/entities/user'; import { RoleService } from '@/services/role.service'; -import * as utils from './shared/utils/'; import { createMember } from './shared/db/users'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; const testServer = utils.setupTestServer({ endpointGroups: ['role'], diff --git a/packages/cli/test/integration/saml/saml-helpers.test.ts b/packages/cli/test/integration/saml/saml-helpers.test.ts index b09103ab4f068..6ac48ee93b646 100644 --- a/packages/cli/test/integration/saml/saml-helpers.test.ts +++ b/packages/cli/test/integration/saml/saml-helpers.test.ts @@ -1,7 +1,7 @@ import * as helpers from '@/sso/saml/saml-helpers'; import type { SamlUserAttributes } from '@/sso/saml/types/saml-user-attributes'; -import { getPersonalProject } from '../shared/db/projects'; +import { getPersonalProject } from '../shared/db/projects'; import * as testDb from '../shared/test-db'; beforeAll(async () => { diff --git a/packages/cli/test/integration/saml/saml.api.test.ts b/packages/cli/test/integration/saml/saml.api.test.ts index c5db39eb821e3..94110454bd5d0 100644 --- a/packages/cli/test/integration/saml/saml.api.test.ts +++ b/packages/cli/test/integration/saml/saml.api.test.ts @@ -2,11 +2,11 @@ import type { User } from '@/databases/entities/user'; import { setSamlLoginEnabled } from '@/sso/saml/saml-helpers'; import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '@/sso/sso-helpers'; -import { randomEmail, randomName, randomValidPassword } from '../shared/random'; -import * as utils from '../shared/utils/'; import { sampleConfig } from './sample-metadata'; import { createOwner, createUser } from '../shared/db/users'; +import { randomEmail, randomName, randomValidPassword } from '../shared/random'; import type { SuperAgentTest } from '../shared/types'; +import * as utils from '../shared/utils/'; let someUser: User; let owner: User; diff --git a/packages/cli/test/integration/security-audit/credentials-risk-reporter.test.ts b/packages/cli/test/integration/security-audit/credentials-risk-reporter.test.ts index d9b14b8881d1e..8da1f3e1bf62f 100644 --- a/packages/cli/test/integration/security-audit/credentials-risk-reporter.test.ts +++ b/packages/cli/test/integration/security-audit/credentials-risk-reporter.test.ts @@ -1,15 +1,17 @@ +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; + import config from '@/config'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; +import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; +import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import { CREDENTIALS_REPORT } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; + import { getRiskSection } from './utils'; import * as testDb from '../shared/test-db'; -import { generateNanoId } from '@/databases/utils/generators'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import Container from 'typedi'; -import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; -import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository'; let securityAuditService: SecurityAuditService; diff --git a/packages/cli/test/integration/security-audit/database-risk-reporter.test.ts b/packages/cli/test/integration/security-audit/database-risk-reporter.test.ts index 819f1dbf9e578..d519f97a238a9 100644 --- a/packages/cli/test/integration/security-audit/database-risk-reporter.test.ts +++ b/packages/cli/test/integration/security-audit/database-risk-reporter.test.ts @@ -1,15 +1,17 @@ +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; + +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import { DATABASE_REPORT, SQL_NODE_TYPES, SQL_NODE_TYPES_WITH_QUERY_PARAMS, } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; + import { getRiskSection, saveManualTriggerWorkflow } from './utils'; import * as testDb from '../shared/test-db'; -import { generateNanoId } from '@/databases/utils/generators'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import Container from 'typedi'; let securityAuditService: SecurityAuditService; diff --git a/packages/cli/test/integration/security-audit/filesystem-risk-reporter.test.ts b/packages/cli/test/integration/security-audit/filesystem-risk-reporter.test.ts index a33d8cd74d57a..34bcb83b497ba 100644 --- a/packages/cli/test/integration/security-audit/filesystem-risk-reporter.test.ts +++ b/packages/cli/test/integration/security-audit/filesystem-risk-reporter.test.ts @@ -1,10 +1,12 @@ +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; + +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { FILESYSTEM_INTERACTION_NODE_TYPES, FILESYSTEM_REPORT } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; + import { getRiskSection, saveManualTriggerWorkflow } from './utils'; import * as testDb from '../shared/test-db'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import Container from 'typedi'; let securityAuditService: SecurityAuditService; diff --git a/packages/cli/test/integration/security-audit/instance-risk-reporter.test.ts b/packages/cli/test/integration/security-audit/instance-risk-reporter.test.ts index 722f06fffa3aa..4f355cbcbc603 100644 --- a/packages/cli/test/integration/security-audit/instance-risk-reporter.test.ts +++ b/packages/cli/test/integration/security-audit/instance-risk-reporter.test.ts @@ -1,6 +1,14 @@ +import { NodeConnectionType } from 'n8n-workflow'; +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; + +import config from '@/config'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { generateNanoId } from '@/databases/utils/generators'; import { INSTANCE_REPORT, WEBHOOK_VALIDATOR_NODE_TYPES } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; +import { toReportTitle } from '@/security-audit/utils'; + import { getRiskSection, saveManualTriggerWorkflow, @@ -9,12 +17,6 @@ import { simulateUpToDateInstance, } from './utils'; import * as testDb from '../shared/test-db'; -import { toReportTitle } from '@/security-audit/utils'; -import config from '@/config'; -import { generateNanoId } from '@/databases/utils/generators'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import Container from 'typedi'; -import { NodeConnectionType } from 'n8n-workflow'; let securityAuditService: SecurityAuditService; diff --git a/packages/cli/test/integration/security-audit/nodes-risk-reporter.test.ts b/packages/cli/test/integration/security-audit/nodes-risk-reporter.test.ts index 46b64d73fddc0..133a574d40887 100644 --- a/packages/cli/test/integration/security-audit/nodes-risk-reporter.test.ts +++ b/packages/cli/test/integration/security-audit/nodes-risk-reporter.test.ts @@ -1,15 +1,16 @@ -import { v4 as uuid } from 'uuid'; import { Container } from 'typedi'; -import { SecurityAuditService } from '@/security-audit/security-audit.service'; -import { OFFICIAL_RISKY_NODE_TYPES, NODES_REPORT } from '@/security-audit/constants'; -import { toReportTitle } from '@/security-audit/utils'; +import { v4 as uuid } from 'uuid'; + +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { NodeTypes } from '@/node-types'; +import { OFFICIAL_RISKY_NODE_TYPES, NODES_REPORT } from '@/security-audit/constants'; +import { SecurityAuditService } from '@/security-audit/security-audit.service'; +import { toReportTitle } from '@/security-audit/utils'; import { CommunityPackagesService } from '@/services/community-packages.service'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import { mockInstance } from '../../shared/mocking'; import { getRiskSection, MOCK_PACKAGE, saveManualTriggerWorkflow } from './utils'; +import { mockInstance } from '../../shared/mocking'; import * as testDb from '../shared/test-db'; const nodesAndCredentials = mockInstance(LoadNodesAndCredentials); diff --git a/packages/cli/test/integration/security-audit/utils.ts b/packages/cli/test/integration/security-audit/utils.ts index d245b801e0564..d74bcc9d8747f 100644 --- a/packages/cli/test/integration/security-audit/utils.ts +++ b/packages/cli/test/integration/security-audit/utils.ts @@ -1,13 +1,14 @@ +import { GlobalConfig } from '@n8n/config'; import nock from 'nock'; +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import { toReportTitle } from '@/security-audit/utils'; + import * as constants from '@/constants'; -import type { Risk } from '@/security-audit/types'; import type { InstalledNodes } from '@/databases/entities/installed-nodes'; import type { InstalledPackages } from '@/databases/entities/installed-packages'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import Container from 'typedi'; -import { GlobalConfig } from '@n8n/config'; +import type { Risk } from '@/security-audit/types'; +import { toReportTitle } from '@/security-audit/utils'; type GetSectionKind = C extends 'instance' ? Risk.InstanceSection diff --git a/packages/cli/test/integration/services/execution-metadata.service.test.ts b/packages/cli/test/integration/services/execution-metadata.service.test.ts index 4257979a98c7c..b69c78b5fe623 100644 --- a/packages/cli/test/integration/services/execution-metadata.service.test.ts +++ b/packages/cli/test/integration/services/execution-metadata.service.test.ts @@ -1,10 +1,12 @@ -import * as testDb from '../shared/test-db'; import Container from 'typedi'; + import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; import { ExecutionMetadataService } from '@/services/execution-metadata.service'; import { createExecution } from '@test-integration/db/executions'; import { createWorkflow } from '@test-integration/db/workflows'; +import * as testDb from '../shared/test-db'; + let executionMetadataRepository: ExecutionMetadataRepository; let executionMetadataService: ExecutionMetadataService; diff --git a/packages/cli/test/integration/services/project.service.test.ts b/packages/cli/test/integration/services/project.service.test.ts index b1b4f02880a7c..85393a4013278 100644 --- a/packages/cli/test/integration/services/project.service.test.ts +++ b/packages/cli/test/integration/services/project.service.test.ts @@ -1,11 +1,13 @@ -import { ProjectService } from '@/services/project.service'; -import * as testDb from '../shared/test-db'; +import type { Scope } from '@n8n/permissions'; import Container from 'typedi'; -import { createMember } from '../shared/db/users'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; + import type { ProjectRole } from '@/databases/entities/project-relation'; -import type { Scope } from '@n8n/permissions'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; +import { ProjectService } from '@/services/project.service'; + +import { createMember } from '../shared/db/users'; +import * as testDb from '../shared/test-db'; let projectRepository: ProjectRepository; let projectService: ProjectService; diff --git a/packages/cli/test/integration/services/workflow-static-data.service.test.ts b/packages/cli/test/integration/services/workflow-static-data.service.test.ts index f6a0233e346dd..c6ab9301ce8ad 100644 --- a/packages/cli/test/integration/services/workflow-static-data.service.test.ts +++ b/packages/cli/test/integration/services/workflow-static-data.service.test.ts @@ -1,11 +1,12 @@ -import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; -import * as testDb from '@test-integration/test-db'; -import Container from 'typedi'; -import { createWorkflow } from '@test-integration/db/workflows'; import { Workflow } from 'n8n-workflow'; -import { mockInstance } from '@test/mocking'; -import { NodeTypes } from '@/node-types'; +import Container from 'typedi'; + import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import { NodeTypes } from '@/node-types'; +import { WorkflowStaticDataService } from '@/workflows/workflow-static-data.service'; +import { mockInstance } from '@test/mocking'; +import { createWorkflow } from '@test-integration/db/workflows'; +import * as testDb from '@test-integration/test-db'; const nodeTypes = mockInstance(NodeTypes); let workflowStaticDataService: WorkflowStaticDataService; diff --git a/packages/cli/test/integration/shared/db/credentials.ts b/packages/cli/test/integration/shared/db/credentials.ts index 2174fd440ddb1..5593b7d55a90c 100644 --- a/packages/cli/test/integration/shared/db/credentials.ts +++ b/packages/cli/test/integration/shared/db/credentials.ts @@ -1,13 +1,15 @@ import { Container } from 'typedi'; + import { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { Project } from '@/databases/entities/project'; +import type { CredentialSharingRole } from '@/databases/entities/shared-credentials'; 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 { CredentialSharingRole } from '@/databases/entities/shared-credentials'; import type { ICredentialsDb } from '@/interfaces'; + import type { CredentialPayload } from '../types'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import type { Project } from '@/databases/entities/project'; export async function encryptCredentialData( credential: CredentialsEntity, diff --git a/packages/cli/test/integration/shared/db/executions.ts b/packages/cli/test/integration/shared/db/executions.ts index 09010ece914e6..dac31246810de 100644 --- a/packages/cli/test/integration/shared/db/executions.ts +++ b/packages/cli/test/integration/shared/db/executions.ts @@ -1,15 +1,16 @@ +import type { AnnotationVote } from 'n8n-workflow'; import Container from 'typedi'; + import type { ExecutionData } from '@/databases/entities/execution-data'; import type { ExecutionEntity } from '@/databases/entities/execution-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import { ExecutionRepository } from '@/databases/repositories/execution.repository'; +import { AnnotationTagRepository } from '@/databases/repositories/annotation-tag.repository'; import { ExecutionDataRepository } from '@/databases/repositories/execution-data.repository'; import { ExecutionMetadataRepository } from '@/databases/repositories/execution-metadata.repository'; +import { ExecutionRepository } from '@/databases/repositories/execution.repository'; import { ExecutionService } from '@/executions/execution.service'; -import type { AnnotationVote } from 'n8n-workflow'; -import { mockInstance } from '@test/mocking'; import { Telemetry } from '@/telemetry'; -import { AnnotationTagRepository } from '@/databases/repositories/annotation-tag.repository'; +import { mockInstance } from '@test/mocking'; mockInstance(Telemetry); diff --git a/packages/cli/test/integration/shared/db/projects.ts b/packages/cli/test/integration/shared/db/projects.ts index 4f569bcebd159..93310d5a99b8e 100644 --- a/packages/cli/test/integration/shared/db/projects.ts +++ b/packages/cli/test/integration/shared/db/projects.ts @@ -1,11 +1,12 @@ import Container from 'typedi'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { randomName } from '../random'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import type { User } from '@/databases/entities/user'; import type { Project } from '@/databases/entities/project'; import type { ProjectRelation, ProjectRole } from '@/databases/entities/project-relation'; +import type { User } from '@/databases/entities/user'; +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; + +import { randomName } from '../random'; export const createTeamProject = async (name?: string, adminUser?: User) => { const projectRepository = Container.get(ProjectRepository); diff --git a/packages/cli/test/integration/shared/db/tags.ts b/packages/cli/test/integration/shared/db/tags.ts index e3a61855e506c..b9d943b938f33 100644 --- a/packages/cli/test/integration/shared/db/tags.ts +++ b/packages/cli/test/integration/shared/db/tags.ts @@ -1,4 +1,5 @@ import Container from 'typedi'; + import type { TagEntity } from '@/databases/entities/tag-entity'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { TagRepository } from '@/databases/repositories/tag.repository'; diff --git a/packages/cli/test/integration/shared/db/users.ts b/packages/cli/test/integration/shared/db/users.ts index 45556ccb26ca2..83192822f9905 100644 --- a/packages/cli/test/integration/shared/db/users.ts +++ b/packages/cli/test/integration/shared/db/users.ts @@ -1,14 +1,15 @@ -import Container from 'typedi'; import { hash } from 'bcryptjs'; +import Container from 'typedi'; + import { AuthIdentity } from '@/databases/entities/auth-identity'; import { type GlobalRole, type User } from '@/databases/entities/user'; import { AuthIdentityRepository } from '@/databases/repositories/auth-identity.repository'; +import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; -import { TOTPService } from '@/mfa/totp.service'; import { MfaService } from '@/mfa/mfa.service'; +import { TOTPService } from '@/mfa/totp.service'; import { randomApiKey, randomEmail, randomName, randomValidPassword } from '../random'; -import { AuthUserRepository } from '@/databases/repositories/auth-user.repository'; // pre-computed bcrypt hash for the string 'password', using `await hash('password', 10)` const passwordHash = '$2a$10$njedH7S6V5898mj6p0Jr..IGY9Ms.qNwR7RbSzzX9yubJocKfvGGK'; diff --git a/packages/cli/test/integration/shared/db/variables.ts b/packages/cli/test/integration/shared/db/variables.ts index 68495da3b180f..582d3ccc1be00 100644 --- a/packages/cli/test/integration/shared/db/variables.ts +++ b/packages/cli/test/integration/shared/db/variables.ts @@ -1,8 +1,9 @@ -import { VariablesRepository } from '@/databases/repositories/variables.repository'; -import { generateNanoId } from '@/databases/utils/generators'; import { randomString } from 'n8n-workflow'; import Container from 'typedi'; +import { VariablesRepository } from '@/databases/repositories/variables.repository'; +import { generateNanoId } from '@/databases/utils/generators'; + export async function createVariable(key = randomString(5), value = randomString(5)) { return await Container.get(VariablesRepository).save({ id: generateNanoId(), key, value }); } diff --git a/packages/cli/test/integration/shared/db/workflow-history.ts b/packages/cli/test/integration/shared/db/workflow-history.ts index 09d2738c7100d..31d7e50cf5d61 100644 --- a/packages/cli/test/integration/shared/db/workflow-history.ts +++ b/packages/cli/test/integration/shared/db/workflow-history.ts @@ -1,5 +1,6 @@ import Container from 'typedi'; import { v4 as uuid } from 'uuid'; + import type { WorkflowHistory } from '@/databases/entities/workflow-history'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; diff --git a/packages/cli/test/integration/shared/db/workflow-statistics.ts b/packages/cli/test/integration/shared/db/workflow-statistics.ts index 1a5de72287369..842ce6518abe0 100644 --- a/packages/cli/test/integration/shared/db/workflow-statistics.ts +++ b/packages/cli/test/integration/shared/db/workflow-statistics.ts @@ -1,6 +1,7 @@ +import type { Workflow } from 'n8n-workflow'; import Container from 'typedi'; + import { StatisticsNames, type WorkflowStatistics } from '@/databases/entities/workflow-statistics'; -import type { Workflow } from 'n8n-workflow'; import { WorkflowStatisticsRepository } from '@/databases/repositories/workflow-statistics.repository'; export async function createWorkflowStatisticsItem( diff --git a/packages/cli/test/integration/shared/db/workflows.ts b/packages/cli/test/integration/shared/db/workflows.ts index 5b52dd62ffbfb..5c86f1dc3534b 100644 --- a/packages/cli/test/integration/shared/db/workflows.ts +++ b/packages/cli/test/integration/shared/db/workflows.ts @@ -1,15 +1,15 @@ -import Container from 'typedi'; import type { DeepPartial } from '@n8n/typeorm'; +import { NodeConnectionType } from 'n8n-workflow'; +import Container from 'typedi'; import { v4 as uuid } from 'uuid'; +import { Project } from '@/databases/entities/project'; +import type { SharedWorkflow, WorkflowSharingRole } from '@/databases/entities/shared-workflow'; import { User } from '@/databases/entities/user'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; -import type { SharedWorkflow, WorkflowSharingRole } from '@/databases/entities/shared-workflow'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; -import { Project } from '@/databases/entities/project'; -import { NodeConnectionType } from 'n8n-workflow'; export async function createManyWorkflows( amount: number, diff --git a/packages/cli/test/integration/shared/ldap.ts b/packages/cli/test/integration/shared/ldap.ts index 147b01f4c67bf..3f48cf2e3cfc5 100644 --- a/packages/cli/test/integration/shared/ldap.ts +++ b/packages/cli/test/integration/shared/ldap.ts @@ -1,9 +1,10 @@ -import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; -import type { LdapConfig } from '@/ldap/types'; -import { SettingsRepository } from '@/databases/repositories/settings.repository'; import { jsonParse } from 'n8n-workflow'; import Container from 'typedi'; +import { SettingsRepository } from '@/databases/repositories/settings.repository'; +import { LDAP_DEFAULT_CONFIGURATION, LDAP_FEATURE_NAME } from '@/ldap/constants'; +import type { LdapConfig } from '@/ldap/types'; + export const defaultLdapConfig = { ...LDAP_DEFAULT_CONFIGURATION, loginEnabled: true, diff --git a/packages/cli/test/integration/shared/random.ts b/packages/cli/test/integration/shared/random.ts index c6c62f7124091..a51fae3a051e8 100644 --- a/packages/cli/test/integration/shared/random.ts +++ b/packages/cli/test/integration/shared/random.ts @@ -1,7 +1,8 @@ -import { v4 as uuid } from 'uuid'; import { randomInt, randomString, UPPERCASE_LETTERS } from 'n8n-workflow'; +import { v4 as uuid } from 'uuid'; import { MIN_PASSWORD_CHAR_LENGTH, MAX_PASSWORD_CHAR_LENGTH } from '@/constants'; + import type { CredentialPayload } from './types'; export const randomApiKey = () => `n8n_api_${randomString(40)}`; diff --git a/packages/cli/test/integration/shared/test-db.ts b/packages/cli/test/integration/shared/test-db.ts index 1bb6944911944..365bc81fa847b 100644 --- a/packages/cli/test/integration/shared/test-db.ts +++ b/packages/cli/test/integration/shared/test-db.ts @@ -1,13 +1,13 @@ -import { Container } from 'typedi'; +import { GlobalConfig } from '@n8n/config'; import type { DataSourceOptions, Repository } from '@n8n/typeorm'; import { DataSource as Connection } from '@n8n/typeorm'; -import { GlobalConfig } from '@n8n/config'; +import { kebabCase } from 'lodash'; import type { Class } from 'n8n-core'; import { randomString } from 'n8n-workflow'; +import { Container } from 'typedi'; -import * as Db from '@/db'; import { getOptionOverrides } from '@/databases/config'; -import { kebabCase } from 'lodash'; +import * as Db from '@/db'; export const testDbPrefix = 'n8n_test_'; diff --git a/packages/cli/test/integration/shared/types.ts b/packages/cli/test/integration/shared/types.ts index e285c5aab67e1..66ca2d016f466 100644 --- a/packages/cli/test/integration/shared/types.ts +++ b/packages/cli/test/integration/shared/types.ts @@ -1,13 +1,14 @@ import type { Application } from 'express'; +import type { Server } from 'http'; import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import type TestAgent from 'supertest/lib/agent'; -import type { Server } from 'http'; import type { CredentialsEntity } from '@/databases/entities/credentials-entity'; +import type { Project } from '@/databases/entities/project'; import type { User } from '@/databases/entities/user'; import type { BooleanLicenseFeature, ICredentialsDb, NumericLicenseFeature } from '@/interfaces'; + import type { LicenseMocker } from './license'; -import type { Project } from '@/databases/entities/project'; type EndpointGroup = | 'health' diff --git a/packages/cli/test/integration/shared/utils/community-nodes.ts b/packages/cli/test/integration/shared/utils/community-nodes.ts index ff47aeb5a5f1f..7734f707620fa 100644 --- a/packages/cli/test/integration/shared/utils/community-nodes.ts +++ b/packages/cli/test/integration/shared/utils/community-nodes.ts @@ -1,11 +1,12 @@ +import Container from 'typedi'; + import { NODE_PACKAGE_PREFIX } from '@/constants'; import { InstalledPackages } from '@/databases/entities/installed-packages'; - -import { randomName } from '../random'; -import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '../constants'; import { InstalledNodesRepository } from '@/databases/repositories/installed-nodes.repository'; import { InstalledPackagesRepository } from '@/databases/repositories/installed-packages.repository'; -import Container from 'typedi'; + +import { COMMUNITY_NODE_VERSION, COMMUNITY_PACKAGE_VERSION } from '../constants'; +import { randomName } from '../random'; export const mockPackageName = () => NODE_PACKAGE_PREFIX + randomName(); diff --git a/packages/cli/test/integration/shared/utils/index.ts b/packages/cli/test/integration/shared/utils/index.ts index d135f55a9e324..4d4a207f94a17 100644 --- a/packages/cli/test/integration/shared/utils/index.ts +++ b/packages/cli/test/integration/shared/utils/index.ts @@ -1,18 +1,18 @@ -import { Container } from 'typedi'; import { BinaryDataService } from 'n8n-core'; -import { type INode } from 'n8n-workflow'; -import { GithubApi } from 'n8n-nodes-base/credentials/GithubApi.credentials'; import { Ftp } from 'n8n-nodes-base/credentials/Ftp.credentials'; +import { GithubApi } from 'n8n-nodes-base/credentials/GithubApi.credentials'; import { Cron } from 'n8n-nodes-base/nodes/Cron/Cron.node'; import { Set } from 'n8n-nodes-base/nodes/Set/Set.node'; import { Start } from 'n8n-nodes-base/nodes/Start/Start.node'; +import { type INode } from 'n8n-workflow'; import type request from 'supertest'; +import { Container } from 'typedi'; import { v4 as uuid } from 'uuid'; import config from '@/config'; +import { AUTH_COOKIE_NAME } from '@/constants'; import { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { SettingsRepository } from '@/databases/repositories/settings.repository'; -import { AUTH_COOKIE_NAME } from '@/constants'; import { ExecutionService } from '@/executions/execution.service'; import { LoadNodesAndCredentials } from '@/load-nodes-and-credentials'; import { Push } from '@/push'; diff --git a/packages/cli/test/integration/shared/utils/test-command.ts b/packages/cli/test/integration/shared/utils/test-command.ts index a81875e89c94e..82effd1818953 100644 --- a/packages/cli/test/integration/shared/utils/test-command.ts +++ b/packages/cli/test/integration/shared/utils/test-command.ts @@ -1,12 +1,13 @@ import type { Config } from '@oclif/core'; -import type { Class } from 'n8n-core'; import { mock } from 'jest-mock-extended'; +import type { Class } from 'n8n-core'; import type { BaseCommand } from '@/commands/base-command'; -import * as testDb from '../test-db'; +import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; import { TelemetryEventRelay } from '@/events/telemetry-event-relay'; import { mockInstance } from '@test/mocking'; -import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; + +import * as testDb from '../test-db'; mockInstance(MessageEventBus); diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index b2b86daefcf3c..9498893defe60 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -1,27 +1,27 @@ -import { Container } from 'typedi'; import cookieParser from 'cookie-parser'; import express from 'express'; import type superagent from 'superagent'; import request from 'supertest'; +import { Container } from 'typedi'; import { URL } from 'url'; +import { AuthService } from '@/auth/auth.service'; import config from '@/config'; import { AUTH_COOKIE_NAME } from '@/constants'; import type { User } from '@/databases/entities/user'; import { ControllerRegistry } from '@/decorators'; +import { License } from '@/license'; +import { Logger } from '@/logger'; import { rawBodyReader, bodyParser } from '@/middlewares'; import { PostHogClient } from '@/posthog'; import { Push } from '@/push'; -import { License } from '@/license'; -import { Logger } from '@/logger'; -import { AuthService } from '@/auth/auth.service'; import type { APIRequest } from '@/requests'; import { mockInstance } from '../../../shared/mocking'; -import * as testDb from '../test-db'; import { PUBLIC_API_REST_PATH_SEGMENT, REST_PATH_SEGMENT } from '../constants'; -import type { SetupProps, TestServer } from '../types'; import { LicenseMocker } from '../license'; +import * as testDb from '../test-db'; +import type { SetupProps, TestServer } from '../types'; /** * Plugin to prefix a path segment into a request URL pathname. diff --git a/packages/cli/test/integration/shared/utils/users.ts b/packages/cli/test/integration/shared/utils/users.ts index 13887d3ce9748..498e62bbb06fa 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 { PublicUser } from '@/interfaces'; import type { User } from '@/databases/entities/user'; +import type { PublicUser } from '@/interfaces'; export const validateUser = (user: PublicUser) => { expect(typeof user.id).toBe('string'); diff --git a/packages/cli/test/integration/shared/workflow.ts b/packages/cli/test/integration/shared/workflow.ts index bf5ab0423e76e..83901b6f1588e 100644 --- a/packages/cli/test/integration/shared/workflow.ts +++ b/packages/cli/test/integration/shared/workflow.ts @@ -1,4 +1,5 @@ import type { INode } from 'n8n-workflow'; + import { WorkflowEntity } from '@/databases/entities/workflow-entity'; export const FIRST_CREDENTIAL_ID = '1'; diff --git a/packages/cli/test/integration/tags.api.test.ts b/packages/cli/test/integration/tags.api.test.ts index 90933366eba25..e3acc2a65019a 100644 --- a/packages/cli/test/integration/tags.api.test.ts +++ b/packages/cli/test/integration/tags.api.test.ts @@ -2,10 +2,10 @@ import { Container } from 'typedi'; import { TagRepository } from '@/databases/repositories/tag.repository'; -import * as utils from './shared/utils/'; +import { createUserShell } from './shared/db/users'; import * as testDb from './shared/test-db'; import type { SuperAgentTest } from './shared/types'; -import { createUserShell } from './shared/db/users'; +import * as utils from './shared/utils/'; let authOwnerAgent: SuperAgentTest; const testServer = utils.setupTestServer({ endpointGroups: ['tags'] }); diff --git a/packages/cli/test/integration/user.repository.test.ts b/packages/cli/test/integration/user.repository.test.ts index 018a9fcf2a94b..4de084ba39a5a 100644 --- a/packages/cli/test/integration/user.repository.test.ts +++ b/packages/cli/test/integration/user.repository.test.ts @@ -1,9 +1,11 @@ import Container from 'typedi'; + +import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; import { UserRepository } from '@/databases/repositories/user.repository'; + import { createAdmin, createMember, createOwner } from './shared/db/users'; -import * as testDb from './shared/test-db'; import { randomEmail } from './shared/random'; -import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; +import * as testDb from './shared/test-db'; describe('UserRepository', () => { let userRepository: UserRepository; diff --git a/packages/cli/test/integration/users.api.test.ts b/packages/cli/test/integration/users.api.test.ts index ff9d428799588..d5d2d10a5de8d 100644 --- a/packages/cli/test/integration/users.api.test.ts +++ b/packages/cli/test/integration/users.api.test.ts @@ -4,30 +4,30 @@ import { v4 as uuid } from 'uuid'; import { RESPONSE_ERROR_MESSAGES } from '@/constants'; import { UsersController } from '@/controllers/users.controller'; import type { User } from '@/databases/entities/user'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import { ProjectRelationRepository } from '@/databases/repositories/project-relation.repository'; -import { UserRepository } from '@/databases/repositories/user.repository'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { SharedCredentialsRepository } from '@/databases/repositories/shared-credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; -import { CacheService } from '@/services/cache/cache.service'; +import { UserRepository } from '@/databases/repositories/user.repository'; import { ExecutionService } from '@/executions/execution.service'; +import { CacheService } from '@/services/cache/cache.service'; +import { Telemetry } from '@/telemetry'; +import { SUCCESS_RESPONSE_BODY } from './shared/constants'; import { getCredentialById, saveCredential, shareCredentialWithUsers, } from './shared/db/credentials'; +import { createTeamProject, getPersonalProject, linkUserToProject } from './shared/db/projects'; import { createAdmin, createMember, createOwner, getUserById } from './shared/db/users'; import { createWorkflow, getWorkflowById, shareWorkflowWithUsers } from './shared/db/workflows'; -import { SUCCESS_RESPONSE_BODY } from './shared/constants'; -import { validateUser } from './shared/utils/users'; import { randomCredentialPayload } from './shared/random'; -import * as utils from './shared/utils/'; import * as testDb from './shared/test-db'; -import { mockInstance } from '../shared/mocking'; import type { SuperAgentTest } from './shared/types'; -import { createTeamProject, getPersonalProject, linkUserToProject } from './shared/db/projects'; -import { Telemetry } from '@/telemetry'; +import * as utils from './shared/utils/'; +import { validateUser } from './shared/utils/users'; +import { mockInstance } from '../shared/mocking'; mockInstance(Telemetry); mockInstance(ExecutionService); diff --git a/packages/cli/test/integration/variables.test.ts b/packages/cli/test/integration/variables.test.ts index 16eeb3c205d71..f8cef375391a4 100644 --- a/packages/cli/test/integration/variables.test.ts +++ b/packages/cli/test/integration/variables.test.ts @@ -5,10 +5,10 @@ import { VariablesRepository } from '@/databases/repositories/variables.reposito import { generateNanoId } from '@/databases/utils/generators'; import { VariablesService } from '@/environments/variables/variables.service.ee'; -import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; import { createOwner, createUser } from './shared/db/users'; +import * as testDb from './shared/test-db'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; let authOwnerAgent: SuperAgentTest; let authMemberAgent: SuperAgentTest; diff --git a/packages/cli/test/integration/webhooks.api.test.ts b/packages/cli/test/integration/webhooks.api.test.ts index 7090a1e91e0cf..75ada5b820c1f 100644 --- a/packages/cli/test/integration/webhooks.api.test.ts +++ b/packages/cli/test/integration/webhooks.api.test.ts @@ -1,25 +1,25 @@ import { readFileSync } from 'fs'; -import { agent as testAgent } from 'supertest'; import { NodeConnectionType, type INodeType, type INodeTypeDescription, type IWebhookFunctions, } from 'n8n-workflow'; +import { agent as testAgent } from 'supertest'; import { AbstractServer } from '@/abstract-server'; +import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; import { ExternalHooks } from '@/external-hooks'; import { NodeTypes } from '@/node-types'; import { Push } from '@/push'; -import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; +import { Telemetry } from '@/telemetry'; -import { mockInstance } from '../shared/mocking'; -import { initActiveWorkflowManager } from './shared/utils'; -import * as testDb from './shared/test-db'; import { createUser } from './shared/db/users'; import { createWorkflow } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; import type { SuperAgentTest } from './shared/types'; -import { Telemetry } from '@/telemetry'; +import { initActiveWorkflowManager } from './shared/utils'; +import { mockInstance } from '../shared/mocking'; mockInstance(Telemetry); diff --git a/packages/cli/test/integration/webhooks.test.ts b/packages/cli/test/integration/webhooks.test.ts index 789ced02c6ca6..e4a6ca1025b6e 100644 --- a/packages/cli/test/integration/webhooks.test.ts +++ b/packages/cli/test/integration/webhooks.test.ts @@ -1,18 +1,17 @@ -import type SuperAgentTest from 'supertest/lib/agent'; -import { agent as testAgent } from 'supertest'; +import { GlobalConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; +import { agent as testAgent } from 'supertest'; +import type SuperAgentTest from 'supertest/lib/agent'; +import Container from 'typedi'; import { AbstractServer } from '@/abstract-server'; -import { LiveWebhooks } from '@/webhooks/live-webhooks'; import { ExternalHooks } from '@/external-hooks'; +import { WaitingForms } from '@/waiting-forms'; +import { LiveWebhooks } from '@/webhooks/live-webhooks'; import { TestWebhooks } from '@/webhooks/test-webhooks'; import { WaitingWebhooks } from '@/webhooks/waiting-webhooks'; -import { WaitingForms } from '@/waiting-forms'; import type { IWebhookResponseCallbackData } from '@/webhooks/webhook.types'; - import { mockInstance } from '@test/mocking'; -import { GlobalConfig } from '@n8n/config'; -import Container from 'typedi'; let agent: SuperAgentTest; diff --git a/packages/cli/test/integration/workflow-history-manager.test.ts b/packages/cli/test/integration/workflow-history-manager.test.ts index 587c105ffe9e0..825da9fcbf021 100644 --- a/packages/cli/test/integration/workflow-history-manager.test.ts +++ b/packages/cli/test/integration/workflow-history-manager.test.ts @@ -1,16 +1,16 @@ -import Container from 'typedi'; import { In } from '@n8n/typeorm'; import { DateTime } from 'luxon'; +import Container from 'typedi'; import config from '@/config'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; import { License } from '@/license'; import { WorkflowHistoryManager } from '@/workflows/workflow-history/workflow-history-manager.ee'; -import { mockInstance } from '../shared/mocking'; -import * as testDb from './shared/test-db'; -import { createWorkflow } from './shared/db/workflows'; import { createManyWorkflowHistoryItems } from './shared/db/workflow-history'; +import { createWorkflow } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; +import { mockInstance } from '../shared/mocking'; describe('Workflow History Manager', () => { const license = mockInstance(License); diff --git a/packages/cli/test/integration/workflow-history.api.test.ts b/packages/cli/test/integration/workflow-history.api.test.ts index 4451dafa79b2b..42fb1d6a69cad 100644 --- a/packages/cli/test/integration/workflow-history.api.test.ts +++ b/packages/cli/test/integration/workflow-history.api.test.ts @@ -1,11 +1,11 @@ import type { User } from '@/databases/entities/user'; -import * as testDb from './shared/test-db'; -import * as utils from './shared/utils/'; import { createOwner, createUser } from './shared/db/users'; -import { createWorkflow } from './shared/db/workflows'; import { createWorkflowHistoryItem } from './shared/db/workflow-history'; +import { createWorkflow } from './shared/db/workflows'; +import * as testDb from './shared/test-db'; import type { SuperAgentTest } from './shared/types'; +import * as utils from './shared/utils/'; let owner: User; let authOwnerAgent: SuperAgentTest; diff --git a/packages/cli/test/integration/workflow-tag-mapping.repository.integration.test.ts b/packages/cli/test/integration/workflow-tag-mapping.repository.integration.test.ts index 6ea88a698a15e..563764de7f115 100644 --- a/packages/cli/test/integration/workflow-tag-mapping.repository.integration.test.ts +++ b/packages/cli/test/integration/workflow-tag-mapping.repository.integration.test.ts @@ -1,9 +1,10 @@ import Container from 'typedi'; -import * as testDb from './shared/test-db'; +import { TagRepository } from '@/databases/repositories/tag.repository'; import { WorkflowTagMappingRepository } from '@/databases/repositories/workflow-tag-mapping.repository'; + import { createWorkflow } from './shared/db/workflows'; -import { TagRepository } from '@/databases/repositories/tag.repository'; +import * as testDb from './shared/test-db'; describe('WorkflowTagMappingRepository', () => { let taggingRepository: WorkflowTagMappingRepository; diff --git a/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts b/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts index 496436860b9bc..3730d0db6cd11 100644 --- a/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts +++ b/packages/cli/test/integration/workflows/workflow-sharing.service.test.ts @@ -1,14 +1,14 @@ import Container from 'typedi'; import type { User } from '@/databases/entities/user'; +import { License } from '@/license'; +import { ProjectService } from '@/services/project.service'; import { WorkflowSharingService } from '@/workflows/workflow-sharing.service'; -import * as testDb from '../shared/test-db'; import { createUser } from '../shared/db/users'; import { createWorkflow, shareWorkflowWithUsers } from '../shared/db/workflows'; -import { ProjectService } from '@/services/project.service'; import { LicenseMocker } from '../shared/license'; -import { License } from '@/license'; +import * as testDb from '../shared/test-db'; let owner: User; let member: User; diff --git a/packages/cli/test/integration/workflows/workflow.service.ee.test.ts b/packages/cli/test/integration/workflows/workflow.service.ee.test.ts index 44d44f05c030e..5fbab55840286 100644 --- a/packages/cli/test/integration/workflows/workflow.service.ee.test.ts +++ b/packages/cli/test/integration/workflows/workflow.service.ee.test.ts @@ -1,5 +1,6 @@ -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; +import Container from 'typedi'; + import { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { CredentialsRepository } from '@/databases/repositories/credentials.repository'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; @@ -7,8 +8,8 @@ import { WorkflowRepository } from '@/databases/repositories/workflow.repository import { Telemetry } from '@/telemetry'; import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; -import * as testDb from '../shared/test-db'; import { mockInstance } from '../../shared/mocking'; +import * as testDb from '../shared/test-db'; import { FIRST_CREDENTIAL_ID, SECOND_CREDENTIAL_ID, diff --git a/packages/cli/test/integration/workflows/workflow.service.test.ts b/packages/cli/test/integration/workflows/workflow.service.test.ts index 4c65f24858698..759dbc54c8d7d 100644 --- a/packages/cli/test/integration/workflows/workflow.service.test.ts +++ b/packages/cli/test/integration/workflows/workflow.service.test.ts @@ -1,17 +1,18 @@ -import Container from 'typedi'; import { mock } from 'jest-mock-extended'; +import Container from 'typedi'; + import { ActiveWorkflowManager } from '@/active-workflow-manager'; import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus'; -import { Telemetry } from '@/telemetry'; import { OrchestrationService } from '@/services/orchestration.service'; +import { Telemetry } from '@/telemetry'; import { WorkflowService } from '@/workflows/workflow.service'; -import * as testDb from '../shared/test-db'; import { mockInstance } from '../../shared/mocking'; import { createOwner } from '../shared/db/users'; import { createWorkflow } from '../shared/db/workflows'; +import * as testDb from '../shared/test-db'; let workflowService: WorkflowService; const activeWorkflowManager = mockInstance(ActiveWorkflowManager); diff --git a/packages/cli/test/integration/workflows/workflows.controller-with-active-workflow-manager.ee.test.ts b/packages/cli/test/integration/workflows/workflows.controller-with-active-workflow-manager.ee.test.ts index d27a341d5d1f6..2cbc23ffe942c 100644 --- a/packages/cli/test/integration/workflows/workflows.controller-with-active-workflow-manager.ee.test.ts +++ b/packages/cli/test/integration/workflows/workflows.controller-with-active-workflow-manager.ee.test.ts @@ -1,12 +1,12 @@ import type { User } from '@/databases/entities/user'; +import { Telemetry } from '@/telemetry'; +import { mockInstance } from '@test/mocking'; -import * as utils from '../shared/utils/'; -import * as testDb from '../shared/test-db'; +import { createTeamProject } from '../shared/db/projects'; import { createUser } from '../shared/db/users'; import { createWorkflowWithTrigger } from '../shared/db/workflows'; -import { createTeamProject } from '../shared/db/projects'; -import { mockInstance } from '@test/mocking'; -import { Telemetry } from '@/telemetry'; +import * as testDb from '../shared/test-db'; +import * as utils from '../shared/utils/'; mockInstance(Telemetry); 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 035e53a1b4a16..c8f2db889f7da 100644 --- a/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts +++ b/packages/cli/test/integration/workflows/workflows.controller.ee.test.ts @@ -1,30 +1,30 @@ +import { ApplicationError, WorkflowActivationError, type INode } from 'n8n-workflow'; import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import { ApplicationError, WorkflowActivationError, type INode } from 'n8n-workflow'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import config from '@/config'; import type { Project } from '@/databases/entities/project'; -import { ProjectRepository } from '@/databases/repositories/project.repository'; import type { User } from '@/databases/entities/user'; +import { ProjectRepository } from '@/databases/repositories/project.repository'; import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; +import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import { License } from '@/license'; import { UserManagementMailer } from '@/user-management/email'; import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types'; import { mockInstance } from '../../shared/mocking'; -import * as utils from '../shared/utils/'; -import * as testDb from '../shared/test-db'; -import type { SaveCredentialFunction } from '../shared/types'; -import { makeWorkflow } from '../shared/utils/'; -import { randomCredentialPayload } from '../shared/random'; import { affixRoleToSaveCredential, shareCredentialWithUsers } from '../shared/db/credentials'; +import { createTeamProject, linkUserToProject } from '../shared/db/projects'; +import { createTag } from '../shared/db/tags'; import { createAdmin, createOwner, createUser, createUserShell } from '../shared/db/users'; import { createWorkflow, getWorkflowSharing, shareWorkflowWithUsers } from '../shared/db/workflows'; -import { createTag } from '../shared/db/tags'; +import { randomCredentialPayload } from '../shared/random'; +import * as testDb from '../shared/test-db'; +import type { SaveCredentialFunction } from '../shared/types'; import type { SuperAgentTest } from '../shared/types'; -import { createTeamProject, linkUserToProject } from '../shared/db/projects'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; +import * as utils from '../shared/utils/'; +import { makeWorkflow } from '../shared/utils/'; let owner: User; let admin: User; diff --git a/packages/cli/test/integration/workflows/workflows.controller.test.ts b/packages/cli/test/integration/workflows/workflows.controller.test.ts index 8959ca7af4c43..84c1505887684 100644 --- a/packages/cli/test/integration/workflows/workflows.controller.test.ts +++ b/packages/cli/test/integration/workflows/workflows.controller.test.ts @@ -1,31 +1,31 @@ +import type { Scope } from '@n8n/permissions'; +import type { INode, IPinData } from 'n8n-workflow'; import Container from 'typedi'; import { v4 as uuid } from 'uuid'; -import type { INode, IPinData } from 'n8n-workflow'; -import type { Scope } from '@n8n/permissions'; +import { ActiveWorkflowManager } from '@/active-workflow-manager'; import type { User } from '@/databases/entities/user'; -import { WorkflowRepository } from '@/databases/repositories/workflow.repository'; import type { WorkflowEntity } from '@/databases/entities/workflow-entity'; -import type { ListQuery } from '@/requests'; -import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository'; -import { SharedWorkflowRepository } from '@/databases/repositories/shared-workflow.repository'; 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 { License } from '@/license'; +import type { ListQuery } from '@/requests'; import { ProjectService } from '@/services/project.service'; -import { ActiveWorkflowManager } from '@/active-workflow-manager'; import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee'; -import { License } from '@/license'; import { mockInstance } from '../../shared/mocking'; -import * as utils from '../shared/utils/'; -import * as testDb from '../shared/test-db'; -import { makeWorkflow, MOCK_PINDATA } from '../shared/utils/'; -import { randomCredentialPayload } from '../shared/random'; import { saveCredential } from '../shared/db/credentials'; +import { createTeamProject, linkUserToProject } from '../shared/db/projects'; +import { createTag } from '../shared/db/tags'; import { createManyUsers, createMember, createOwner } from '../shared/db/users'; import { createWorkflow, shareWorkflowWithProjects } from '../shared/db/workflows'; -import { createTag } from '../shared/db/tags'; -import { createTeamProject, linkUserToProject } from '../shared/db/projects'; +import { randomCredentialPayload } from '../shared/random'; +import * as testDb from '../shared/test-db'; import type { SuperAgentTest } from '../shared/types'; +import * as utils from '../shared/utils/'; +import { makeWorkflow, MOCK_PINDATA } from '../shared/utils/'; let owner: User; let member: User; diff --git a/packages/cli/test/setup-test-folder.ts b/packages/cli/test/setup-test-folder.ts index 4435df5ece441..94e45e6c905b5 100644 --- a/packages/cli/test/setup-test-folder.ts +++ b/packages/cli/test/setup-test-folder.ts @@ -1,6 +1,6 @@ +import { mkdirSync, mkdtempSync, writeFileSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; -import { mkdirSync, mkdtempSync, writeFileSync } from 'fs'; process.env.N8N_ENCRYPTION_KEY = 'test_key'; diff --git a/packages/cli/test/shared/external-secrets/utils.ts b/packages/cli/test/shared/external-secrets/utils.ts index f488adf84bc8c..f4bb8a7d3aada 100644 --- a/packages/cli/test/shared/external-secrets/utils.ts +++ b/packages/cli/test/shared/external-secrets/utils.ts @@ -1,6 +1,7 @@ +import type { IDataObject, INodeProperties } from 'n8n-workflow'; + import { SecretsProvider } from '@/interfaces'; import type { SecretsProviderSettings, SecretsProviderState } from '@/interfaces'; -import type { IDataObject, INodeProperties } from 'n8n-workflow'; export class MockProviders { providers: Record = { diff --git a/packages/cli/test/shared/mock-objects.ts b/packages/cli/test/shared/mock-objects.ts index d22f20016dbb2..2559694b01b68 100644 --- a/packages/cli/test/shared/mock-objects.ts +++ b/packages/cli/test/shared/mock-objects.ts @@ -1,7 +1,8 @@ import { randomInt } from 'n8n-workflow'; -import { User } from '@/databases/entities/user'; + import { CredentialsEntity } from '@/databases/entities/credentials-entity'; import { Project } from '@/databases/entities/project'; +import { User } from '@/databases/entities/user'; import { randomCredentialPayload, diff --git a/packages/cli/test/shared/mocking.ts b/packages/cli/test/shared/mocking.ts index 5a6183c0e8cbc..60b712b1150e5 100644 --- a/packages/cli/test/shared/mocking.ts +++ b/packages/cli/test/shared/mocking.ts @@ -1,8 +1,8 @@ -import { Container } from 'typedi'; -import { mock } from 'jest-mock-extended'; -import type { DeepPartial } from 'ts-essentials'; import { DataSource, EntityManager, type EntityMetadata } from '@n8n/typeorm'; +import { mock } from 'jest-mock-extended'; import type { Class } from 'n8n-core'; +import type { DeepPartial } from 'ts-essentials'; +import { Container } from 'typedi'; export const mockInstance = ( serviceClass: Class, diff --git a/packages/cli/test/teardown.ts b/packages/cli/test/teardown.ts index 476ea948416d4..1c40bf2df67ed 100644 --- a/packages/cli/test/teardown.ts +++ b/packages/cli/test/teardown.ts @@ -1,7 +1,8 @@ import 'tsconfig-paths/register'; -import { Container } from 'typedi'; import { GlobalConfig } from '@n8n/config'; import { DataSource as Connection } from '@n8n/typeorm'; +import { Container } from 'typedi'; + import { getBootstrapDBOptions, testDbPrefix } from './integration/shared/test-db'; export default async () => { From 47456cd9e9177d68713641191720b9ae1417ddde Mon Sep 17 00:00:00 2001 From: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:17:08 +0300 Subject: [PATCH 2/2] test: Mock telemetry in test server --- packages/cli/test/integration/shared/utils/test-server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/cli/test/integration/shared/utils/test-server.ts b/packages/cli/test/integration/shared/utils/test-server.ts index 9498893defe60..f16bbf9833953 100644 --- a/packages/cli/test/integration/shared/utils/test-server.ts +++ b/packages/cli/test/integration/shared/utils/test-server.ts @@ -16,6 +16,7 @@ import { rawBodyReader, bodyParser } from '@/middlewares'; import { PostHogClient } from '@/posthog'; import { Push } from '@/push'; import type { APIRequest } from '@/requests'; +import { Telemetry } from '@/telemetry'; import { mockInstance } from '../../../shared/mocking'; import { PUBLIC_API_REST_PATH_SEGMENT, REST_PATH_SEGMENT } from '../constants'; @@ -90,6 +91,7 @@ export const setupTestServer = ({ mockInstance(Logger); mockInstance(PostHogClient); mockInstance(Push); + mockInstance(Telemetry); const testServer: TestServer = { app,