refactor: Introduce IActionOutput and ITriggerOutput types

This commit is contained in:
Faruk AYDIN
2022-10-12 21:10:44 +02:00
committed by Ali BARIN
parent 6895378d33
commit d9192f6e6b
22 changed files with 327 additions and 279 deletions

View File

@@ -20,7 +20,7 @@ export default {
async run($: IGlobalVariable) {
return await getUserTweets($, {
currentUser: true,
lastInternalId: $.db.flow.lastInternalId,
lastInternalId: $.flow.lastInternalId,
});
},

View File

@@ -18,7 +18,7 @@ export default {
],
async run($: IGlobalVariable) {
return await myFollowers($, $.db.flow.lastInternalId);
return await myFollowers($, $.flow.lastInternalId);
},
async testRun($: IGlobalVariable) {

View File

@@ -32,14 +32,14 @@ export default {
async run($: IGlobalVariable) {
return await searchTweets($, {
searchTerm: $.db.step.parameters.searchTerm as string,
lastInternalId: $.db.flow.lastInternalId,
searchTerm: $.step.parameters.searchTerm as string,
lastInternalId: $.flow.lastInternalId,
});
},
async testRun($: IGlobalVariable) {
return await searchTweets($, {
searchTerm: $.db.step.parameters.searchTerm as string,
searchTerm: $.step.parameters.searchTerm as string,
});
},
};

View File

@@ -1,4 +1,8 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
import {
IGlobalVariable,
IJSONObject,
ITriggerOutput,
} from '@automatisch/types';
import qs from 'qs';
import generateRequest from '../../common/generate-request';
import { omitBy, isEmpty } from 'lodash';
@@ -14,12 +18,8 @@ const searchTweets = async (
) => {
let response;
const tweets: {
data: IJSONObject[];
error: IJSONObject | null;
} = {
const tweets: ITriggerOutput = {
data: [],
error: null,
};
do {
@@ -56,7 +56,14 @@ const searchTweets = async (
!options.lastInternalId ||
Number(tweet.id) > Number(options.lastInternalId)
) {
tweets.data.push(tweet);
const dataItem = {
raw: tweet,
meta: {
internalId: tweet.id as string,
},
};
tweets.data.push(dataItem);
} else {
return;
}

View File

@@ -32,15 +32,15 @@ export default {
async run($: IGlobalVariable) {
return await getUserTweets($, {
currentUser: false,
userId: $.db.step.parameters.username as string,
lastInternalId: $.db.flow.lastInternalId,
userId: $.step.parameters.username as string,
lastInternalId: $.flow.lastInternalId,
});
},
async testRun($: IGlobalVariable) {
return await getUserTweets($, {
currentUser: false,
userId: $.db.step.parameters.username as string,
userId: $.step.parameters.username as string,
});
},
};