Skip to content

Commit

Permalink
Merge pull request #35 from openintegrationhub/MakeActionOverride
Browse files Browse the repository at this point in the history
Added an override to duplicate a trigger as an action if necessary
  • Loading branch information
SvenHoeffler committed Apr 23, 2024
2 parents 7fa1646 + 7ddbb46 commit adba229
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/utils/schemaAndComponentJsonBuilder.js
Expand Up @@ -22,6 +22,14 @@ async function schemaBuilder(api, componentJson, existingNames, outputDir) {
if (method === "parameters") {
return;
}

// In cases where we need a triggers also as an action
let makeAction = false;
if (method.includes('get') && operation.summary.includes('#MAKEACTION#')) {
operation.summary = operation.summary.replace('#MAKEACTION#', '');
makeAction = true;
}

let name = operation.operationId || method + opPath;
name = name.replace(/[^a-z0-9_]/gi, "_");
if (!name.match(/^[a-z]/i)) {
Expand Down Expand Up @@ -123,6 +131,13 @@ async function schemaBuilder(api, componentJson, existingNames, outputDir) {
componentJson.actions[name] = action;
}

// triggers that were marked with makeaction are also actions
if (makeAction) {
const newAction = _.cloneDeep(action);
newAction.main = filename("lib/actions/action.js");
componentJson.actions[`${name}_action`] = newAction;
}

// get requests with path params are also triggers
// we need to add a postfix to the trigger name, so that we don't break old components
if (method === "get" && opPath.includes("{")) {
Expand Down

0 comments on commit adba229

Please sign in to comment.