refactor: Pass connection, flow and step as params to apps

This commit is contained in:
Faruk AYDIN
2022-08-21 20:25:04 +03:00
parent cd6c5216ff
commit 44e3de8534
18 changed files with 60 additions and 85 deletions

View File

@@ -78,6 +78,10 @@ class Step extends Base {
return `${appConfig.baseUrl}/apps/${this.appKey}/assets/favicon.svg`;
}
get appData() {
return App.findOneByKey(this.appKey);
}
async $afterInsert(queryContext: QueryContext) {
await super.$afterInsert(queryContext);
Telemetry.stepCreated(this);
@@ -95,17 +99,13 @@ class Step extends Base {
async getTrigger() {
if (!this.isTrigger) return null;
const { appKey, key, parameters = {} } = this;
const { appKey, key } = this;
const connection = await this.$relatedQuery('connection');
const flow = await this.$relatedQuery('flow');
const appData = App.findOneByKey(appKey);
const AppClass = (await import(`../apps/${appKey}`)).default;
const appInstance = new AppClass(
appData,
connection?.formattedData,
parameters
);
const appInstance = new AppClass(connection, flow, this);
const command = appInstance.triggers[key];
return command;