@wmfs/cardscript-cleaner
v1.5.0
Published
Cleans Cardscript form data to ensure we only submit the data that we should.
Downloads
3
Readme
cardscript-expressions
cardscript-expressions provides a number of utilities to generate expressions, generate AST's, and clean cardscript data for submissions
Install
$ npm install cardscript-expressions --save
Usage
const expressions = new CardscriptExpressionsxpressions()
Method summary
| Usage | Description |
| ----------- | ----------- |
| const expressionList = getExpressionsFromCardscript(cardscript)
| Takes a cardscript schema and extracts a list of expressions. |
| convertExpressionsToAst(expressions)
| Takes a list of expressions generated by getExpressionsFromCardscript()
and amends the generated AST's to an object asts
available from expressions.asts
|
| addCardscript(cardscript)
| A combination of getExpressionsFromCardscript(cardscript)
and convertExpressionsToAst(expressions)
, used to generate AST's from cardscript in one function call |
| const visibilityList = calculateWidgetVisibility(cardscript, data, asts)
| Takes a cardscript schema, submission data, and a list of AST's to generate an object of {key: boolean}
values representing whether a widget should be visible or not |
| const clean = cleanData(data, visibilityList)
| Takes submission data and a visibility list generated by calculateWidgetVisibility
and returns a cleaned data object with values of hidden fields removed |