mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Move remaining tags logic to service (no-changelog) (#6920)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -11,14 +11,13 @@ import { SharedWorkflow } from '@db/entities/SharedWorkflow';
|
||||
import { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import type { Role } from '@db/entities/Role';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { setTagsForImport } from '@/TagHelpers';
|
||||
import { disableAutoGeneratedIds } from '@db/utils/commandHelpers';
|
||||
import type { ICredentialsDb, IWorkflowToImport } from '@/Interfaces';
|
||||
import { replaceInvalidCredentials } from '@/WorkflowHelpers';
|
||||
import { BaseCommand, UM_FIX_INSTRUCTION } from '../BaseCommand';
|
||||
import { generateNanoId } from '@db/utils/generators';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import { TagRepository } from '@/databases/repositories';
|
||||
import { TagService } from '@/services/tag.service';
|
||||
|
||||
function assertHasWorkflowsToImport(workflows: unknown): asserts workflows is IWorkflowToImport[] {
|
||||
if (!Array.isArray(workflows)) {
|
||||
@@ -66,6 +65,8 @@ export class ImportWorkflowsCommand extends BaseCommand {
|
||||
|
||||
private transactionManager: EntityManager;
|
||||
|
||||
private tagService = Container.get(TagService);
|
||||
|
||||
async init() {
|
||||
disableAutoGeneratedIds(WorkflowEntity);
|
||||
await super.init();
|
||||
@@ -93,7 +94,7 @@ export class ImportWorkflowsCommand extends BaseCommand {
|
||||
const user = flags.userId ? await this.getAssignee(flags.userId) : await this.getOwner();
|
||||
|
||||
const credentials = await Db.collections.Credentials.find();
|
||||
const tags = await Container.get(TagRepository).find();
|
||||
const tags = await this.tagService.getAll();
|
||||
|
||||
let totalImported = 0;
|
||||
|
||||
@@ -133,7 +134,7 @@ export class ImportWorkflowsCommand extends BaseCommand {
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(workflow, 'tags')) {
|
||||
await setTagsForImport(transactionManager, workflow, tags);
|
||||
await this.tagService.setTagsForImport(transactionManager, workflow, tags);
|
||||
}
|
||||
|
||||
if (workflow.active) {
|
||||
@@ -183,7 +184,7 @@ export class ImportWorkflowsCommand extends BaseCommand {
|
||||
}
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(workflow, 'tags')) {
|
||||
await setTagsForImport(transactionManager, workflow, tags);
|
||||
await this.tagService.setTagsForImport(transactionManager, workflow, tags);
|
||||
}
|
||||
if (workflow.active) {
|
||||
this.logger.info(
|
||||
|
||||
Reference in New Issue
Block a user