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,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: '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,6 +1,4 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const verifyCredentials = async ($) => {
const { data } = await $.http.get('/v2/me');
await $.auth.set({

View File

@@ -1,6 +1,4 @@
import { TBeforeRequest } from '@automatisch/types';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
const addAuthHeader = ($, requestConfig) => {
if ($.auth.data?.apiToken) {
requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiToken}`;
}

View File

@@ -0,0 +1,3 @@
import listNumbers from './list-numbers/index.js';
export default [listNumbers];

View File

@@ -1,3 +0,0 @@
import listNumbers from './list-numbers';
export default [listNumbers];

View File

@@ -1,13 +1,9 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
export default {
name: 'List numbers',
key: 'listNumbers',
async run($: IGlobalVariable) {
const numbers: {
data: IJSONObject[];
} = {
async run($) {
const numbers = {
data: [],
};

View File

@@ -1,8 +1,8 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
import dynamicData from './dynamic-data';
import defineApp from '../../helpers/define-app.js';
import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import triggers from './triggers/index.js';
import dynamicData from './dynamic-data/index.js';
export default defineApp({
name: 'Placetel',

View File

@@ -1,6 +1,6 @@
import Crypto from 'crypto';
import { IJSONObject } from '@automatisch/types';
import defineTrigger from '../../../../helpers/define-trigger';
import defineTrigger from '../../../../helpers/define-trigger.js';
import getRawBody from 'raw-body';
export default defineTrigger({
@@ -12,14 +12,14 @@ export default defineTrigger({
{
label: 'Types',
key: 'types',
type: 'dynamic' as const,
type: 'dynamic',
required: false,
description: '',
fields: [
{
label: 'Type',
key: 'type',
type: 'dropdown' as const,
type: 'dropdown',
required: true,
description:
'Filter events by type. If the types are not specified, all types will be notified.',
@@ -41,14 +41,14 @@ export default defineTrigger({
{
label: 'Numbers',
key: 'numbers',
type: 'dynamic' as const,
type: 'dynamic',
required: false,
description: '',
fields: [
{
label: 'Number',
key: 'number',
type: 'dropdown' as const,
type: 'dropdown',
required: true,
description:
'Filter events by number. If the numbers are not specified, all numbers will be notified.',
@@ -76,9 +76,7 @@ export default defineTrigger({
const jsonRequestBody = JSON.parse(stringBody);
let types = ($.step.parameters.types as IJSONObject[]).map(
(type) => type.type
);
let types = $.step.parameters.types.map((type) => type.type);
if (types.length === 0) {
types = ['all'];
@@ -97,9 +95,7 @@ export default defineTrigger({
},
async testRun($) {
const types = ($.step.parameters.types as IJSONObject[]).map(
(type) => type.type
);
const types = $.step.parameters.types.map((type) => type.type);
const sampleEventData = {
type: types[0] || 'missed',
@@ -123,8 +119,8 @@ export default defineTrigger({
},
async registerHook($) {
const numbers = ($.step.parameters.numbers as IJSONObject[])
.map((number: IJSONObject) => number.number)
const numbers = $.step.parameters.numbers
.map((number) => number.number)
.filter(Boolean);
const subscriptionPayload = {

View File

@@ -0,0 +1,3 @@
import hungupCall from './hungup-call/index.js';
export default [hungupCall];

View File

@@ -1,3 +0,0 @@
import hungupCall from './hungup-call';
export default [hungupCall];