@hubspot/local-dev-lib 4.0.4 → 5.0.0-beta.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 (205) hide show
  1. package/api/appsDev.d.ts +2 -2
  2. package/api/appsDev.js +13 -22
  3. package/api/crm.d.ts +2 -2
  4. package/api/crm.js +9 -16
  5. package/api/customObjects.d.ts +2 -2
  6. package/api/customObjects.js +13 -22
  7. package/api/designManager.d.ts +2 -2
  8. package/api/designManager.js +5 -10
  9. package/api/devSecrets.d.ts +2 -2
  10. package/api/devSecrets.js +9 -16
  11. package/api/developerTestAccounts.d.ts +2 -4
  12. package/api/developerTestAccounts.js +23 -52
  13. package/api/fileManager.d.ts +2 -2
  14. package/api/fileManager.js +14 -24
  15. package/api/fileMapper.d.ts +2 -3
  16. package/api/fileMapper.js +34 -49
  17. package/api/fileTransport.d.ts +1 -1
  18. package/api/fileTransport.js +12 -21
  19. package/api/fireAlarm.d.ts +2 -3
  20. package/api/fireAlarm.js +5 -9
  21. package/api/functions.d.ts +2 -2
  22. package/api/functions.js +11 -19
  23. package/api/github.d.ts +2 -4
  24. package/api/github.js +16 -27
  25. package/api/hubdb.d.ts +2 -2
  26. package/api/hubdb.js +19 -31
  27. package/api/lighthouseScore.d.ts +2 -2
  28. package/api/lighthouseScore.js +7 -13
  29. package/api/localDevAuth.d.ts +3 -6
  30. package/api/localDevAuth.js +10 -37
  31. package/api/marketplaceValidation.d.ts +2 -2
  32. package/api/marketplaceValidation.js +7 -13
  33. package/api/projects.d.ts +6 -8
  34. package/api/projects.js +65 -100
  35. package/api/sandboxHubs.d.ts +2 -5
  36. package/api/sandboxHubs.js +15 -42
  37. package/api/sandboxSync.d.ts +2 -2
  38. package/api/sandboxSync.js +7 -12
  39. package/api/secrets.d.ts +2 -2
  40. package/api/secrets.js +9 -16
  41. package/api/validateHubl.d.ts +2 -2
  42. package/api/validateHubl.js +3 -7
  43. package/config/defaultAccountOverride.d.ts +2 -1
  44. package/config/defaultAccountOverride.js +16 -26
  45. package/config/index.d.ts +4 -4
  46. package/config/index.js +141 -177
  47. package/config/migrate.d.ts +2 -2
  48. package/config/migrate.js +26 -37
  49. package/config/state.d.ts +1 -1
  50. package/config/state.js +17 -45
  51. package/config/utils.d.ts +4 -4
  52. package/config/utils.js +85 -108
  53. package/constants/api.js +3 -6
  54. package/constants/auth.js +9 -12
  55. package/constants/config.js +37 -43
  56. package/constants/endpoints.d.ts +6 -0
  57. package/constants/endpoints.js +6 -0
  58. package/constants/environments.js +1 -4
  59. package/constants/extensions.js +6 -9
  60. package/constants/files.js +5 -8
  61. package/constants/ports.js +3 -6
  62. package/constants/projects.js +2 -5
  63. package/enums/build.d.ts +1 -0
  64. package/enums/build.js +6 -8
  65. package/enums/deploy.js +2 -5
  66. package/enums/project.js +1 -4
  67. package/errors/index.d.ts +4 -5
  68. package/errors/index.js +17 -39
  69. package/errors/isSystemError.d.ts +2 -0
  70. package/errors/isSystemError.js +9 -0
  71. package/http/addQueryParams.d.ts +1 -1
  72. package/http/addQueryParams.js +1 -5
  73. package/http/client.js +14 -42
  74. package/http/getAxiosConfig.d.ts +1 -1
  75. package/http/getAxiosConfig.js +21 -31
  76. package/http/index.d.ts +2 -2
  77. package/http/index.js +39 -46
  78. package/http/unauthed.d.ts +1 -1
  79. package/http/unauthed.js +15 -18
  80. package/lang/en.json +1 -1
  81. package/lib/archive.d.ts +1 -3
  82. package/lib/archive.js +37 -67
  83. package/lib/cms/functions.d.ts +1 -1
  84. package/lib/cms/functions.js +45 -55
  85. package/lib/cms/handleFieldsJS.js +36 -44
  86. package/lib/cms/modules.d.ts +2 -2
  87. package/lib/cms/modules.js +49 -59
  88. package/lib/cms/processFieldsJs.js +17 -32
  89. package/lib/cms/templates.js +17 -26
  90. package/lib/cms/themes.js +10 -18
  91. package/lib/cms/uploadFolder.d.ts +4 -4
  92. package/lib/cms/uploadFolder.js +55 -64
  93. package/lib/cms/validate.d.ts +1 -1
  94. package/lib/cms/validate.js +11 -18
  95. package/lib/cms/watch.d.ts +2 -2
  96. package/lib/cms/watch.js +66 -73
  97. package/lib/crm.d.ts +1 -1
  98. package/lib/crm.js +15 -23
  99. package/lib/customObjects.d.ts +1 -1
  100. package/lib/customObjects.js +15 -25
  101. package/lib/environment.d.ts +1 -1
  102. package/lib/environment.js +5 -11
  103. package/lib/escapeRegExp.js +1 -5
  104. package/lib/fileManager.js +43 -51
  105. package/lib/fileMapper.d.ts +1 -1
  106. package/lib/fileMapper.js +68 -84
  107. package/lib/fs.d.ts +1 -1
  108. package/lib/fs.js +18 -27
  109. package/lib/github.d.ts +1 -3
  110. package/lib/github.js +39 -51
  111. package/lib/gitignore.d.ts +1 -1
  112. package/lib/gitignore.js +16 -24
  113. package/lib/hubdb.d.ts +1 -1
  114. package/lib/hubdb.js +29 -40
  115. package/lib/ignoreRules.js +25 -34
  116. package/lib/isDeepEqual.js +1 -5
  117. package/lib/logger.d.ts +8 -20
  118. package/lib/logger.js +47 -59
  119. package/lib/notify.js +9 -16
  120. package/lib/oauth.d.ts +2 -2
  121. package/lib/oauth.js +12 -17
  122. package/lib/path.d.ts +0 -1
  123. package/lib/path.js +30 -48
  124. package/lib/personalAccessKey.d.ts +2 -4
  125. package/lib/personalAccessKey.js +43 -60
  126. package/lib/portManager.d.ts +2 -2
  127. package/lib/portManager.js +26 -41
  128. package/lib/text.js +2 -7
  129. package/lib/trackUsage.d.ts +0 -2
  130. package/lib/trackUsage.js +23 -29
  131. package/lib/urls.js +4 -9
  132. package/models/FileSystemError.d.ts +1 -1
  133. package/models/FileSystemError.js +12 -16
  134. package/models/HubSpotConfigError.d.ts +1 -1
  135. package/models/HubSpotConfigError.js +8 -12
  136. package/models/HubSpotHttpError.d.ts +1 -1
  137. package/models/HubSpotHttpError.js +22 -26
  138. package/models/OAuth2Manager.d.ts +1 -1
  139. package/models/OAuth2Manager.js +17 -24
  140. package/package.json +20 -16
  141. package/types/Accounts.d.ts +6 -5
  142. package/types/Accounts.js +1 -2
  143. package/types/Activity.d.ts +3 -3
  144. package/types/Activity.js +1 -2
  145. package/types/Api.d.ts +1 -1
  146. package/types/Api.js +1 -2
  147. package/types/Apps.js +1 -2
  148. package/types/Archive.js +1 -2
  149. package/types/Build.d.ts +4 -5
  150. package/types/Build.js +1 -2
  151. package/types/CLIOptions.js +1 -2
  152. package/types/ComponentStructure.d.ts +2 -2
  153. package/types/ComponentStructure.js +1 -2
  154. package/types/Config.d.ts +4 -6
  155. package/types/Config.js +1 -2
  156. package/types/Crm.js +1 -2
  157. package/types/Deploy.d.ts +5 -11
  158. package/types/Deploy.js +1 -2
  159. package/types/DesignManager.js +1 -2
  160. package/types/DevSecrets.js +1 -2
  161. package/types/Error.js +1 -2
  162. package/types/FieldsJS.js +1 -2
  163. package/types/FileManager.js +1 -2
  164. package/types/Files.d.ts +4 -4
  165. package/types/Files.js +1 -2
  166. package/types/FireAlarm.js +1 -2
  167. package/types/Functions.js +1 -2
  168. package/types/Github.d.ts +1 -1
  169. package/types/Github.js +1 -2
  170. package/types/Http.d.ts +0 -4
  171. package/types/Http.js +1 -2
  172. package/types/Hubdb.js +1 -2
  173. package/types/HublValidation.js +1 -2
  174. package/types/Lang.d.ts +1 -1
  175. package/types/Lang.js +1 -2
  176. package/types/Lighthouse.js +1 -2
  177. package/types/MarketplaceValidation.js +1 -2
  178. package/types/Migration.d.ts +2 -2
  179. package/types/Migration.js +1 -4
  180. package/types/Modules.js +1 -2
  181. package/types/PortManager.js +1 -2
  182. package/types/Project.d.ts +3 -21
  183. package/types/Project.js +1 -2
  184. package/types/ProjectComponents.d.ts +24 -0
  185. package/types/ProjectComponents.js +1 -0
  186. package/types/ProjectLog.js +1 -2
  187. package/types/Sandbox.js +2 -5
  188. package/types/Schemas.js +1 -2
  189. package/types/Secrets.js +1 -2
  190. package/types/Utils.js +1 -2
  191. package/types/developerTestAccounts.js +1 -2
  192. package/utils/PortManagerServer.d.ts +1 -2
  193. package/utils/PortManagerServer.js +32 -38
  194. package/utils/cms/fieldsJS.d.ts +1 -1
  195. package/utils/cms/fieldsJS.js +1 -5
  196. package/utils/cms/modules.d.ts +1 -1
  197. package/utils/cms/modules.js +13 -22
  198. package/utils/detectPort.js +12 -19
  199. package/utils/git.js +17 -26
  200. package/utils/lang.d.ts +1 -1
  201. package/utils/lang.js +5 -14
  202. package/utils/personalAccessKey.d.ts +8 -0
  203. package/utils/personalAccessKey.js +51 -0
  204. package/errors/errors_DEPRECATED.d.ts +0 -3
  205. package/errors/errors_DEPRECATED.js +0 -60
