Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
10 changes: 7 additions & 3 deletions platform/dist/axios.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createAxiosInstance = void 0;
const axios_1 = require("axios");
const buildURL = require("axios/lib/helpers/buildURL");
const querystring = require("querystring");
Expand Down Expand Up @@ -96,11 +97,13 @@ async function default_1(step, config, signConfig) {
if (config.debug) {
stepExport(step, config, "debug_config");
}
const { data } = await axios_1.default(config);
const response = await axios_1.default(config);
if (config.debug) {
stepExport(step, data, "debug_response");
stepExport(step, response.data, "debug_response");
}
return data;
return config.returnRawResponse
? response
: response.data;
}
catch (err) {
if (err.response) {
Expand Down Expand Up @@ -128,3 +131,4 @@ function convertAxiosError(err) {
err.message = JSON.stringify(err.response.data);
return err;
}
exports.createAxiosInstance = axios_1.default.create;
3 changes: 2 additions & 1 deletion platform/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.$sendConfigRuntimeTypeChecker = exports.$send = exports.$end = exports.END_NEEDLE = exports.$event = exports.sendTypeMap = exports.SendConfigSSE = exports.SendConfigSnowflake = exports.SendConfigSQL = exports.SendConfigS3 = exports.SendConfigHTTP = exports.HTTP_METHODS = exports.SendConfigEmit = exports.SendConfigEmit_optional = exports.SendConfigEmit_required = exports.SendConfigEmail = exports.axios = void 0;
exports.$sendConfigRuntimeTypeChecker = exports.$send = exports.$end = exports.END_NEEDLE = exports.$event = exports.sendTypeMap = exports.SendConfigSSE = exports.SendConfigSnowflake = exports.SendConfigSQL = exports.SendConfigS3 = exports.SendConfigHTTP = exports.HTTP_METHODS = exports.SendConfigEmit = exports.SendConfigEmit_optional = exports.SendConfigEmit_required = exports.SendConfigEmail = exports.createAxiosInstance = exports.axios = void 0;
const t = require("io-ts");
const axios_1 = require("./axios");
exports.axios = axios_1.default;
Object.defineProperty(exports, "createAxiosInstance", { enumerable: true, get: function () { return axios_1.createAxiosInstance; } });
var utils_1 = require("./utils");
Object.defineProperty(exports, "cloneSafe", { enumerable: true, get: function () { return utils_1.cloneSafe; } });
Object.defineProperty(exports, "jsonStringifySafe", { enumerable: true, get: function () { return utils_1.jsonStringifySafe; } });
Expand Down
17 changes: 13 additions & 4 deletions platform/lib/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import * as querystring from "querystring";
import { cloneSafe } from "./utils";
import { ConfigurationError } from "./errors";

interface PipedreamAxiosRequestConfig extends AxiosRequestConfig {
returnRawResponse?: boolean;
}

function cleanObject(o: { string: any; }) {
for (const k in o || {}) {
if (typeof o[k] === "undefined") {
Expand Down Expand Up @@ -49,7 +53,7 @@ function oauth1ParamsSerializer(p: any) {
}

// XXX warn about mutating config object... or clone?
export default async function (step: any, config: AxiosRequestConfig, signConfig?: any) {
export default async function (step: any, config: PipedreamAxiosRequestConfig, signConfig?: any) {
cleanObject(config.headers);
cleanObject(config.params);
if (typeof config.data === "object") {
Expand Down Expand Up @@ -100,11 +104,14 @@ export default async function (step: any, config: AxiosRequestConfig, signConfig
if (config.debug) {
stepExport(step, config, "debug_config");
}
const { data } = await axios(config);
const response = await axios(config);
if (config.debug) {
stepExport(step, data, "debug_response");
stepExport(step, response.data, "debug_response");
}
return data;

return config.returnRawResponse
? response
: response.data;
} catch (err) {
if (err.response) {
convertAxiosError(err);
Expand Down Expand Up @@ -134,3 +141,5 @@ function convertAxiosError(err) {
err.message = JSON.stringify(err.response.data);
return err;
}

export const createAxiosInstance = axios.create;
7 changes: 4 additions & 3 deletions platform/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as t from "io-ts";

import axios from "./axios";
import axios, { createAxiosInstance } from "./axios";
import { AxiosRequestConfig as AxiosConfig } from "axios";

export {
axios,
createAxiosInstance,
};
export {
cloneSafe, jsonStringifySafe,
Expand All @@ -15,8 +16,8 @@ export {
} from "./errors";

export {
DEFAULT_POLLING_SOURCE_TIMER_INTERVAL
} from "./constants"
DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
} from "./constants";

const SendPayload = t.union([
t.string,
Expand Down