feat: Convert all app files to JS
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Copy board',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Original board',
|
||||
key: 'originalBoard',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: 'The board that you want to copy.',
|
||||
variables: true,
|
||||
@@ -26,7 +26,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Title for the board.',
|
||||
variables: true,
|
||||
@@ -34,7 +34,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Description of the board.',
|
||||
variables: true,
|
||||
@@ -42,7 +42,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Team Access',
|
||||
key: 'teamAccess',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Team access to the board. Can be private, view, comment or edit. Default: private.',
|
||||
@@ -69,7 +69,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Access Via Link',
|
||||
key: 'accessViaLink',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Access to the board by link. Can be private, view, comment. Default: private.',
|
@@ -1,4 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create board',
|
||||
@@ -8,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Title for the board.',
|
||||
variables: true,
|
||||
@@ -16,7 +16,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Description of the board.',
|
||||
variables: true,
|
||||
@@ -24,7 +24,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Team Access',
|
||||
key: 'teamAccess',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Team access to the board. Can be private, view, comment or edit. Default: private.',
|
||||
@@ -51,7 +51,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Access Via Link',
|
||||
key: 'accessViaLink',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description:
|
||||
'Access to the board by link. Can be private, view, comment. Default: private.',
|
@@ -1,18 +1,4 @@
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
type Body = {
|
||||
data: {
|
||||
title: string;
|
||||
description?: string;
|
||||
dueDate?: string;
|
||||
};
|
||||
style?: {
|
||||
cardTheme?: string;
|
||||
};
|
||||
parent: {
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create card widget',
|
||||
@@ -22,7 +8,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Board',
|
||||
key: 'boardId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -40,7 +26,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Frame',
|
||||
key: 'frameId',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
dependsOn: ['parameters.boardId'],
|
||||
description:
|
||||
@@ -64,7 +50,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Title',
|
||||
key: 'cardTitle',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -72,7 +58,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Title Link',
|
||||
key: 'cardTitleLink',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -80,7 +66,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Description',
|
||||
key: 'cardDescription',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
@@ -88,7 +74,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Due Date',
|
||||
key: 'cardDueDate',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'format: date-time. Example value: 2023-10-12 22:00:55+00:00',
|
||||
@@ -97,7 +83,7 @@ export default defineAction({
|
||||
{
|
||||
label: 'Card Border Color',
|
||||
key: 'cardBorderColor',
|
||||
type: 'dropdown' as const,
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: 'In hex format. Default is blue (#2399F3).',
|
||||
variables: true,
|
||||
@@ -140,23 +126,23 @@ export default defineAction({
|
||||
title = cardTitle;
|
||||
}
|
||||
|
||||
const body: Body = {
|
||||
const body = {
|
||||
data: {
|
||||
title: title as string,
|
||||
description: cardDescription as string,
|
||||
title: title,
|
||||
description: cardDescription,
|
||||
},
|
||||
style: {},
|
||||
parent: {
|
||||
id: frameId as string,
|
||||
id: frameId,
|
||||
},
|
||||
};
|
||||
|
||||
if (cardBorderColor) {
|
||||
body.style.cardTheme = cardBorderColor as string;
|
||||
body.style.cardTheme = cardBorderColor;
|
||||
}
|
||||
|
||||
if (cardDueDate) {
|
||||
body.data.dueDate = cardDueDate as string;
|
||||
body.data.dueDate = cardDueDate;
|
||||
}
|
||||
|
||||
const response = await $.http.post(`/v2/boards/${boardId}/cards`, body);
|
5
packages/backend/src/apps/miro/actions/index.js
Normal file
5
packages/backend/src/apps/miro/actions/index.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import copyBoard from './copy-board/index.js';
|
||||
import createBoard from './create-board/index.js';
|
||||
import createCardWidget from './create-card-widget/index.js';
|
||||
|
||||
export default [copyBoard, createBoard, createCardWidget];
|
@@ -1,5 +0,0 @@
|
||||
import copyBoard from './copy-board';
|
||||
import createBoard from './create-board';
|
||||
import createCardWidget from './create-card-widget';
|
||||
|
||||
export default [copyBoard, createBoard, createCardWidget];
|
@@ -1,14 +1,13 @@
|
||||
import { IField, IGlobalVariable } from '@automatisch/types';
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
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({
|
||||
response_type: 'code',
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
@@ -1,14 +1,14 @@
|
||||
import generateAuthUrl from './generate-auth-url';
|
||||
import verifyCredentials from './verify-credentials';
|
||||
import refreshToken from './refresh-token';
|
||||
import isStillVerified from './is-still-verified';
|
||||
import generateAuthUrl from './generate-auth-url.js';
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import refreshToken from './refresh-token.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/miro/connections/add',
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
{
|
||||
key: 'clientId',
|
||||
label: 'Client ID',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
{
|
||||
key: 'clientSecret',
|
||||
label: 'Client Secret',
|
||||
type: 'string' as const,
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
8
packages/backend/src/apps/miro/auth/is-still-verified.js
Normal file
8
packages/backend/src/apps/miro/auth/is-still-verified.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,9 +0,0 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import getCurrentUser from '../common/get-current-user';
|
||||
|
||||
const isStillVerified = async ($: IGlobalVariable) => {
|
||||
const currentUser = await getCurrentUser($);
|
||||
return !!currentUser;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -1,12 +1,11 @@
|
||||
import { URLSearchParams } from 'node:url';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const refreshToken = async ($: IGlobalVariable) => {
|
||||
const refreshToken = async ($) => {
|
||||
const params = new URLSearchParams({
|
||||
grant_type: 'refresh_token',
|
||||
client_id: $.auth.data.clientId as string,
|
||||
client_secret: $.auth.data.clientSecret as string,
|
||||
refresh_token: $.auth.data.refreshToken as string,
|
||||
client_id: $.auth.data.clientId,
|
||||
client_secret: $.auth.data.clientSecret,
|
||||
refresh_token: $.auth.data.refreshToken,
|
||||
});
|
||||
|
||||
const { data } = await $.http.post('/v1/oauth/token', params.toString());
|
@@ -1,11 +1,10 @@
|
||||
import { IField, 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 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 params = {
|
||||
grant_type: 'authorization_code',
|
||||
client_id: $.auth.data.clientId,
|
@@ -1,6 +1,4 @@
|
||||
import { TBeforeRequest } from '@automatisch/types';
|
||||
|
||||
const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.accessToken) {
|
||||
requestConfig.headers.Authorization = `${$.auth.data.tokenType} ${$.auth.data.accessToken}`;
|
||||
}
|
@@ -1,6 +1,4 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
|
||||
const getCurrentUser = async ($: IGlobalVariable) => {
|
||||
const getCurrentUser = async ($) => {
|
||||
const { data } = await $.http.get(
|
||||
`https://api.miro.com/v1/oauth-token?access_token=${$.auth.data.accessToken}`
|
||||
);
|
4
packages/backend/src/apps/miro/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/miro/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import listBoards from './list-boards/index.js';
|
||||
import listFrames from './list-frames/index.js';
|
||||
|
||||
export default [listBoards, listFrames];
|
@@ -1,4 +0,0 @@
|
||||
import listBoards from './list-boards';
|
||||
import listFrames from './list-frames';
|
||||
|
||||
export default [listBoards, listFrames];
|
@@ -1,25 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
type ResponseBody = {
|
||||
data: {
|
||||
data: {
|
||||
id: number;
|
||||
name: string;
|
||||
}[];
|
||||
links: {
|
||||
next: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export default {
|
||||
name: 'List boards',
|
||||
key: 'listBoards',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const boards: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const boards = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
@@ -27,7 +11,7 @@ export default {
|
||||
do {
|
||||
const {
|
||||
data: { data, links },
|
||||
}: ResponseBody = await $.http.get('/v2/boards');
|
||||
} = await $.http.get('/v2/boards');
|
||||
|
||||
next = links?.next;
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List frames',
|
||||
key: 'listFrames',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const frames: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
async run($) {
|
||||
const frames = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
@@ -25,9 +21,7 @@ export default {
|
||||
|
||||
next = links?.next;
|
||||
|
||||
const allFrames = data.filter(
|
||||
(item: IJSONObject) => item.type === 'frame'
|
||||
);
|
||||
const allFrames = data.filter((item) => item.type === 'frame');
|
||||
|
||||
if (allFrames.length) {
|
||||
for (const frame of allFrames) {
|
@@ -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: 'Miro',
|
Reference in New Issue
Block a user