feat: Convert all app files to JS
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
import capitalize from './transformers/capitalize';
|
||||
import extractEmailAddress from './transformers/extract-email-address';
|
||||
import extractNumber from './transformers/extract-number';
|
||||
import htmlToMarkdown from './transformers/html-to-markdown';
|
||||
import lowercase from './transformers/lowercase';
|
||||
import markdownToHtml from './transformers/markdown-to-html';
|
||||
import pluralize from './transformers/pluralize';
|
||||
import replace from './transformers/replace';
|
||||
import trimWhitespace from './transformers/trim-whitespace';
|
||||
import useDefaultValue from './transformers/use-default-value';
|
||||
import capitalize from './transformers/capitalize.js';
|
||||
import extractEmailAddress from './transformers/extract-email-address.js';
|
||||
import extractNumber from './transformers/extract-number.js';
|
||||
import htmlToMarkdown from './transformers/html-to-markdown.js';
|
||||
import lowercase from './transformers/lowercase.js';
|
||||
import markdownToHtml from './transformers/markdown-to-html.js';
|
||||
import pluralize from './transformers/pluralize.js';
|
||||
import replace from './transformers/replace.js';
|
||||
import trimWhitespace from './transformers/trim-whitespace.js';
|
||||
import useDefaultValue from './transformers/use-default-value.js';
|
||||
|
||||
const transformers = {
|
||||
capitalize,
|
||||
@@ -33,7 +33,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Transform',
|
||||
key: 'transform',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
variables: true,
|
||||
options: [
|
||||
@@ -66,8 +66,7 @@ export default defineAction({
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const transformerName = $.step.parameters
|
||||
.transform as keyof typeof transformers;
|
||||
const transformerName = $.step.parameters.transform;
|
||||
const output = transformers[transformerName]($);
|
||||
|
||||
$.setActionItem({
|
@@ -0,0 +1,10 @@
|
||||
import lodashCapitalize from 'lodash/capitalize.js';
|
||||
|
||||
const capitalize = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
const capitalizedInput = input.replace(/\w+/g, lodashCapitalize);
|
||||
|
||||
return capitalizedInput;
|
||||
};
|
||||
|
||||
export default capitalize;
|
@@ -1,11 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { capitalize as lodashCapitalize } from 'lodash';
|
||||
|
||||
const capitalize = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const capitalizedInput = input.replace(/\w+/g, lodashCapitalize);
|
||||
|
||||
return capitalizedInput;
|
||||
};
|
||||
|
||||
export default capitalize;
|
@@ -1,7 +1,5 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const extractEmailAddress = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const extractEmailAddress = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
const emailRegexp =
|
||||
/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const extractNumber = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const extractNumber = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
|
||||
// Example numbers that's supported:
|
||||
// 123
|
@@ -1,8 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import { NodeHtmlMarkdown } from 'node-html-markdown';
|
||||
|
||||
const htmlToMarkdown = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const htmlToMarkdown = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
|
||||
const markdown = NodeHtmlMarkdown.translate(input);
|
||||
return markdown;
|
@@ -0,0 +1,6 @@
|
||||
const lowercase = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
return input.toLowerCase();
|
||||
};
|
||||
|
||||
export default lowercase;
|
@@ -1,8 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const lowercase = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
return input.toLowerCase();
|
||||
};
|
||||
|
||||
export default lowercase;
|
@@ -1,10 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import showdown from 'showdown';
|
||||
|
||||
const converter = new showdown.Converter();
|
||||
|
||||
const markdownToHtml = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
const markdownToHtml = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
|
||||
const html = converter.makeHtml(input);
|
||||
return html;
|
@@ -0,0 +1,8 @@
|
||||
import pluralizeLibrary from 'pluralize';
|
||||
|
||||
const pluralize = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
return pluralizeLibrary(input);
|
||||
};
|
||||
|
||||
export default pluralize;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import pluralizeLibrary from 'pluralize';
|
||||
|
||||
const pluralize = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
return pluralizeLibrary(input);
|
||||
};
|
||||
|
||||
export default pluralize;
|
@@ -0,0 +1,10 @@
|
||||
const replace = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
|
||||
const find = $.step.parameters.find;
|
||||
const replace = $.step.parameters.replace;
|
||||
|
||||
return input.replaceAll(find, replace);
|
||||
};
|
||||
|
||||
export default replace;
|
@@ -1,12 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const replace = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
|
||||
const find = $.step.parameters.find as string;
|
||||
const replace = $.step.parameters.replace as string;
|
||||
|
||||
return input.replaceAll(find, replace);
|
||||
};
|
||||
|
||||
export default replace;
|
@@ -0,0 +1,6 @@
|
||||
const trimWhitespace = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
return input.trim();
|
||||
};
|
||||
|
||||
export default trimWhitespace;
|
@@ -1,8 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const trimWhitespace = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
return input.trim();
|
||||
};
|
||||
|
||||
export default trimWhitespace;
|
@@ -0,0 +1,11 @@
|
||||
const useDefaultValue = ($) => {
|
||||
const input = $.step.parameters.input;
|
||||
|
||||
if (input && input.trim().length > 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return $.step.parameters.defaultValue;
|
||||
};
|
||||
|
||||
export default useDefaultValue;
|
@@ -1,13 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const useDefaultValue = ($: IGlobalVariable) => {
|
||||
const input = $.step.parameters.input as string;
|
||||
|
||||
if (input && input.trim().length > 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
return $.step.parameters.defaultValue as string;
|
||||
};
|
||||
|
||||
export default useDefaultValue;
|
Reference in New Issue
Block a user