chore: Differentiate trigger and action output types
This commit is contained in:
@@ -30,7 +30,7 @@ const fetchTweets = async ($: IGlobalVariable, username: string) => {
|
||||
|
||||
if (response.data.meta.result_count > 0) {
|
||||
response.data.data.forEach((tweet: IJSONObject) => {
|
||||
$.output.data.push({
|
||||
$.triggerOutput.data.push({
|
||||
raw: tweet,
|
||||
meta: {
|
||||
internalId: tweet.id as string,
|
||||
@@ -40,7 +40,7 @@ const fetchTweets = async ($: IGlobalVariable, username: string) => {
|
||||
}
|
||||
} while (response.data.meta.next_token && !$.execution.testRun);
|
||||
|
||||
return $.output;
|
||||
return $.triggerOutput;
|
||||
};
|
||||
|
||||
const getUserTweets = async (
|
||||
|
@@ -22,7 +22,7 @@ export default defineTrigger({
|
||||
},
|
||||
|
||||
sort($) {
|
||||
$.output.data.sort((tweet, nextTweet) => {
|
||||
$.triggerOutput.data.sort((tweet, nextTweet) => {
|
||||
return Number(nextTweet.meta.internalId) - Number(tweet.meta.internalId);
|
||||
});
|
||||
},
|
||||
|
@@ -35,7 +35,7 @@ export default defineTrigger({
|
||||
},
|
||||
|
||||
sort($) {
|
||||
$.output.data.sort((tweet, nextTweet) => {
|
||||
$.triggerOutput.data.sort((tweet, nextTweet) => {
|
||||
return Number(nextTweet.meta.internalId) - Number(tweet.meta.internalId);
|
||||
});
|
||||
},
|
||||
|
@@ -35,7 +35,7 @@ const searchTweets = async ($: IGlobalVariable) => {
|
||||
},
|
||||
};
|
||||
|
||||
$.output.data.push(dataItem);
|
||||
$.triggerOutput.data.push(dataItem);
|
||||
});
|
||||
}
|
||||
} while (response.data.meta.next_token && !$.execution.testRun);
|
||||
|
@@ -34,7 +34,7 @@ export default defineTrigger({
|
||||
},
|
||||
|
||||
sort($) {
|
||||
$.output.data.sort((tweet, nextTweet) => {
|
||||
$.triggerOutput.data.sort((tweet, nextTweet) => {
|
||||
return Number(nextTweet.meta.internalId) - Number(tweet.meta.internalId);
|
||||
});
|
||||
},
|
||||
|
@@ -59,10 +59,14 @@ const globalVariable = async (
|
||||
id: execution?.id,
|
||||
testRun,
|
||||
},
|
||||
output: {
|
||||
triggerOutput: {
|
||||
data: [],
|
||||
error: null,
|
||||
},
|
||||
actionOutput: {
|
||||
data: null,
|
||||
error: null,
|
||||
},
|
||||
};
|
||||
|
||||
$.http = createHttpClient({
|
||||
|
@@ -24,12 +24,12 @@ export const processFlow = async (options: ProcessFlowOptions) => {
|
||||
await triggerCommand.run($);
|
||||
} catch (error) {
|
||||
if (error?.response?.httpError) {
|
||||
$.output.error = error.response.httpError;
|
||||
$.triggerOutput.error = error.response.httpError;
|
||||
} else {
|
||||
try {
|
||||
$.output.error = JSON.parse(error.message);
|
||||
$.triggerOutput.error = JSON.parse(error.message);
|
||||
} catch {
|
||||
$.output.error = { error: error.message };
|
||||
$.triggerOutput.error = { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,5 @@ export const processFlow = async (options: ProcessFlowOptions) => {
|
||||
triggerCommand.sort($);
|
||||
}
|
||||
|
||||
return $.output;
|
||||
return $.triggerOutput;
|
||||
};
|
||||
|
10
packages/types/index.d.ts
vendored
10
packages/types/index.d.ts
vendored
@@ -171,7 +171,7 @@ export interface IApp {
|
||||
|
||||
export type TBeforeRequest = {
|
||||
($: IGlobalVariable, requestConfig: AxiosRequestConfig): AxiosRequestConfig;
|
||||
}
|
||||
};
|
||||
|
||||
export interface IData {
|
||||
[index: string]: any;
|
||||
@@ -233,7 +233,7 @@ export interface IAction {
|
||||
key: string;
|
||||
description: string;
|
||||
substeps: ISubstep[];
|
||||
run($: IGlobalVariable): Promise<IActionOutput>;
|
||||
run($: IGlobalVariable): Promise<void | IActionOutput>;
|
||||
}
|
||||
|
||||
export interface IAuthentication {
|
||||
@@ -280,10 +280,8 @@ export type IGlobalVariable = {
|
||||
id: string;
|
||||
testRun: boolean;
|
||||
};
|
||||
output: {
|
||||
data: ITriggerDataItem[];
|
||||
error?: IJSONObject;
|
||||
}
|
||||
triggerOutput?: ITriggerOutput;
|
||||
actionOutput?: IActionOutput;
|
||||
process?: (triggerDataItem: ITriggerDataItem) => Promise<void>;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user