@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.
Files changed (195) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +17 -0
  3. package/api/appsDev.d.ts +6 -0
  4. package/api/appsDev.js +29 -0
  5. package/api/customObjects.d.ts +8 -7
  6. package/api/customObjects.js +13 -16
  7. package/api/designManager.d.ts +4 -13
  8. package/api/designManager.js +6 -9
  9. package/api/developerTestAccounts.d.ts +7 -0
  10. package/api/developerTestAccounts.js +48 -0
  11. package/api/fileManager.d.ts +5 -4
  12. package/api/fileManager.js +11 -11
  13. package/api/fileMapper.d.ts +8 -7
  14. package/api/fileMapper.js +17 -17
  15. package/api/fileTransport.d.ts +4 -0
  16. package/api/fileTransport.js +39 -0
  17. package/api/functions.d.ts +7 -4
  18. package/api/functions.js +22 -11
  19. package/api/github.d.ts +8 -9
  20. package/api/github.js +31 -13
  21. package/api/hubdb.d.ts +11 -10
  22. package/api/hubdb.js +28 -22
  23. package/api/lighthouseScore.d.ts +4 -4
  24. package/api/lighthouseScore.js +9 -12
  25. package/api/localDevAuth.d.ts +8 -15
  26. package/api/localDevAuth.js +34 -13
  27. package/api/marketplaceValidation.d.ts +4 -4
  28. package/api/marketplaceValidation.js +8 -11
  29. package/api/projects.d.ts +32 -24
  30. package/api/projects.js +164 -44
  31. package/api/sandboxHubs.d.ts +6 -4
  32. package/api/sandboxHubs.js +10 -11
  33. package/api/sandboxSync.d.ts +4 -4
  34. package/api/sandboxSync.js +4 -13
  35. package/api/secrets.d.ts +6 -8
  36. package/api/secrets.js +9 -12
  37. package/api/validateHubl.d.ts +2 -1
  38. package/api/validateHubl.js +3 -6
  39. package/config/defaultAccountOverride.d.ts +2 -0
  40. package/config/defaultAccountOverride.js +57 -0
  41. package/config/index.d.ts +26 -37
  42. package/config/index.js +253 -201
  43. package/config/utils.d.ts +70 -0
  44. package/config/utils.js +328 -0
  45. package/constants/config.d.ts +42 -1
  46. package/constants/config.js +44 -3
  47. package/constants/environments.d.ts +0 -10
  48. package/constants/environments.js +1 -11
  49. package/constants/extensions.d.ts +2 -0
  50. package/constants/extensions.js +3 -1
  51. package/constants/files.d.ts +2 -2
  52. package/constants/files.js +3 -3
  53. package/errors/errors_DEPRECATED.d.ts +1 -5
  54. package/errors/errors_DEPRECATED.js +2 -2
  55. package/errors/index.d.ts +18 -0
  56. package/errors/index.js +63 -0
  57. package/http/addQueryParams.d.ts +2 -0
  58. package/http/addQueryParams.js +14 -0
  59. package/http/getAxiosConfig.d.ts +6 -3
  60. package/http/getAxiosConfig.js +57 -7
  61. package/http/index.d.ts +11 -12
  62. package/http/index.js +56 -58
  63. package/http/unauthed.d.ts +14 -0
  64. package/http/unauthed.js +38 -0
  65. package/lang/en.json +370 -386
  66. package/lib/archive.d.ts +3 -8
  67. package/lib/archive.js +34 -30
  68. package/lib/cms/functions.d.ts +7 -12
  69. package/lib/cms/functions.js +49 -51
  70. package/lib/cms/handleFieldsJS.js +16 -14
  71. package/lib/cms/modules.d.ts +4 -15
  72. package/lib/cms/modules.js +81 -78
  73. package/lib/cms/processFieldsJs.js +10 -33
  74. package/lib/cms/templates.d.ts +43 -3
  75. package/lib/cms/templates.js +53 -11
  76. package/lib/cms/themes.js +3 -1
  77. package/lib/cms/uploadFolder.d.ts +3 -14
  78. package/lib/cms/uploadFolder.js +58 -42
  79. package/lib/cms/validate.js +1 -1
  80. package/lib/cms/watch.d.ts +2 -18
  81. package/lib/cms/watch.js +63 -68
  82. package/lib/customObjects.js +4 -15
  83. package/lib/environment.d.ts +1 -1
  84. package/lib/fileManager.d.ts +2 -6
  85. package/lib/fileManager.js +54 -65
  86. package/lib/fileMapper.d.ts +4 -15
  87. package/lib/fileMapper.js +67 -88
  88. package/lib/fs.d.ts +1 -1
  89. package/lib/fs.js +10 -6
  90. package/lib/github.d.ts +13 -14
  91. package/lib/github.js +70 -35
  92. package/lib/gitignore.d.ts +2 -0
  93. package/lib/gitignore.js +21 -4
  94. package/lib/hubdb.d.ts +3 -2
  95. package/lib/hubdb.js +11 -9
  96. package/{utils → lib}/notify.js +2 -2
  97. package/lib/oauth.d.ts +4 -7
  98. package/lib/oauth.js +14 -33
  99. package/lib/path.d.ts +3 -0
  100. package/lib/path.js +46 -1
  101. package/lib/personalAccessKey.d.ts +9 -11
  102. package/lib/personalAccessKey.js +108 -68
  103. package/lib/portManager.d.ts +3 -5
  104. package/lib/portManager.js +18 -6
  105. package/lib/text.d.ts +1 -0
  106. package/lib/text.js +9 -1
  107. package/lib/trackUsage.js +24 -14
  108. package/lib/urls.js +5 -1
  109. package/models/FileSystemError.d.ts +6 -0
  110. package/models/FileSystemError.js +47 -0
  111. package/models/HubSpotHttpError.d.ts +24 -0
  112. package/models/HubSpotHttpError.js +197 -0
  113. package/models/OAuth2Manager.d.ts +5 -28
  114. package/models/OAuth2Manager.js +34 -66
  115. package/package.json +34 -35
  116. package/types/Accounts.d.ts +82 -71
  117. package/types/Apps.d.ts +77 -0
  118. package/types/Archive.d.ts +9 -0
  119. package/types/Archive.js +2 -0
  120. package/types/Build.d.ts +4 -2
  121. package/types/ComponentStructure.d.ts +30 -10
  122. package/types/Config.d.ts +19 -15
  123. package/types/Deploy.d.ts +3 -2
  124. package/types/DesignManager.d.ts +10 -0
  125. package/types/DesignManager.js +2 -0
  126. package/types/Error.d.ts +9 -5
  127. package/types/FieldsJS.d.ts +1 -0
  128. package/types/FieldsJS.js +2 -0
  129. package/types/FileManager.d.ts +1 -1
  130. package/types/Files.d.ts +43 -4
  131. package/types/Functions.d.ts +52 -0
  132. package/types/Github.d.ts +13 -0
  133. package/types/Http.d.ts +13 -11
  134. package/types/Hubdb.d.ts +9 -0
  135. package/types/MarketplaceValidation.d.ts +7 -3
  136. package/types/Migration.d.ts +28 -0
  137. package/types/Migration.js +10 -0
  138. package/types/Modules.d.ts +11 -0
  139. package/types/PortManager.d.ts +7 -0
  140. package/types/Project.d.ts +30 -0
  141. package/types/ProjectLog.d.ts +9 -0
  142. package/types/ProjectLog.js +2 -0
  143. package/types/Sandbox.d.ts +37 -47
  144. package/types/Schemas.d.ts +56 -0
  145. package/types/Secrets.d.ts +3 -0
  146. package/types/Secrets.js +2 -0
  147. package/types/developerTestAccounts.d.ts +13 -0
  148. package/types/developerTestAccounts.js +2 -0
  149. package/utils/PortManagerServer.d.ts +6 -7
  150. package/utils/PortManagerServer.js +22 -16
  151. package/utils/cms/fieldsJS.d.ts +1 -2
  152. package/utils/cms/modules.js +2 -2
  153. package/utils/detectPort.js +3 -3
  154. package/utils/git.d.ts +1 -7
  155. package/utils/git.js +2 -18
  156. package/config/CLIConfiguration.d.ts +0 -61
  157. package/config/CLIConfiguration.js +0 -424
  158. package/config/configFile.d.ts +0 -21
  159. package/config/configFile.js +0 -108
  160. package/config/configUtils.d.ts +0 -24
  161. package/config/configUtils.js +0 -86
  162. package/config/config_DEPRECATED.d.ts +0 -78
  163. package/config/config_DEPRECATED.js +0 -639
  164. package/config/environment.d.ts +0 -2
  165. package/config/environment.js +0 -59
  166. package/errors/apiErrors.d.ts +0 -19
  167. package/errors/apiErrors.js +0 -179
  168. package/errors/fileSystemErrors.d.ts +0 -5
  169. package/errors/fileSystemErrors.js +0 -31
  170. package/errors/standardErrors.d.ts +0 -27
  171. package/errors/standardErrors.js +0 -59
  172. package/lang/lang/en.json +0 -401
  173. package/lib/logging/git.d.ts +0 -2
  174. package/lib/logging/git.js +0 -54
  175. package/lib/logging/logs.d.ts +0 -22
  176. package/lib/logging/logs.js +0 -86
  177. package/lib/logging/table.d.ts +0 -3
  178. package/lib/logging/table.js +0 -47
  179. package/lib/sandboxes.d.ts +0 -14
  180. package/lib/sandboxes.js +0 -71
  181. package/models/HubSpotAuthError.d.ts +0 -12
  182. package/models/HubSpotAuthError.js +0 -20
  183. package/types/LogCallbacks.d.ts +0 -7
  184. package/utils/getAccountIdentifier.d.ts +0 -10
  185. package/utils/getAccountIdentifier.js +0 -40
  186. package/utils/logger.d.ts +0 -5
  187. package/utils/logger.js +0 -23
  188. package/utils/objectUtils.d.ts +0 -8
  189. package/utils/objectUtils.js +0 -33
  190. /package/{utils → lib}/escapeRegExp.d.ts +0 -0
  191. /package/{utils → lib}/escapeRegExp.js +0 -0
  192. /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
  193. /package/lib/{logging/logger.js → logger.js} +0 -0
  194. /package/{utils → lib}/notify.d.ts +0 -0
  195. /package/types/{LogCallbacks.js → Apps.js} +0 -0
