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,15 @@
import { URLSearchParams } from 'url';
export default async function generateAuthUrl($) {
const scopes = ['data:read_write'];
const searchParams = new URLSearchParams({
client_id: $.auth.data.clientId,
scope: scopes.join(','),
});
const url = `${$.app.baseUrl}/oauth/authorize?${searchParams.toString()}`;
await $.auth.set({
url,
});
}

View File

@@ -1,17 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
import { URLSearchParams } from 'url';
export default async function generateAuthUrl($: IGlobalVariable) {
const scopes = ['data:read_write'];
const searchParams = new URLSearchParams({
client_id: $.auth.data.clientId as string,
scope: scopes.join(','),
});
const url = `${$.app.baseUrl
}/oauth/authorize?${searchParams.toString()}`;
await $.auth.set({
url,
});
}

View File

@@ -1,13 +1,13 @@
import generateAuthUrl from './generate-auth-url';
import verifyCredentials from './verify-credentials';
import isStillVerified from './is-still-verified';
import generateAuthUrl from './generate-auth-url.js';
import verifyCredentials from './verify-credentials.js';
import isStillVerified from './is-still-verified.js';
export default {
fields: [
{
key: 'oAuthRedirectUrl',
label: 'OAuth Redirect URL',
type: 'string' as const,
type: 'string',
required: true,
readOnly: true,
value: '{WEB_APP_URL}/app/todoist/connections/add',
@@ -20,7 +20,7 @@ export default {
{
key: 'screenName',
label: 'Screen Name',
type: 'string' as const,
type: 'string',
required: true,
readOnly: false,
value: null,
@@ -31,7 +31,7 @@ export default {
{
key: 'clientId',
label: 'Client ID',
type: 'string' as const,
type: 'string',
required: true,
readOnly: false,
value: null,
@@ -42,7 +42,7 @@ export default {
{
key: 'clientSecret',
label: 'Client Secret',
type: 'string' as const,
type: 'string',
required: true,
readOnly: false,
value: null,

View File

@@ -0,0 +1,6 @@
const isStillVerified = async ($) => {
await $.http.get('/projects');
return true;
};
export default isStillVerified;

View File

@@ -1,8 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
const isStillVerified = async ($: IGlobalVariable) => {
await $.http.get('/projects');
return true;
};
export default isStillVerified;

View File

@@ -0,0 +1,14 @@
const verifyCredentials = async ($) => {
const { data } = await $.http.post(`${$.app.baseUrl}/oauth/access_token`, {
client_id: $.auth.data.clientId,
client_secret: $.auth.data.clientSecret,
code: $.auth.data.code,
});
await $.auth.set({
tokenType: data.token_type,
accessToken: data.access_token,
});
};
export default verifyCredentials;

View File

@@ -1,19 +0,0 @@
import { IGlobalVariable } from '@automatisch/types';
const verifyCredentials = async ($: IGlobalVariable) => {
const { data } = await $.http.post(
`${$.app.baseUrl}/oauth/access_token`,
{
client_id: $.auth.data.clientId,
client_secret: $.auth.data.clientSecret,
code: $.auth.data.code,
},
);
await $.auth.set({
tokenType: data.token_type,
accessToken: data.access_token,
});
};
export default verifyCredentials;