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