Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(formatter): Add trim whitespace transformer to text action #1261

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;