Compare commits
1 Commits
AUT-985
...
formatter-
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0b8e33f96d |
@@ -1,5 +1,6 @@
|
|||||||
import text from './text';
|
import text from './text';
|
||||||
import numbers from './numbers';
|
import numbers from './numbers';
|
||||||
import dateTime from './date-time';
|
import dateTime from './date-time';
|
||||||
|
import utilities from './utilities';
|
||||||
|
|
||||||
export default [text, numbers, dateTime];
|
export default [text, numbers, dateTime, utilities];
|
||||||
|
@@ -0,0 +1,54 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
|
||||||
|
import findArrayItemByProperty from './transformers/find-array-item-by-property';
|
||||||
|
|
||||||
|
const transformers = {
|
||||||
|
findArrayItemByProperty,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Utilities',
|
||||||
|
key: 'utilities',
|
||||||
|
description: 'Specific utilities to help you transform your data.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Transform',
|
||||||
|
key: 'transform',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: true,
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'Find Array Item By Property',
|
||||||
|
value: 'findArrayItemByProperty',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
additionalFields: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicFields',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listTransformOptions',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.transform',
|
||||||
|
value: '{parameters.transform}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const transformerName = $.step.parameters
|
||||||
|
.transform as keyof typeof transformers;
|
||||||
|
const output = transformers[transformerName]($);
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: {
|
||||||
|
output,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,13 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import { find } from 'lodash';
|
||||||
|
|
||||||
|
const findArrayItemByProperty = ($: IGlobalVariable) => {
|
||||||
|
const value = JSON.parse($.step.parameters.value as string);
|
||||||
|
const propertyName = $.step.parameters.propertyName as string;
|
||||||
|
const propertyValue = $.step.parameters.propertyValue as string;
|
||||||
|
|
||||||
|
const foundItem = find(value, { [propertyName]: propertyValue });
|
||||||
|
return foundItem;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default findArrayItemByProperty;
|
@@ -2,33 +2,35 @@ import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
|||||||
import capitalize from './text/capitalize';
|
import capitalize from './text/capitalize';
|
||||||
import extractEmailAddress from './text/extract-email-address';
|
import extractEmailAddress from './text/extract-email-address';
|
||||||
import extractNumber from './text/extract-number';
|
import extractNumber from './text/extract-number';
|
||||||
|
import findArrayItemByProperty from './utilities/find-array-item-by-property';
|
||||||
|
import formatDateTime from './date-time/format-date-time';
|
||||||
|
import formatNumber from './numbers/format-number';
|
||||||
import htmlToMarkdown from './text/html-to-markdown';
|
import htmlToMarkdown from './text/html-to-markdown';
|
||||||
import lowercase from './text/lowercase';
|
import lowercase from './text/lowercase';
|
||||||
import markdownToHtml from './text/markdown-to-html';
|
import markdownToHtml from './text/markdown-to-html';
|
||||||
|
import performMathOperation from './numbers/perform-math-operation';
|
||||||
import pluralize from './text/pluralize';
|
import pluralize from './text/pluralize';
|
||||||
|
import randomNumber from './numbers/random-number';
|
||||||
import replace from './text/replace';
|
import replace from './text/replace';
|
||||||
import trimWhitespace from './text/trim-whitespace';
|
import trimWhitespace from './text/trim-whitespace';
|
||||||
import useDefaultValue from './text/use-default-value';
|
import useDefaultValue from './text/use-default-value';
|
||||||
import performMathOperation from './numbers/perform-math-operation';
|
|
||||||
import randomNumber from './numbers/random-number';
|
|
||||||
import formatNumber from './numbers/format-number';
|
|
||||||
import formatDateTime from './date-time/format-date-time';
|
|
||||||
|
|
||||||
const options: IJSONObject = {
|
const options: IJSONObject = {
|
||||||
capitalize,
|
capitalize,
|
||||||
extractEmailAddress,
|
extractEmailAddress,
|
||||||
extractNumber,
|
extractNumber,
|
||||||
|
findArrayItemByProperty,
|
||||||
|
formatDateTime,
|
||||||
|
formatNumber,
|
||||||
htmlToMarkdown,
|
htmlToMarkdown,
|
||||||
lowercase,
|
lowercase,
|
||||||
markdownToHtml,
|
markdownToHtml,
|
||||||
|
performMathOperation,
|
||||||
pluralize,
|
pluralize,
|
||||||
|
randomNumber,
|
||||||
replace,
|
replace,
|
||||||
trimWhitespace,
|
trimWhitespace,
|
||||||
useDefaultValue,
|
useDefaultValue,
|
||||||
performMathOperation,
|
|
||||||
randomNumber,
|
|
||||||
formatNumber,
|
|
||||||
formatDateTime,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
const findArrayItemByProperty = [
|
||||||
|
{
|
||||||
|
label: 'Value',
|
||||||
|
key: 'value',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'Array of objects that will be searched.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Property Name',
|
||||||
|
key: 'propertyName',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'Property name that will be searched.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Property Value',
|
||||||
|
key: 'propertyValue',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'Property value that will be matched.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export default findArrayItemByProperty;
|
Reference in New Issue
Block a user