feat: add schedule integration

This commit is contained in:
Ali BARIN
2022-05-06 10:10:01 +02:00
parent c4c3779646
commit d864831bc5
22 changed files with 222 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
import { QueryContext, ModelOptions } from 'objection';
import Base from './base';
import App from './app';
import Flow from './flow';
import Connection from './connection';
import ExecutionStep from './execution-step';
@@ -75,6 +76,27 @@ class Step extends Base {
await super.$afterUpdate(opt, queryContext);
Telemetry.stepUpdated(this);
}
get isTrigger(): boolean {
return this.type === 'trigger';
}
async getTrigger() {
if (!this.isTrigger) return null;
const { appKey, connection, key, parameters = {} } = this;
const appData = App.findOneByKey(appKey);
const AppClass = (await import(`../apps/${appKey}`)).default;
const appInstance = new AppClass(
appData,
connection?.formattedData,
parameters,
);
const command = appInstance.triggers[key];
return command;
}
}
export default Step;