feat: Implement create dynamic fields API endpoint

This commit is contained in:
Faruk AYDIN
2024-03-22 02:55:23 +01:00
parent de77488f7e
commit 7664b58553
6 changed files with 255 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import Connection from './connection.js';
import ExecutionStep from './execution-step.js';
import Telemetry from '../helpers/telemetry/index.js';
import appConfig from '../config/app.js';
import globalVariable from '../helpers/global-variable.js';
class Step extends Base {
static tableName = 'steps';
@@ -196,6 +197,26 @@ class Step extends Base {
return existingArguments;
}
async createDynamicFields(dynamicFieldsKey, parameters) {
const connection = await this.$relatedQuery('connection');
const flow = await this.$relatedQuery('flow');
const app = await this.getApp();
const $ = await globalVariable({ connection, app, flow, step: this });
const command = app.dynamicFields.find(
(data) => data.key === dynamicFieldsKey
);
for (const parameterKey in parameters) {
const parameterValue = parameters[parameterKey];
$.step.parameters[parameterKey] = parameterValue;
}
const dynamicFields = (await command.run($)) || [];
return dynamicFields;
}
async updateWebhookUrl() {
if (this.isAction) return this;