Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an override to duplicate a trigger as an action if necessary #35

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/utils/schemaAndComponentJsonBuilder.js
Original file line number Diff line number Diff line change
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
Loading