@hubspot/local-dev-lib 0.6.1-experimental.0 → 0.6.2-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/http/index.js +13 -15
- package/package.json +2 -2
package/http/index.js
CHANGED
|
@@ -51,6 +51,10 @@ const IGNORE_URLS_NETWORK_DEBUG = [
|
|
|
51
51
|
trackUsage_1.VSCODE_USAGE_PATH,
|
|
52
52
|
fireAlarm_1.FIREALARM_API_AUTH_PATH,
|
|
53
53
|
];
|
|
54
|
+
// Create an isolated axios instance for this copy of local-dev-lib.
|
|
55
|
+
// This prevents issues when multiple copies are loaded and share the global
|
|
56
|
+
// register interceptors on the shared instance causing errors to be wrapped multiple times.
|
|
57
|
+
const httpClient = axios_1.default.create();
|
|
54
58
|
function logRequest(response) {
|
|
55
59
|
try {
|
|
56
60
|
if (!process.env.HUBSPOT_NETWORK_LOGGING) {
|
|
@@ -72,7 +76,8 @@ function logRequest(response) {
|
|
|
72
76
|
// Ignore any errors that occur while logging the response
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
|
-
|
|
79
|
+
// Register interceptor on our isolated instance
|
|
80
|
+
httpClient.interceptors.response.use((response) => {
|
|
76
81
|
logRequest(response);
|
|
77
82
|
return response;
|
|
78
83
|
}, error => {
|
|
@@ -84,14 +89,7 @@ axios_1.default.interceptors.response.use((response) => {
|
|
|
84
89
|
catch (e) {
|
|
85
90
|
// Ignore any errors that occur while logging the response
|
|
86
91
|
}
|
|
87
|
-
//
|
|
88
|
-
// multiple copies of local-dev-lib are loaded and share the same axios
|
|
89
|
-
// instance, causing multiple interceptors to be registered.
|
|
90
|
-
if (error instanceof HubSpotHttpError_1.HubSpotHttpError ||
|
|
91
|
-
error?.name === HubSpotHttpError_1.HubSpotHttpErrorName) {
|
|
92
|
-
return Promise.reject(error);
|
|
93
|
-
}
|
|
94
|
-
// Wrap all axios errors in our own Error class. Attach the error
|
|
92
|
+
// Wrap all axios errors in our own Error class. Attach the error
|
|
95
93
|
// as the cause for the new error, so we maintain the stack trace
|
|
96
94
|
return Promise.reject(new HubSpotHttpError_1.HubSpotHttpError(error.message, { cause: error }));
|
|
97
95
|
});
|
|
@@ -164,23 +162,23 @@ async function getRequest(accountId, options) {
|
|
|
164
162
|
const { params, ...rest } = options;
|
|
165
163
|
const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
166
164
|
const requestConfig = await withAuth(accountId, optionsWithParams);
|
|
167
|
-
return (
|
|
165
|
+
return httpClient(requestConfig);
|
|
168
166
|
}
|
|
169
167
|
async function postRequest(accountId, options) {
|
|
170
168
|
const requestConfig = await withAuth(accountId, options);
|
|
171
|
-
return (
|
|
169
|
+
return httpClient({ ...requestConfig, method: 'post' });
|
|
172
170
|
}
|
|
173
171
|
async function putRequest(accountId, options) {
|
|
174
172
|
const requestConfig = await withAuth(accountId, options);
|
|
175
|
-
return (
|
|
173
|
+
return httpClient({ ...requestConfig, method: 'put' });
|
|
176
174
|
}
|
|
177
175
|
async function patchRequest(accountId, options) {
|
|
178
176
|
const requestConfig = await withAuth(accountId, options);
|
|
179
|
-
return (
|
|
177
|
+
return httpClient({ ...requestConfig, method: 'patch' });
|
|
180
178
|
}
|
|
181
179
|
async function deleteRequest(accountId, options) {
|
|
182
180
|
const requestConfig = await withAuth(accountId, options);
|
|
183
|
-
return (
|
|
181
|
+
return httpClient({ ...requestConfig, method: 'delete' });
|
|
184
182
|
}
|
|
185
183
|
function createGetRequestStream(contentType) {
|
|
186
184
|
return async (accountId, options, destPath) => {
|
|
@@ -190,7 +188,7 @@ function createGetRequestStream(contentType) {
|
|
|
190
188
|
return new Promise(async (resolve, reject) => {
|
|
191
189
|
try {
|
|
192
190
|
const { headers, ...opts } = await withAuth(accountId, axiosConfig);
|
|
193
|
-
const res = await (
|
|
191
|
+
const res = await httpClient({
|
|
194
192
|
method: 'get',
|
|
195
193
|
...opts,
|
|
196
194
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/local-dev-lib",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2-experimental.0",
|
|
4
4
|
"description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@hubspot/npm-scripts": "0.0.
|
|
23
|
+
"@hubspot/npm-scripts": "0.0.6",
|
|
24
24
|
"@types/content-disposition": "^0.5.5",
|
|
25
25
|
"@types/cors": "^2.8.15",
|
|
26
26
|
"@types/debounce": "^1.2.1",
|