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

@@ -0,0 +1,3 @@
import sendMessage from './send-message/index.js';
export default [sendMessage];

View File

@@ -1,3 +0,0 @@
import sendMessage from './send-message';
export default [sendMessage];

View File

@@ -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,15 +9,16 @@ export default defineAction({
{
label: 'Chat ID',
key: 'chatId',
type: 'string' as const,
type: 'string',
required: true,
description: 'Unique identifier for the target chat or username of the target channel (in the format @channelusername).',
description:
'Unique identifier for the target chat or username of the target channel (in the format @channelusername).',
variables: true,
},
{
label: 'Message text',
key: 'text',
type: 'string' as const,
type: 'string',
required: true,
description: 'Text of the message to be sent, 1-4096 characters.',
variables: true,
@@ -25,10 +26,11 @@ export default defineAction({
{
label: 'Disable notification?',
key: 'disableNotification',
type: 'dropdown' as const,
type: 'dropdown',
required: false,
value: false,
description: 'Sends the message silently. Users will receive a notification with no sound.',
description:
'Sends the message silently. Users will receive a notification with no sound.',
variables: true,
options: [
{

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: 'token',
label: 'Bot 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('/getMe');
const { result: me } = data;

View File

@@ -0,0 +1,15 @@
import { URL } from 'node:url';
const addAuthHeader = ($, requestConfig) => {
if ($.auth.data?.token) {
const token = $.auth.data.token;
requestConfig.baseURL = new URL(
`/bot${token}`,
requestConfig.baseURL
).toString();
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -1,13 +0,0 @@
import { TBeforeRequest } from '@automatisch/types';
import { URL } from 'node:url';
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
if ($.auth.data?.token) {
const token = $.auth.data.token as string;
requestConfig.baseURL = (new URL(`/bot${token}`, requestConfig.baseURL)).toString();
}
return requestConfig;
};
export default addAuthHeader;

View File

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