feat: Convert all app files to JS
This commit is contained in:
3
packages/backend/src/apps/ntfy/actions/index.js
Normal file
3
packages/backend/src/apps/ntfy/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendMessage from './send-message/index.js';
|
||||
|
||||
export default [sendMessage];
|
@@ -1,3 +0,0 @@
|
||||
import sendMessage from './send-message';
|
||||
|
||||
export default [sendMessage];
|
@@ -1,5 +1,5 @@
|
||||
import qs from 'qs';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send message',
|
||||
@@ -9,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Topic',
|
||||
key: 'topic',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Target topic name.',
|
||||
variables: true,
|
||||
@@ -17,15 +17,16 @@ export default defineAction({
|
||||
{
|
||||
label: 'Message body',
|
||||
key: 'message',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Message body to be sent, set to triggered if empty or not passed.',
|
||||
description:
|
||||
'Message body to be sent, set to triggered if empty or not passed.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Message title.',
|
||||
variables: true,
|
||||
@@ -33,7 +34,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'E-mail address for e-mail notifications.',
|
||||
variables: true,
|
||||
@@ -41,7 +42,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Click URL',
|
||||
key: 'click',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Website opened when notification is clicked.',
|
||||
variables: true,
|
||||
@@ -49,7 +50,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Attach file by URL',
|
||||
key: 'attach',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'URL of an attachment.',
|
||||
variables: true,
|
||||
@@ -57,7 +58,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Filename',
|
||||
key: 'filename',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'File name of the attachment.',
|
||||
variables: true,
|
||||
@@ -65,24 +66,17 @@ export default defineAction({
|
||||
{
|
||||
label: 'Delay',
|
||||
key: 'delay',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Timestamp or duration for delayed delivery. For example, 30min or 9am.',
|
||||
description:
|
||||
'Timestamp or duration for delayed delivery. For example, 30min or 9am.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
topic,
|
||||
message,
|
||||
title,
|
||||
email,
|
||||
click,
|
||||
attach,
|
||||
filename,
|
||||
delay
|
||||
} = $.step.parameters;
|
||||
const { topic, message, title, email, click, attach, filename, delay } =
|
||||
$.step.parameters;
|
||||
const payload = {
|
||||
topic,
|
||||
message,
|
||||
@@ -91,7 +85,7 @@ export default defineAction({
|
||||
click,
|
||||
attach,
|
||||
filename,
|
||||
delay
|
||||
delay,
|
||||
};
|
||||
|
||||
const response = await $.http.post('/', payload);
|
@@ -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: 'serverUrl',
|
||||
label: 'Server URL',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: 'https://ntfy.sh',
|
||||
@@ -17,22 +17,24 @@ export default {
|
||||
{
|
||||
key: 'username',
|
||||
label: 'Username',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
description: 'You may need to provide your username if your installation requires authentication.',
|
||||
description:
|
||||
'You may need to provide your username if your installation requires authentication.',
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
label: 'Password',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
placeholder: null,
|
||||
clickToCopy: false,
|
||||
description: 'You may need to provide your password if your installation requires authentication.',
|
||||
description:
|
||||
'You may need to provide your password if your installation requires authentication.',
|
||||
},
|
||||
],
|
||||
|
8
packages/backend/src/apps/ntfy/auth/is-still-verified.js
Normal file
8
packages/backend/src/apps/ntfy/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;
|
@@ -1,11 +1,9 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.post('/', { topic: 'automatisch' });
|
||||
let screenName = $.auth.data.serverUrl;
|
||||
|
||||
if ($.auth.data.username) {
|
||||
screenName = `${$.auth.data.username} @ ${screenName}`
|
||||
screenName = `${$.auth.data.username} @ ${screenName}`;
|
||||
}
|
||||
|
||||
await $.auth.set({
|
16
packages/backend/src/apps/ntfy/common/add-auth-header.js
Normal file
16
packages/backend/src/apps/ntfy/common/add-auth-header.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data.serverUrl) {
|
||||
requestConfig.baseURL = $.auth.data.serverUrl;
|
||||
}
|
||||
|
||||
if ($.auth.data?.username && $.auth.data?.password) {
|
||||
requestConfig.auth = {
|
||||
username: $.auth.data.username,
|
||||
password: $.auth.data.password,
|
||||
};
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -1,18 +0,0 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
if ($.auth.data.serverUrl) {
|
||||
requestConfig.baseURL = $.auth.data.serverUrl as string;
|
||||
}
|
||||
|
||||
if ($.auth.data?.username && $.auth.data?.password) {
|
||||
requestConfig.auth = {
|
||||
username: $.auth.data.username as string,
|
||||
password: $.auth.data.password as string,
|
||||
}
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -1,7 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Ntfy',
|
Reference in New Issue
Block a user