@@ -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.DEFAULT_USER_AGENT_HEADERS = void 0;
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
- exports.DEFAULT_USER_AGENT_HEADERS = {
8
- 'User-Agent': `HubSpot Local Dev Lib/${package_json_1.version}`,
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
- const { httpTimeout, httpUseLocalhost } = (0, config_1.getAndLoadConfigIfNeeded)();
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
- ...exports.DEFAULT_USER_AGENT_HEADERS,
62
+ ...getDefaultUserAgentHeader(),
63
+ ...(headers || {}),
17
64
  },
18
- timeout: httpTimeout || 15000,
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 { LogCallbacksArg } from '../types/LogCallbacks';
2
- import { HttpOptions } from '../types/Http';
3
- import { AxiosResponse } from 'axios';
4
- declare function getRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
5
- declare function postRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
6
- declare function putRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
7
- declare function patchRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
8
- declare function deleteRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
9
- declare const getRequestStreamCallbackKeys: readonly ["onWrite"];
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, logCallbacks?: LogCallbacksArg<typeof getRequestStreamCallbackKeys>) => Promise<AxiosResponse>;
15
+ getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => AxiosPromise<any>;
17
16
  };
18
- export default http;
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 standardErrors_1 = require("../errors/standardErrors");
14
- const logger_1 = require("../utils/logger");
15
- const axios_1 = __importDefault(require("axios"));
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
- async function withOauth(accountId, accountConfig, axiosConfig) {
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)(accountId, accountConfig);
32
+ const oauth = (0, oauth_1.getOauthManager)(account);
20
33
  if (!oauth) {
21
- (0, standardErrors_1.throwErrorWithMessage)(`${i18nKey}.errors.withOauth`, { accountId });
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 accountConfig = (0, config_1.getAccountConfig)(accountId);
55
- if (!accountConfig) {
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 === 'personalaccesskey') {
70
+ if (authType === auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
61
71
  return withPersonalAccessKey(accountId, axiosConfig);
62
72
  }
63
- if (authType === 'oauth2') {
64
- return withOauth(accountId, accountConfig, axiosConfig);
73
+ if (authType === auth_1.OAUTH_AUTH_METHOD.value) {
74
+ return withOauth(account, axiosConfig);
65
75
  }
66
- const { params } = axiosConfig;
67
- return {
68
- ...axiosConfig,
69
- params: {
70
- ...params,
71
- hapikey: apiKey,
72
- },
73
- };
74
- }
75
- function addQueryParams(configOptions, queryParams = {}) {
76
- const { params } = configOptions;
77
- return {
78
- ...configOptions,
79
- params: {
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 { query, ...rest } = options;
87
- const axiosConfig = addQueryParams(rest, query);
88
- const configWithAuth = await withAuth(accountId, axiosConfig);
89
- const { data } = await (0, axios_1.default)(configWithAuth);
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 configWithAuth = await withAuth(accountId, options);
94
- const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'post' });
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 configWithAuth = await withAuth(accountId, options);
99
- const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'put' });
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 configWithAuth = await withAuth(accountId, options);
104
- const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'put' });
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 configWithAuth = await withAuth(accountId, options);
109
- const { data } = await (0, axios_1.default)({ ...configWithAuth, method: 'delete' });
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, logCallbacks) => {
115
- const { query, ...rest } = options;
116
- const axiosConfig = addQueryParams(rest, query);
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('onWrite', `${i18nKey}.createGetRequestStream.onWrite`, {
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
- const http = {
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 {};
@@ -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
+ };