feat: Convert all app files to JS
This commit is contained in:
3
packages/backend/src/apps/smtp/actions/index.js
Normal file
3
packages/backend/src/apps/smtp/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendEmail from './send-email/index.js';
|
||||
|
||||
export default [sendEmail];
|
@@ -1,3 +0,0 @@
|
||||
import sendEmail from './send-email';
|
||||
|
||||
export default [sendEmail];
|
@@ -1,6 +1,5 @@
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import transporter from '../../common/transporter';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import transporter from '../../common/transporter.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send an email',
|
||||
@@ -10,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'From name',
|
||||
key: 'fromName',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Display name of the sender.',
|
||||
variables: true,
|
||||
@@ -18,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'From email',
|
||||
key: 'fromEmail',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Email address of the sender.',
|
||||
variables: true,
|
||||
@@ -26,7 +25,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Reply to',
|
||||
key: 'replyTo',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'Email address to reply to. Defaults to the from email address.',
|
||||
@@ -35,7 +34,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'To',
|
||||
key: 'to',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description:
|
||||
'Comma seperated list of email addresses to send the email to.',
|
||||
@@ -44,7 +43,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Cc',
|
||||
key: 'cc',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Comma seperated list of email addresses.',
|
||||
variables: true,
|
||||
@@ -52,7 +51,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Bcc',
|
||||
key: 'bcc',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Comma seperated list of email addresses.',
|
||||
variables: true,
|
||||
@@ -60,7 +59,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Subject',
|
||||
key: 'subject',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Subject of the email.',
|
||||
variables: true,
|
||||
@@ -68,7 +67,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Body',
|
||||
key: 'body',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Body of the email.',
|
||||
variables: true,
|
||||
@@ -78,14 +77,14 @@ export default defineAction({
|
||||
async run($) {
|
||||
const info = await transporter($).sendMail({
|
||||
from: `${$.step.parameters.fromName} <${$.step.parameters.fromEmail}>`,
|
||||
to: ($.step.parameters.to as string).split(','),
|
||||
replyTo: $.step.parameters.replyTo as string,
|
||||
cc: ($.step.parameters.cc as string).split(','),
|
||||
bcc: ($.step.parameters.bcc as string).split(','),
|
||||
subject: $.step.parameters.subject as string,
|
||||
text: $.step.parameters.body as string,
|
||||
to: $.step.parameters.to.split(','),
|
||||
replyTo: $.step.parameters.replyTo,
|
||||
cc: $.step.parameters.cc.split(','),
|
||||
bcc: $.step.parameters.bcc.split(','),
|
||||
subject: $.step.parameters.subject,
|
||||
text: $.step.parameters.body,
|
||||
});
|
||||
|
||||
$.setActionItem({ raw: info as IJSONObject });
|
||||
$.setActionItem({ raw: info });
|
||||
},
|
||||
});
|
@@ -1,12 +1,12 @@
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'host',
|
||||
label: 'Host',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'username',
|
||||
label: 'Email/Username',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -30,7 +30,7 @@ export default {
|
||||
{
|
||||
key: 'password',
|
||||
label: 'Password',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -42,7 +42,7 @@ export default {
|
||||
{
|
||||
key: 'useTls',
|
||||
label: 'Use TLS?',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: false,
|
||||
@@ -64,7 +64,7 @@ export default {
|
||||
{
|
||||
key: 'port',
|
||||
label: 'Port',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: '25',
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
{
|
||||
key: 'fromEmail',
|
||||
label: 'From Email',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: null,
|
8
packages/backend/src/apps/smtp/auth/is-still-verified.js
Normal file
8
packages/backend/src/apps/smtp/auth/is-still-verified.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
11
packages/backend/src/apps/smtp/auth/verify-credentials.js
Normal file
11
packages/backend/src/apps/smtp/auth/verify-credentials.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import transporter from '../common/transporter.js';
|
||||
|
||||
const verifyCredentials = async ($) => {
|
||||
await transporter($).verify();
|
||||
|
||||
await $.auth.set({
|
||||
screenName: $.auth.data.username,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -1,12 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import transporter from '../common/transporter';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
await transporter($).verify();
|
||||
|
||||
await $.auth.set({
|
||||
screenName: $.auth.data.username,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -1,7 +1,6 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import nodemailer, { TransportOptions } from 'nodemailer';
|
||||
import nodemailer from 'nodemailer';
|
||||
|
||||
const transporter = ($: IGlobalVariable) => {
|
||||
const transporter = ($) => {
|
||||
return nodemailer.createTransport({
|
||||
host: $.auth.data.host,
|
||||
port: $.auth.data.port,
|
||||
@@ -10,7 +9,7 @@ const transporter = ($: IGlobalVariable) => {
|
||||
user: $.auth.data.username,
|
||||
pass: $.auth.data.password,
|
||||
},
|
||||
} as TransportOptions);
|
||||
});
|
||||
};
|
||||
|
||||
export default transporter;
|
@@ -1,6 +1,6 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'SMTP',
|
Reference in New Issue
Block a user