feat: Convert all app files to JS
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
import sendAPushoverNotification from './send-a-pushover-notification';
|
||||
import sendAPushoverNotification from './send-a-pushover-notification/index.js';
|
||||
|
||||
export default [sendAPushoverNotification];
|
@@ -1,5 +1,4 @@
|
||||
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send a Pushover Notification',
|
||||
@@ -10,7 +9,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'An optional title displayed with the message.',
|
||||
variables: true,
|
||||
@@ -18,7 +17,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Message',
|
||||
key: 'message',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The main message text of your notification.',
|
||||
variables: true,
|
||||
@@ -26,7 +25,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Priority',
|
||||
key: 'priority',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -44,7 +43,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Sound',
|
||||
key: 'sound',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'Optional sound to override your default.',
|
||||
variables: true,
|
||||
@@ -62,7 +61,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'URL',
|
||||
key: 'url',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'URL to display with message.',
|
||||
variables: true,
|
||||
@@ -70,7 +69,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'URL Title',
|
||||
key: 'urlTitle',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'Title of URL to display, otherwise URL itself will be displayed.',
|
||||
@@ -79,14 +78,14 @@ export default defineAction({
|
||||
{
|
||||
label: 'Devices',
|
||||
key: 'devices',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Device',
|
||||
key: 'device',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Restrict sending to just these devices on your account.',
|
||||
@@ -110,10 +109,8 @@ export default defineAction({
|
||||
const { title, message, priority, sound, url, urlTitle } =
|
||||
$.step.parameters;
|
||||
|
||||
const devices = $.step.parameters.devices as IJSONArray;
|
||||
const allDevices = devices
|
||||
.map((device: IJSONObject) => device.device)
|
||||
.join(',');
|
||||
const devices = $.step.parameters.devices;
|
||||
const allDevices = devices.map((device) => device.device).join(',');
|
||||
|
||||
const payload = {
|
||||
token: $.auth.data.apiToken,
|
@@ -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: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'userKey',
|
||||
label: 'User Key',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -29,7 +29,7 @@ export default {
|
||||
{
|
||||
key: 'apiToken',
|
||||
label: 'API Token',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
@@ -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,10 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import HttpError from '../../../errors/http';
|
||||
import HttpError from '../../../errors/http.js';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
try {
|
||||
await $.http.post(`/1/users/validate.json`, {
|
||||
token: $.auth.data.apiToken as string,
|
||||
user: $.auth.data.userKey as string,
|
||||
token: $.auth.data.apiToken,
|
||||
user: $.auth.data.userKey,
|
||||
});
|
||||
} catch (error) {
|
||||
const noDeviceError = 'user is valid but has no active devices';
|
4
packages/backend/src/apps/pushover/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/pushover/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import listDevices from './list-devices/index.js';
|
||||
import listSounds from './list-sounds/index.js';
|
||||
|
||||
export default [listDevices, listSounds];
|
@@ -1,4 +0,0 @@
|
||||
import listDevices from './list-devices';
|
||||
import listSounds from './list-sounds';
|
||||
|
||||
export default [listDevices, listSounds];
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List devices',
|
||||
key: 'listDevices',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const devices: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const devices = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List sounds',
|
||||
key: 'listSounds',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const sounds: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const sounds = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
@@ -21,7 +17,7 @@ export default {
|
||||
for (const [key, value] of soundEntries) {
|
||||
sounds.data.push({
|
||||
value: key,
|
||||
name: value as string,
|
||||
name: value,
|
||||
});
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
import dynamicData from './dynamic-data';
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import auth from './auth/index.js';
|
||||
import actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Pushover',
|
Reference in New Issue
Block a user