mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
refactor: Remove cli/src/helpers
(no-changelog) (#9368)
This commit is contained in:
parent
359ade45bc
commit
4d2115c163
|
@ -2,11 +2,12 @@ import type Bull from 'bull';
|
||||||
import { Service } from 'typedi';
|
import { Service } from 'typedi';
|
||||||
import {
|
import {
|
||||||
ApplicationError,
|
ApplicationError,
|
||||||
|
BINARY_ENCODING,
|
||||||
|
type IDataObject,
|
||||||
type ExecutionError,
|
type ExecutionError,
|
||||||
type IExecuteResponsePromiseData,
|
type IExecuteResponsePromiseData,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { ActiveExecutions } from '@/ActiveExecutions';
|
import { ActiveExecutions } from '@/ActiveExecutions';
|
||||||
import { decodeWebhookResponse } from '@/helpers/decodeWebhookResponse';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getRedisClusterClient,
|
getRedisClusterClient,
|
||||||
|
@ -68,11 +69,26 @@ export class Queue {
|
||||||
this.jobQueue.on('global:progress', (jobId, progress: WebhookResponse) => {
|
this.jobQueue.on('global:progress', (jobId, progress: WebhookResponse) => {
|
||||||
this.activeExecutions.resolveResponsePromise(
|
this.activeExecutions.resolveResponsePromise(
|
||||||
progress.executionId,
|
progress.executionId,
|
||||||
decodeWebhookResponse(progress.response),
|
this.decodeWebhookResponse(progress.response),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
decodeWebhookResponse(response: IExecuteResponsePromiseData): IExecuteResponsePromiseData {
|
||||||
|
if (
|
||||||
|
typeof response === 'object' &&
|
||||||
|
typeof response.body === 'object' &&
|
||||||
|
(response.body as IDataObject)['__@N8nEncodedBuffer@__']
|
||||||
|
) {
|
||||||
|
response.body = Buffer.from(
|
||||||
|
(response.body as IDataObject)['__@N8nEncodedBuffer@__'] as string,
|
||||||
|
BINARY_ENCODING,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
async add(jobData: JobData, jobOptions: object): Promise<Job> {
|
async add(jobData: JobData, jobOptions: object): Promise<Job> {
|
||||||
return await this.jobQueue.add(jobData, jobOptions);
|
return await this.jobQueue.add(jobData, jobOptions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { BINARY_ENCODING, type IDataObject, type IExecuteResponsePromiseData } from 'n8n-workflow';
|
|
||||||
|
|
||||||
export function decodeWebhookResponse(
|
|
||||||
response: IExecuteResponsePromiseData,
|
|
||||||
): IExecuteResponsePromiseData {
|
|
||||||
if (
|
|
||||||
typeof response === 'object' &&
|
|
||||||
typeof response.body === 'object' &&
|
|
||||||
(response.body as IDataObject)['__@N8nEncodedBuffer@__']
|
|
||||||
) {
|
|
||||||
response.body = Buffer.from(
|
|
||||||
(response.body as IDataObject)['__@N8nEncodedBuffer@__'] as string,
|
|
||||||
BINARY_ENCODING,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
|
Loading…
Reference in a new issue