mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -08:00
refactor: Async functions don't need to explicitly return promises (no-changelog) (#6041)
This commit is contained in:
parent
03be725cef
commit
308a94311f
|
@ -542,10 +542,10 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
): Promise<INodeCredentialTestResult> {
|
): Promise<INodeCredentialTestResult> {
|
||||||
const credentialTestFunction = this.getCredentialTestFunction(credentialType);
|
const credentialTestFunction = this.getCredentialTestFunction(credentialType);
|
||||||
if (credentialTestFunction === undefined) {
|
if (credentialTestFunction === undefined) {
|
||||||
return Promise.resolve({
|
return {
|
||||||
status: 'Error',
|
status: 'Error',
|
||||||
message: 'No testing function found for this credential.',
|
message: 'No testing function found for this credential.',
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (credentialsDecrypted.data) {
|
if (credentialsDecrypted.data) {
|
||||||
|
|
|
@ -271,12 +271,12 @@ export class InternalHooks implements IInternalHooksClass {
|
||||||
runData?: IRun,
|
runData?: IRun,
|
||||||
userId?: string,
|
userId?: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const promises = [Promise.resolve()];
|
|
||||||
|
|
||||||
if (!workflow.id) {
|
if (!workflow.id) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const promises = [];
|
||||||
|
|
||||||
const properties: IExecutionTrackProperties = {
|
const properties: IExecutionTrackProperties = {
|
||||||
workflow_id: workflow.id,
|
workflow_id: workflow.id,
|
||||||
is_manual: false,
|
is_manual: false,
|
||||||
|
|
|
@ -82,7 +82,7 @@ export class LdapService {
|
||||||
await this.client.unbind();
|
await this.client.unbind();
|
||||||
return searchEntries;
|
return searchEntries;
|
||||||
}
|
}
|
||||||
return Promise.resolve([]);
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,7 +44,7 @@ export class PostHogClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFeatureFlags(user: Pick<PublicUser, 'id' | 'createdAt'>): Promise<FeatureFlags> {
|
async getFeatureFlags(user: Pick<PublicUser, 'id' | 'createdAt'>): Promise<FeatureFlags> {
|
||||||
if (!this.postHog) return Promise.resolve({});
|
if (!this.postHog) return {};
|
||||||
|
|
||||||
const fullId = [this.instanceId, user.id].join('#');
|
const fullId = [this.instanceId, user.id].join('#');
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,8 @@ export class SamlService {
|
||||||
validate: async (response: string) => {
|
validate: async (response: string) => {
|
||||||
const valid = await validateResponse(response);
|
const valid = await validateResponse(response);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
return Promise.reject(new Error('Invalid SAML response'));
|
throw new Error('Invalid SAML response');
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class Telemetry {
|
||||||
|
|
||||||
private async pulse(): Promise<unknown> {
|
private async pulse(): Promise<unknown> {
|
||||||
if (!this.rudderStack) {
|
if (!this.rudderStack) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const allPromises = Object.keys(this.executionCountsBuffer).map(async (workflowId) => {
|
const allPromises = Object.keys(this.executionCountsBuffer).map(async (workflowId) => {
|
||||||
|
|
|
@ -205,9 +205,7 @@ test('GET /ldap/config route should retrieve current configuration', async () =>
|
||||||
|
|
||||||
describe('POST /ldap/test-connection', () => {
|
describe('POST /ldap/test-connection', () => {
|
||||||
test('route should success', async () => {
|
test('route should success', async () => {
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'testConnection').mockResolvedValue();
|
||||||
.spyOn(LdapService.prototype, 'testConnection')
|
|
||||||
.mockImplementation(async () => Promise.resolve());
|
|
||||||
|
|
||||||
const response = await authAgent(owner).post('/ldap/test-connection');
|
const response = await authAgent(owner).post('/ldap/test-connection');
|
||||||
expect(response.statusCode).toBe(200);
|
expect(response.statusCode).toBe(200);
|
||||||
|
@ -216,9 +214,7 @@ describe('POST /ldap/test-connection', () => {
|
||||||
test('route should fail', async () => {
|
test('route should fail', async () => {
|
||||||
const errorMessage = 'Invalid connection';
|
const errorMessage = 'Invalid connection';
|
||||||
|
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'testConnection').mockRejectedValue(new Error(errorMessage));
|
||||||
.spyOn(LdapService.prototype, 'testConnection')
|
|
||||||
.mockImplementation(async () => Promise.reject(new Error(errorMessage)));
|
|
||||||
|
|
||||||
const response = await authAgent(owner).post('/ldap/test-connection');
|
const response = await authAgent(owner).post('/ldap/test-connection');
|
||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400);
|
||||||
|
@ -240,9 +236,7 @@ describe('POST /ldap/sync', () => {
|
||||||
|
|
||||||
describe('dry mode', () => {
|
describe('dry mode', () => {
|
||||||
const runTest = async (ldapUsers: LdapUser[]) => {
|
const runTest = async (ldapUsers: LdapUser[]) => {
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'searchWithAdminBinding').mockResolvedValue(ldapUsers);
|
||||||
.spyOn(LdapService.prototype, 'searchWithAdminBinding')
|
|
||||||
.mockImplementation(async () => Promise.resolve(ldapUsers));
|
|
||||||
|
|
||||||
const response = await authAgent(owner).post('/ldap/sync').send({ type: 'dry' });
|
const response = await authAgent(owner).post('/ldap/sync').send({ type: 'dry' });
|
||||||
|
|
||||||
|
@ -337,9 +331,7 @@ describe('POST /ldap/sync', () => {
|
||||||
|
|
||||||
describe('live mode', () => {
|
describe('live mode', () => {
|
||||||
const runTest = async (ldapUsers: LdapUser[]) => {
|
const runTest = async (ldapUsers: LdapUser[]) => {
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'searchWithAdminBinding').mockResolvedValue(ldapUsers);
|
||||||
.spyOn(LdapService.prototype, 'searchWithAdminBinding')
|
|
||||||
.mockImplementation(async () => Promise.resolve(ldapUsers));
|
|
||||||
|
|
||||||
const response = await authAgent(owner).post('/ldap/sync').send({ type: 'live' });
|
const response = await authAgent(owner).post('/ldap/sync').send({ type: 'live' });
|
||||||
|
|
||||||
|
@ -467,9 +459,7 @@ describe('POST /ldap/sync', () => {
|
||||||
test('should remove user instance access once the user is disabled during synchronization', async () => {
|
test('should remove user instance access once the user is disabled during synchronization', async () => {
|
||||||
const member = await testDb.createLdapUser({ globalRole: globalMemberRole }, uniqueId());
|
const member = await testDb.createLdapUser({ globalRole: globalMemberRole }, uniqueId());
|
||||||
|
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'searchWithAdminBinding').mockResolvedValue([]);
|
||||||
.spyOn(LdapService.prototype, 'searchWithAdminBinding')
|
|
||||||
.mockImplementation(async () => Promise.resolve([]));
|
|
||||||
|
|
||||||
await authAgent(owner).post('/ldap/sync').send({ type: 'live' });
|
await authAgent(owner).post('/ldap/sync').send({ type: 'live' });
|
||||||
|
|
||||||
|
@ -508,13 +498,9 @@ describe('POST /login', () => {
|
||||||
|
|
||||||
const authlessAgent = utils.createAgent(app);
|
const authlessAgent = utils.createAgent(app);
|
||||||
|
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'searchWithAdminBinding').mockResolvedValue([ldapUser]);
|
||||||
.spyOn(LdapService.prototype, 'searchWithAdminBinding')
|
|
||||||
.mockImplementation(async () => Promise.resolve([ldapUser]));
|
|
||||||
|
|
||||||
jest
|
jest.spyOn(LdapService.prototype, 'validUser').mockResolvedValue();
|
||||||
.spyOn(LdapService.prototype, 'validUser')
|
|
||||||
.mockImplementation(async () => Promise.resolve());
|
|
||||||
|
|
||||||
const response = await authlessAgent
|
const response = await authlessAgent
|
||||||
.post('/login')
|
.post('/login')
|
||||||
|
|
|
@ -799,11 +799,11 @@ export function installedNodePayload(packageName: string): InstalledNodePayload
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const emptyPackage = () => {
|
export const emptyPackage = async () => {
|
||||||
const installedPackage = new InstalledPackages();
|
const installedPackage = new InstalledPackages();
|
||||||
installedPackage.installedNodes = [];
|
installedPackage.installedNodes = [];
|
||||||
|
|
||||||
return Promise.resolve(installedPackage);
|
return installedPackage;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
|
@ -18,7 +18,7 @@ jest.mock('@/Db', () => {
|
||||||
return {
|
return {
|
||||||
collections: {
|
collections: {
|
||||||
Execution: {
|
Execution: {
|
||||||
save: jest.fn(async () => Promise.resolve({ id: FAKE_EXECUTION_ID })),
|
save: jest.fn(async () => ({ id: FAKE_EXECUTION_ID })),
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -99,12 +99,11 @@ jest.mock('@/Db', () => {
|
||||||
return {
|
return {
|
||||||
collections: {
|
collections: {
|
||||||
Workflow: {
|
Workflow: {
|
||||||
find: jest.fn(async () => Promise.resolve(generateWorkflows(databaseActiveWorkflowsCount))),
|
find: jest.fn(async () => generateWorkflows(databaseActiveWorkflowsCount)),
|
||||||
findOne: jest.fn(async (searchParams) => {
|
findOne: jest.fn(async (searchParams) => {
|
||||||
const foundWorkflow = databaseActiveWorkflowsList.find(
|
return databaseActiveWorkflowsList.find(
|
||||||
(workflow) => workflow.id.toString() === searchParams.where.id.toString(),
|
(workflow) => workflow.id.toString() === searchParams.where.id.toString(),
|
||||||
);
|
);
|
||||||
return Promise.resolve(foundWorkflow);
|
|
||||||
}),
|
}),
|
||||||
update: jest.fn(),
|
update: jest.fn(),
|
||||||
createQueryBuilder: jest.fn(() => {
|
createQueryBuilder: jest.fn(() => {
|
||||||
|
@ -112,7 +111,7 @@ jest.mock('@/Db', () => {
|
||||||
update: () => fakeQueryBuilder,
|
update: () => fakeQueryBuilder,
|
||||||
set: () => fakeQueryBuilder,
|
set: () => fakeQueryBuilder,
|
||||||
where: () => fakeQueryBuilder,
|
where: () => fakeQueryBuilder,
|
||||||
execute: () => Promise.resolve(),
|
execute: async () => {},
|
||||||
};
|
};
|
||||||
return fakeQueryBuilder;
|
return fakeQueryBuilder;
|
||||||
}),
|
}),
|
||||||
|
@ -246,7 +245,7 @@ describe('ActiveWorkflowRunner', () => {
|
||||||
const workflow = generateWorkflows(1);
|
const workflow = generateWorkflows(1);
|
||||||
const additionalData = await WorkflowExecuteAdditionalData.getBase('fake-user-id');
|
const additionalData = await WorkflowExecuteAdditionalData.getBase('fake-user-id');
|
||||||
|
|
||||||
workflowRunnerRun.mockImplementationOnce(() => Promise.resolve('invalid-execution-id'));
|
workflowRunnerRun.mockResolvedValueOnce('invalid-execution-id');
|
||||||
|
|
||||||
await activeWorkflowRunner.runWorkflow(
|
await activeWorkflowRunner.runWorkflow(
|
||||||
workflow[0],
|
workflow[0],
|
||||||
|
|
|
@ -6,7 +6,7 @@ jest.mock('@/Db', () => {
|
||||||
return {
|
return {
|
||||||
collections: {
|
collections: {
|
||||||
ExecutionMetadata: {
|
ExecutionMetadata: {
|
||||||
save: jest.fn(async () => Promise.resolve([])),
|
save: jest.fn(async () => []),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -134,63 +134,58 @@ export class BinaryDataFileSystem implements IBinaryDataManager {
|
||||||
|
|
||||||
const execsAdded: { [key: string]: number } = {};
|
const execsAdded: { [key: string]: number } = {};
|
||||||
|
|
||||||
const proms = metaFileNames.reduce(
|
const promises = metaFileNames.reduce<Array<Promise<void>>>((prev, curr) => {
|
||||||
(prev, curr) => {
|
const [prefix, executionId, ts] = curr.split('_');
|
||||||
const [prefix, executionId, ts] = curr.split('_');
|
|
||||||
|
|
||||||
if (prefix !== filePrefix) {
|
if (prefix !== filePrefix) {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
const execTimestamp = parseInt(ts, 10);
|
||||||
|
|
||||||
|
if (execTimestamp < currentTimeValue) {
|
||||||
|
if (execsAdded[executionId]) {
|
||||||
|
// do not delete data, only meta file
|
||||||
|
prev.push(this.deleteMetaFileByPath(path.join(metaPath, curr)));
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
const execTimestamp = parseInt(ts, 10);
|
execsAdded[executionId] = 1;
|
||||||
|
prev.push(
|
||||||
|
this.deleteBinaryDataByExecutionId(executionId).then(async () =>
|
||||||
|
this.deleteMetaFileByPath(path.join(metaPath, curr)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (execTimestamp < currentTimeValue) {
|
return prev;
|
||||||
if (execsAdded[executionId]) {
|
}, []);
|
||||||
// do not delete data, only meta file
|
|
||||||
prev.push(this.deleteMetaFileByPath(path.join(metaPath, curr)));
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
execsAdded[executionId] = 1;
|
await Promise.all(promises);
|
||||||
prev.push(
|
|
||||||
this.deleteBinaryDataByExecutionId(executionId).then(async () =>
|
|
||||||
this.deleteMetaFileByPath(path.join(metaPath, curr)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return prev;
|
|
||||||
},
|
|
||||||
[Promise.resolve()],
|
|
||||||
);
|
|
||||||
|
|
||||||
return Promise.all(proms).then(() => {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async duplicateBinaryDataByIdentifier(binaryDataId: string, prefix: string): Promise<string> {
|
async duplicateBinaryDataByIdentifier(binaryDataId: string, prefix: string): Promise<string> {
|
||||||
const newBinaryDataId = this.generateFileName(prefix);
|
const newBinaryDataId = this.generateFileName(prefix);
|
||||||
|
|
||||||
return fs
|
await fs.copyFile(
|
||||||
.copyFile(this.resolveStoragePath(binaryDataId), this.resolveStoragePath(newBinaryDataId))
|
this.resolveStoragePath(binaryDataId),
|
||||||
.then(() => newBinaryDataId);
|
this.resolveStoragePath(newBinaryDataId),
|
||||||
|
);
|
||||||
|
return newBinaryDataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteBinaryDataByExecutionId(executionId: string): Promise<void> {
|
async deleteBinaryDataByExecutionId(executionId: string): Promise<void> {
|
||||||
const regex = new RegExp(`${executionId}_*`);
|
const regex = new RegExp(`${executionId}_*`);
|
||||||
const filenames = await fs.readdir(this.storagePath);
|
const filenames = await fs.readdir(this.storagePath);
|
||||||
|
|
||||||
const proms = filenames.reduce(
|
const promises = filenames.reduce<Array<Promise<void>>>((allProms, filename) => {
|
||||||
(allProms, filename) => {
|
if (regex.test(filename)) {
|
||||||
if (regex.test(filename)) {
|
allProms.push(fs.rm(this.resolveStoragePath(filename)));
|
||||||
allProms.push(fs.rm(this.resolveStoragePath(filename)));
|
}
|
||||||
}
|
return allProms;
|
||||||
|
}, []);
|
||||||
|
|
||||||
return allProms;
|
await Promise.all(promises);
|
||||||
},
|
|
||||||
[Promise.resolve()],
|
|
||||||
);
|
|
||||||
|
|
||||||
return Promise.all(proms).then(async () => Promise.resolve());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteBinaryDataByIdentifier(identifier: string): Promise<void> {
|
async deleteBinaryDataByIdentifier(identifier: string): Promise<void> {
|
||||||
|
@ -198,20 +193,17 @@ export class BinaryDataFileSystem implements IBinaryDataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
async persistBinaryDataForExecutionId(executionId: string): Promise<void> {
|
async persistBinaryDataForExecutionId(executionId: string): Promise<void> {
|
||||||
return fs.readdir(this.getBinaryDataPersistMetaPath()).then(async (metafiles) => {
|
return fs.readdir(this.getBinaryDataPersistMetaPath()).then(async (metaFiles) => {
|
||||||
const proms = metafiles.reduce(
|
const promises = metaFiles.reduce<Array<Promise<void>>>((prev, curr) => {
|
||||||
(prev, curr) => {
|
if (curr.startsWith(`${PREFIX_PERSISTED_METAFILE}_${executionId}_`)) {
|
||||||
if (curr.startsWith(`${PREFIX_PERSISTED_METAFILE}_${executionId}_`)) {
|
prev.push(fs.rm(path.join(this.getBinaryDataPersistMetaPath(), curr)));
|
||||||
prev.push(fs.rm(path.join(this.getBinaryDataPersistMetaPath(), curr)));
|
|
||||||
return prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
return prev;
|
return prev;
|
||||||
},
|
}
|
||||||
[Promise.resolve()],
|
|
||||||
);
|
|
||||||
|
|
||||||
return Promise.all(proms).then(() => {});
|
return prev;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
await Promise.all(promises);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +219,8 @@ export class BinaryDataFileSystem implements IBinaryDataManager {
|
||||||
return path.join(this.storagePath, 'persistMeta');
|
return path.join(this.storagePath, 'persistMeta');
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteMetaFileByPath(metafilePath: string): Promise<void> {
|
private async deleteMetaFileByPath(metaFilePath: string): Promise<void> {
|
||||||
return fs.rm(metafilePath);
|
return fs.rm(metaFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteFromLocalStorage(identifier: string) {
|
private async deleteFromLocalStorage(identifier: string) {
|
||||||
|
|
|
@ -158,38 +158,30 @@ export class BinaryDataManager {
|
||||||
|
|
||||||
async markDataForDeletionByExecutionId(executionId: string): Promise<void> {
|
async markDataForDeletionByExecutionId(executionId: string): Promise<void> {
|
||||||
if (this.managers[this.binaryDataMode]) {
|
if (this.managers[this.binaryDataMode]) {
|
||||||
return this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(executionId);
|
await this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(executionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async markDataForDeletionByExecutionIds(executionIds: string[]): Promise<void> {
|
async markDataForDeletionByExecutionIds(executionIds: string[]): Promise<void> {
|
||||||
if (this.managers[this.binaryDataMode]) {
|
if (this.managers[this.binaryDataMode]) {
|
||||||
return Promise.all(
|
await Promise.all(
|
||||||
executionIds.map(async (id) =>
|
executionIds.map(async (id) =>
|
||||||
this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(id),
|
this.managers[this.binaryDataMode].markDataForDeletionByExecutionId(id),
|
||||||
),
|
),
|
||||||
).then(() => {});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async persistBinaryDataForExecutionId(executionId: string): Promise<void> {
|
async persistBinaryDataForExecutionId(executionId: string): Promise<void> {
|
||||||
if (this.managers[this.binaryDataMode]) {
|
if (this.managers[this.binaryDataMode]) {
|
||||||
return this.managers[this.binaryDataMode].persistBinaryDataForExecutionId(executionId);
|
await this.managers[this.binaryDataMode].persistBinaryDataForExecutionId(executionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteBinaryDataByExecutionId(executionId: string): Promise<void> {
|
async deleteBinaryDataByExecutionId(executionId: string): Promise<void> {
|
||||||
if (this.managers[this.binaryDataMode]) {
|
if (this.managers[this.binaryDataMode]) {
|
||||||
return this.managers[this.binaryDataMode].deleteBinaryDataByExecutionId(executionId);
|
await this.managers[this.binaryDataMode].deleteBinaryDataByExecutionId(executionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async duplicateBinaryData(
|
async duplicateBinaryData(
|
||||||
|
@ -218,7 +210,7 @@ export class BinaryDataManager {
|
||||||
return Promise.all(returnInputData);
|
return Promise.all(returnInputData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(inputData as INodeExecutionData[][]);
|
return inputData as INodeExecutionData[][];
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateBinaryId(filename: string) {
|
private generateBinaryId(filename: string) {
|
||||||
|
|
|
@ -792,7 +792,7 @@ export class WorkflowExecute {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gotCancel) {
|
if (gotCancel) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeSuccessData = null;
|
nodeSuccessData = null;
|
||||||
|
@ -919,7 +919,7 @@ export class WorkflowExecute {
|
||||||
|
|
||||||
for (let tryIndex = 0; tryIndex < maxTries; tryIndex++) {
|
for (let tryIndex = 0; tryIndex < maxTries; tryIndex++) {
|
||||||
if (gotCancel) {
|
if (gotCancel) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (tryIndex !== 0) {
|
if (tryIndex !== 0) {
|
||||||
|
@ -1175,10 +1175,8 @@ export class WorkflowExecute {
|
||||||
outputIndex
|
outputIndex
|
||||||
]) {
|
]) {
|
||||||
if (!workflow.nodes.hasOwnProperty(connectionData.node)) {
|
if (!workflow.nodes.hasOwnProperty(connectionData.node)) {
|
||||||
return Promise.reject(
|
throw new Error(
|
||||||
new Error(
|
`The node "${executionNode.name}" connects to not found node "${connectionData.node}"`,
|
||||||
`The node "${executionNode.name}" connects to not found node "${connectionData.node}"`,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,7 +1210,7 @@ export class WorkflowExecute {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve();
|
return;
|
||||||
})()
|
})()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (gotCancel && executionError === undefined) {
|
if (gotCancel && executionError === undefined) {
|
||||||
|
|
|
@ -527,15 +527,12 @@ export default mixins(externalHooks, genericHelpers, executionHelpers, showMessa
|
||||||
// Suppose 504 finishes before 500, 501, 502 and 503.
|
// Suppose 504 finishes before 500, 501, 502 and 503.
|
||||||
// iF you use firstId, filtering id >= 504 you won't
|
// iF you use firstId, filtering id >= 504 you won't
|
||||||
// ever get ids 500, 501, 502 and 503 when they finish
|
// ever get ids 500, 501, 502 and 503 when they finish
|
||||||
const pastExecutionsPromise: Promise<IExecutionsListResponse> =
|
const promises = [this.workflowsStore.getPastExecutions(filter, this.requestItemsPerRequest)];
|
||||||
this.workflowsStore.getPastExecutions(filter, this.requestItemsPerRequest);
|
if (isEmpty(filter.metadata)) {
|
||||||
const currentExecutionsPromise: Promise<IExecutionsCurrentSummaryExtended[]> = isEmpty(
|
promises.push(this.workflowsStore.getCurrentExecutions({}));
|
||||||
filter.metadata,
|
}
|
||||||
)
|
|
||||||
? this.workflowsStore.getCurrentExecutions({})
|
|
||||||
: Promise.resolve([]);
|
|
||||||
|
|
||||||
const results = await Promise.all([pastExecutionsPromise, currentExecutionsPromise]);
|
const results = await Promise.all(promises);
|
||||||
|
|
||||||
for (const activeExecution of results[1]) {
|
for (const activeExecution of results[1]) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -250,7 +250,7 @@ export default mixins(showMessage, debounceHelper).extend({
|
||||||
},
|
},
|
||||||
initialize: {
|
initialize: {
|
||||||
type: Function as PropType<() => Promise<void>>,
|
type: Function as PropType<() => Promise<void>>,
|
||||||
default: () => () => Promise.resolve(),
|
default: () => async () => {},
|
||||||
},
|
},
|
||||||
filters: {
|
filters: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
|
|
@ -460,7 +460,7 @@ export const workflowHelpers = mixins(externalHooks, nodeHelpers, showMessage).e
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns the currently loaded workflow as JSON.
|
// Returns the currently loaded workflow as JSON.
|
||||||
getWorkflowDataToSave(): Promise<IWorkflowData> {
|
async getWorkflowDataToSave(): Promise<IWorkflowData> {
|
||||||
const workflowNodes = this.workflowsStore.allNodes;
|
const workflowNodes = this.workflowsStore.allNodes;
|
||||||
const workflowConnections = this.workflowsStore.allConnections;
|
const workflowConnections = this.workflowsStore.allConnections;
|
||||||
|
|
||||||
|
@ -468,12 +468,8 @@ export const workflowHelpers = mixins(externalHooks, nodeHelpers, showMessage).e
|
||||||
|
|
||||||
const nodes = [];
|
const nodes = [];
|
||||||
for (let nodeIndex = 0; nodeIndex < workflowNodes.length; nodeIndex++) {
|
for (let nodeIndex = 0; nodeIndex < workflowNodes.length; nodeIndex++) {
|
||||||
try {
|
// @ts-ignore
|
||||||
// @ts-ignore
|
nodeData = this.getNodeDataToSave(workflowNodes[nodeIndex]);
|
||||||
nodeData = this.getNodeDataToSave(workflowNodes[nodeIndex]);
|
|
||||||
} catch (e) {
|
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
nodes.push(nodeData);
|
nodes.push(nodeData);
|
||||||
}
|
}
|
||||||
|
@ -494,7 +490,7 @@ export const workflowHelpers = mixins(externalHooks, nodeHelpers, showMessage).e
|
||||||
data.id = workflowId;
|
data.id = workflowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.resolve(data);
|
return data;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Returns all node-types
|
// Returns all node-types
|
||||||
|
|
|
@ -535,14 +535,16 @@ function setLanguage(language: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadLanguage(language?: string) {
|
export async function loadLanguage(language?: string) {
|
||||||
if (!language) return Promise.resolve();
|
if (!language) return;
|
||||||
|
|
||||||
if (i18nInstance.locale === language) {
|
if (i18nInstance.locale === language) {
|
||||||
return Promise.resolve(setLanguage(language));
|
setLanguage(language);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadedLanguages.includes(language)) {
|
if (loadedLanguages.includes(language)) {
|
||||||
return Promise.resolve(setLanguage(language));
|
setLanguage(language);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { numberFormats, ...rest } = (await import(`./locales/${language}.json`)).default;
|
const { numberFormats, ...rest } = (await import(`./locales/${language}.json`)).default;
|
||||||
|
|
|
@ -243,27 +243,23 @@ export const useSettingsStore = defineStore(STORES.SETTINGS, {
|
||||||
},
|
},
|
||||||
async fetchPromptsData(): Promise<void> {
|
async fetchPromptsData(): Promise<void> {
|
||||||
if (!this.isTelemetryEnabled) {
|
if (!this.isTelemetryEnabled) {
|
||||||
Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
const uiStore = useUIStore();
|
|
||||||
const usersStore = useUsersStore();
|
|
||||||
const promptsData: IN8nPrompts = await getPromptsData(
|
|
||||||
this.settings.instanceId,
|
|
||||||
usersStore.currentUserId || '',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (promptsData && promptsData.showContactPrompt) {
|
const uiStore = useUIStore();
|
||||||
uiStore.openModal(CONTACT_PROMPT_MODAL_KEY);
|
const usersStore = useUsersStore();
|
||||||
} else if (promptsData && promptsData.showValueSurvey) {
|
const promptsData: IN8nPrompts = await getPromptsData(
|
||||||
uiStore.openModal(VALUE_SURVEY_MODAL_KEY);
|
this.settings.instanceId,
|
||||||
}
|
usersStore.currentUserId || '',
|
||||||
|
);
|
||||||
|
|
||||||
this.setPromptsData(promptsData);
|
if (promptsData && promptsData.showContactPrompt) {
|
||||||
Promise.resolve();
|
uiStore.openModal(CONTACT_PROMPT_MODAL_KEY);
|
||||||
} catch (error) {
|
} else if (promptsData && promptsData.showValueSurvey) {
|
||||||
Promise.reject(error);
|
uiStore.openModal(VALUE_SURVEY_MODAL_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setPromptsData(promptsData);
|
||||||
},
|
},
|
||||||
async submitContactInfo(email: string): Promise<IN8nPromptResponse | undefined> {
|
async submitContactInfo(email: string): Promise<IN8nPromptResponse | undefined> {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -445,7 +445,7 @@ export default mixins(
|
||||||
}
|
}
|
||||||
} else if (confirmModal === MODAL_CANCEL) {
|
} else if (confirmModal === MODAL_CANCEL) {
|
||||||
this.workflowsStore.setWorkflowId(PLACEHOLDER_EMPTY_WORKFLOW_ID);
|
this.workflowsStore.setWorkflowId(PLACEHOLDER_EMPTY_WORKFLOW_ID);
|
||||||
await this.resetWorkspace();
|
this.resetWorkspace();
|
||||||
this.uiStore.stateIsDirty = false;
|
this.uiStore.stateIsDirty = false;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
@ -2529,7 +2529,7 @@ export default mixins(
|
||||||
},
|
},
|
||||||
async newWorkflow(): Promise<void> {
|
async newWorkflow(): Promise<void> {
|
||||||
this.startLoading();
|
this.startLoading();
|
||||||
await this.resetWorkspace();
|
this.resetWorkspace();
|
||||||
this.workflowData = await this.workflowsStore.getNewWorkflowData();
|
this.workflowData = await this.workflowsStore.getNewWorkflowData();
|
||||||
this.workflowsStore.currentWorkflowExecutions = [];
|
this.workflowsStore.currentWorkflowExecutions = [];
|
||||||
this.workflowsStore.activeWorkflowExecution = null;
|
this.workflowsStore.activeWorkflowExecution = null;
|
||||||
|
@ -2551,7 +2551,7 @@ export default mixins(
|
||||||
// In case the workflow got saved we do not have to run init
|
// In case the workflow got saved we do not have to run init
|
||||||
// as only the route changed but all the needed data is already loaded
|
// as only the route changed but all the needed data is already loaded
|
||||||
this.uiStore.stateIsDirty = false;
|
this.uiStore.stateIsDirty = false;
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
if (this.blankRedirect) {
|
if (this.blankRedirect) {
|
||||||
this.blankRedirect = false;
|
this.blankRedirect = false;
|
||||||
|
@ -2573,7 +2573,7 @@ export default mixins(
|
||||||
const saved = await this.saveCurrentWorkflow();
|
const saved = await this.saveCurrentWorkflow();
|
||||||
if (saved) await this.settingsStore.fetchPromptsData();
|
if (saved) await this.settingsStore.fetchPromptsData();
|
||||||
} else if (confirmModal === MODAL_CLOSE) {
|
} else if (confirmModal === MODAL_CLOSE) {
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Load a workflow
|
// Load a workflow
|
||||||
|
@ -3473,7 +3473,7 @@ export default mixins(
|
||||||
connections: tempWorkflow.connectionsBySourceNode,
|
connections: tempWorkflow.connectionsBySourceNode,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getSelectedNodesToSave(): Promise<IWorkflowData> {
|
async getSelectedNodesToSave(): Promise<IWorkflowData> {
|
||||||
const data: IWorkflowData = {
|
const data: IWorkflowData = {
|
||||||
nodes: [],
|
nodes: [],
|
||||||
connections: {},
|
connections: {},
|
||||||
|
@ -3484,12 +3484,8 @@ export default mixins(
|
||||||
const exportNodeNames: string[] = [];
|
const exportNodeNames: string[] = [];
|
||||||
|
|
||||||
for (const node of this.uiStore.getSelectedNodes) {
|
for (const node of this.uiStore.getSelectedNodes) {
|
||||||
try {
|
nodeData = this.getNodeDataToSave(node);
|
||||||
nodeData = this.getNodeDataToSave(node);
|
exportNodeNames.push(node.name);
|
||||||
exportNodeNames.push(node.name);
|
|
||||||
} catch (e) {
|
|
||||||
return Promise.reject(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
data.nodes.push(nodeData);
|
data.nodes.push(nodeData);
|
||||||
}
|
}
|
||||||
|
@ -3539,7 +3535,7 @@ export default mixins(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.resolve(data);
|
return data;
|
||||||
},
|
},
|
||||||
resetWorkspace() {
|
resetWorkspace() {
|
||||||
this.workflowsStore.resetWorkflow();
|
this.workflowsStore.resetWorkflow();
|
||||||
|
@ -3581,7 +3577,6 @@ export default mixins(
|
||||||
this.uiStore.nodeViewOffsetPosition = [0, 0];
|
this.uiStore.nodeViewOffsetPosition = [0, 0];
|
||||||
|
|
||||||
this.credentialsUpdated = false;
|
this.credentialsUpdated = false;
|
||||||
return Promise.resolve();
|
|
||||||
},
|
},
|
||||||
async loadActiveWorkflows(): Promise<void> {
|
async loadActiveWorkflows(): Promise<void> {
|
||||||
await this.workflowsStore.fetchActiveWorkflows();
|
await this.workflowsStore.fetchActiveWorkflows();
|
||||||
|
|
|
@ -88,7 +88,7 @@ export class Code implements INodeType {
|
||||||
try {
|
try {
|
||||||
result = await sandbox.runCodeAllItems();
|
result = await sandbox.runCodeAllItems();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!this.continueOnFail()) return Promise.reject(error);
|
if (!this.continueOnFail()) throw error;
|
||||||
result = [{ json: { error: error.message } }];
|
result = [{ json: { error: error.message } }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export class Code implements INodeType {
|
||||||
try {
|
try {
|
||||||
result = await sandbox.runCodeEachItem(index);
|
result = await sandbox.runCodeEachItem(index);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (!this.continueOnFail()) return Promise.reject(error);
|
if (!this.continueOnFail()) throw error;
|
||||||
returnData.push({ json: { error: error.message } });
|
returnData.push({ json: { error: error.message } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ return items;`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,14 +208,14 @@ return item;`,
|
||||||
const lineNumber = lineParts.splice(-2, 1);
|
const lineNumber = lineParts.splice(-2, 1);
|
||||||
if (!isNaN(lineNumber as number)) {
|
if (!isNaN(lineNumber as number)) {
|
||||||
error.message = `${error.message} [Line ${lineNumber} | Item Index: ${itemIndex}]`;
|
error.message = `${error.message} [Line ${lineNumber} | Item Index: ${itemIndex}]`;
|
||||||
return Promise.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error.message = `${error.message} [Item Index: ${itemIndex}]`;
|
error.message = `${error.message} [Item Index: ${itemIndex}]`;
|
||||||
|
|
||||||
return Promise.reject(error);
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,13 @@ async function processCampaignSearchResponse(
|
||||||
): Promise<INodeExecutionData[]> {
|
): Promise<INodeExecutionData[]> {
|
||||||
const results = (responseData.body as IDataObject).results as GoogleAdsCampaignElement;
|
const results = (responseData.body as IDataObject).results as GoogleAdsCampaignElement;
|
||||||
|
|
||||||
return Promise.resolve(
|
return results.map((result) => ({
|
||||||
results.map((result) => {
|
json: {
|
||||||
return {
|
...result.campaign,
|
||||||
json: {
|
...result.metrics,
|
||||||
...result.campaign,
|
...result.campaignBudget,
|
||||||
...result.metrics,
|
},
|
||||||
...result.campaignBudget,
|
}));
|
||||||
},
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const campaignOperations: INodeProperties[] = [
|
export const campaignOperations: INodeProperties[] = [
|
||||||
|
|
|
@ -14,21 +14,20 @@ jest.mock('../../../v2/transport', () => {
|
||||||
...originalModule,
|
...originalModule,
|
||||||
googleApiRequest: jest.fn(async (method: string, resource: string) => {
|
googleApiRequest: jest.fn(async (method: string, resource: string) => {
|
||||||
if (resource === '/v2/projects/test-project/jobs' && method === 'POST') {
|
if (resource === '/v2/projects/test-project/jobs' && method === 'POST') {
|
||||||
return Promise.resolve({
|
return {
|
||||||
jobReference: {
|
jobReference: {
|
||||||
jobId: 'job_123',
|
jobId: 'job_123',
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
state: 'DONE',
|
state: 'DONE',
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
if (resource === '/v2/projects/test-project/queries/job_123' && method === 'GET') {
|
if (resource === '/v2/projects/test-project/queries/job_123' && method === 'GET') {
|
||||||
return Promise.resolve({});
|
return {};
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
|
||||||
}),
|
}),
|
||||||
// googleApiRequestAllItems: jest.fn(async () => Promise.resolve()),
|
// googleApiRequestAllItems: jest.fn(async () => {}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,25 +17,24 @@ jest.mock('../../../v2/transport', () => {
|
||||||
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/num_text' &&
|
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/num_text' &&
|
||||||
method === 'GET'
|
method === 'GET'
|
||||||
) {
|
) {
|
||||||
return Promise.resolve({
|
return {
|
||||||
schema: {
|
schema: {
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'id', type: 'INT' },
|
{ name: 'id', type: 'INT' },
|
||||||
{ name: 'test', type: 'STRING' },
|
{ name: 'test', type: 'STRING' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
resource ===
|
resource ===
|
||||||
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/num_text/insertAll' &&
|
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/num_text/insertAll' &&
|
||||||
method === 'POST'
|
method === 'POST'
|
||||||
) {
|
) {
|
||||||
return Promise.resolve({ kind: 'bigquery#tableDataInsertAllResponse' });
|
return { kind: 'bigquery#tableDataInsertAllResponse' };
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
|
||||||
}),
|
}),
|
||||||
googleApiRequestAllItems: jest.fn(async () => Promise.resolve()),
|
googleApiRequestAllItems: jest.fn(async () => {}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ jest.mock('../../../v2/transport', () => {
|
||||||
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/test_json' &&
|
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/test_json' &&
|
||||||
method === 'GET'
|
method === 'GET'
|
||||||
) {
|
) {
|
||||||
return Promise.resolve({
|
return {
|
||||||
schema: {
|
schema: {
|
||||||
fields: [
|
fields: [
|
||||||
{ name: 'json', type: 'JSON' },
|
{ name: 'json', type: 'JSON' },
|
||||||
|
@ -25,22 +25,21 @@ jest.mock('../../../v2/transport', () => {
|
||||||
{ name: 'active', type: 'BOOLEAN' },
|
{ name: 'active', type: 'BOOLEAN' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
resource ===
|
resource ===
|
||||||
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/test_json/insertAll' &&
|
'/v2/projects/test-project/datasets/bigquery_node_dev_test_dataset/tables/test_json/insertAll' &&
|
||||||
method === 'POST'
|
method === 'POST'
|
||||||
) {
|
) {
|
||||||
return Promise.resolve({ kind: 'bigquery#tableDataInsertAllResponse' });
|
return { kind: 'bigquery#tableDataInsertAllResponse' };
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
|
||||||
}),
|
}),
|
||||||
googleApiRequestAllItems: jest.fn(async () => Promise.resolve()),
|
googleApiRequestAllItems: jest.fn(async () => {}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Test Google BigQuery V2, insert define manualy', () => {
|
describe('Test Google BigQuery V2, insert define manually', () => {
|
||||||
const workflows = ['nodes/Google/BigQuery/test/v2/node/insert.manualMode.workflow.json'];
|
const workflows = ['nodes/Google/BigQuery/test/v2/node/insert.manualMode.workflow.json'];
|
||||||
const tests = workflowToTests(workflows);
|
const tests = workflowToTests(workflows);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const fakeConnection = {
|
||||||
format(query: string, values: any[]) {
|
format(query: string, values: any[]) {
|
||||||
return mysql2.format(query, values);
|
return mysql2.format(query, values);
|
||||||
},
|
},
|
||||||
query: jest.fn(async (_query = ''): Promise<any> => Promise.resolve([{}])),
|
query: jest.fn(async (_query = '') => [{}]),
|
||||||
release: jest.fn(),
|
release: jest.fn(),
|
||||||
beginTransaction: jest.fn(),
|
beginTransaction: jest.fn(),
|
||||||
commit: jest.fn(),
|
commit: jest.fn(),
|
||||||
|
@ -41,7 +41,7 @@ const createFakePool = (connection: IDataObject) => {
|
||||||
getConnection() {
|
getConnection() {
|
||||||
return connection;
|
return connection;
|
||||||
},
|
},
|
||||||
query: jest.fn(async () => Promise.resolve([{}])),
|
query: jest.fn(async () => [{}]),
|
||||||
} as unknown as Mysql2Pool;
|
} as unknown as Mysql2Pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ describe('Test MySql V2, operations', () => {
|
||||||
} else {
|
} else {
|
||||||
result.push({});
|
result.push({});
|
||||||
}
|
}
|
||||||
return Promise.resolve(result);
|
return result;
|
||||||
});
|
});
|
||||||
const pool = createFakePool(fakeConnectionCopy);
|
const pool = createFakePool(fakeConnectionCopy);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ const fakeConnection = {
|
||||||
format(query: string, values: any[]) {
|
format(query: string, values: any[]) {
|
||||||
return mysql2.format(query, values);
|
return mysql2.format(query, values);
|
||||||
},
|
},
|
||||||
query: jest.fn(async () => Promise.resolve([{}])),
|
query: jest.fn(async () => [{}]),
|
||||||
release: jest.fn(),
|
release: jest.fn(),
|
||||||
beginTransaction: jest.fn(),
|
beginTransaction: jest.fn(),
|
||||||
commit: jest.fn(),
|
commit: jest.fn(),
|
||||||
|
@ -35,7 +35,7 @@ const createFakePool = (connection: IDataObject) => {
|
||||||
getConnection() {
|
getConnection() {
|
||||||
return connection;
|
return connection;
|
||||||
},
|
},
|
||||||
query: jest.fn(async () => Promise.resolve([{}])),
|
query: jest.fn(async () => [{}]),
|
||||||
} as unknown as Mysql2Pool;
|
} as unknown as Mysql2Pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ const createMockDb = (columnInfo: ColumnInfo[]) => {
|
||||||
} as unknown as PgpDatabase;
|
} as unknown as PgpDatabase;
|
||||||
};
|
};
|
||||||
|
|
||||||
// if node parameters copied from canvas all default parameters has to be added manualy as JSON would not have them
|
// if node parameters copied from canvas all default parameters has to be added manually as JSON would not have them
|
||||||
describe('Test PostgresV2, deleteTable operation', () => {
|
describe('Test PostgresV2, deleteTable operation', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
|
@ -1236,13 +1236,7 @@ export class Workflow {
|
||||||
return { data: null };
|
return { data: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
let promiseResults;
|
const promiseResults = await Promise.all(returnPromises);
|
||||||
try {
|
|
||||||
promiseResults = await Promise.all(returnPromises);
|
|
||||||
} catch (error) {
|
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (promiseResults) {
|
if (promiseResults) {
|
||||||
return { data: [promiseResults] };
|
return { data: [promiseResults] };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue