@hubspot/local-dev-lib 0.2.0 → 0.2.1-experimental.1
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/LICENSE +12 -0
- package/README.md +17 -0
- package/api/appsDev.d.ts +6 -0
- package/api/appsDev.js +29 -0
- package/api/customObjects.d.ts +8 -7
- package/api/customObjects.js +13 -16
- package/api/designManager.d.ts +4 -13
- package/api/designManager.js +6 -9
- package/api/developerTestAccounts.d.ts +7 -0
- package/api/developerTestAccounts.js +48 -0
- package/api/fileManager.d.ts +5 -4
- package/api/fileManager.js +11 -11
- package/api/fileMapper.d.ts +8 -7
- package/api/fileMapper.js +17 -17
- package/api/fileTransport.d.ts +4 -0
- package/api/fileTransport.js +39 -0
- package/api/functions.d.ts +7 -4
- package/api/functions.js +22 -11
- package/api/github.d.ts +8 -9
- package/api/github.js +31 -13
- package/api/hubdb.d.ts +11 -10
- package/api/hubdb.js +28 -22
- package/api/lighthouseScore.d.ts +4 -4
- package/api/lighthouseScore.js +9 -12
- package/api/localDevAuth.d.ts +8 -15
- package/api/localDevAuth.js +34 -13
- package/api/marketplaceValidation.d.ts +4 -4
- package/api/marketplaceValidation.js +8 -11
- package/api/projects.d.ts +32 -24
- package/api/projects.js +164 -44
- package/api/sandboxHubs.d.ts +6 -4
- package/api/sandboxHubs.js +10 -11
- package/api/sandboxSync.d.ts +4 -4
- package/api/sandboxSync.js +4 -13
- package/api/secrets.d.ts +6 -8
- package/api/secrets.js +9 -12
- package/api/validateHubl.d.ts +2 -1
- package/api/validateHubl.js +3 -6
- package/config/defaultAccountOverride.d.ts +2 -0
- package/config/defaultAccountOverride.js +57 -0
- package/config/index.d.ts +26 -37
- package/config/index.js +253 -201
- package/config/utils.d.ts +70 -0
- package/config/utils.js +328 -0
- package/constants/config.d.ts +42 -1
- package/constants/config.js +44 -3
- package/constants/environments.d.ts +0 -10
- package/constants/environments.js +1 -11
- package/constants/extensions.d.ts +2 -0
- package/constants/extensions.js +3 -1
- package/constants/files.d.ts +2 -2
- package/constants/files.js +3 -3
- package/errors/errors_DEPRECATED.d.ts +1 -5
- package/errors/errors_DEPRECATED.js +2 -2
- package/errors/index.d.ts +18 -0
- package/errors/index.js +63 -0
- package/http/addQueryParams.d.ts +2 -0
- package/http/addQueryParams.js +14 -0
- package/http/getAxiosConfig.d.ts +6 -3
- package/http/getAxiosConfig.js +57 -7
- package/http/index.d.ts +11 -12
- package/http/index.js +56 -58
- package/http/unauthed.d.ts +14 -0
- package/http/unauthed.js +38 -0
- package/lang/en.json +370 -386
- package/lib/archive.d.ts +3 -8
- package/lib/archive.js +34 -30
- package/lib/cms/functions.d.ts +7 -12
- package/lib/cms/functions.js +49 -51
- package/lib/cms/handleFieldsJS.js +16 -14
- package/lib/cms/modules.d.ts +4 -15
- package/lib/cms/modules.js +81 -78
- package/lib/cms/processFieldsJs.js +10 -33
- package/lib/cms/templates.d.ts +43 -3
- package/lib/cms/templates.js +53 -11
- package/lib/cms/themes.js +3 -1
- package/lib/cms/uploadFolder.d.ts +3 -14
- package/lib/cms/uploadFolder.js +58 -42
- package/lib/cms/validate.js +1 -1
- package/lib/cms/watch.d.ts +2 -18
- package/lib/cms/watch.js +63 -68
- package/lib/customObjects.js +4 -15
- package/lib/environment.d.ts +1 -1
- package/lib/fileManager.d.ts +2 -6
- package/lib/fileManager.js +54 -65
- package/lib/fileMapper.d.ts +4 -15
- package/lib/fileMapper.js +67 -88
- package/lib/fs.d.ts +1 -1
- package/lib/fs.js +10 -6
- package/lib/github.d.ts +13 -14
- package/lib/github.js +70 -35
- package/lib/gitignore.d.ts +2 -0
- package/lib/gitignore.js +21 -4
- package/lib/hubdb.d.ts +3 -2
- package/lib/hubdb.js +11 -9
- package/{utils → lib}/notify.js +2 -2
- package/lib/oauth.d.ts +4 -7
- package/lib/oauth.js +14 -33
- package/lib/path.d.ts +3 -0
- package/lib/path.js +46 -1
- package/lib/personalAccessKey.d.ts +9 -11
- package/lib/personalAccessKey.js +108 -68
- package/lib/portManager.d.ts +3 -5
- package/lib/portManager.js +18 -6
- package/lib/text.d.ts +1 -0
- package/lib/text.js +9 -1
- package/lib/trackUsage.js +24 -14
- package/lib/urls.js +5 -1
- package/models/FileSystemError.d.ts +6 -0
- package/models/FileSystemError.js +47 -0
- package/models/HubSpotHttpError.d.ts +24 -0
- package/models/HubSpotHttpError.js +197 -0
- package/models/OAuth2Manager.d.ts +5 -28
- package/models/OAuth2Manager.js +34 -66
- package/package.json +34 -35
- package/types/Accounts.d.ts +82 -71
- package/types/Apps.d.ts +77 -0
- package/types/Archive.d.ts +9 -0
- package/types/Archive.js +2 -0
- package/types/Build.d.ts +4 -2
- package/types/ComponentStructure.d.ts +30 -10
- package/types/Config.d.ts +19 -15
- package/types/Deploy.d.ts +3 -2
- package/types/DesignManager.d.ts +10 -0
- package/types/DesignManager.js +2 -0
- package/types/Error.d.ts +9 -5
- package/types/FieldsJS.d.ts +1 -0
- package/types/FieldsJS.js +2 -0
- package/types/FileManager.d.ts +1 -1
- package/types/Files.d.ts +43 -4
- package/types/Functions.d.ts +52 -0
- package/types/Github.d.ts +13 -0
- package/types/Http.d.ts +13 -11
- package/types/Hubdb.d.ts +9 -0
- package/types/MarketplaceValidation.d.ts +7 -3
- package/types/Migration.d.ts +28 -0
- package/types/Migration.js +10 -0
- package/types/Modules.d.ts +11 -0
- package/types/PortManager.d.ts +7 -0
- package/types/Project.d.ts +30 -0
- package/types/ProjectLog.d.ts +9 -0
- package/types/ProjectLog.js +2 -0
- package/types/Sandbox.d.ts +37 -47
- package/types/Schemas.d.ts +56 -0
- package/types/Secrets.d.ts +3 -0
- package/types/Secrets.js +2 -0
- package/types/developerTestAccounts.d.ts +13 -0
- package/types/developerTestAccounts.js +2 -0
- package/utils/PortManagerServer.d.ts +6 -7
- package/utils/PortManagerServer.js +22 -16
- package/utils/cms/fieldsJS.d.ts +1 -2
- package/utils/cms/modules.js +2 -2
- package/utils/detectPort.js +3 -3
- package/utils/git.d.ts +1 -7
- package/utils/git.js +2 -18
- package/config/CLIConfiguration.d.ts +0 -61
- package/config/CLIConfiguration.js +0 -424
- package/config/configFile.d.ts +0 -21
- package/config/configFile.js +0 -108
- package/config/configUtils.d.ts +0 -24
- package/config/configUtils.js +0 -86
- package/config/config_DEPRECATED.d.ts +0 -78
- package/config/config_DEPRECATED.js +0 -639
- package/config/environment.d.ts +0 -2
- package/config/environment.js +0 -59
- package/errors/apiErrors.d.ts +0 -19
- package/errors/apiErrors.js +0 -179
- package/errors/fileSystemErrors.d.ts +0 -5
- package/errors/fileSystemErrors.js +0 -31
- package/errors/standardErrors.d.ts +0 -27
- package/errors/standardErrors.js +0 -59
- package/lang/lang/en.json +0 -401
- package/lib/logging/git.d.ts +0 -2
- package/lib/logging/git.js +0 -54
- package/lib/logging/logs.d.ts +0 -22
- package/lib/logging/logs.js +0 -86
- package/lib/logging/table.d.ts +0 -3
- package/lib/logging/table.js +0 -47
- package/lib/sandboxes.d.ts +0 -14
- package/lib/sandboxes.js +0 -71
- package/models/HubSpotAuthError.d.ts +0 -12
- package/models/HubSpotAuthError.js +0 -20
- package/types/LogCallbacks.d.ts +0 -7
- package/utils/getAccountIdentifier.d.ts +0 -10
- package/utils/getAccountIdentifier.js +0 -40
- package/utils/logger.d.ts +0 -5
- package/utils/logger.js +0 -23
- package/utils/objectUtils.d.ts +0 -8
- package/utils/objectUtils.js +0 -33
- /package/{utils → lib}/escapeRegExp.d.ts +0 -0
- /package/{utils → lib}/escapeRegExp.js +0 -0
- /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
- /package/lib/{logging/logger.js → logger.js} +0 -0
- /package/{utils → lib}/notify.d.ts +0 -0
- /package/types/{LogCallbacks.js → Apps.js} +0 -0
package/http/getAxiosConfig.js
CHANGED
|
@@ -1,21 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAxiosConfig = exports.
|
|
6
|
+
exports.getAxiosConfig = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
|
|
4
7
|
const package_json_1 = require("../package.json");
|
|
5
8
|
const config_1 = require("../config");
|
|
6
9
|
const urls_1 = require("../lib/urls");
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const https_1 = __importDefault(require("https"));
|
|
11
|
+
const http_1 = __importDefault(require("http"));
|
|
12
|
+
// Total number of sockets across all hosts
|
|
13
|
+
const MAX_TOTAL_SOCKETS = 25;
|
|
14
|
+
// Total number of sockets per each host
|
|
15
|
+
const MAX_SOCKETS_PER_HOST = 5;
|
|
16
|
+
const httpAgent = new http_1.default.Agent({
|
|
17
|
+
keepAlive: true,
|
|
18
|
+
maxTotalSockets: MAX_TOTAL_SOCKETS,
|
|
19
|
+
maxSockets: MAX_SOCKETS_PER_HOST,
|
|
20
|
+
});
|
|
21
|
+
const httpsAgent = new https_1.default.Agent({
|
|
22
|
+
keepAlive: true,
|
|
23
|
+
maxTotalSockets: MAX_TOTAL_SOCKETS,
|
|
24
|
+
maxSockets: MAX_SOCKETS_PER_HOST,
|
|
25
|
+
});
|
|
26
|
+
exports.USER_AGENTS = {
|
|
27
|
+
'HubSpot Local Dev Lib': package_json_1.version,
|
|
28
|
+
};
|
|
29
|
+
function getDefaultUserAgentHeader() {
|
|
30
|
+
let userAgentString = '';
|
|
31
|
+
Object.keys(exports.USER_AGENTS).forEach((userAgentKey, i) => {
|
|
32
|
+
userAgentString += `${i > 0 ? ', ' : ''}${userAgentKey}/${exports.USER_AGENTS[userAgentKey]}`;
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
'User-Agent': userAgentString,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.getDefaultUserAgentHeader = getDefaultUserAgentHeader;
|
|
39
|
+
const DEFAULT_TRANSITIONAL = {
|
|
40
|
+
clarifyTimeoutError: true,
|
|
9
41
|
};
|
|
10
42
|
function getAxiosConfig(options) {
|
|
11
|
-
const { env, localHostOverride, ...rest } = options;
|
|
12
|
-
|
|
43
|
+
const { env, localHostOverride, headers, ...rest } = options;
|
|
44
|
+
let config;
|
|
45
|
+
try {
|
|
46
|
+
config = (0, config_1.getConfig)();
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
config = null;
|
|
50
|
+
}
|
|
51
|
+
let httpTimeout = 15000;
|
|
52
|
+
let httpUseLocalhost = false;
|
|
53
|
+
if (config && config.httpTimeout) {
|
|
54
|
+
httpTimeout = config.httpTimeout;
|
|
55
|
+
}
|
|
56
|
+
if (config && config.httpUseLocalhost) {
|
|
57
|
+
httpUseLocalhost = config.httpUseLocalhost;
|
|
58
|
+
}
|
|
13
59
|
return {
|
|
14
60
|
baseURL: (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost),
|
|
15
61
|
headers: {
|
|
16
|
-
...
|
|
62
|
+
...getDefaultUserAgentHeader(),
|
|
63
|
+
...(headers || {}),
|
|
17
64
|
},
|
|
18
|
-
timeout: httpTimeout
|
|
65
|
+
timeout: httpTimeout,
|
|
66
|
+
transitional: DEFAULT_TRANSITIONAL,
|
|
67
|
+
httpAgent,
|
|
68
|
+
httpsAgent,
|
|
19
69
|
...rest,
|
|
20
70
|
};
|
|
21
71
|
}
|
package/http/index.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HttpOptions } from '../types/Http';
|
|
3
|
-
|
|
4
|
-
declare function getRequest<T>(accountId: number, options: HttpOptions):
|
|
5
|
-
declare function postRequest<T>(accountId: number, options: HttpOptions):
|
|
6
|
-
declare function putRequest<T>(accountId: number, options: HttpOptions):
|
|
7
|
-
declare function patchRequest<T>(accountId: number, options: HttpOptions):
|
|
8
|
-
declare function deleteRequest<T>(accountId: number, options: HttpOptions):
|
|
9
|
-
declare const
|
|
10
|
-
declare const http: {
|
|
1
|
+
import { AxiosPromise } from 'axios';
|
|
2
|
+
import { HttpOptions, HubSpotPromise } from '../types/Http';
|
|
3
|
+
export declare function addUserAgentHeader(key: string, value: string): void;
|
|
4
|
+
declare function getRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
|
|
5
|
+
declare function postRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
|
|
6
|
+
declare function putRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
|
|
7
|
+
declare function patchRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
|
|
8
|
+
declare function deleteRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
|
|
9
|
+
export declare const http: {
|
|
11
10
|
get: typeof getRequest;
|
|
12
11
|
post: typeof postRequest;
|
|
13
12
|
put: typeof putRequest;
|
|
14
13
|
patch: typeof patchRequest;
|
|
15
14
|
delete: typeof deleteRequest;
|
|
16
|
-
getOctetStream: (accountId: number, options: HttpOptions, destPath: string
|
|
15
|
+
getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => AxiosPromise<any>;
|
|
17
16
|
};
|
|
18
|
-
export
|
|
17
|
+
export {};
|
package/http/index.js
CHANGED
|
@@ -3,22 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.http = exports.addUserAgentHeader = void 0;
|
|
6
7
|
const path_1 = __importDefault(require("path"));
|
|
7
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
9
|
const content_disposition_1 = __importDefault(require("content-disposition"));
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
9
11
|
const config_1 = require("../config");
|
|
10
12
|
const getAxiosConfig_1 = require("./getAxiosConfig");
|
|
13
|
+
const addQueryParams_1 = require("./addQueryParams");
|
|
11
14
|
const personalAccessKey_1 = require("../lib/personalAccessKey");
|
|
12
15
|
const oauth_1 = require("../lib/oauth");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
+
const logger_1 = require("../lib/logger");
|
|
17
|
+
const lang_1 = require("../utils/lang");
|
|
18
|
+
const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
|
|
19
|
+
const auth_1 = require("../constants/auth");
|
|
16
20
|
const i18nKey = 'http.index';
|
|
17
|
-
|
|
21
|
+
axios_1.default.interceptors.response.use(undefined, error => {
|
|
22
|
+
// Wrap all axios errors in our own Error class. Attach the error
|
|
23
|
+
// as the cause for the new error, so we maintain the stack trace
|
|
24
|
+
return Promise.reject(new HubSpotHttpError_1.HubSpotHttpError(error.message, { cause: error }));
|
|
25
|
+
});
|
|
26
|
+
function addUserAgentHeader(key, value) {
|
|
27
|
+
getAxiosConfig_1.USER_AGENTS[key] = value;
|
|
28
|
+
}
|
|
29
|
+
exports.addUserAgentHeader = addUserAgentHeader;
|
|
30
|
+
async function withOauth(account, axiosConfig) {
|
|
18
31
|
const { headers } = axiosConfig;
|
|
19
|
-
const oauth = (0, oauth_1.getOauthManager)(
|
|
32
|
+
const oauth = (0, oauth_1.getOauthManager)(account);
|
|
20
33
|
if (!oauth) {
|
|
21
|
-
(0,
|
|
34
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.withOauth`, { accountId: account.accountId }));
|
|
22
35
|
}
|
|
23
36
|
const accessToken = await oauth.accessToken();
|
|
24
37
|
return {
|
|
@@ -51,70 +64,56 @@ function withPortalId(portalId, axiosConfig) {
|
|
|
51
64
|
};
|
|
52
65
|
}
|
|
53
66
|
async function withAuth(accountId, options) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
(0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.withAuth`, { accountId });
|
|
57
|
-
}
|
|
58
|
-
const { env, authType, apiKey } = accountConfig;
|
|
67
|
+
const account = (0, config_1.getConfigAccountById)(accountId);
|
|
68
|
+
const { env, authType } = account;
|
|
59
69
|
const axiosConfig = withPortalId(accountId, (0, getAxiosConfig_1.getAxiosConfig)({ env, ...options }));
|
|
60
|
-
if (authType ===
|
|
70
|
+
if (authType === auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
|
|
61
71
|
return withPersonalAccessKey(accountId, axiosConfig);
|
|
62
72
|
}
|
|
63
|
-
if (authType ===
|
|
64
|
-
return withOauth(
|
|
73
|
+
if (authType === auth_1.OAUTH_AUTH_METHOD.value) {
|
|
74
|
+
return withOauth(account, axiosConfig);
|
|
65
75
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...queryParams,
|
|
81
|
-
...params,
|
|
82
|
-
},
|
|
83
|
-
};
|
|
76
|
+
if (authType === auth_1.API_KEY_AUTH_METHOD.value) {
|
|
77
|
+
const { params } = axiosConfig;
|
|
78
|
+
return {
|
|
79
|
+
...axiosConfig,
|
|
80
|
+
params: {
|
|
81
|
+
...params,
|
|
82
|
+
hapikey: account.apiKey,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.invalidAuthType`, {
|
|
87
|
+
accountId,
|
|
88
|
+
authType,
|
|
89
|
+
}));
|
|
84
90
|
}
|
|
85
91
|
async function getRequest(accountId, options) {
|
|
86
|
-
const {
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
return data;
|
|
92
|
+
const { params, ...rest } = options;
|
|
93
|
+
const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
94
|
+
const requestConfig = await withAuth(accountId, optionsWithParams);
|
|
95
|
+
return (0, axios_1.default)(requestConfig);
|
|
91
96
|
}
|
|
92
97
|
async function postRequest(accountId, options) {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
return data;
|
|
98
|
+
const requestConfig = await withAuth(accountId, options);
|
|
99
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'post' });
|
|
96
100
|
}
|
|
97
101
|
async function putRequest(accountId, options) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
return data;
|
|
102
|
+
const requestConfig = await withAuth(accountId, options);
|
|
103
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'put' });
|
|
101
104
|
}
|
|
102
105
|
async function patchRequest(accountId, options) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
return data;
|
|
106
|
+
const requestConfig = await withAuth(accountId, options);
|
|
107
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'patch' });
|
|
106
108
|
}
|
|
107
109
|
async function deleteRequest(accountId, options) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
return data;
|
|
110
|
+
const requestConfig = await withAuth(accountId, options);
|
|
111
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'delete' });
|
|
111
112
|
}
|
|
112
|
-
const getRequestStreamCallbackKeys = ['onWrite'];
|
|
113
113
|
function createGetRequestStream(contentType) {
|
|
114
|
-
return async (accountId, options, destPath
|
|
115
|
-
const {
|
|
116
|
-
const axiosConfig = addQueryParams(rest,
|
|
117
|
-
const logger = (0, logger_1.makeTypedLogger)(logCallbacks);
|
|
114
|
+
return async (accountId, options, destPath) => {
|
|
115
|
+
const { params, ...rest } = options;
|
|
116
|
+
const axiosConfig = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
118
117
|
// eslint-disable-next-line no-async-promise-executor
|
|
119
118
|
return new Promise(async (resolve, reject) => {
|
|
120
119
|
try {
|
|
@@ -151,9 +150,9 @@ function createGetRequestStream(contentType) {
|
|
|
151
150
|
reject(err);
|
|
152
151
|
});
|
|
153
152
|
writeStream.on('close', async () => {
|
|
154
|
-
logger(
|
|
153
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.createGetRequestStream.onWrite`, {
|
|
155
154
|
filepath,
|
|
156
|
-
});
|
|
155
|
+
}));
|
|
157
156
|
resolve(res);
|
|
158
157
|
});
|
|
159
158
|
}
|
|
@@ -168,7 +167,7 @@ function createGetRequestStream(contentType) {
|
|
|
168
167
|
};
|
|
169
168
|
}
|
|
170
169
|
const getOctetStream = createGetRequestStream('application/octet-stream');
|
|
171
|
-
|
|
170
|
+
exports.http = {
|
|
172
171
|
get: getRequest,
|
|
173
172
|
post: postRequest,
|
|
174
173
|
put: putRequest,
|
|
@@ -176,4 +175,3 @@ const http = {
|
|
|
176
175
|
delete: deleteRequest,
|
|
177
176
|
getOctetStream,
|
|
178
177
|
};
|
|
179
|
-
exports.default = http;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpOptions, HubSpotPromise } from '../types/Http';
|
|
2
|
+
declare function getRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
3
|
+
declare function postRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
4
|
+
declare function putRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
5
|
+
declare function patchRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
6
|
+
declare function deleteRequest<T>(options: HttpOptions): HubSpotPromise<T>;
|
|
7
|
+
export declare const http: {
|
|
8
|
+
get: typeof getRequest;
|
|
9
|
+
post: typeof postRequest;
|
|
10
|
+
put: typeof putRequest;
|
|
11
|
+
patch: typeof patchRequest;
|
|
12
|
+
delete: typeof deleteRequest;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
package/http/unauthed.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.http = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const getAxiosConfig_1 = require("./getAxiosConfig");
|
|
9
|
+
const addQueryParams_1 = require("./addQueryParams");
|
|
10
|
+
async function getRequest(options) {
|
|
11
|
+
const { params, ...rest } = options;
|
|
12
|
+
const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
|
|
13
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(optionsWithParams);
|
|
14
|
+
return (0, axios_1.default)(requestConfig);
|
|
15
|
+
}
|
|
16
|
+
async function postRequest(options) {
|
|
17
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
18
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'post' });
|
|
19
|
+
}
|
|
20
|
+
async function putRequest(options) {
|
|
21
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
22
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'put' });
|
|
23
|
+
}
|
|
24
|
+
async function patchRequest(options) {
|
|
25
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
26
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'patch' });
|
|
27
|
+
}
|
|
28
|
+
async function deleteRequest(options) {
|
|
29
|
+
const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
|
|
30
|
+
return (0, axios_1.default)({ ...requestConfig, method: 'delete' });
|
|
31
|
+
}
|
|
32
|
+
exports.http = {
|
|
33
|
+
get: getRequest,
|
|
34
|
+
post: postRequest,
|
|
35
|
+
put: putRequest,
|
|
36
|
+
patch: patchRequest,
|
|
37
|
+
delete: deleteRequest,
|
|
38
|
+
};
|