mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(core): Use stricter typing on queries in cli commands (no-changelog) (#5476)
This has been broken since TypeORM upgrade Fixes: https://linear.app/n8n/issue/ENG-50 https://community.n8n.io/t/execute-command-stdout/22994
This commit is contained in:
parent
522ddfc0cd
commit
a6c59fcbc2
|
@ -1,10 +1,10 @@
|
||||||
import { flags } from '@oclif/command';
|
import { flags } from '@oclif/command';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
import { Credentials, UserSettings } from 'n8n-core';
|
import { Credentials, UserSettings } from 'n8n-core';
|
||||||
import type { IDataObject } from 'n8n-workflow';
|
|
||||||
import * as Db from '@/Db';
|
import * as Db from '@/Db';
|
||||||
import type { ICredentialsDecryptedDb } from '@/Interfaces';
|
import type { ICredentialsDb, ICredentialsDecryptedDb } from '@/Interfaces';
|
||||||
import { BaseCommand } from '../BaseCommand';
|
import { BaseCommand } from '../BaseCommand';
|
||||||
|
|
||||||
export class ExportCredentialsCommand extends BaseCommand {
|
export class ExportCredentialsCommand extends BaseCommand {
|
||||||
|
@ -105,13 +105,12 @@ export class ExportCredentialsCommand extends BaseCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const findQuery: IDataObject = {};
|
const findQuery: FindOptionsWhere<ICredentialsDb> = {};
|
||||||
if (flags.id) {
|
if (flags.id) {
|
||||||
findQuery.id = flags.id;
|
findQuery.id = flags.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
const credentials = await Db.collections.Credentials.findBy(findQuery);
|
||||||
const credentials = await Db.collections.Credentials.find(findQuery);
|
|
||||||
|
|
||||||
if (flags.decrypted) {
|
if (flags.decrypted) {
|
||||||
const encryptionKey = await UserSettings.getEncryptionKey();
|
const encryptionKey = await UserSettings.getEncryptionKey();
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { flags } from '@oclif/command';
|
import { flags } from '@oclif/command';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import type { IDataObject } from 'n8n-workflow';
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
import * as Db from '@/Db';
|
import * as Db from '@/Db';
|
||||||
|
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||||
import { BaseCommand } from '../BaseCommand';
|
import { BaseCommand } from '../BaseCommand';
|
||||||
|
|
||||||
export class ExportWorkflowsCommand extends BaseCommand {
|
export class ExportWorkflowsCommand extends BaseCommand {
|
||||||
|
@ -98,7 +99,7 @@ export class ExportWorkflowsCommand extends BaseCommand {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const findQuery: IDataObject = {};
|
const findQuery: FindOptionsWhere<WorkflowEntity> = {};
|
||||||
if (flags.id) {
|
if (flags.id) {
|
||||||
findQuery.id = flags.id;
|
findQuery.id = flags.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { flags } from '@oclif/command';
|
import { flags } from '@oclif/command';
|
||||||
import type { IDataObject } from 'n8n-workflow';
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
import * as Db from '@/Db';
|
import * as Db from '@/Db';
|
||||||
|
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||||
import { BaseCommand } from '../BaseCommand';
|
import { BaseCommand } from '../BaseCommand';
|
||||||
|
|
||||||
export class ListWorkflowCommand extends BaseCommand {
|
export class ListWorkflowCommand extends BaseCommand {
|
||||||
|
@ -30,12 +31,12 @@ export class ListWorkflowCommand extends BaseCommand {
|
||||||
this.error('The --active flag has to be passed using true or false');
|
this.error('The --active flag has to be passed using true or false');
|
||||||
}
|
}
|
||||||
|
|
||||||
const findQuery: IDataObject = {};
|
const findQuery: FindOptionsWhere<WorkflowEntity> = {};
|
||||||
if (flags.active !== undefined) {
|
if (flags.active !== undefined) {
|
||||||
findQuery.active = flags.active === 'true';
|
findQuery.active = flags.active === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
const workflows = await Db.collections.Workflow.find(findQuery);
|
const workflows = await Db.collections.Workflow.findBy(findQuery);
|
||||||
if (flags.onlyId) {
|
if (flags.onlyId) {
|
||||||
workflows.forEach((workflow) => this.logger.info(workflow.id));
|
workflows.forEach((workflow) => this.logger.info(workflow.id));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { flags } from '@oclif/command';
|
import { flags } from '@oclif/command';
|
||||||
import type { IDataObject } from 'n8n-workflow';
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
|
import type { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
|
||||||
import * as Db from '@/Db';
|
import * as Db from '@/Db';
|
||||||
|
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||||
import { BaseCommand } from '../BaseCommand';
|
import { BaseCommand } from '../BaseCommand';
|
||||||
|
|
||||||
export class UpdateWorkflowCommand extends BaseCommand {
|
export class UpdateWorkflowCommand extends BaseCommand {
|
||||||
|
@ -43,7 +45,7 @@ export class UpdateWorkflowCommand extends BaseCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateQuery: IDataObject = {};
|
const updateQuery: QueryDeepPartialEntity<WorkflowEntity> = {};
|
||||||
if (flags.active === undefined) {
|
if (flags.active === undefined) {
|
||||||
console.info('No update flag like "--active=true" has been set!');
|
console.info('No update flag like "--active=true" has been set!');
|
||||||
return;
|
return;
|
||||||
|
@ -56,7 +58,7 @@ export class UpdateWorkflowCommand extends BaseCommand {
|
||||||
|
|
||||||
updateQuery.active = flags.active === 'true';
|
updateQuery.active = flags.active === 'true';
|
||||||
|
|
||||||
const findQuery: IDataObject = {};
|
const findQuery: FindOptionsWhere<WorkflowEntity> = {};
|
||||||
if (flags.id) {
|
if (flags.id) {
|
||||||
this.logger.info(`Deactivating workflow with ID: ${flags.id}`);
|
this.logger.info(`Deactivating workflow with ID: ${flags.id}`);
|
||||||
findQuery.id = flags.id;
|
findQuery.id = flags.id;
|
||||||
|
|
Loading…
Reference in a new issue