feat: validate trigger input in updateStep
This commit is contained in:
@@ -43,6 +43,10 @@ const updateStep = async (
|
||||
}
|
||||
}
|
||||
|
||||
if (step.isTrigger) {
|
||||
await App.checkAppAndTrigger(input.appKey, input.key);
|
||||
}
|
||||
|
||||
if (step.isAction) {
|
||||
await App.checkAppAndAction(input.appKey, input.key);
|
||||
}
|
||||
|
@@ -46,6 +46,16 @@ class App {
|
||||
throw new Error(`${app.name} does not have an action with the "${actionKey}" key!`);
|
||||
}
|
||||
}
|
||||
|
||||
static async checkAppAndTrigger(appKey: string, triggerKey: string): Promise<void> {
|
||||
const app = await this.findOneByKey(appKey);
|
||||
|
||||
const hasTrigger = app.triggers?.find(trigger => trigger.key === triggerKey);
|
||||
|
||||
if (!hasTrigger) {
|
||||
throw new Error(`${app.name} does not have a trigger with the "${triggerKey}" key!`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
Reference in New Issue
Block a user