Merge branch 'main' into issue-553
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"license": "AGPL-3.0",
|
||||
"description": "The open source Zapier alternative. Build workflow automation without spending time and money.",
|
||||
"scripts": {
|
||||
"dev": "ts-node-dev src/server.ts",
|
||||
"dev": "ts-node-dev --exit-child src/server.ts",
|
||||
"worker": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/worker.ts",
|
||||
"build": "tsc && yarn copy-statics",
|
||||
"build:watch": "nodemon --watch 'src/**/*.ts' --watch 'bin/**/*.ts' --exec yarn build --ext ts",
|
||||
@@ -134,4 +134,4 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default function getDateTimeObjectRepresentation(dateTime: DateTime) {
|
||||
const defaults = dateTime.toObject();
|
||||
@@ -10,5 +11,5 @@ export default function getDateTimeObjectRepresentation(dateTime: DateTime) {
|
||||
pretty_time: dateTime.toLocaleString(DateTime.TIME_WITH_SECONDS),
|
||||
pretty_day_of_week: dateTime.toFormat('cccc'),
|
||||
day_of_week: dateTime.weekday,
|
||||
};
|
||||
} as IJSONObject;
|
||||
}
|
||||
|
@@ -6,5 +6,4 @@ export default {
|
||||
authDocUrl: "https://automatisch.io/docs/connections/scheduler",
|
||||
primaryColor: "0059F7",
|
||||
supportsConnections: false,
|
||||
requiresAuthentication: false,
|
||||
};
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IGlobalVariable, IJSONValue } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import cronTimes from '../../common/cron-times';
|
||||
import getNextCronDateTime from '../../common/get-next-cron-date-time';
|
||||
import getDateTimeObjectRepresentation from '../../common/get-date-time-object';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Every day',
|
||||
key: 'everyDay',
|
||||
description: 'Triggers every day.',
|
||||
@@ -154,23 +155,22 @@ export default {
|
||||
return cronTimes.everyDayExcludingWeekendsAt(parameters.hour as number);
|
||||
},
|
||||
|
||||
async run($: IGlobalVariable, startDateTime: Date) {
|
||||
const dateTime = DateTime.fromJSDate(startDateTime);
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
dateTime
|
||||
) as IJSONValue;
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const nextCronDateTime = getNextCronDateTime(
|
||||
this.getInterval($.step.parameters)
|
||||
);
|
||||
const dateTime = DateTime.now();
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
nextCronDateTime
|
||||
) as IJSONValue;
|
||||
$.execution.testRun ? nextCronDateTime : dateTime
|
||||
);
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
const dataItem = {
|
||||
raw: dateTimeObjectRepresentation,
|
||||
meta: {
|
||||
internalId: dateTime.toMillis().toString(),
|
||||
},
|
||||
};
|
||||
|
||||
return { data: [dataItem] };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IGlobalVariable, IJSONValue } from '@automatisch/types';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import cronTimes from '../../common/cron-times';
|
||||
import getNextCronDateTime from '../../common/get-next-cron-date-time';
|
||||
import getDateTimeObjectRepresentation from '../../common/get-date-time-object';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Every hour',
|
||||
key: 'everyHour',
|
||||
description: 'Triggers every hour.',
|
||||
@@ -48,23 +49,22 @@ export default {
|
||||
return cronTimes.everyHourExcludingWeekends;
|
||||
},
|
||||
|
||||
async run($: IGlobalVariable, startDateTime: Date) {
|
||||
const dateTime = DateTime.fromJSDate(startDateTime);
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
dateTime
|
||||
) as IJSONValue;
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const nextCronDateTime = getNextCronDateTime(
|
||||
this.getInterval($.step.parameters)
|
||||
);
|
||||
const dateTime = DateTime.now();
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
nextCronDateTime
|
||||
) as IJSONValue;
|
||||
$.execution.testRun ? nextCronDateTime : dateTime
|
||||
);
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
const dataItem = {
|
||||
raw: dateTimeObjectRepresentation,
|
||||
meta: {
|
||||
internalId: dateTime.toMillis().toString(),
|
||||
},
|
||||
};
|
||||
|
||||
return { data: [dataItem] };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IGlobalVariable, IJSONValue } from '@automatisch/types';
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import cronTimes from '../../common/cron-times';
|
||||
import getNextCronDateTime from '../../common/get-next-cron-date-time';
|
||||
import getDateTimeObjectRepresentation from '../../common/get-date-time-object';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Every month',
|
||||
key: 'everyMonth',
|
||||
description: 'Triggers every month.',
|
||||
@@ -22,127 +23,127 @@ export default {
|
||||
variables: false,
|
||||
options: [
|
||||
{
|
||||
label: 1,
|
||||
label: '1',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: 2,
|
||||
label: '2',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
label: 3,
|
||||
label: '3',
|
||||
value: 3,
|
||||
},
|
||||
{
|
||||
label: 4,
|
||||
label: '4',
|
||||
value: 4,
|
||||
},
|
||||
{
|
||||
label: 5,
|
||||
label: '5',
|
||||
value: 5,
|
||||
},
|
||||
{
|
||||
label: 6,
|
||||
label: '6',
|
||||
value: 6,
|
||||
},
|
||||
{
|
||||
label: 7,
|
||||
label: '7',
|
||||
value: 7,
|
||||
},
|
||||
{
|
||||
label: 8,
|
||||
label: '8',
|
||||
value: 8,
|
||||
},
|
||||
{
|
||||
label: 9,
|
||||
label: '9',
|
||||
value: 9,
|
||||
},
|
||||
{
|
||||
label: 10,
|
||||
label: '10',
|
||||
value: 10,
|
||||
},
|
||||
{
|
||||
label: 11,
|
||||
label: '11',
|
||||
value: 11,
|
||||
},
|
||||
{
|
||||
label: 12,
|
||||
label: '12',
|
||||
value: 12,
|
||||
},
|
||||
{
|
||||
label: 13,
|
||||
label: '13',
|
||||
value: 13,
|
||||
},
|
||||
{
|
||||
label: 14,
|
||||
label: '14',
|
||||
value: 14,
|
||||
},
|
||||
{
|
||||
label: 15,
|
||||
label: '15',
|
||||
value: 15,
|
||||
},
|
||||
{
|
||||
label: 16,
|
||||
label: '16',
|
||||
value: 16,
|
||||
},
|
||||
{
|
||||
label: 17,
|
||||
label: '17',
|
||||
value: 17,
|
||||
},
|
||||
{
|
||||
label: 18,
|
||||
label: '18',
|
||||
value: 18,
|
||||
},
|
||||
{
|
||||
label: 19,
|
||||
label: '19',
|
||||
value: 19,
|
||||
},
|
||||
{
|
||||
label: 20,
|
||||
label: '20',
|
||||
value: 20,
|
||||
},
|
||||
{
|
||||
label: 21,
|
||||
label: '21',
|
||||
value: 21,
|
||||
},
|
||||
{
|
||||
label: 22,
|
||||
label: '22',
|
||||
value: 22,
|
||||
},
|
||||
{
|
||||
label: 23,
|
||||
label: '23',
|
||||
value: 23,
|
||||
},
|
||||
{
|
||||
label: 24,
|
||||
label: '24',
|
||||
value: 24,
|
||||
},
|
||||
{
|
||||
label: 25,
|
||||
label: '25',
|
||||
value: 25,
|
||||
},
|
||||
{
|
||||
label: 26,
|
||||
label: '26',
|
||||
value: 26,
|
||||
},
|
||||
{
|
||||
label: 27,
|
||||
label: '27',
|
||||
value: 27,
|
||||
},
|
||||
{
|
||||
label: 28,
|
||||
label: '28',
|
||||
value: 28,
|
||||
},
|
||||
{
|
||||
label: 29,
|
||||
label: '29',
|
||||
value: 29,
|
||||
},
|
||||
{
|
||||
label: 30,
|
||||
label: '30',
|
||||
value: 30,
|
||||
},
|
||||
{
|
||||
label: 31,
|
||||
label: '31',
|
||||
value: 31,
|
||||
},
|
||||
],
|
||||
@@ -270,23 +271,22 @@ export default {
|
||||
return interval;
|
||||
},
|
||||
|
||||
async run($: IGlobalVariable, startDateTime: Date) {
|
||||
const dateTime = DateTime.fromJSDate(startDateTime);
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
dateTime
|
||||
) as IJSONValue;
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const nextCronDateTime = getNextCronDateTime(
|
||||
this.getInterval($.step.parameters)
|
||||
);
|
||||
const dateTime = DateTime.now();
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
nextCronDateTime
|
||||
) as IJSONValue;
|
||||
$.execution.testRun ? nextCronDateTime : dateTime
|
||||
);
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
const dataItem = {
|
||||
raw: dateTimeObjectRepresentation,
|
||||
meta: {
|
||||
internalId: dateTime.toMillis().toString(),
|
||||
},
|
||||
};
|
||||
|
||||
return { data: [dataItem] };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { DateTime } from 'luxon';
|
||||
import { IGlobalVariable, IJSONValue } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import cronTimes from '../../common/cron-times';
|
||||
import getNextCronDateTime from '../../common/get-next-cron-date-time';
|
||||
import getDateTimeObjectRepresentation from '../../common/get-date-time-object';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Every week',
|
||||
key: 'everyWeek',
|
||||
description: 'Triggers every week.',
|
||||
@@ -174,23 +175,22 @@ export default {
|
||||
return interval;
|
||||
},
|
||||
|
||||
async run($: IGlobalVariable, startDateTime: Date) {
|
||||
const dateTime = DateTime.fromJSDate(startDateTime);
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
dateTime
|
||||
) as IJSONValue;
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const nextCronDateTime = getNextCronDateTime(
|
||||
this.getInterval($.step.parameters)
|
||||
);
|
||||
const dateTime = DateTime.now();
|
||||
const dateTimeObjectRepresentation = getDateTimeObjectRepresentation(
|
||||
nextCronDateTime
|
||||
) as IJSONValue;
|
||||
$.execution.testRun ? nextCronDateTime : dateTime
|
||||
);
|
||||
|
||||
return { data: [dateTimeObjectRepresentation] };
|
||||
const dataItem = {
|
||||
raw: dateTimeObjectRepresentation,
|
||||
meta: {
|
||||
internalId: dateTime.toMillis().toString(),
|
||||
},
|
||||
};
|
||||
|
||||
return { data: [dataItem] };
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -28,7 +28,7 @@ const findMessage = async ($: IGlobalVariable, options: FindMessageOptions) => {
|
||||
|
||||
const message: IActionOutput = {
|
||||
data: {
|
||||
raw: data?.data?.messages.matches[0],
|
||||
raw: data?.messages.matches[0],
|
||||
},
|
||||
error: response?.integrationError || (!data.ok && data),
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import findMessage from './find-message';
|
||||
|
||||
export default {
|
||||
export default defineAction({
|
||||
name: 'Find message',
|
||||
key: 'findMessage',
|
||||
description: 'Find a Slack message using the Slack Search feature.',
|
||||
@@ -71,7 +71,7 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const parameters = $.step.parameters;
|
||||
const query = parameters.query as string;
|
||||
const sortBy = parameters.sortBy as string;
|
||||
@@ -87,4 +87,4 @@ export default {
|
||||
|
||||
return messages;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
import postMessage from './post-message';
|
||||
|
||||
export default {
|
||||
export default defineAction({
|
||||
name: 'Send a message to channel',
|
||||
key: 'sendMessageToChannel',
|
||||
description: 'Send a message to a specific channel you specify.',
|
||||
@@ -48,7 +48,7 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
const channelId = $.step.parameters.channel as string;
|
||||
const text = $.step.parameters.message as string;
|
||||
|
||||
@@ -56,4 +56,4 @@ export default {
|
||||
|
||||
return message;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -12,8 +12,6 @@ import getUserByUsername from './get-user-by-username';
|
||||
|
||||
type IGetUserTweetsOptions = {
|
||||
currentUser: boolean;
|
||||
userId?: string;
|
||||
lastInternalId?: string;
|
||||
};
|
||||
|
||||
const getUserTweets = async (
|
||||
@@ -39,7 +37,7 @@ const getUserTweets = async (
|
||||
|
||||
do {
|
||||
const params: IJSONObject = {
|
||||
since_id: options.lastInternalId,
|
||||
since_id: $.execution.testRun ? null : $.flow.lastInternalId,
|
||||
pagination_token: response?.data?.meta?.next_token,
|
||||
};
|
||||
|
||||
@@ -63,15 +61,13 @@ const getUserTweets = async (
|
||||
response.data.data.forEach((tweet: IJSONObject) => {
|
||||
tweets.data.push({
|
||||
raw: tweet,
|
||||
meta: { internalId: tweet.id as string },
|
||||
meta: {
|
||||
internalId: tweet.id as string,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
} while (response.data.meta.next_token && options.lastInternalId);
|
||||
|
||||
tweets.data.sort((tweet, nextTweet) => {
|
||||
return (tweet.raw.id as number) - (nextTweet.raw.id as number);
|
||||
});
|
||||
} while (response.data.meta.next_token && !$.execution.testRun);
|
||||
|
||||
return tweets;
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import getUserTweets from '../../common/get-user-tweets';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'My Tweets',
|
||||
key: 'myTweets',
|
||||
pollInterval: 15,
|
||||
@@ -17,14 +17,9 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: true,
|
||||
lastInternalId: $.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
return await getUserTweets($, { currentUser: true });
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import myFollowers from './my-followers';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'New follower of me',
|
||||
key: 'myFollowers',
|
||||
pollInterval: 15,
|
||||
@@ -17,11 +17,7 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
return await myFollowers($, $.flow.lastInternalId);
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
return await myFollowers($);
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import searchTweets from './search-tweets';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'Search Tweets',
|
||||
key: 'searchTweets',
|
||||
pollInterval: 15,
|
||||
@@ -30,15 +30,7 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
return await searchTweets($, {
|
||||
searchTerm: $.step.parameters.searchTerm as string,
|
||||
});
|
||||
async run($) {
|
||||
return await searchTweets($);
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
return await searchTweets($, {
|
||||
searchTerm: $.step.parameters.searchTerm as string,
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -7,15 +7,9 @@ import qs from 'qs';
|
||||
import generateRequest from '../../common/generate-request';
|
||||
import { omitBy, isEmpty } from 'lodash';
|
||||
|
||||
type ISearchTweetsOptions = {
|
||||
searchTerm: string;
|
||||
lastInternalId?: string;
|
||||
};
|
||||
const searchTweets = async ($: IGlobalVariable) => {
|
||||
const searchTerm = $.step.parameters.searchTerm as string;
|
||||
|
||||
const searchTweets = async (
|
||||
$: IGlobalVariable,
|
||||
options: ISearchTweetsOptions
|
||||
) => {
|
||||
let response;
|
||||
|
||||
const tweets: ITriggerOutput = {
|
||||
@@ -24,7 +18,7 @@ const searchTweets = async (
|
||||
|
||||
do {
|
||||
const params: IJSONObject = {
|
||||
query: options.searchTerm,
|
||||
query: searchTerm,
|
||||
since_id: $.execution.testRun ? null : $.flow.lastInternalId,
|
||||
pagination_token: response?.data?.meta?.next_token,
|
||||
};
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { IGlobalVariable } from '@automatisch/types';
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
import getUserTweets from '../../common/get-user-tweets';
|
||||
|
||||
export default {
|
||||
export default defineTrigger({
|
||||
name: 'User Tweets',
|
||||
key: 'userTweets',
|
||||
pollInterval: 15,
|
||||
@@ -29,18 +29,9 @@ export default {
|
||||
},
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
async run($) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: false,
|
||||
userId: $.step.parameters.username as string,
|
||||
lastInternalId: $.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: false,
|
||||
userId: $.step.parameters.username as string,
|
||||
});
|
||||
},
|
||||
};
|
||||
});
|
||||
|
@@ -4,6 +4,7 @@ import { IApp } from '@automatisch/types';
|
||||
type Params = {
|
||||
name: string;
|
||||
onlyWithTriggers: boolean;
|
||||
onlyWithActions: boolean;
|
||||
};
|
||||
|
||||
const getApps = async (_parent: unknown, params: Params) => {
|
||||
@@ -13,6 +14,10 @@ const getApps = async (_parent: unknown, params: Params) => {
|
||||
return apps.filter((app: IApp) => app.triggers?.length);
|
||||
}
|
||||
|
||||
if (params.onlyWithActions) {
|
||||
return apps.filter((app: IApp) => app.actions?.length);
|
||||
}
|
||||
|
||||
return apps;
|
||||
};
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
type Query {
|
||||
getApps(name: String, onlyWithTriggers: Boolean): [App]
|
||||
getApps(name: String, onlyWithTriggers: Boolean, onlyWithActions: Boolean): [App]
|
||||
getApp(key: AvailableAppsEnumType!): App
|
||||
getConnectedApps(name: String): [App]
|
||||
testConnection(id: String!): Connection
|
||||
|
@@ -9,10 +9,14 @@ const appInfoConverter = (rawAppData: IApp) => {
|
||||
|
||||
if (rawAppData.auth?.fields) {
|
||||
rawAppData.auth.fields = rawAppData.auth.fields.map((field) => {
|
||||
return {
|
||||
...field,
|
||||
value: field.value?.replace('{WEB_APP_URL}', appConfig.webAppUrl),
|
||||
};
|
||||
if (typeof field.value === 'string') {
|
||||
return {
|
||||
...field,
|
||||
value: field.value.replace('{WEB_APP_URL}', appConfig.webAppUrl),
|
||||
};
|
||||
}
|
||||
|
||||
return field
|
||||
});
|
||||
}
|
||||
|
||||
|
5
packages/backend/src/helpers/define-action.ts
Normal file
5
packages/backend/src/helpers/define-action.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { IAction } from '@automatisch/types';
|
||||
|
||||
export default function defineAction(actionDefinition: IAction): IAction {
|
||||
return actionDefinition;
|
||||
}
|
5
packages/backend/src/helpers/define-trigger.ts
Normal file
5
packages/backend/src/helpers/define-trigger.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { ITrigger } from '@automatisch/types';
|
||||
|
||||
export default function defineTrigger(triggerDefinition: ITrigger): ITrigger {
|
||||
return triggerDefinition;
|
||||
}
|
@@ -16,17 +16,13 @@ async function getFileContent<C>(
|
||||
path: string,
|
||||
stripFuncs: boolean
|
||||
): Promise<C> {
|
||||
try {
|
||||
const fileContent = await getDefaultExport(path);
|
||||
const fileContent = await getDefaultExport(path);
|
||||
|
||||
if (stripFuncs) {
|
||||
return stripFunctions(fileContent);
|
||||
}
|
||||
|
||||
return fileContent;
|
||||
} catch (err) {
|
||||
return null;
|
||||
if (stripFuncs) {
|
||||
return stripFunctions(fileContent);
|
||||
}
|
||||
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
async function getChildrenContentInDirectory<C>(
|
||||
@@ -55,10 +51,12 @@ async function getChildrenContentInDirectory<C>(
|
||||
const getApp = async (appKey: string, stripFuncs = true) => {
|
||||
const appData: IApp = await getDefaultExport(`../apps/${appKey}`);
|
||||
|
||||
appData.auth = await getFileContent<IAuth>(
|
||||
`../apps/${appKey}/auth`,
|
||||
stripFuncs
|
||||
);
|
||||
if (appData.supportsConnections) {
|
||||
appData.auth = await getFileContent<IAuth>(
|
||||
`../apps/${appKey}/auth`,
|
||||
stripFuncs
|
||||
);
|
||||
}
|
||||
appData.triggers = await getChildrenContentInDirectory<ITrigger>(
|
||||
`${appKey}/triggers`,
|
||||
stripFuncs
|
||||
|
@@ -48,7 +48,7 @@ export const processAction = async (options: ProcessActionOptions) => {
|
||||
status: actionOutput.error ? 'failure' : 'success',
|
||||
dataIn: computedParameters,
|
||||
dataOut: actionOutput.error ? null : actionOutput.data.raw,
|
||||
errorDetails: actionOutput.error,
|
||||
errorDetails: actionOutput.error ? actionOutput.error : null,
|
||||
});
|
||||
|
||||
return { flowId, stepId, executionId, executionStep };
|
||||
|
Reference in New Issue
Block a user