Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

Commit c199599

Browse files
authored
Merge pull request #14 from dylburger/component-action-changes
Supporting component actions with error response
2 parents cf731bb + eb97379 commit c199599

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

dist/axios.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,15 @@ async function default_1(step, config, signConfig) {
8787
return (await axios_1.default(config)).data;
8888
}
8989
catch (err) {
90-
if (err.response)
91-
step.debug = utils_1.cloneSafe(err.response);
92-
throw err;
90+
if (err.response) {
91+
if (step.export) {
92+
step.export("debug", utils_1.cloneSafe(err.response));
93+
}
94+
else {
95+
step.debug = utils_1.cloneSafe(err.response);
96+
}
97+
throw err;
98+
}
9399
}
94100
}
95101
exports.default = default_1;

lib/axios.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as buildURL from "axios/lib/helpers/buildURL"
44
import * as querystring from "querystring"
55
import { cloneSafe } from "./utils"
66

7-
function cleanObject(o: {string: any}) {
7+
function cleanObject(o: { string: any }) {
88
for (const k in o || {}) {
99
if (typeof o[k] === "undefined") {
1010
delete o[k]
@@ -19,7 +19,7 @@ function removeSearchFromUrl(config: AxiosRequestConfig) {
1919
const queryString = url.search.substr(1)
2020
if (queryString) {
2121
// https://stackoverflow.com/a/8649003/387413
22-
const urlParams = JSON.parse('{"' + queryString.replace(/&/g, '","').replace(/=/g,'":"') + '"}', function(key, value) {
22+
const urlParams = JSON.parse('{"' + queryString.replace(/&/g, '","').replace(/=/g, '":"') + '"}', function (key, value) {
2323
return key === "" ? value : decodeURIComponent(value)
2424
})
2525
for (const k in urlParams) {
@@ -43,7 +43,7 @@ function oauth1ParamsSerializer(p: any) {
4343
}
4444

4545
// XXX warn about mutating config object... or clone?
46-
export default async function(step: any, config: AxiosRequestConfig, signConfig?: any) {
46+
export default async function (step: any, config: AxiosRequestConfig, signConfig?: any) {
4747
cleanObject(config.headers)
4848
cleanObject(config.params)
4949
if (typeof config.data === "object") {
@@ -52,7 +52,7 @@ export default async function(step: any, config: AxiosRequestConfig, signConfig?
5252
removeSearchFromUrl(config)
5353
// OAuth1 request
5454
if (signConfig) {
55-
const {oauthSignerUri, token} = signConfig
55+
const { oauthSignerUri, token } = signConfig
5656
const requestData = {
5757
method: config.method || "get",
5858
url: buildURL(config.url, config.params, oauth1ParamsSerializer), // build url as axios will
@@ -84,7 +84,13 @@ export default async function(step: any, config: AxiosRequestConfig, signConfig?
8484
try {
8585
return (await axios(config)).data
8686
} catch (err) {
87-
if (err.response) step.debug = cloneSafe(err.response)
88-
throw err
87+
if (err.response) {
88+
if (step.export) {
89+
step.export("debug", cloneSafe(err.response))
90+
} else {
91+
step.debug = cloneSafe(err.response)
92+
}
93+
throw err
94+
}
8995
}
9096
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedreamhq/platform",
3-
"version": "0.8.1",
3+
"version": "0.9.0",
44
"description": "Pipedream platform globals (typing and runtime type checking)",
55
"homepage": "https://pipedream.com",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)