feat: Implement webhook logic along with new entry typeform trigger

This commit is contained in:
Faruk AYDIN
2022-11-28 23:30:03 +01:00
committed by Ali BARIN
parent 397926f994
commit d83e8dabf8
13 changed files with 246 additions and 12 deletions

View File

@@ -3,12 +3,14 @@ import Connection from '../models/connection';
import Flow from '../models/flow';
import Step from '../models/step';
import Execution from '../models/execution';
import appConfig from '../config/app';
import {
IJSONObject,
IApp,
IGlobalVariable,
ITriggerItem,
IActionItem,
IRequest,
} from '@automatisch/types';
import EarlyExitError from '../errors/early-exit';
@@ -19,12 +21,21 @@ type GlobalVariableOptions = {
step?: Step;
execution?: Execution;
testRun?: boolean;
request?: IRequest;
};
const globalVariable = async (
options: GlobalVariableOptions
): Promise<IGlobalVariable> => {
const { connection, app, flow, step, execution, testRun = false } = options;
const {
connection,
app,
flow,
step,
execution,
request,
testRun = false,
} = options;
const lastInternalId = testRun ? undefined : await flow?.lastInternalId();
const nextStep = await step?.getNextStep();
@@ -95,12 +106,22 @@ const globalVariable = async (
},
};
if (request) {
$.request = request;
}
$.http = createHttpClient({
$,
baseURL: app.apiBaseUrl,
beforeRequest: app.beforeRequest,
});
if (flow) {
const webhookUrl = appConfig.webhookUrl + '/webhooks/' + flow.id;
$.webhookUrl = webhookUrl;
}
const lastInternalIds =
testRun || (flow && step.isAction) ? [] : await flow?.lastInternalIds(2000);