Removing mention of mustache from the server package.
This commit is contained in:
parent
3d967c2070
commit
67cc893670
|
@ -78,7 +78,6 @@
|
|||
"koa-session": "^5.12.0",
|
||||
"koa-static": "^5.0.0",
|
||||
"lodash": "^4.17.13",
|
||||
"mustache": "^4.0.1",
|
||||
"node-fetch": "^2.6.0",
|
||||
"open": "^7.3.0",
|
||||
"pino-pretty": "^4.0.0",
|
||||
|
|
|
@ -31,7 +31,7 @@ const {
|
|||
createLoginScreen,
|
||||
} = require("../../constants/screens")
|
||||
const { cloneDeep } = require("lodash/fp")
|
||||
const { recurseMustache } = require("../../utilities/mustache")
|
||||
const { recurseHandlebars } = require("../../utilities/handlebars")
|
||||
const { USERS_TABLE_SCHEMA } = require("../../constants")
|
||||
|
||||
const APP_PREFIX = DocumentTypes.APP + SEPARATOR
|
||||
|
@ -214,7 +214,7 @@ const createEmptyAppPackage = async (ctx, app) => {
|
|||
for (let layout of BASE_LAYOUTS) {
|
||||
const cloned = cloneDeep(layout)
|
||||
cloned.title = app.name
|
||||
screensAndLayouts.push(recurseMustache(cloned, app))
|
||||
screensAndLayouts.push(recurseHandlebars(cloned, app))
|
||||
}
|
||||
|
||||
const homeScreen = createHomeScreen(app)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const CouchDB = require("../db")
|
||||
|
||||
/**
|
||||
* When values are input to the system generally they will be of type string as this is required for mustache. This can
|
||||
* When values are input to the system generally they will be of type string as this is required for handlebars. This can
|
||||
* generate some odd scenarios as the Schema of the automation requires a number but the builder might supply a string
|
||||
* with mustache syntax to get the number from the rest of the context. To support this the server has to make sure that
|
||||
* the post mustache statement can be cast into the correct type, this function does this for numbers and booleans.
|
||||
* with handlebars syntax to get the number from the rest of the context. To support this the server has to make sure that
|
||||
* the post handlebars statement can be cast into the correct type, this function does this for numbers and booleans.
|
||||
*
|
||||
* @param {object} inputs An object of inputs, please note this will not recurse down into any objects within, it simply
|
||||
* cleanses the top level inputs, however it can be used by recursively calling it deeper into the object structures if
|
||||
|
@ -54,7 +54,7 @@ module.exports.cleanInputValues = (inputs, schema) => {
|
|||
*
|
||||
* @param {string} appId The instance which the Table/Table is contained under.
|
||||
* @param {string} tableId The ID of the Table/Table which the schema is to be retrieved for.
|
||||
* @param {object} row The input row structure which requires clean-up after having been through mustache statements.
|
||||
* @param {object} row The input row structure which requires clean-up after having been through handlebars statements.
|
||||
* @returns {Promise<Object>} The cleaned up rows object, will should now have all the required primitive types.
|
||||
*/
|
||||
module.exports.cleanUpRow = async (appId, tableId, row) => {
|
||||
|
@ -66,11 +66,11 @@ module.exports.cleanUpRow = async (appId, tableId, row) => {
|
|||
|
||||
/**
|
||||
* A utility function for the cleanUpRow, which can be used if only the row ID is known (not the table ID) to clean
|
||||
* up a row after mustache statements have been replaced. This is specifically useful for the update row action.
|
||||
* up a row after handlebars statements have been replaced. This is specifically useful for the update row action.
|
||||
*
|
||||
* @param {string} appId The instance which the Table/Table is contained under.
|
||||
* @param {string} rowId The ID of the row from which the tableId will be extracted, to get the Table/Table schema.
|
||||
* @param {object} row The input row structure which requires clean-up after having been through mustache statements.
|
||||
* @param {object} row The input row structure which requires clean-up after having been through handlebars statements.
|
||||
* @returns {Promise<Object>} The cleaned up rows object, which will now have all the required primitive types.
|
||||
*/
|
||||
module.exports.cleanUpRowById = async (appId, rowId, row) => {
|
||||
|
|
|
@ -3,7 +3,7 @@ const actions = require("./actions")
|
|||
const logic = require("./logic")
|
||||
const automationUtils = require("./automationUtils")
|
||||
const AutomationEmitter = require("../events/AutomationEmitter")
|
||||
const { recurseMustache } = require("../utilities/mustache")
|
||||
const { recurseHandlebars } = require("../utilities/handlebars")
|
||||
|
||||
handlebars.registerHelper("object", value => {
|
||||
return new handlebars.SafeString(JSON.stringify(value))
|
||||
|
@ -24,7 +24,7 @@ class Orchestrator {
|
|||
// remove from context
|
||||
delete triggerOutput.appId
|
||||
delete triggerOutput.metadata
|
||||
// step zero is never used as the mustache is zero indexed for customer facing
|
||||
// step zero is never used as the handlebars is zero indexed for customer facing
|
||||
this._context = { steps: [{}], trigger: triggerOutput }
|
||||
this._automation = automation
|
||||
// create an emitter which has the chain count for this automation run in it, so it can block
|
||||
|
@ -49,7 +49,7 @@ class Orchestrator {
|
|||
let automation = this._automation
|
||||
for (let step of automation.definition.steps) {
|
||||
let stepFn = await this.getStepFunctionality(step.type, step.stepId)
|
||||
step.inputs = recurseMustache(step.inputs, this._context)
|
||||
step.inputs = recurseHandlebars(step.inputs, this._context)
|
||||
step.inputs = automationUtils.cleanInputValues(
|
||||
step.inputs,
|
||||
step.schema.inputs
|
||||
|
|
|
@ -9,7 +9,7 @@ const { rowEmission, tableEmission } = require("./utils")
|
|||
|
||||
/**
|
||||
* Extending the standard emitter to some syntactic sugar and standardisation to the emitted event.
|
||||
* This is specifically quite important for mustache used in automations.
|
||||
* This is specifically quite important for handlebars used in automations.
|
||||
*/
|
||||
class BudibaseEmitter extends EventEmitter {
|
||||
emitRow(eventName, appId, row, table = null) {
|
||||
|
|
|
@ -5,17 +5,17 @@ handlebars.registerHelper("object", value => {
|
|||
})
|
||||
|
||||
/**
|
||||
* When running mustache statements to execute on the context of the automation it possible user's may input mustache
|
||||
* in a few different forms, some of which are invalid but are logically valid. An example of this would be the mustache
|
||||
* When running handlebars statements to execute on the context of the automation it possible user's may input handlebars
|
||||
* in a few different forms, some of which are invalid but are logically valid. An example of this would be the handlebars
|
||||
* statement "{{steps[0].revision}}" here it is obvious the user is attempting to access an array or object using array
|
||||
* like operators. These are not supported by Mustache and therefore the statement will fail. This function will clean up
|
||||
* the mustache statement so it instead reads as "{{steps.0.revision}}" which is valid and will work. It may also be expanded
|
||||
* to include any other mustache statement cleanup that has been deemed necessary for the system.
|
||||
* like operators. These are not supported by handlebars and therefore the statement will fail. This function will clean up
|
||||
* the handlebars statement so it instead reads as "{{steps.0.revision}}" which is valid and will work. It may also be expanded
|
||||
* to include any other handlebars statement cleanup that has been deemed necessary for the system.
|
||||
*
|
||||
* @param {string} string The string which *may* contain mustache statements, it is OK if it does not contain any.
|
||||
* @returns {string} The string that was input with cleaned up mustache statements as required.
|
||||
* @param {string} string The string which *may* contain handlebars statements, it is OK if it does not contain any.
|
||||
* @returns {string} The string that was input with cleaned up handlebars statements as required.
|
||||
*/
|
||||
function cleanMustache(string) {
|
||||
function cleanHandlebars(string) {
|
||||
let charToReplace = {
|
||||
"[": ".",
|
||||
"]": "",
|
||||
|
@ -42,13 +42,13 @@ function cleanMustache(string) {
|
|||
|
||||
/**
|
||||
* Given an input object this will recurse through all props to try and update
|
||||
* any handlebars/mustache statements within.
|
||||
* any handlebars statements within.
|
||||
* @param {object|array} inputs The input structure which is to be recursed, it is important to note that
|
||||
* if the structure contains any cycles then this will fail.
|
||||
* @param {object} context The context that handlebars should fill data from.
|
||||
* @returns {object|array} The structure input, as fully updated as possible.
|
||||
*/
|
||||
function recurseMustache(inputs, context) {
|
||||
function recurseHandlebars(inputs, context) {
|
||||
// JSON stringify will fail if there are any cycles, stops infinite recursion
|
||||
try {
|
||||
JSON.stringify(inputs)
|
||||
|
@ -58,16 +58,16 @@ function recurseMustache(inputs, context) {
|
|||
for (let key of Object.keys(inputs)) {
|
||||
let val = inputs[key]
|
||||
if (typeof val === "string") {
|
||||
val = cleanMustache(inputs[key])
|
||||
val = cleanHandlebars(inputs[key])
|
||||
const template = handlebars.compile(val)
|
||||
inputs[key] = template(context)
|
||||
}
|
||||
// this covers objects and arrays
|
||||
else if (typeof val === "object") {
|
||||
inputs[key] = recurseMustache(inputs[key], context)
|
||||
inputs[key] = recurseHandlebars(inputs[key], context)
|
||||
}
|
||||
}
|
||||
return inputs
|
||||
}
|
||||
|
||||
exports.recurseMustache = recurseMustache
|
||||
exports.recurseHandlebars = recurseHandlebars
|
|
@ -200,10 +200,10 @@
|
|||
lodash "^4.17.19"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@budibase/client@^0.4.3":
|
||||
version "0.4.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.4.3.tgz#eaf1ac83ed04722c29ea51907ac7c2190bd09b74"
|
||||
integrity sha512-gfVIU7P1HCMuH9rgmqgv2pD5oFDwwuX0QF3+FXuKR3/Cr6JW+bstVsNZHGgwOrmbxT3oAxfeNX186zrQupJ42w==
|
||||
"@budibase/client@^0.5.3":
|
||||
version "0.5.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.5.3.tgz#d2406b9a5b25ac446ba0f776b0ef3a38777a131a"
|
||||
integrity sha512-pv8pMH5vxgvIAEl+2zjp1ScWAtqVWqeH65e9EDqX6oVK2AsnJe9r0HxywOHN5mCgOFxou972+39c6fYR9/enyw==
|
||||
dependencies:
|
||||
deep-equal "^2.0.1"
|
||||
mustache "^4.0.1"
|
||||
|
|
Loading…
Reference in New Issue