refactor: Introduce IActionOutput and ITriggerOutput types
This commit is contained in:
@@ -20,7 +20,7 @@ export default {
|
||||
async run($: IGlobalVariable) {
|
||||
return await getUserTweets($, {
|
||||
currentUser: true,
|
||||
lastInternalId: $.db.flow.lastInternalId,
|
||||
lastInternalId: $.flow.lastInternalId,
|
||||
});
|
||||
},
|
||||
|
||||
|
@@ -18,7 +18,7 @@ export default {
|
||||
],
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
return await myFollowers($, $.db.flow.lastInternalId);
|
||||
return await myFollowers($, $.flow.lastInternalId);
|
||||
},
|
||||
|
||||
async testRun($: IGlobalVariable) {
|
||||
|
@@ -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,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user