feat: Convert all app files to JS
This commit is contained in:
@@ -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: 'Create card',
|
||||
@@ -9,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Board',
|
||||
key: 'boardId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -27,7 +26,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'List',
|
||||
key: 'listId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
dependsOn: ['parameters.boardId'],
|
||||
description: '',
|
||||
@@ -50,7 +49,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -58,7 +57,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: '',
|
||||
@@ -67,7 +66,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Label',
|
||||
key: 'label',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.boardId'],
|
||||
description: 'Select a color tag to attach to the card.',
|
||||
@@ -90,7 +89,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Position',
|
||||
key: 'cardPosition',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -108,14 +107,14 @@ export default defineAction({
|
||||
{
|
||||
label: 'Members',
|
||||
key: 'memberIds',
|
||||
type: 'dynamic' as const,
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Member',
|
||||
key: 'memberId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.boardId'],
|
||||
description: '',
|
||||
@@ -140,7 +139,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Due Date',
|
||||
key: 'dueDate',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'Format: mm-dd-yyyy HH:mm:ss or yyyy-MM-dd HH:mm:ss.',
|
||||
@@ -148,7 +147,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'URL Attachment',
|
||||
key: 'urlSource',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
variables: true,
|
||||
description: 'A URL to attach to the card.',
|
||||
@@ -166,10 +165,8 @@ export default defineAction({
|
||||
urlSource,
|
||||
} = $.step.parameters;
|
||||
|
||||
const memberIds = $.step.parameters.memberIds as IJSONArray;
|
||||
const idMembers = memberIds.map(
|
||||
(memberId: IJSONObject) => memberId.memberId
|
||||
);
|
||||
const memberIds = $.step.parameters.memberIds;
|
||||
const idMembers = memberIds.map((memberId) => memberId.memberId);
|
||||
|
||||
const fields = {
|
||||
name,
|
3
packages/backend/src/apps/trello/actions/index.js
Normal file
3
packages/backend/src/apps/trello/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import createCard from './create-card/index.js';
|
||||
|
||||
export default [createCard];
|
@@ -1,3 +0,0 @@
|
||||
import createCard from './create-card';
|
||||
|
||||
export default [createCard];
|
@@ -1,17 +1,16 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
import authScope from '../common/auth-scope';
|
||||
import authScope from '../common/auth-scope.js';
|
||||
|
||||
export default async function generateAuthUrl($: IGlobalVariable) {
|
||||
export default async function generateAuthUrl($) {
|
||||
const oauthRedirectUrlField = $.app.auth.fields.find(
|
||||
(field: IField) => field.key == 'oAuthRedirectUrl'
|
||||
(field) => field.key == 'oAuthRedirectUrl'
|
||||
);
|
||||
const redirectUri = oauthRedirectUrlField.value as string;
|
||||
const redirectUri = oauthRedirectUrlField.value;
|
||||
const searchParams = new URLSearchParams({
|
||||
return_url: redirectUri,
|
||||
scope: authScope.join(','),
|
||||
expiration: 'never',
|
||||
key: $.auth.data.apiKey as string,
|
||||
key: $.auth.data.apiKey,
|
||||
response_type: 'token',
|
||||
});
|
||||
|
@@ -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/trello/connections/add',
|
||||
@@ -18,7 +18,7 @@ export default {
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
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,7 +1,6 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const verifyCredentials = async ($: IGlobalVariable) => {
|
||||
const verifyCredentials = async ($) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
const screenName = [currentUser.username, currentUser.email]
|
||||
.filter(Boolean)
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.token) {
|
||||
requestConfig.headers.Authorization = `OAuth oauth_consumer_key="${$.auth.data.apiKey}", oauth_token="${$.auth.data.token}"`;
|
||||
}
|
3
packages/backend/src/apps/trello/common/auth-scope.js
Normal file
3
packages/backend/src/apps/trello/common/auth-scope.js
Normal file
@@ -0,0 +1,3 @@
|
||||
const authScope = ['read', 'write', 'account'];
|
||||
|
||||
export default authScope;
|
@@ -1,3 +0,0 @@
|
||||
const authScope: string[] = ['read', 'write', 'account'];
|
||||
|
||||
export default authScope;
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable): Promise<IJSONObject> => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get('/1/members/me/');
|
||||
const currentUser = response.data;
|
||||
|
6
packages/backend/src/apps/trello/dynamic-data/index.js
Normal file
6
packages/backend/src/apps/trello/dynamic-data/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import listBoardLabels from './list-board-labels/index.js';
|
||||
import listBoardLists from './list-board-lists/index.js';
|
||||
import listBoards from './list-boards/index.js';
|
||||
import listMembers from './listMembers/index.js';
|
||||
|
||||
export default [listBoardLabels, listBoardLists, listBoards, listMembers];
|
@@ -1,6 +0,0 @@
|
||||
import listBoardLabels from './list-board-labels';
|
||||
import listBoardLists from './list-board-lists';
|
||||
import listBoards from './list-boards';
|
||||
import listMembers from './listMembers';
|
||||
|
||||
export default [listBoardLabels, listBoardLists, listBoards, listMembers];
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List board labels',
|
||||
key: 'listBoardLabels',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const boardLabels: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const boardLabels = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List board lists',
|
||||
key: 'listBoardLists',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const boards: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const boards = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List boards',
|
||||
key: 'listBoards',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const boards: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const boards = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List members',
|
||||
key: 'listMembers',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const members: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const members = {
|
||||
data: [],
|
||||
};
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
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 actions from './actions/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Trello',
|
Reference in New Issue
Block a user