feat: Convert all app files to JS
This commit is contained in:
@@ -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,
|
@@ -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,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({
|
@@ -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}`;
|
||||
}
|
3
packages/backend/src/apps/placetel/dynamic-data/index.js
Normal file
3
packages/backend/src/apps/placetel/dynamic-data/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import listNumbers from './list-numbers/index.js';
|
||||
|
||||
export default [listNumbers];
|
@@ -1,3 +0,0 @@
|
||||
import listNumbers from './list-numbers';
|
||||
|
||||
export default [listNumbers];
|
@@ -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: [],
|
||||
};
|
||||
|
@@ -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',
|
@@ -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 = {
|
3
packages/backend/src/apps/placetel/triggers/index.js
Normal file
3
packages/backend/src/apps/placetel/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import hungupCall from './hungup-call/index.js';
|
||||
|
||||
export default [hungupCall];
|
@@ -1,3 +0,0 @@
|
||||
import hungupCall from './hungup-call';
|
||||
|
||||
export default [hungupCall];
|
Reference in New Issue
Block a user