mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Refactor Schedule component to include run method in WebhookTrigger
This commit is contained in:
parent
59a6771e73
commit
7e6af77d70
@ -1,7 +1,7 @@
|
||||
import LIMIT_MAX from 'Common/Types/Database/LimitMax';
|
||||
import BadDataException from 'Common/Types/Exception/BadDataException';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import ComponentMetadata from 'Common/Types/Workflow/Component';
|
||||
import ComponentMetadata, { Port } from 'Common/Types/Workflow/Component';
|
||||
import ComponentID from 'Common/Types/Workflow/ComponentID';
|
||||
import ScheduleComponents from 'Common/Types/Workflow/Components/Schedule';
|
||||
import Workflow from 'Model/Models/Workflow';
|
||||
@ -12,6 +12,8 @@ import TriggerCode, {
|
||||
InitProps,
|
||||
UpdateProps,
|
||||
} from '../TriggerCode';
|
||||
import { JSONObject } from 'Common/Types/JSON';
|
||||
import { RunOptions, RunReturnType } from '../ComponentCode';
|
||||
|
||||
export default class WebhookTrigger extends TriggerCode {
|
||||
public constructor() {
|
||||
@ -69,6 +71,30 @@ export default class WebhookTrigger extends TriggerCode {
|
||||
}
|
||||
}
|
||||
|
||||
public override async run(
|
||||
args: JSONObject,
|
||||
options: RunOptions
|
||||
): Promise<RunReturnType> {
|
||||
const successPort: Port | undefined = this.getMetadata().outPorts.find(
|
||||
(p: Port) => {
|
||||
return p.id === 'execute';
|
||||
}
|
||||
);
|
||||
|
||||
if (!successPort) {
|
||||
throw options.onError(
|
||||
new BadDataException('Execute port not found')
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
returnValues: {
|
||||
...args,
|
||||
},
|
||||
executePort: successPort,
|
||||
};
|
||||
}
|
||||
|
||||
public override async update(props: UpdateProps): Promise<void> {
|
||||
const workflow: Workflow | null = await WorkflowService.findOneBy({
|
||||
query: {
|
||||
|
Loading…
Reference in New Issue
Block a user