Merge pull request #1126 from automatisch/optimize-last-execution
refactor: Optimize fetching last execution step
This commit is contained in:
@@ -20,12 +20,14 @@ export default defineTrigger({
|
|||||||
],
|
],
|
||||||
|
|
||||||
async testRun($) {
|
async testRun($) {
|
||||||
if (!isEmpty($.lastExecutionStep?.dataOut)) {
|
const lastExecutionStep = await $.getLastExecutionStep();
|
||||||
|
|
||||||
|
if (!isEmpty(lastExecutionStep?.dataOut)) {
|
||||||
$.pushTriggerItem({
|
$.pushTriggerItem({
|
||||||
raw: $.lastExecutionStep.dataOut,
|
raw: lastExecutionStep.dataOut,
|
||||||
meta: {
|
meta: {
|
||||||
internalId: '',
|
internalId: '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -35,20 +37,15 @@ export default defineTrigger({
|
|||||||
name: $.flow.id,
|
name: $.flow.id,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: $.webhookUrl,
|
url: $.webhookUrl,
|
||||||
filters: [$.step.parameters.filters]
|
filters: [$.step.parameters.filters],
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data } = await $.http.post(
|
const { data } = await $.http.post(`/v2/public/api/webhooks`, payload);
|
||||||
`/v2/public/api/webhooks`,
|
|
||||||
payload
|
|
||||||
);
|
|
||||||
|
|
||||||
await $.flow.setRemoteWebhookId(data.id);
|
await $.flow.setRemoteWebhookId(data.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
async unregisterHook($) {
|
async unregisterHook($) {
|
||||||
await $.http.delete(
|
await $.http.delete(`/v2/public/api/webhooks/${$.flow.remoteWebhookId}`);
|
||||||
`/v2/public/api/webhooks/${$.flow.remoteWebhookId}`
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ export default defineTrigger({
|
|||||||
{
|
{
|
||||||
name: 'parameters.valueType',
|
name: 'parameters.valueType',
|
||||||
value: 'sid',
|
value: 'sid',
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -37,12 +37,14 @@ export default defineTrigger({
|
|||||||
async testRun($) {
|
async testRun($) {
|
||||||
await fetchMessages($);
|
await fetchMessages($);
|
||||||
|
|
||||||
if (!isEmpty($.lastExecutionStep?.dataOut)) {
|
const lastExecutionStep = await $.getLastExecutionStep();
|
||||||
|
|
||||||
|
if (!isEmpty(lastExecutionStep?.dataOut)) {
|
||||||
$.pushTriggerItem({
|
$.pushTriggerItem({
|
||||||
raw: $.lastExecutionStep.dataOut,
|
raw: lastExecutionStep.dataOut,
|
||||||
meta: {
|
meta: {
|
||||||
internalId: '',
|
internalId: '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -8,12 +8,14 @@ export default defineTrigger({
|
|||||||
description: 'Triggers when the webhook receives a request.',
|
description: 'Triggers when the webhook receives a request.',
|
||||||
|
|
||||||
async testRun($) {
|
async testRun($) {
|
||||||
if (!isEmpty($.lastExecutionStep?.dataOut)) {
|
const lastExecutionStep = await $.getLastExecutionStep();
|
||||||
|
|
||||||
|
if (!isEmpty(lastExecutionStep?.dataOut)) {
|
||||||
$.pushTriggerItem({
|
$.pushTriggerItem({
|
||||||
raw: $.lastExecutionStep.dataOut,
|
raw: lastExecutionStep.dataOut,
|
||||||
meta: {
|
meta: {
|
||||||
internalId: '',
|
internalId: '',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -80,9 +80,10 @@ const globalVariable = async (
|
|||||||
testRun,
|
testRun,
|
||||||
exit: () => {
|
exit: () => {
|
||||||
throw new EarlyExitError();
|
throw new EarlyExitError();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
lastExecutionStep: (await step?.getLastExecutionStep())?.toJSON(),
|
},
|
||||||
|
getLastExecutionStep: async () =>
|
||||||
|
(await step?.getLastExecutionStep())?.toJSON(),
|
||||||
triggerOutput: {
|
triggerOutput: {
|
||||||
data: [],
|
data: [],
|
||||||
},
|
},
|
||||||
|
2
packages/types/index.d.ts
vendored
2
packages/types/index.d.ts
vendored
@@ -331,7 +331,7 @@ export type IGlobalVariable = {
|
|||||||
testRun: boolean;
|
testRun: boolean;
|
||||||
exit: () => void;
|
exit: () => void;
|
||||||
};
|
};
|
||||||
lastExecutionStep?: IExecutionStep;
|
getLastExecutionStep?: () => Promise<IExecutionStep>;
|
||||||
webhookUrl?: string;
|
webhookUrl?: string;
|
||||||
triggerOutput?: ITriggerOutput;
|
triggerOutput?: ITriggerOutput;
|
||||||
actionOutput?: IActionOutput;
|
actionOutput?: IActionOutput;
|
||||||
|
Reference in New Issue
Block a user