feat(formatter): add number action with math operation transformer (#1264)

* feat(formatter): Add number action with math operation transformer

* chore: Use different folders for list transform options of formatter
This commit is contained in:
Ömer Faruk Aydın
2023-09-05 13:02:43 +02:00
committed by GitHub
parent 18cef5f3bd
commit c9f292e252
17 changed files with 175 additions and 13 deletions

View File

@@ -1,14 +1,15 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
import capitalize from './options/capitalize';
import extractEmailAddress from './options/extract-email-address';
import extractNumber from './options/extract-number';
import htmlToMarkdown from './options/html-to-markdown';
import lowercase from './options/lowercase';
import markdownToHtml from './options/markdown-to-html';
import pluralize from './options/pluralize';
import replace from './options/replace';
import trimWhitespace from './options/trim-whitespace';
import useDefaultValue from './options/use-default-value';
import capitalize from './text/capitalize';
import extractEmailAddress from './text/extract-email-address';
import extractNumber from './text/extract-number';
import htmlToMarkdown from './text/html-to-markdown';
import lowercase from './text/lowercase';
import markdownToHtml from './text/markdown-to-html';
import pluralize from './text/pluralize';
import replace from './text/replace';
import trimWhitespace from './text/trim-whitespace';
import useDefaultValue from './text/use-default-value';
import performMathOperation from './numbers/perform-math-operation';
const options: IJSONObject = {
capitalize,
@@ -21,6 +22,7 @@ const options: IJSONObject = {
replace,
trimWhitespace,
useDefaultValue,
performMathOperation,
};
export default {

View File

@@ -0,0 +1,36 @@
const performMathOperation = [
{
label: 'Math Operation',
key: 'mathOperation',
type: 'dropdown' as const,
required: true,
description: 'The math operation to perform.',
variables: true,
options: [
{ label: 'Add', value: 'add' },
{ label: 'Divide', value: 'divide' },
{ label: 'Make Negative', value: 'makeNegative' },
{ label: 'Multiply', value: 'multiply' },
{ label: 'Subtract', value: 'subtract' },
],
},
{
label: 'Values',
key: 'values',
type: 'dynamic' as const,
required: false,
description: 'Add or remove numbers as needed.',
fields: [
{
label: 'Input',
key: 'input',
type: 'string' as const,
required: true,
description: 'The number to perform the math operation on.',
variables: true,
},
],
},
];
export default performMathOperation;