@@ -1,26 +1,20 @@
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.getAxiosConfig = exports.shouldUseProxy = exports.hostnameMatchesNoProxyPattern = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
7
- const package_json_1 = require("../package.json");
8
- const config_1 = require("../config");
9
- const urls_1 = require("../lib/urls");
10
- const http_1 = __importDefault(require("http"));
11
- const https_1 = __importDefault(require("https"));
12
- const http_proxy_agent_1 = require("http-proxy-agent");
13
- const https_proxy_agent_1 = require("https-proxy-agent");
1
+ import pkg from '../package.json' with { type: 'json' };
2
+ import { getConfig } from '../config/index.js';
3
+ import { getHubSpotApiOrigin } from '../lib/urls.js';
4
+ import http from 'http';
5
+ import https from 'https';
6
+ import { HttpProxyAgent } from 'http-proxy-agent';
7
+ import { HttpsProxyAgent } from 'https-proxy-agent';
14
8
  // Total number of sockets across all hosts
15
9
  const MAX_TOTAL_SOCKETS = 25;
16
10
  // Total number of sockets per each host
17
11
  const MAX_SOCKETS_PER_HOST = 5;
18
- const httpAgent = new http_1.default.Agent({
12
+ const httpAgent = new http.Agent({
19
13
  keepAlive: true,
20
14
  maxTotalSockets: MAX_TOTAL_SOCKETS,
21
15
  maxSockets: MAX_SOCKETS_PER_HOST,
22
16
  });
23
- const httpsAgent = new https_1.default.Agent({
17
+ const httpsAgent = new https.Agent({
24
18
  keepAlive: true,
25
19
  maxTotalSockets: MAX_TOTAL_SOCKETS,
26
20
  maxSockets: MAX_SOCKETS_PER_HOST,
@@ -39,7 +33,7 @@ function getHttpProxyAgent() {
39
33
  if (!proxyUrl) {
40
34
  return httpAgent;
41
35
  }
42
- return new http_proxy_agent_1.HttpProxyAgent(proxyUrl, {
36
+ return new HttpProxyAgent(proxyUrl, {
43
37
  keepAlive: true,
44
38
  maxTotalSockets: MAX_TOTAL_SOCKETS,
45
39
  maxSockets: MAX_SOCKETS_PER_HOST,
@@ -52,29 +46,28 @@ function getHttpsProxyAgent() {
52
46
  if (!proxyUrl) {
53
47
  return httpsAgent;
54
48
  }
55
- return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, {
49
+ return new HttpsProxyAgent(proxyUrl, {
56
50
  keepAlive: true,
57
51
  maxTotalSockets: MAX_TOTAL_SOCKETS,
58
52
  maxSockets: MAX_SOCKETS_PER_HOST,
59
53
  });
60
54
  }
61
- exports.USER_AGENTS = {
62
- 'HubSpot Local Dev Lib': package_json_1.version,
55
+ export const USER_AGENTS = {
56
+ 'HubSpot Local Dev Lib': pkg.version,
63
57
  };
64
- function getDefaultUserAgentHeader() {
58
+ export function getDefaultUserAgentHeader() {
65
59
  let userAgentString = '';
66
- Object.keys(exports.USER_AGENTS).forEach((userAgentKey, i) => {
67
- userAgentString += `${i > 0 ? ', ' : ''}${userAgentKey}/${exports.USER_AGENTS[userAgentKey]}`;
60
+ Object.keys(USER_AGENTS).forEach((userAgentKey, i) => {
61
+ userAgentString += `${i > 0 ? ', ' : ''}${userAgentKey}/${USER_AGENTS[userAgentKey]}`;
68
62
  });
69
63
  return {
70
64
  'User-Agent': userAgentString,
71
65
  };
72
66
  }
73
- exports.getDefaultUserAgentHeader = getDefaultUserAgentHeader;
74
67
  const DEFAULT_TRANSITIONAL = {
75
68
  clarifyTimeoutError: true,
76
69
  };
77
- function hostnameMatchesNoProxyPattern(hostname, pattern) {
70
+ export function hostnameMatchesNoProxyPattern(hostname, pattern) {
78
71
  const hostnameNormalized = hostname.toLowerCase();
79
72
  const patternNormalized = pattern.trim().toLowerCase();
80
73
  if (patternNormalized === '*') {
@@ -87,8 +80,7 @@ function hostnameMatchesNoProxyPattern(hostname, pattern) {
87
80
  hostnameNormalized.endsWith(`.${patternNormalized}`) // domain suffix match (e.g. "api.hubapi.com" matches ".hubapi.com")
88
81
  );
89
82
  }
90
- exports.hostnameMatchesNoProxyPattern = hostnameMatchesNoProxyPattern;
91
- function shouldUseProxy(baseURL) {
83
+ export function shouldUseProxy(baseURL) {
92
84
  if (!getHttpProxyEnvVariable() &&
93
85
  !getHttpsProxyEnvVariable() &&
94
86
  !getAllProxyEnvVariable()) {
@@ -104,12 +96,11 @@ function shouldUseProxy(baseURL) {
104
96
  }
105
97
  return true;
106
98
  }
107
- exports.shouldUseProxy = shouldUseProxy;
108
- function getAxiosConfig(options) {
99
+ export function getAxiosConfig(options) {
109
100
  const { env, localHostOverride, headers, ...rest } = options;
110
101
  let config;
111
102
  try {
112
- config = (0, config_1.getConfig)();
103
+ config = getConfig();
113
104
  }
114
105
  catch (e) {
115
106
  config = null;
@@ -122,7 +113,7 @@ function getAxiosConfig(options) {
122
113
  if (config && config.httpUseLocalhost) {
123
114
  httpUseLocalhost = config.httpUseLocalhost;
124
115
  }
125
- const baseURL = (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost);
116
+ const baseURL = getHubSpotApiOrigin(env, localHostOverride ? false : httpUseLocalhost);
126
117
  return {
127
118
  baseURL,
128
119
  headers: {
@@ -138,4 +129,3 @@ function getAxiosConfig(options) {
138
129
  ...rest,
139
130
  };
140
131
  }
141
- exports.getAxiosConfig = getAxiosConfig;
package/http/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosPromise } from 'axios';
2
- import { HttpOptions, HubSpotPromise } from '../types/Http';
2
+ import { HttpOptions, HubSpotPromise } from '../types/Http.js';
3
3
  export declare function addUserAgentHeader(key: string, value: string): void;
4
4
  declare function getRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
5
5
  declare function postRequest<T>(accountId: number, options: HttpOptions): HubSpotPromise<T>;
@@ -12,6 +12,6 @@ export declare const http: {
12
12
  put: typeof putRequest;
13
13
  patch: typeof patchRequest;
14
14
  delete: typeof deleteRequest;
15
- getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => AxiosPromise<any>;
15
+ getOctetStream: (accountId: number, options: HttpOptions, destPath: string) => AxiosPromise;
16
16
  };
17
17
  export {};
package/http/index.js CHANGED
@@ -1,31 +1,24 @@
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 = exports.addUserAgentHeader = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const content_disposition_1 = __importDefault(require("content-disposition"));
10
- const config_1 = require("../config");
11
- const getAxiosConfig_1 = require("./getAxiosConfig");
12
- const addQueryParams_1 = require("./addQueryParams");
13
- const personalAccessKey_1 = require("../lib/personalAccessKey");
14
- const oauth_1 = require("../lib/oauth");
15
- const logger_1 = require("../lib/logger");
16
- const lang_1 = require("../utils/lang");
17
- const auth_1 = require("../constants/auth");
18
- const client_1 = require("./client");
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import contentDisposition from 'content-disposition';
4
+ import { getConfigAccountById } from '../config/index.js';
5
+ import { USER_AGENTS, getAxiosConfig } from './getAxiosConfig.js';
6
+ import { addQueryParams } from './addQueryParams.js';
7
+ import { accessTokenForPersonalAccessKey } from '../lib/personalAccessKey.js';
8
+ import { getOauthManager } from '../lib/oauth.js';
9
+ import { logger } from '../lib/logger.js';
10
+ import { i18n } from '../utils/lang.js';
11
+ import { PERSONAL_ACCESS_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, API_KEY_AUTH_METHOD, } from '../constants/auth.js';
12
+ import { httpClient } from './client.js';
19
13
  const i18nKey = 'http.index';
20
- function addUserAgentHeader(key, value) {
21
- getAxiosConfig_1.USER_AGENTS[key] = value;
14
+ export function addUserAgentHeader(key, value) {
15
+ USER_AGENTS[key] = value;
22
16
  }
23
- exports.addUserAgentHeader = addUserAgentHeader;
24
17
  async function withOauth(account, axiosConfig) {
25
18
  const { headers } = axiosConfig;
26
- const oauth = (0, oauth_1.getOauthManager)(account);
19
+ const oauth = getOauthManager(account);
27
20
  if (!oauth) {
28
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.withOauth`, { accountId: account.accountId }));
21
+ throw new Error(i18n(`${i18nKey}.errors.withOauth`, { accountId: account.accountId }));
29
22
  }
30
23
  const accessToken = await oauth.accessToken();
31
24
  return {
@@ -38,7 +31,7 @@ async function withOauth(account, axiosConfig) {
38
31
  }
39
32
  async function withPersonalAccessKey(accountId, axiosConfig) {
40
33
  const { headers } = axiosConfig;
41
- const accessToken = await (0, personalAccessKey_1.accessTokenForPersonalAccessKey)(accountId);
34
+ const accessToken = await accessTokenForPersonalAccessKey(accountId);
42
35
  return {
43
36
  ...axiosConfig,
44
37
  headers: {
@@ -58,16 +51,16 @@ function withPortalId(portalId, axiosConfig) {
58
51
  };
59
52
  }
60
53
  async function withAuth(accountId, options) {
61
- const account = (0, config_1.getConfigAccountById)(accountId);
54
+ const account = getConfigAccountById(accountId);
62
55
  const { env, authType } = account;
63
- const axiosConfig = withPortalId(accountId, (0, getAxiosConfig_1.getAxiosConfig)({ env, ...options }));
64
- if (authType === auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
56
+ const axiosConfig = withPortalId(accountId, getAxiosConfig({ env, ...options }));
57
+ if (authType === PERSONAL_ACCESS_KEY_AUTH_METHOD.value) {
65
58
  return withPersonalAccessKey(accountId, axiosConfig);
66
59
  }
67
- if (authType === auth_1.OAUTH_AUTH_METHOD.value) {
60
+ if (authType === OAUTH_AUTH_METHOD.value) {
68
61
  return withOauth(account, axiosConfig);
69
62
  }
70
- if (authType === auth_1.API_KEY_AUTH_METHOD.value) {
63
+ if (authType === API_KEY_AUTH_METHOD.value) {
71
64
  const { params } = axiosConfig;
72
65
  return {
73
66
  ...axiosConfig,
@@ -77,42 +70,42 @@ async function withAuth(accountId, options) {
77
70
  },
78
71
  };
79
72
  }
80
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.invalidAuthType`, {
73
+ throw new Error(i18n(`${i18nKey}.errors.invalidAuthType`, {
81
74
  accountId,
82
75
  authType,
83
76
  }));
84
77
  }
85
78
  async function getRequest(accountId, options) {
86
79
  const { params, ...rest } = options;
87
- const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
80
+ const optionsWithParams = addQueryParams(rest, params);
88
81
  const requestConfig = await withAuth(accountId, optionsWithParams);
89
- return (0, client_1.httpClient)(requestConfig);
82
+ return httpClient(requestConfig);
90
83
  }
91
84
  async function postRequest(accountId, options) {
92
85
  const requestConfig = await withAuth(accountId, options);
93
- return (0, client_1.httpClient)({ ...requestConfig, method: 'post' });
86
+ return httpClient({ ...requestConfig, method: 'post' });
94
87
  }
95
88
  async function putRequest(accountId, options) {
96
89
  const requestConfig = await withAuth(accountId, options);
97
- return (0, client_1.httpClient)({ ...requestConfig, method: 'put' });
90
+ return httpClient({ ...requestConfig, method: 'put' });
98
91
  }
99
92
  async function patchRequest(accountId, options) {
100
93
  const requestConfig = await withAuth(accountId, options);
101
- return (0, client_1.httpClient)({ ...requestConfig, method: 'patch' });
94
+ return httpClient({ ...requestConfig, method: 'patch' });
102
95
  }
103
96
  async function deleteRequest(accountId, options) {
104
97
  const requestConfig = await withAuth(accountId, options);
105
- return (0, client_1.httpClient)({ ...requestConfig, method: 'delete' });
98
+ return httpClient({ ...requestConfig, method: 'delete' });
106
99
  }
107
100
  function createGetRequestStream(contentType) {
108
101
  return async (accountId, options, destPath) => {
109
102
  const { params, ...rest } = options;
110
- const axiosConfig = (0, addQueryParams_1.addQueryParams)(rest, params);
103
+ const axiosConfig = addQueryParams(rest, params);
111
104
  // eslint-disable-next-line no-async-promise-executor
112
105
  return new Promise(async (resolve, reject) => {
113
106
  try {
114
107
  const { headers, ...opts } = await withAuth(accountId, axiosConfig);
115
- const res = await (0, client_1.httpClient)({
108
+ const res = await httpClient({
116
109
  method: 'get',
117
110
  ...opts,
118
111
  headers: {
@@ -123,20 +116,20 @@ function createGetRequestStream(contentType) {
123
116
  });
124
117
  if (res.status >= 200 && res.status < 300) {
125
118
  let filepath = destPath;
126
- if (fs_extra_1.default.existsSync(destPath)) {
127
- const stat = fs_extra_1.default.statSync(destPath);
119
+ if (fs.existsSync(destPath)) {
120
+ const stat = fs.statSync(destPath);
128
121
  if (stat.isDirectory()) {
129
- const { parameters } = content_disposition_1.default.parse(res.headers['content-disposition'] || '');
130
- filepath = path_1.default.join(destPath, parameters.filename);
122
+ const { parameters } = contentDisposition.parse(res.headers['content-disposition'] || '');
123
+ filepath = path.join(destPath, parameters.filename);
131
124
  }
132
125
  }
133
126
  try {
134
- fs_extra_1.default.ensureFileSync(filepath);
127
+ fs.ensureFileSync(filepath);
135
128
  }
136
129
  catch (err) {
137
130
  reject(err);
138
131
  }
139
- const writeStream = fs_extra_1.default.createWriteStream(filepath, {
132
+ const writeStream = fs.createWriteStream(filepath, {
140
133
  encoding: 'binary',
141
134
  });
142
135
  res.data.pipe(writeStream);
@@ -144,7 +137,7 @@ function createGetRequestStream(contentType) {
144
137
  reject(err);
145
138
  });
146
139
  writeStream.on('close', async () => {
147
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.createGetRequestStream.onWrite`, {
140
+ logger.log(i18n(`${i18nKey}.createGetRequestStream.onWrite`, {
148
141
  filepath,
149
142
  }));
150
143
  resolve(res);
@@ -161,7 +154,7 @@ function createGetRequestStream(contentType) {
161
154
  };
162
155
  }
163
156
  const getOctetStream = createGetRequestStream('application/octet-stream');
164
- exports.http = {
157
+ export const http = {
165
158
  get: getRequest,
166
159
  post: postRequest,
167
160
  put: putRequest,
@@ -1,4 +1,4 @@
1
- import { HttpOptions, HubSpotPromise } from '../types/Http';
1
+ import { HttpOptions, HubSpotPromise } from '../types/Http.js';
2
2
  declare function getRequest<T>(options: HttpOptions): HubSpotPromise<T>;
3
3
  declare function postRequest<T>(options: HttpOptions): HubSpotPromise<T>;
4
4
  declare function putRequest<T>(options: HttpOptions): HubSpotPromise<T>;
package/http/unauthed.js CHANGED
@@ -1,32 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.http = void 0;
4
- const client_1 = require("./client");
5
- const getAxiosConfig_1 = require("./getAxiosConfig");
6
- const addQueryParams_1 = require("./addQueryParams");
1
+ import { httpClient } from './client.js';
2
+ import { getAxiosConfig } from './getAxiosConfig.js';
3
+ import { addQueryParams } from './addQueryParams.js';
7
4
  async function getRequest(options) {
8
5
  const { params, ...rest } = options;
9
- const optionsWithParams = (0, addQueryParams_1.addQueryParams)(rest, params);
10
- const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(optionsWithParams);
11
- return (0, client_1.httpClient)(requestConfig);
6
+ const optionsWithParams = addQueryParams(rest, params);
7
+ const requestConfig = await getAxiosConfig(optionsWithParams);
8
+ return httpClient(requestConfig);
12
9
  }
13
10
  async function postRequest(options) {
14
- const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
15
- return (0, client_1.httpClient)({ ...requestConfig, method: 'post' });
11
+ const requestConfig = await getAxiosConfig(options);
12
+ return httpClient({ ...requestConfig, method: 'post' });
16
13
  }
17
14
  async function putRequest(options) {
18
- const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
19
- return (0, client_1.httpClient)({ ...requestConfig, method: 'put' });
15
+ const requestConfig = await getAxiosConfig(options);
16
+ return httpClient({ ...requestConfig, method: 'put' });
20
17
  }
21
18
  async function patchRequest(options) {
22
- const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
23
- return (0, client_1.httpClient)({ ...requestConfig, method: 'patch' });
19
+ const requestConfig = await getAxiosConfig(options);
20
+ return httpClient({ ...requestConfig, method: 'patch' });
24
21
  }
25
22
  async function deleteRequest(options) {
26
- const requestConfig = await (0, getAxiosConfig_1.getAxiosConfig)(options);
27
- return (0, client_1.httpClient)({ ...requestConfig, method: 'delete' });
23
+ const requestConfig = await getAxiosConfig(options);
24
+ return httpClient({ ...requestConfig, method: 'delete' });
28
25
  }
29
- exports.http = {
26
+ export const http = {
30
27
  get: getRequest,
31
28
  post: postRequest,
32
29
  put: putRequest,
package/lang/en.json CHANGED
@@ -316,7 +316,7 @@
316
316
  },
317
317
  "buildConfigFromEnvironment": {
318
318
  "missingAccountId": "HUBSPOT_ACCOUNT_ID is required, but not currently set",
319
- "invalidAuthType": "Auth type is invalid. Use HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, and HUBSPOT_REFRESH_TOKEN to authenticate with Oauth2, PERSONAL_ACCESS_KEY to authenticate with Personal Access Key, or API_KEY to authenticate with API Key."
319
+ "invalidAuthType": "Auth type is invalid. Use HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, and HUBSPOT_REFRESH_TOKEN to authenticate with Oauth2, HUBSPOT_PERSONAL_ACCESS_KEY to authenticate with Personal Access Key, or API_KEY to authenticate with API Key."
320
320
  }
321
321
  },
322
322
  "defaultAccountOverride": {
package/lib/archive.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { CopySourceToDestOptions } from '../types/Archive';
1
+ import { CopySourceToDestOptions } from '../types/Archive.js';
4
2
  export declare function extractZipArchive(zip: Buffer, name: string, dest: string, { sourceDir, includesRootDir, hideLogs, handleCollision, }?: CopySourceToDestOptions): Promise<boolean>;
package/lib/archive.js CHANGED
@@ -1,97 +1,68 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.extractZipArchive = void 0;
30
- const fs_extra_1 = __importDefault(require("fs-extra"));
31
- const path_1 = __importStar(require("path"));
32
- const os_1 = require("os");
33
- const extract_zip_1 = __importDefault(require("extract-zip"));
34
- const logger_1 = require("./logger");
35
- const lang_1 = require("../utils/lang");
36
- const FileSystemError_1 = require("../models/FileSystemError");
37
- const fs_1 = require("./fs");
1
+ import fs from 'fs-extra';
2
+ import path, { join } from 'path';
3
+ import { tmpdir } from 'os';
4
+ import extract from 'extract-zip';
5
+ import { logger } from './logger.js';
6
+ import { i18n } from '../utils/lang.js';
7
+ import { FileSystemError } from '../models/FileSystemError.js';
8
+ import { walk } from './fs.js';
38
9
  const i18nKey = 'lib.archive';
39
10
  async function extractZip(name, zip, hideLogs = false) {
40
11
  const result = { extractDir: '', tmpDir: '' };
41
12
  const TMP_FOLDER_PREFIX = `hubspot-temp-${name}-`;
42
13
  if (!hideLogs) {
43
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.extractZip.init`));
14
+ logger.log(i18n(`${i18nKey}.extractZip.init`));
44
15
  }
45
16
  // Write zip to disk
46
17
  let tmpZipPath = '';
47
18
  try {
48
- result.tmpDir = await fs_extra_1.default.mkdtemp((0, path_1.join)((0, os_1.tmpdir)(), TMP_FOLDER_PREFIX));
49
- tmpZipPath = (0, path_1.join)(result.tmpDir, 'hubspot-temp.zip');
50
- await fs_extra_1.default.ensureFile(tmpZipPath);
51
- await fs_extra_1.default.writeFile(tmpZipPath, zip, {
19
+ result.tmpDir = await fs.mkdtemp(join(tmpdir(), TMP_FOLDER_PREFIX));
20
+ tmpZipPath = join(result.tmpDir, 'hubspot-temp.zip');
21
+ await fs.ensureFile(tmpZipPath);
22
+ await fs.writeFile(tmpZipPath, zip, {
52
23
  mode: 0o777,
53
24
  });
54
25
  }
55
26
  catch (err) {
56
27
  if (tmpZipPath || result.tmpDir) {
57
- throw new FileSystemError_1.FileSystemError({ cause: err }, {
28
+ throw new FileSystemError({ cause: err }, {
58
29
  filepath: tmpZipPath || result.tmpDir,
59
30
  operation: 'write',
60
31
  });
61
32
  }
62
33
  else {
63
- throw new Error((0, lang_1.i18n)(`${i18nKey}.extractZip.errors.write`), {
34
+ throw new Error(i18n(`${i18nKey}.extractZip.errors.write`), {
64
35
  cause: err,
65
36
  });
66
37
  }
67
38
  }
68
39
  // Extract zip
69
40
  try {
70
- const tmpExtractPath = (0, path_1.join)(result.tmpDir, 'extracted');
71
- await (0, extract_zip_1.default)(tmpZipPath, { dir: tmpExtractPath });
41
+ const tmpExtractPath = join(result.tmpDir, 'extracted');
42
+ await extract(tmpZipPath, { dir: tmpExtractPath });
72
43
  result.extractDir = tmpExtractPath;
73
44
  }
74
45
  catch (err) {
75
- throw new Error((0, lang_1.i18n)(`${i18nKey}.extractZip.errors.extract`), {
46
+ throw new Error(i18n(`${i18nKey}.extractZip.errors.extract`), {
76
47
  cause: err,
77
48
  });
78
49
  }
79
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.extractZip.success`));
50
+ logger.debug(i18n(`${i18nKey}.extractZip.success`));
80
51
  return result;
81
52
  }
82
53
  async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true, hideLogs = false, handleCollision, } = {}) {
83
54
  try {
84
55
  if (!hideLogs) {
85
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.init`));
56
+ logger.log(i18n(`${i18nKey}.copySourceToDest.init`));
86
57
  }
87
58
  const srcDirPath = [src];
88
59
  if (includesRootDir) {
89
- const files = await fs_extra_1.default.readdir(src);
60
+ const files = await fs.readdir(src);
90
61
  const rootDir = files[0];
91
62
  if (!rootDir) {
92
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.sourceEmpty`));
63
+ logger.debug(i18n(`${i18nKey}.copySourceToDest.sourceEmpty`));
93
64
  // Create the dest path if it doesn't already exist
94
- await fs_extra_1.default.ensureDir(dest);
65
+ await fs.ensureDir(dest);
95
66
  // No root found so nothing to copy
96
67
  return true;
97
68
  }
@@ -102,19 +73,19 @@ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true,
102
73
  sourceDirs.push(...(Array.isArray(sourceDir) ? new Set(sourceDir) : [sourceDir]));
103
74
  }
104
75
  if (sourceDirs.length === 0) {
105
- const projectSrcDir = (0, path_1.join)(...srcDirPath);
106
- await fs_extra_1.default.copy(projectSrcDir, dest);
76
+ const projectSrcDir = join(...srcDirPath);
77
+ await fs.copy(projectSrcDir, dest);
107
78
  }
108
79
  else {
109
80
  for (let i = 0; i < sourceDirs.length; i++) {
110
- const projectSrcDir = (0, path_1.join)(...srcDirPath, sourceDirs[i]);
81
+ const projectSrcDir = join(...srcDirPath, sourceDirs[i]);
111
82
  let collisions = [];
112
83
  let filesWithoutCollisions = [];
113
- if (fs_extra_1.default.existsSync(dest) &&
84
+ if (fs.existsSync(dest) &&
114
85
  handleCollision &&
115
86
  typeof handleCollision === 'function') {
116
- const existingFiles = (await (0, fs_1.walk)(dest, ['node_modules'])).map(file => path_1.default.normalize(path_1.default.relative(dest, file)));
117
- const newFiles = (await (0, fs_1.walk)(projectSrcDir, ['node_modules'])).map(file => path_1.default.relative(projectSrcDir, file));
87
+ const existingFiles = (await walk(dest, ['node_modules'])).map(file => path.normalize(path.relative(dest, file)));
88
+ const newFiles = (await walk(projectSrcDir, ['node_modules'])).map(file => path.relative(projectSrcDir, file));
118
89
  // Find files that exist in the same positions in both directories
119
90
  collisions = existingFiles.filter(currentFile => newFiles.includes(currentFile));
120
91
  filesWithoutCollisions = newFiles.filter(currentFile => !collisions.includes(currentFile));
@@ -127,19 +98,19 @@ async function copySourceToDest(src, dest, { sourceDir, includesRootDir = true,
127
98
  src: projectSrcDir,
128
99
  collisions,
129
100
  });
130
- await Promise.all(filesWithoutCollisions.map(currentFile => fs_extra_1.default.copy(path_1.default.join(projectSrcDir, currentFile), path_1.default.join(dest, currentFile))));
101
+ await Promise.all(filesWithoutCollisions.map(currentFile => fs.copy(path.join(projectSrcDir, currentFile), path.join(dest, currentFile))));
131
102
  }
132
103
  else {
133
- await fs_extra_1.default.copy(projectSrcDir, dest);
104
+ await fs.copy(projectSrcDir, dest);
134
105
  }
135
106
  }
136
107
  }
137
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.success`));
108
+ logger.debug(i18n(`${i18nKey}.copySourceToDest.success`));
138
109
  return true;
139
110
  }
140
111
  catch (err) {
141
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.copySourceToDest.error`, { dest }));
142
- throw new FileSystemError_1.FileSystemError({ cause: err }, {
112
+ logger.debug(i18n(`${i18nKey}.copySourceToDest.error`, { dest }));
113
+ throw new FileSystemError({ cause: err }, {
143
114
  filepath: dest,
144
115
  operation: 'write',
145
116
  });
@@ -149,13 +120,13 @@ async function cleanupTempDir(tmpDir) {
149
120
  if (!tmpDir)
150
121
  return;
151
122
  try {
152
- await fs_extra_1.default.remove(tmpDir);
123
+ await fs.remove(tmpDir);
153
124
  }
154
125
  catch (e) {
155
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
126
+ logger.debug(i18n(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
156
127
  }
157
128
  }
158
- async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir, hideLogs, handleCollision, } = {}) {
129
+ export async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir, hideLogs, handleCollision, } = {}) {
159
130
  let success = false;
160
131
  if (zip) {
161
132
  const { extractDir, tmpDir } = await extractZip(name, zip, hideLogs);
@@ -171,4 +142,3 @@ async function extractZipArchive(zip, name, dest, { sourceDir, includesRootDir,
171
142
  }
172
143
  return success;
173
144
  }
174
- exports.extractZipArchive = extractZipArchive;
@@ -1,4 +1,4 @@
1
- import { FunctionConfig, FunctionConfigInfo, FunctionInfo, FunctionOptions } from '../../types/Functions';
1
+ import { FunctionConfig, FunctionConfigInfo, FunctionInfo, FunctionOptions } from '../../types/Functions.js';
2
2
  export declare function isObjectOrFunction(value: object): boolean;
3
3
  export declare function createEndpoint(endpointMethod: string, filename: string): {
4
4
  method: string;