Browse Source
Merge pull request #6448 from Budibase/fix/loop-item-javascript
Fix issue with loop item in javascript bindings
pull/6499/head
Peter Clement
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
23 additions and
7 deletions
-
charts/budibase/values.yaml
-
packages/server/src/automations/automationUtils.js
-
packages/server/src/environment.js
-
packages/server/src/threads/automation.js
|
|
|
@ -103,7 +103,7 @@ globals: |
|
|
|
google: |
|
|
|
clientId: "" |
|
|
|
secret: "" |
|
|
|
automationMaxIterations: "500" |
|
|
|
automationMaxIterations: "200" |
|
|
|
|
|
|
|
createSecrets: true # creates an internal API key, JWT secrets and redis password for you |
|
|
|
|
|
|
|
|
|
|
|
@ -1,5 +1,10 @@ |
|
|
|
const { getTable } = require("../api/controllers/table/utils") |
|
|
|
const { findHBSBlocks } = require("@budibase/string-templates") |
|
|
|
const { |
|
|
|
findHBSBlocks, |
|
|
|
decodeJSBinding, |
|
|
|
isJSBinding, |
|
|
|
encodeJSBinding, |
|
|
|
} = require("@budibase/string-templates") |
|
|
|
|
|
|
|
/** |
|
|
|
* When values are input to the system generally they will be of type string as this is required for template strings. |
|
|
|
@ -77,11 +82,21 @@ exports.getError = err => { |
|
|
|
} |
|
|
|
|
|
|
|
exports.substituteLoopStep = (hbsString, substitute) => { |
|
|
|
let blocks = findHBSBlocks(hbsString) |
|
|
|
let blocks = [] |
|
|
|
let checkForJS = isJSBinding(hbsString) |
|
|
|
if (checkForJS) { |
|
|
|
hbsString = decodeJSBinding(hbsString) |
|
|
|
blocks.push(hbsString) |
|
|
|
} else { |
|
|
|
blocks = findHBSBlocks(hbsString) |
|
|
|
} |
|
|
|
for (let block of blocks) { |
|
|
|
let oldBlock = block |
|
|
|
block = block.replace(/loop/, substitute) |
|
|
|
hbsString = hbsString.replace(new RegExp(oldBlock, "g"), block) |
|
|
|
if (checkForJS) { |
|
|
|
hbsString = encodeJSBinding(block) |
|
|
|
} else { |
|
|
|
hbsString = block |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return hbsString |
|
|
|
|
|
|
|
@ -67,7 +67,8 @@ module.exports = { |
|
|
|
SALT_ROUNDS: process.env.SALT_ROUNDS, |
|
|
|
LOGGER: process.env.LOGGER, |
|
|
|
LOG_LEVEL: process.env.LOG_LEVEL, |
|
|
|
AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS, |
|
|
|
AUTOMATION_MAX_ITERATIONS: |
|
|
|
parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200, |
|
|
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY, |
|
|
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT, |
|
|
|
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT), |
|
|
|
|
|
|
|
@ -218,7 +218,7 @@ class Orchestrator { |
|
|
|
} |
|
|
|
} |
|
|
|
if ( |
|
|
|
index === parseInt(env.AUTOMATION_MAX_ITERATIONS) || |
|
|
|
index === env.AUTOMATION_MAX_ITERATION || |
|
|
|
index === parseInt(loopStep.inputs.iterations) |
|
|
|
) { |
|
|
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, { |
|
|
|
|