Skip to content

Commit

Permalink
feat(formatter): Add trim whitespace transformer to text action
Browse files Browse the repository at this point in the history
  • Loading branch information
farukaydin committed Sep 1, 2023
1 parent 200e6d9 commit 3a5723d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/backend/src/apps/formatter/actions/text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import extractEmailAddress from './transformers/extract-email-address';
import extractNumber from './transformers/extract-number';
import lowercase from './transformers/lowercase';
import pluralize from './transformers/pluralize';
import trimWhitespace from './transformers/trim-whitespace';

const transformers = {
capitalize,
Expand All @@ -17,6 +18,7 @@ const transformers = {
extractNumber,
lowercase,
pluralize,
trimWhitespace,
};

export default defineAction({
Expand All @@ -41,6 +43,7 @@ export default defineAction({
{ label: 'Extract Number', value: 'extractNumber' },
{ label: 'Lowercase', value: 'lowercase' },
{ label: 'Pluralize', value: 'pluralize' },
{ label: 'Trim Whitespace', value: 'trimWhitespace' },
],
additionalFields: {
type: 'query',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IGlobalVariable } from '@automatisch/types';

const trimWhitespace = ($: IGlobalVariable) => {
const input = $.step.parameters.input as string;
return input.trim();
};

export default trimWhitespace;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import extractEmailAddress from './options/extract-email-address';
import extractNumber from './options/extract-number';
import lowercase from './options/lowercase';
import pluralize from './options/pluralize';
import trimWhitespace from './options/trim-whitespace';

const options: IJSONObject = {
capitalize,
Expand All @@ -17,6 +18,7 @@ const options: IJSONObject = {
extractNumber,
lowercase,
pluralize,
trimWhitespace,
};

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const trimWhitespace = [
{
label: 'Input',
key: 'input',
type: 'string' as const,
required: true,
description: 'Text you want to remove leading and trailing spaces.',
variables: true,
},
];

export default trimWhitespace;

0 comments on commit 3a5723d

Please sign in to comment.