feat: Convert all app files to JS

This commit is contained in:
Faruk AYDIN
2024-01-05 17:44:21 +01:00
parent b95478b635
commit 43dba351c3
1030 changed files with 5114 additions and 6436 deletions

View File

@@ -1,3 +1,3 @@
import sendAPushoverNotification from './send-a-pushover-notification';
import sendAPushoverNotification from './send-a-pushover-notification/index.js';
export default [sendAPushoverNotification];

View File

@@ -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,

View File

@@ -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,

View File

@@ -0,0 +1,8 @@
import verifyCredentials from './verify-credentials.js';
const isStillVerified = async ($) => {
await verifyCredentials($);
return true;
};
export default isStillVerified;

View File

@@ -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;

View File

@@ -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';

View File

@@ -0,0 +1,4 @@
import listDevices from './list-devices/index.js';
import listSounds from './list-sounds/index.js';
export default [listDevices, listSounds];

View File

@@ -1,4 +0,0 @@
import listDevices from './list-devices';
import listSounds from './list-sounds';
export default [listDevices, listSounds];

View File

@@ -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: [],
};

View File

@@ -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,
});
}

View File

@@ -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',