refactor: inline auth, data, triggers and actions in apps

This commit is contained in:
Ali BARIN
2022-10-28 15:48:39 +02:00
parent 179fe512af
commit 9a973c8257
47 changed files with 233 additions and 167 deletions

View File

@@ -7,7 +7,7 @@ export default {
{
key: 'oAuthRedirectUrl',
label: 'OAuth Redirect URL',
type: 'string',
type: 'string' as const,
required: true,
readOnly: true,
value: '{WEB_APP_URL}/app/flickr/connections/add',
@@ -19,7 +19,7 @@ export default {
{
key: 'consumerKey',
label: 'Consumer Key',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -31,7 +31,7 @@ export default {
{
key: 'consumerSecret',
label: 'Consumer Secret',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -44,7 +44,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -69,7 +69,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -80,7 +80,7 @@ export default {
},
{
step: 3,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -91,7 +91,7 @@ export default {
},
{
step: 4,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -112,7 +112,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -125,7 +125,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -136,7 +136,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -161,7 +161,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -172,7 +172,7 @@ export default {
},
{
step: 4,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -183,7 +183,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -204,7 +204,7 @@ export default {
},
{
step: 6,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -0,0 +1,3 @@
import listAlbums from './list-albums';
export default [listAlbums];

View File

@@ -1,5 +1,8 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
import data from './data';
export default defineApp({
name: 'Flickr',
@@ -12,4 +15,7 @@ export default defineApp({
baseUrl: 'https://www.flickr.com/',
apiBaseUrl: 'https://www.flickr.com/services',
beforeRequest: [addAuthHeader],
auth,
triggers,
data,
});

View File

@@ -0,0 +1,11 @@
import newAlbums from './new-albums';
import newFavoritePhotos from './new-favorite-photos';
import newPhotos from './new-photos';
import newPhotosInAlbums from './new-photos-in-album';
export default [
newAlbums,
newFavoritePhotos,
newPhotos,
newPhotosInAlbums,
];

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Album',
key: 'album',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
variables: false,
source: {

View File

@@ -18,7 +18,7 @@ export default defineAction({
{
label: 'Repo',
key: 'repo',
type: 'dropdown',
type: 'dropdown' as const,
required: false,
variables: false,
source: {
@@ -35,14 +35,14 @@ export default defineAction({
{
label: 'Title',
key: 'title',
type: 'string',
type: 'string' as const,
required: true,
variables: true,
},
{
label: 'Body',
key: 'body',
type: 'string',
type: 'string' as const,
required: true,
variables: true,
},

View File

@@ -0,0 +1,3 @@
import createIssue from './create-issue';
export default [createIssue];

View File

@@ -7,7 +7,7 @@ export default {
{
key: 'oAuthRedirectUrl',
label: 'OAuth Redirect URL',
type: 'string',
type: 'string' as const,
required: true,
readOnly: true,
value: '{WEB_APP_URL}/app/github/connections/add',
@@ -19,7 +19,7 @@ export default {
{
key: 'consumerKey',
label: 'Client ID',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -31,7 +31,7 @@ export default {
{
key: 'consumerSecret',
label: 'Client Secret',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -44,7 +44,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -69,7 +69,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -80,7 +80,7 @@ export default {
},
{
step: 3,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -91,7 +91,7 @@ export default {
},
{
step: 4,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -112,7 +112,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -125,7 +125,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -136,7 +136,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -161,7 +161,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -172,7 +172,7 @@ export default {
},
{
step: 4,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -183,7 +183,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -204,7 +204,7 @@ export default {
},
{
step: 6,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -0,0 +1,7 @@
import listLabels from './list-labels';
import listRepos from './list-repos';
export default [
listLabels,
listRepos,
];

View File

@@ -1,5 +1,9 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
import actions from './actions';
import data from './data';
export default defineApp({
name: 'Github',
@@ -11,4 +15,8 @@ export default defineApp({
primaryColor: '000000',
supportsConnections: true,
beforeRequest: [addAuthHeader],
auth,
triggers,
actions,
data,
});

View File

@@ -0,0 +1,11 @@
import newIssues from './new-issues';
import newPullRequests from './new-pull-requests';
import newStargazers from './new-stargazers';
import newWatchers from './new-watchers';
export default [
newIssues,
newPullRequests,
newStargazers,
newWatchers,
];

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Repo',
key: 'repo',
type: 'dropdown',
type: 'dropdown' as const,
required: false,
variables: false,
source: {
@@ -35,7 +35,7 @@ export default defineTrigger({
{
label: 'Which types of issues should this trigger on?',
key: 'issueType',
type: 'dropdown',
type: 'dropdown' as const,
description: 'Defaults to any issue you can see.',
required: true,
variables: false,
@@ -66,7 +66,7 @@ export default defineTrigger({
{
label: 'Label',
key: 'label',
type: 'dropdown',
type: 'dropdown' as const,
description: 'Only trigger on issues when this label is added.',
required: false,
variables: false,

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Repo',
key: 'repo',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
variables: false,
source: {

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Repo',
key: 'repo',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
variables: false,
source: {

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Repo',
key: 'repo',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
variables: false,
source: {

View File

@@ -1,4 +1,5 @@
import defineApp from '../../helpers/define-app';
import triggers from './triggers';
export default defineApp({
name: 'RSS',
@@ -10,4 +11,5 @@ export default defineApp({
apiBaseUrl: '',
primaryColor: 'ff8800',
beforeRequest: [],
triggers,
});

View File

@@ -0,0 +1,3 @@
import newItemsInFeed from './new-items-in-feed';
export default [newItemsInFeed];

View File

@@ -14,7 +14,7 @@ export default defineTrigger({
{
label: 'Feed URL',
key: 'feedUrl',
type: 'string',
type: 'string' as const,
required: true,
description: 'Paste your publicly accessible RSS URL here.',
variables: false,

View File

@@ -1,9 +1,16 @@
export default {
import defineApp from "../../helpers/define-app";
import triggers from './triggers';
export default defineApp({
name: "Scheduler",
key: "scheduler",
iconUrl: "{BASE_URL}/apps/scheduler/assets/favicon.svg",
docUrl: "https://automatisch.io/docs/scheduler",
authDocUrl: "https://automatisch.io/docs/connections/scheduler",
baseUrl: '',
apiBaseUrl: '',
primaryColor: "0059F7",
beforeRequest: [],
supportsConnections: false,
};
triggers,
});

View File

@@ -17,7 +17,7 @@ export default defineTrigger({
{
label: 'Trigger on weekends?',
key: 'triggersOnWeekend',
type: 'dropdown',
type: 'dropdown' as const,
description: 'Should this flow trigger on Saturday and Sunday?',
required: true,
value: true,
@@ -36,7 +36,7 @@ export default defineTrigger({
{
label: 'Time of day',
key: 'hour',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
value: null,
variables: false,

View File

@@ -17,7 +17,7 @@ export default defineTrigger({
{
label: 'Trigger on weekends?',
key: 'triggersOnWeekend',
type: 'dropdown',
type: 'dropdown' as const,
description: 'Should this flow trigger on Saturday and Sunday?',
required: true,
value: true,

View File

@@ -17,7 +17,7 @@ export default defineTrigger({
{
label: 'Day of the month',
key: 'day',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
value: null,
variables: false,
@@ -151,7 +151,7 @@ export default defineTrigger({
{
label: 'Time of day',
key: 'hour',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
value: null,
variables: false,

View File

@@ -17,7 +17,7 @@ export default defineTrigger({
{
label: 'Day of the week',
key: 'weekday',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
value: null,
variables: false,
@@ -55,7 +55,7 @@ export default defineTrigger({
{
label: 'Time of day',
key: 'hour',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
value: null,
variables: false,

View File

@@ -0,0 +1,11 @@
import everyHour from './every-hour';
import everyDay from './every-day';
import everyWeek from './every-week';
import everyMonth from './every-month';
export default [
everyHour,
everyDay,
everyWeek,
everyMonth,
];

View File

@@ -17,7 +17,7 @@ export default defineAction({
{
label: 'Search Query',
key: 'query',
type: 'string',
type: 'string' as const,
required: true,
description:
'Search query to use for finding matching messages. See the Slack Search Documentation for more information on constructing a query.',
@@ -26,7 +26,7 @@ export default defineAction({
{
label: 'Sort by',
key: 'sortBy',
type: 'dropdown',
type: 'dropdown' as const,
description:
'Sort messages by their match strength or by their date. Default is score.',
required: true,
@@ -46,7 +46,7 @@ export default defineAction({
{
label: 'Sort direction',
key: 'sortDirection',
type: 'dropdown',
type: 'dropdown' as const,
description:
'Sort matching messages in ascending or descending order. Default is descending.',
required: true,

View File

@@ -0,0 +1,7 @@
import findMessage from './find-message';
import sendMessageToChannel from './send-a-message-to-channel';
export default [
findMessage,
sendMessageToChannel,
];

View File

@@ -17,7 +17,7 @@ export default defineAction({
{
label: 'Channel',
key: 'channel',
type: 'dropdown',
type: 'dropdown' as const,
required: true,
description: 'Pick a channel to send the message to.',
variables: false,
@@ -35,7 +35,7 @@ export default defineAction({
{
label: 'Message text',
key: 'message',
type: 'string',
type: 'string' as const,
required: true,
description: 'The content of your new message.',
variables: true,

View File

@@ -6,7 +6,7 @@ export default {
{
key: 'accessToken',
label: 'Access Token',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -18,7 +18,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -39,7 +39,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -52,7 +52,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -63,7 +63,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -84,7 +84,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -0,0 +1,3 @@
import listChannels from './list-channels';
export default [listChannels];

View File

@@ -1,5 +1,8 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import actions from './actions';
import auth from './auth';
import data from './data';
export default defineApp({
name: 'Slack',
@@ -11,4 +14,7 @@ export default defineApp({
apiBaseUrl: 'https://slack.com/api',
primaryColor: '4a154b',
beforeRequest: [addAuthHeader],
auth,
actions,
data,
});

View File

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

View File

@@ -18,7 +18,7 @@ export default defineAction({
{
label: 'From name',
key: 'fromName',
type: 'string',
type: 'string' as const,
required: false,
description: 'Display name of the sender.',
variables: true,
@@ -26,7 +26,7 @@ export default defineAction({
{
label: 'From email',
key: 'fromEmail',
type: 'string',
type: 'string' as const,
required: true,
description: 'Email address of the sender.',
variables: true,
@@ -34,7 +34,7 @@ export default defineAction({
{
label: 'Reply to',
key: 'replyTo',
type: 'string',
type: 'string' as const,
required: false,
description:
'Email address to reply to. Defaults to the from email address.',
@@ -43,7 +43,7 @@ export default defineAction({
{
label: 'To',
key: 'to',
type: 'string',
type: 'string' as const,
required: true,
description:
'Comma seperated list of email addresses to send the email to.',
@@ -52,7 +52,7 @@ export default defineAction({
{
label: 'Cc',
key: 'cc',
type: 'string',
type: 'string' as const,
required: false,
description: 'Comma seperated list of email addresses.',
variables: true,
@@ -60,7 +60,7 @@ export default defineAction({
{
label: 'Bcc',
key: 'bcc',
type: 'string',
type: 'string' as const,
required: false,
description: 'Comma seperated list of email addresses.',
variables: true,
@@ -68,7 +68,7 @@ export default defineAction({
{
label: 'Subject',
key: 'subject',
type: 'string',
type: 'string' as const,
required: true,
description: 'Subject of the email.',
variables: true,
@@ -76,7 +76,7 @@ export default defineAction({
{
label: 'Body',
key: 'body',
type: 'string',
type: 'string' as const,
required: true,
description: 'Body of the email.',
variables: true,

View File

@@ -6,7 +6,7 @@ export default {
{
key: 'host',
label: 'Host',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -18,7 +18,7 @@ export default {
{
key: 'username',
label: 'Email/Username',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -30,7 +30,7 @@ export default {
{
key: 'password',
label: 'Password',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -42,7 +42,7 @@ export default {
{
key: 'useTls',
label: 'Use TLS?',
type: 'dropdown',
type: 'dropdown' as const,
required: false,
readOnly: false,
value: false,
@@ -64,10 +64,10 @@ export default {
{
key: 'port',
label: 'Port',
type: 'string',
type: 'string' as const,
required: false,
readOnly: false,
value: 25,
value: '25',
placeholder: null,
description: null,
docUrl: 'https://automatisch.io/docs/smtp#port',
@@ -76,7 +76,7 @@ export default {
{
key: 'fromEmail',
label: 'From Email',
type: 'string',
type: 'string' as const,
required: false,
readOnly: false,
value: null,
@@ -89,7 +89,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -130,7 +130,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -143,7 +143,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -154,7 +154,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -195,7 +195,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -1,4 +1,6 @@
import defineApp from '../../helpers/define-app';
import auth from './auth';
import actions from './actions';
export default defineApp({
name: 'SMTP',
@@ -10,4 +12,6 @@ export default defineApp({
apiBaseUrl: '',
primaryColor: '2DAAE1',
beforeRequest: [],
auth,
actions,
});

View File

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

View File

@@ -16,7 +16,7 @@ export default defineAction({
{
label: 'From Number',
key: 'fromNumber',
type: 'string',
type: 'string' as const,
required: true,
description:
'The number to send the SMS from. Include country code. Example: 15551234567',
@@ -25,7 +25,7 @@ export default defineAction({
{
label: 'To Number',
key: 'toNumber',
type: 'string',
type: 'string' as const,
required: true,
description:
'The number to send the SMS to. Include country code. Example: 15551234567',
@@ -34,7 +34,7 @@ export default defineAction({
{
label: 'Message',
key: 'message',
type: 'string',
type: 'string' as const,
required: true,
description: 'The message to send.',
variables: true,

View File

@@ -6,7 +6,7 @@ export default {
{
key: 'accountSid',
label: 'Account SID',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -18,7 +18,7 @@ export default {
{
key: 'authToken',
label: 'Auth Token',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -30,7 +30,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -55,7 +55,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -68,7 +68,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -79,7 +79,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -104,7 +104,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -1,5 +1,7 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import actions from './actions';
export default defineApp({
name: 'Twilio',
@@ -11,4 +13,6 @@ export default defineApp({
apiBaseUrl: 'https://api.twilio.com',
primaryColor: 'e1000f',
beforeRequest: [addAuthHeader],
auth,
actions,
});

View File

@@ -1,4 +1,3 @@
import { IActionOutput } from '@automatisch/types';
import defineAction from '../../../../helpers/define-action';
export default defineAction({
@@ -17,7 +16,7 @@ export default defineAction({
{
label: 'Tweet body',
key: 'tweet',
type: 'string',
type: 'string' as const,
required: true,
description: 'The content of your new tweet.',
variables: true,

View File

@@ -0,0 +1,3 @@
import createTweet from './create-tweet';
export default [createTweet];

View File

@@ -7,7 +7,7 @@ export default {
{
key: 'oAuthRedirectUrl',
label: 'OAuth Redirect URL',
type: 'string',
type: 'string' as const,
required: true,
readOnly: true,
value: '{WEB_APP_URL}/app/twitter/connections/add',
@@ -19,7 +19,7 @@ export default {
{
key: 'consumerKey',
label: 'API Key',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -30,7 +30,7 @@ export default {
{
key: 'consumerSecret',
label: 'API Secret',
type: 'string',
type: 'string' as const,
required: true,
readOnly: false,
value: null,
@@ -42,7 +42,7 @@ export default {
authenticationSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'createConnection',
arguments: [
{
@@ -67,7 +67,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -78,7 +78,7 @@ export default {
},
{
step: 3,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -89,7 +89,7 @@ export default {
},
{
step: 4,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -110,7 +110,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{
@@ -123,7 +123,7 @@ export default {
reconnectionSteps: [
{
step: 1,
type: 'mutation',
type: 'mutation' as const,
name: 'resetConnection',
arguments: [
{
@@ -134,7 +134,7 @@ export default {
},
{
step: 2,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -159,7 +159,7 @@ export default {
},
{
step: 3,
type: 'mutation',
type: 'mutation' as const,
name: 'createAuthData',
arguments: [
{
@@ -170,7 +170,7 @@ export default {
},
{
step: 4,
type: 'openWithPopup',
type: 'openWithPopup' as const,
name: 'openAuthPopup',
arguments: [
{
@@ -181,7 +181,7 @@ export default {
},
{
step: 5,
type: 'mutation',
type: 'mutation' as const,
name: 'updateConnection',
arguments: [
{
@@ -202,7 +202,7 @@ export default {
},
{
step: 6,
type: 'mutation',
type: 'mutation' as const,
name: 'verifyConnection',
arguments: [
{

View File

@@ -1,5 +1,8 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import actions from './actions';
import triggers from './triggers';
export default defineApp({
name: 'Twitter',
@@ -11,4 +14,7 @@ export default defineApp({
apiBaseUrl: 'https://api.twitter.com',
primaryColor: '1da1f2',
beforeRequest: [addAuthHeader],
auth,
triggers,
actions,
});

View File

@@ -0,0 +1,11 @@
import myTweets from './my-tweets';
import newFollowerOfMe from './new-follower-of-me';
import searchTweets from './search-tweets';
import userTweets from './user-tweets';
export default [
myTweets,
newFollowerOfMe,
searchTweets,
userTweets,
];

View File

@@ -19,7 +19,7 @@ export default defineTrigger({
{
label: 'Search Term',
key: 'searchTerm',
type: 'string',
type: 'string' as const,
required: true,
},
],

View File

@@ -18,7 +18,7 @@ export default defineTrigger({
{
label: 'Username',
key: 'username',
type: 'string',
type: 'string' as const,
required: true,
},
],

View File

@@ -1,8 +1,4 @@
import fs from 'fs';
import { join } from 'path';
import { IApp, IAuth, IAction, ITrigger, IData } from '@automatisch/types';
const appsPath = join(__dirname, '../apps');
import { IApp } from '@automatisch/types';
async function getDefaultExport(path: string) {
return (await import(path)).default;
@@ -12,63 +8,12 @@ function stripFunctions<C>(data: C): C {
return JSON.parse(JSON.stringify(data));
}
async function getFileContent<C>(
path: string,
stripFuncs: boolean
): Promise<C> {
const fileContent = await getDefaultExport(path);
if (stripFuncs) {
return stripFunctions(fileContent);
}
return fileContent;
}
async function getChildrenContentInDirectory<C>(
path: string,
stripFuncs: boolean
): Promise<C[]> {
const appSubdirectory = join(appsPath, path);
const childrenContent = [];
if (fs.existsSync(appSubdirectory)) {
const filesInSubdirectory = fs.readdirSync(appSubdirectory);
for (const filename of filesInSubdirectory) {
const filePath = join(appSubdirectory, filename);
const fileContent = await getFileContent<C>(filePath, stripFuncs);
childrenContent.push(fileContent);
}
return childrenContent;
}
return [];
}
const getApp = async (appKey: string, stripFuncs = true) => {
const appData: IApp = await getDefaultExport(`../apps/${appKey}`);
if (appData.supportsConnections) {
appData.auth = await getFileContent<IAuth>(
`../apps/${appKey}/auth`,
stripFuncs
);
if (stripFuncs) {
return stripFunctions(appData);
}
appData.triggers = await getChildrenContentInDirectory<ITrigger>(
`${appKey}/triggers`,
stripFuncs
);
appData.actions = await getChildrenContentInDirectory<IAction>(
`${appKey}/actions`,
stripFuncs
);
appData.data = await getChildrenContentInDirectory<IData>(
`${appKey}/data`,
stripFuncs
);
return appData;
};

View File

@@ -136,7 +136,7 @@ export type IField = IFieldDropdown | IFieldText;
export interface IAuthenticationStepField {
name: string;
value: string | null;
properties: {
properties?: {
name: string;
value: string;
}[];
@@ -178,7 +178,7 @@ export interface IData {
}
export interface IAuth {
createAuthData($: IGlobalVariable): Promise<void>;
createAuthData?($: IGlobalVariable): Promise<void>;
verifyCredentials($: IGlobalVariable): Promise<any>;
isStillVerified($: IGlobalVariable): Promise<boolean>;
fields: IField[];