@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
package/api/fileMapper.js CHANGED
@@ -1,16 +1,10 @@
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.getDirectoryContentsByPath = exports.moveFile = exports.deleteFile = exports.downloadDefault = exports.download = exports.fetchFileStream = exports.fetchModule = exports.upload = exports.createFileMapperNodeFromStreamResponse = exports.FILE_MAPPER_API_PATH = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const content_disposition_1 = __importDefault(require("content-disposition"));
10
- const http_1 = require("../http");
11
- const path_2 = require("../lib/path");
12
- exports.FILE_MAPPER_API_PATH = 'content/filemapper/v1';
13
- function createFileMapperNodeFromStreamResponse(filePath, response) {
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import contentDisposition from 'content-disposition';
4
+ import { http } from '../http/index.js';
5
+ import { getCwd } from '../lib/path.js';
6
+ import { FILE_MAPPER_API_PATH } from '../constants/endpoints.js';
7
+ export function createFileMapperNodeFromStreamResponse(filePath, response) {
14
8
  if (filePath[0] !== '/') {
15
9
  filePath = `/${filePath}`;
16
10
  }
@@ -20,7 +14,7 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
20
14
  const node = {
21
15
  source: null,
22
16
  path: filePath,
23
- name: path_1.default.basename(filePath),
17
+ name: path.basename(filePath),
24
18
  folder: false,
25
19
  children: [],
26
20
  createdAt: 0,
@@ -29,7 +23,7 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
29
23
  if (!(response.headers && response.headers['content-disposition'])) {
30
24
  return node;
31
25
  }
32
- const { parameters } = content_disposition_1.default.parse(response.headers['content-disposition']);
26
+ const { parameters } = contentDisposition.parse(response.headers['content-disposition']);
33
27
  return {
34
28
  ...node,
35
29
  name: parameters.filename,
@@ -37,70 +31,61 @@ function createFileMapperNodeFromStreamResponse(filePath, response) {
37
31
  updatedAt: parseInt(parameters['modification-date'], 10) || 0,
38
32
  };
39
33
  }
40
- exports.createFileMapperNodeFromStreamResponse = createFileMapperNodeFromStreamResponse;
41
- function upload(accountId, src, dest, options = {}) {
42
- return http_1.http.post(accountId, {
43
- url: `${exports.FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
34
+ export function upload(accountId, src, dest, options = {}) {
35
+ return http.post(accountId, {
36
+ url: `${FILE_MAPPER_API_PATH}/upload/${encodeURIComponent(dest)}`,
44
37
  data: {
45
- file: fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), src)),
38
+ file: fs.createReadStream(path.resolve(getCwd(), src)),
46
39
  },
47
40
  headers: { 'Content-Type': 'multipart/form-data' },
48
41
  ...options,
49
42
  });
50
43
  }
51
- exports.upload = upload;
52
44
  // Fetch a module by moduleId
53
- function fetchModule(accountId, moduleId, options = {}) {
54
- return http_1.http.get(accountId, {
55
- url: `${exports.FILE_MAPPER_API_PATH}/modules/${moduleId}`,
45
+ export function fetchModule(accountId, moduleId, options = {}) {
46
+ return http.get(accountId, {
47
+ url: `${FILE_MAPPER_API_PATH}/modules/${moduleId}`,
56
48
  ...options,
57
49
  });
58
50
  }
59
- exports.fetchModule = fetchModule;
60
51
  // Fetch a file by file path.
61
- async function fetchFileStream(accountId, filePath, destination, options = {}) {
62
- const response = await http_1.http.getOctetStream(accountId, {
63
- url: `${exports.FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
52
+ export async function fetchFileStream(accountId, filePath, destination, options = {}) {
53
+ const response = await http.getOctetStream(accountId, {
54
+ url: `${FILE_MAPPER_API_PATH}/stream/${encodeURIComponent(filePath)}`,
64
55
  ...options,
65
56
  }, destination);
66
57
  return createFileMapperNodeFromStreamResponse(filePath, response);
67
58
  }
68
- exports.fetchFileStream = fetchFileStream;
69
59
  // Fetch a folder or file node by path.
70
- function download(accountId, filepath, options = {}) {
71
- return http_1.http.get(accountId, {
72
- url: `${exports.FILE_MAPPER_API_PATH}/download/${encodeURIComponent(filepath)}`,
60
+ export function download(accountId, filepath, options = {}) {
61
+ return http.get(accountId, {
62
+ url: `${FILE_MAPPER_API_PATH}/download/${encodeURIComponent(filepath)}`,
73
63
  ...options,
74
64
  });
75
65
  }
76
- exports.download = download;
77
66
  // Fetch a folder or file node by path.
78
- function downloadDefault(accountId, filepath, options = {}) {
79
- return http_1.http.get(accountId, {
80
- url: `${exports.FILE_MAPPER_API_PATH}/download-default/${filepath}`,
67
+ export function downloadDefault(accountId, filepath, options = {}) {
68
+ return http.get(accountId, {
69
+ url: `${FILE_MAPPER_API_PATH}/download-default/${filepath}`,
81
70
  ...options,
82
71
  });
83
72
  }
84
- exports.downloadDefault = downloadDefault;
85
73
  // Delete a file or folder by path
86
- function deleteFile(accountId, filePath) {
87
- return http_1.http.delete(accountId, {
88
- url: `${exports.FILE_MAPPER_API_PATH}/delete/${encodeURIComponent(filePath)}`,
74
+ export function deleteFile(accountId, filePath) {
75
+ return http.delete(accountId, {
76
+ url: `${FILE_MAPPER_API_PATH}/delete/${encodeURIComponent(filePath)}`,
89
77
  });
90
78
  }
91
- exports.deleteFile = deleteFile;
92
79
  // Moves file from srcPath to destPath
93
- function moveFile(accountId, srcPath, destPath) {
94
- return http_1.http.put(accountId, {
95
- url: `${exports.FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
80
+ export function moveFile(accountId, srcPath, destPath) {
81
+ return http.put(accountId, {
82
+ url: `${FILE_MAPPER_API_PATH}/rename/${srcPath}?path=${destPath}`,
96
83
  headers: { 'Content-Type': 'application/json' },
97
84
  });
98
85
  }
99
- exports.moveFile = moveFile;
100
86
  // Get directory contents
101
- function getDirectoryContentsByPath(accountId, path) {
102
- return http_1.http.get(accountId, {
103
- url: `${exports.FILE_MAPPER_API_PATH}/meta/${path}`,
87
+ export function getDirectoryContentsByPath(accountId, path) {
88
+ return http.get(accountId, {
89
+ url: `${FILE_MAPPER_API_PATH}/meta/${path}`,
104
90
  });
105
91
  }
106
- exports.getDirectoryContentsByPath = getDirectoryContentsByPath;
@@ -1,4 +1,4 @@
1
- import { HubSpotPromise } from '../types/Http';
1
+ import { HubSpotPromise } from '../types/Http.js';
2
2
  export declare function createSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
3
3
  export declare function updateSchemaFromHubFile(accountId: number, filepath: string): HubSpotPromise;
4
4
  export declare function fetchHubFileSchema(accountId: number, objectName: string, path: string): HubSpotPromise;
@@ -1,17 +1,11 @@
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.fetchHubFileSchema = exports.updateSchemaFromHubFile = exports.createSchemaFromHubFile = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const path_2 = require("../lib/path");
10
- const http_1 = require("../http");
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { getCwd } from '../lib/path.js';
4
+ import { http } from '../http/index.js';
11
5
  const HUBFILES_API_PATH = '/file-transport/v1/hubfiles';
12
- function createSchemaFromHubFile(accountId, filepath) {
13
- const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
14
- return http_1.http.post(accountId, {
6
+ export function createSchemaFromHubFile(accountId, filepath) {
7
+ const file = fs.createReadStream(path.resolve(getCwd(), filepath));
8
+ return http.post(accountId, {
15
9
  url: `${HUBFILES_API_PATH}/object-schemas`,
16
10
  data: {
17
11
  file,
@@ -19,10 +13,9 @@ function createSchemaFromHubFile(accountId, filepath) {
19
13
  headers: { 'Content-Type': 'multipart/form-data' },
20
14
  });
21
15
  }
22
- exports.createSchemaFromHubFile = createSchemaFromHubFile;
23
- async function updateSchemaFromHubFile(accountId, filepath) {
24
- const file = fs_1.default.createReadStream(path_1.default.resolve((0, path_2.getCwd)(), filepath));
25
- return http_1.http.put(accountId, {
16
+ export async function updateSchemaFromHubFile(accountId, filepath) {
17
+ const file = fs.createReadStream(path.resolve(getCwd(), filepath));
18
+ return http.put(accountId, {
26
19
  url: `${HUBFILES_API_PATH}/object-schemas`,
27
20
  data: {
28
21
  file,
@@ -30,10 +23,8 @@ async function updateSchemaFromHubFile(accountId, filepath) {
30
23
  headers: { 'Content-Type': 'multipart/form-data' },
31
24
  });
32
25
  }
33
- exports.updateSchemaFromHubFile = updateSchemaFromHubFile;
34
- async function fetchHubFileSchema(accountId, objectName, path) {
35
- return http_1.http.getOctetStream(accountId, {
26
+ export async function fetchHubFileSchema(accountId, objectName, path) {
27
+ return http.getOctetStream(accountId, {
36
28
  url: `${HUBFILES_API_PATH}/object-schemas/${objectName}`,
37
29
  }, path);
38
30
  }
39
- exports.fetchHubFileSchema = fetchHubFileSchema;
@@ -1,4 +1,3 @@
1
- import { FireAlarm } from '../types/FireAlarm';
2
- import { HubSpotPromise } from '../types/Http';
3
- export declare const FIREALARM_API_AUTH_PATH = "firealarm/v4/alarm";
1
+ import { FireAlarm } from '../types/FireAlarm.js';
2
+ import { HubSpotPromise } from '../types/Http.js';
4
3
  export declare function fetchFireAlarms(accountId: number): HubSpotPromise<Array<FireAlarm>>;
package/api/fireAlarm.js CHANGED
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchFireAlarms = exports.FIREALARM_API_AUTH_PATH = void 0;
4
- const http_1 = require("../http");
5
- exports.FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
6
- function fetchFireAlarms(accountId) {
7
- return http_1.http.get(accountId, {
8
- url: `${exports.FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
1
+ import { http } from '../http/index.js';
2
+ import { FIREALARM_API_AUTH_PATH } from '../constants/endpoints.js';
3
+ export function fetchFireAlarms(accountId) {
4
+ return http.get(accountId, {
5
+ url: `${FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
9
6
  });
10
7
  }
11
- exports.fetchFireAlarms = fetchFireAlarms;
@@ -1,5 +1,5 @@
1
- import { HubSpotPromise, QueryParams } from '../types/Http';
2
- import { GetBuildStatusResponse, FunctionLog, GetRoutesResponse, GetFunctionLogsResponse } from '../types/Functions';
1
+ import { HubSpotPromise, QueryParams } from '../types/Http.js';
2
+ import { GetBuildStatusResponse, FunctionLog, GetRoutesResponse, GetFunctionLogsResponse } from '../types/Functions.js';
3
3
  export declare function getRoutes(accountId: number): HubSpotPromise<GetRoutesResponse>;
4
4
  export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): HubSpotPromise<GetFunctionLogsResponse>;
5
5
  export declare function getLatestFunctionLog(accountId: number, route: string): HubSpotPromise<FunctionLog>;
package/api/functions.js CHANGED
@@ -1,30 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBuildStatus = exports.buildPackage = exports.getLatestFunctionLog = exports.getFunctionLogs = exports.getRoutes = void 0;
4
- const http_1 = require("../http");
1
+ import { http } from '../http/index.js';
5
2
  const FUNCTION_API_PATH = 'cms/v3/functions';
6
- function getRoutes(accountId) {
7
- return http_1.http.get(accountId, {
3
+ export function getRoutes(accountId) {
4
+ return http.get(accountId, {
8
5
  url: `${FUNCTION_API_PATH}/routes`,
9
6
  });
10
7
  }
11
- exports.getRoutes = getRoutes;
12
- function getFunctionLogs(accountId, route, params = {}) {
8
+ export function getFunctionLogs(accountId, route, params = {}) {
13
9
  const { limit = 5 } = params;
14
- return http_1.http.get(accountId, {
10
+ return http.get(accountId, {
15
11
  url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}`,
16
12
  params: { ...params, limit },
17
13
  });
18
14
  }
19
- exports.getFunctionLogs = getFunctionLogs;
20
- function getLatestFunctionLog(accountId, route) {
21
- return http_1.http.get(accountId, {
15
+ export function getLatestFunctionLog(accountId, route) {
16
+ return http.get(accountId, {
22
17
  url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}/latest`,
23
18
  });
24
19
  }
25
- exports.getLatestFunctionLog = getLatestFunctionLog;
26
- function buildPackage(accountId, folderPath) {
27
- return http_1.http.post(accountId, {
20
+ export function buildPackage(accountId, folderPath) {
21
+ return http.post(accountId, {
28
22
  url: `${FUNCTION_API_PATH}/build/async`,
29
23
  headers: {
30
24
  Accept: 'text/plain',
@@ -34,10 +28,8 @@ function buildPackage(accountId, folderPath) {
34
28
  },
35
29
  });
36
30
  }
37
- exports.buildPackage = buildPackage;
38
- function getBuildStatus(accountId, buildId) {
39
- return http_1.http.get(accountId, {
31
+ export function getBuildStatus(accountId, buildId) {
32
+ return http.get(accountId, {
40
33
  url: `${FUNCTION_API_PATH}/build/${buildId}/poll`,
41
34
  });
42
35
  }
43
- exports.getBuildStatus = getBuildStatus;
package/api/github.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github';
4
- import { HubSpotPromise } from '../types/Http';
1
+ import { GithubReleaseData, GithubRepoFile, RepoPath } from '../types/Github.js';
2
+ import { HubSpotPromise } from '../types/Http.js';
5
3
  declare global {
6
4
  var githubToken: string;
7
5
  }
package/api/github.js CHANGED
@@ -1,12 +1,6 @@
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.fetchRepoContents = exports.fetchRepoFileByDownloadUrl = exports.fetchRepoFile = exports.fetchRepoAsZip = exports.fetchRepoReleaseData = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- const getAxiosConfig_1 = require("../http/getAxiosConfig");
9
- const errors_1 = require("../errors");
1
+ import axios from 'axios';
2
+ import { getDefaultUserAgentHeader } from '../http/getAxiosConfig.js';
3
+ import { isSpecifiedError } from '../errors/index.js';
10
4
  const GITHUB_REPOS_API = 'https://api.github.com/repos';
11
5
  const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
12
6
  function getAdditionalHeaders() {
@@ -21,17 +15,17 @@ function getAdditionalHeaders() {
21
15
  }
22
16
  function githubRequestWithFallback(url, responseType) {
23
17
  const headersWithAuth = {
24
- ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
18
+ ...getDefaultUserAgentHeader(),
25
19
  ...getAdditionalHeaders(),
26
20
  };
27
21
  if (headersWithAuth.authorization) {
28
- return axios_1.default
22
+ return axios
29
23
  .get(url, { headers: headersWithAuth, responseType })
30
24
  .catch(error => {
31
25
  // 404 with an auth token might mean an SSO issue so retry without the authorization header
32
- if ((0, errors_1.isSpecifiedError)(error, { statusCode: 404 })) {
33
- return axios_1.default.get(url, {
34
- headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)() },
26
+ if (isSpecifiedError(error, { statusCode: 404 })) {
27
+ return axios.get(url, {
28
+ headers: { ...getDefaultUserAgentHeader() },
35
29
  responseType,
36
30
  });
37
31
  }
@@ -39,39 +33,34 @@ function githubRequestWithFallback(url, responseType) {
39
33
  });
40
34
  }
41
35
  // No auth token, proceed normally
42
- return axios_1.default.get(url, { headers: headersWithAuth, responseType });
36
+ return axios.get(url, { headers: headersWithAuth, responseType });
43
37
  }
44
38
  // Returns information about the repo's releases. Defaults to "latest" if no tag is provided
45
39
  // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
46
- function fetchRepoReleaseData(repoPath, tag = '') {
40
+ export function fetchRepoReleaseData(repoPath, tag = '') {
47
41
  const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
48
42
  return githubRequestWithFallback(`${URL}/${tag ? `tags/${tag}` : 'latest'}`);
49
43
  }
50
- exports.fetchRepoReleaseData = fetchRepoReleaseData;
51
44
  // Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
52
45
  // https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-zip
53
- function fetchRepoAsZip(zipUrl) {
54
- return axios_1.default.get(zipUrl, {
46
+ export function fetchRepoAsZip(zipUrl) {
47
+ return axios.get(zipUrl, {
55
48
  responseType: 'arraybuffer',
56
- headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
49
+ headers: { ...getDefaultUserAgentHeader(), ...getAdditionalHeaders() },
57
50
  });
58
51
  }
59
- exports.fetchRepoAsZip = fetchRepoAsZip;
60
52
  // Returns the raw file contents via the raw.githubusercontent endpoint
61
- function fetchRepoFile(repoPath, filePath, ref) {
53
+ export function fetchRepoFile(repoPath, filePath, ref) {
62
54
  const url = `${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`;
63
55
  return githubRequestWithFallback(url);
64
56
  }
65
- exports.fetchRepoFile = fetchRepoFile;
66
57
  // Returns the raw file contents via the raw.githubusercontent endpoint
67
- function fetchRepoFileByDownloadUrl(downloadUrl) {
58
+ export function fetchRepoFileByDownloadUrl(downloadUrl) {
68
59
  return githubRequestWithFallback(downloadUrl, 'arraybuffer');
69
60
  }
70
- exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
71
61
  // Returns the contents of a file or directory in a repository by path
72
62
  // https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
73
- function fetchRepoContents(repoPath, path, ref) {
63
+ export function fetchRepoContents(repoPath, path, ref) {
74
64
  const refQuery = ref ? `?ref=${ref}` : '';
75
65
  return githubRequestWithFallback(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`);
76
66
  }
77
- exports.fetchRepoContents = fetchRepoContents;
package/api/hubdb.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { HubSpotPromise, QueryParams } from '../types/Http';
2
- import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb';
1
+ import { HubSpotPromise, QueryParams } from '../types/Http.js';
2
+ import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb.js';
3
3
  export declare function fetchTables(accountId: number): HubSpotPromise<FetchTablesResponse>;
4
4
  export declare function fetchTable(accountId: number, tableId: string): HubSpotPromise<Table>;
5
5
  export declare function createTable(accountId: number, schema: Schema): HubSpotPromise<Table>;
package/api/hubdb.js CHANGED
@@ -1,67 +1,55 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = exports.fetchTables = void 0;
4
- const http_1 = require("../http");
1
+ import { http } from '../http/index.js';
5
2
  const HUBDB_API_PATH = 'cms/v3/hubdb';
6
- function fetchTables(accountId) {
7
- return http_1.http.get(accountId, {
3
+ export function fetchTables(accountId) {
4
+ return http.get(accountId, {
8
5
  url: `${HUBDB_API_PATH}/tables`,
9
6
  });
10
7
  }
11
- exports.fetchTables = fetchTables;
12
- function fetchTable(accountId, tableId) {
13
- return http_1.http.get(accountId, {
8
+ export function fetchTable(accountId, tableId) {
9
+ return http.get(accountId, {
14
10
  url: `${HUBDB_API_PATH}/tables/${tableId}`,
15
11
  });
16
12
  }
17
- exports.fetchTable = fetchTable;
18
- function createTable(accountId, schema) {
19
- return http_1.http.post(accountId, {
13
+ export function createTable(accountId, schema) {
14
+ return http.post(accountId, {
20
15
  url: `${HUBDB_API_PATH}/tables`,
21
16
  data: schema,
22
17
  });
23
18
  }
24
- exports.createTable = createTable;
25
- function updateTable(accountId, tableId, schema) {
26
- return http_1.http.patch(accountId, {
19
+ export function updateTable(accountId, tableId, schema) {
20
+ return http.patch(accountId, {
27
21
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
28
22
  data: schema,
29
23
  });
30
24
  }
31
- exports.updateTable = updateTable;
32
- function publishTable(accountId, tableId) {
33
- return http_1.http.post(accountId, {
25
+ export function publishTable(accountId, tableId) {
26
+ return http.post(accountId, {
34
27
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft/publish`,
35
28
  headers: {
36
29
  'Content-Type': 'application/json',
37
30
  },
38
31
  });
39
32
  }
40
- exports.publishTable = publishTable;
41
- function deleteTable(accountId, tableId) {
42
- return http_1.http.delete(accountId, {
33
+ export function deleteTable(accountId, tableId) {
34
+ return http.delete(accountId, {
43
35
  url: `${HUBDB_API_PATH}/tables/${tableId}`,
44
36
  });
45
37
  }
46
- exports.deleteTable = deleteTable;
47
- function createRows(accountId, tableId, rows) {
48
- return http_1.http.post(accountId, {
38
+ export function createRows(accountId, tableId, rows) {
39
+ return http.post(accountId, {
49
40
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
50
41
  data: { inputs: rows },
51
42
  });
52
43
  }
53
- exports.createRows = createRows;
54
- function fetchRows(accountId, tableId, params = {}) {
55
- return http_1.http.get(accountId, {
44
+ export function fetchRows(accountId, tableId, params = {}) {
45
+ return http.get(accountId, {
56
46
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft`,
57
47
  params,
58
48
  });
59
49
  }
60
- exports.fetchRows = fetchRows;
61
- function deleteRows(accountId, tableId, rowIds) {
62
- return http_1.http.post(accountId, {
50
+ export function deleteRows(accountId, tableId, rowIds) {
51
+ return http.post(accountId, {
63
52
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
64
53
  data: { inputs: rowIds },
65
54
  });
66
55
  }
67
- exports.deleteRows = deleteRows;
@@ -1,5 +1,5 @@
1
- import { Data, HubSpotPromise, QueryParams } from '../types/Http';
2
- import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
1
+ import { Data, HubSpotPromise, QueryParams } from '../types/Http.js';
2
+ import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse.js';
3
3
  export declare function requestLighthouseScore(accountId: number, data?: Data): HubSpotPromise<RequestLighthouseScoreResponse>;
4
4
  export declare function getLighthouseScoreStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
5
5
  export declare function getLighthouseScore(accountId: number, params?: QueryParams): HubSpotPromise<GetLighthouseScoreResponse>;
@@ -1,26 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
4
- const http_1 = require("../http");
1
+ import { http } from '../http/index.js';
5
2
  const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
6
- function requestLighthouseScore(accountId, data = {}) {
7
- return http_1.http.post(accountId, {
3
+ export function requestLighthouseScore(accountId, data = {}) {
4
+ return http.post(accountId, {
8
5
  url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
9
6
  data,
10
7
  });
11
8
  }
12
- exports.requestLighthouseScore = requestLighthouseScore;
13
- function getLighthouseScoreStatus(accountId, params = {}) {
14
- return http_1.http.get(accountId, {
9
+ export function getLighthouseScoreStatus(accountId, params = {}) {
10
+ return http.get(accountId, {
15
11
  url: `${LIGHTHOUSE_SCORE_API_BASE}/status`,
16
12
  params,
17
13
  });
18
14
  }
19
- exports.getLighthouseScoreStatus = getLighthouseScoreStatus;
20
- function getLighthouseScore(accountId, params = {}) {
21
- return http_1.http.get(accountId, {
15
+ export function getLighthouseScore(accountId, params = {}) {
16
+ return http.get(accountId, {
22
17
  url: `${LIGHTHOUSE_SCORE_API_BASE}/scores`,
23
18
  params,
24
19
  });
25
20
  }
26
- exports.getLighthouseScore = getLighthouseScore;
@@ -1,9 +1,6 @@
1
- import { Environment } from '../types/Config';
2
- import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts';
3
- import { PublicAppInstallationData } from '../types/Apps';
4
- import { HubSpotPromise } from '../types/Http';
5
- export declare const LOCALDEVAUTH_ACCESS_TOKEN_PATH: string;
6
- export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
1
+ import { ScopeData, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts.js';
2
+ import { PublicAppInstallationData } from '../types/Apps.js';
3
+ import { HubSpotPromise } from '../types/Http.js';
7
4
  export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
8
5
  export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
9
6
  export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
@@ -1,43 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeAuthorizationData = exports.fetchScopeData = exports.fetchAccessToken = exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH = void 0;
4
- const getAxiosConfig_1 = require("../http/getAxiosConfig");
5
- const http_1 = require("../http");
6
- const environments_1 = require("../constants/environments");
7
- const client_1 = require("../http/client");
8
- const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
9
- exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH = `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`;
10
- function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
11
- const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
12
- env,
13
- localHostOverride: true,
14
- url: exports.LOCALDEVAUTH_ACCESS_TOKEN_PATH,
15
- data: {
16
- encodedOAuthRefreshToken: personalAccessKey,
17
- },
18
- params: portalId ? { portalId } : {},
19
- });
20
- return (0, client_1.httpClient)({
21
- ...axiosConfig,
22
- method: 'post',
23
- });
24
- }
25
- exports.fetchAccessToken = fetchAccessToken;
26
- function fetchScopeData(accountId, scopeGroup) {
27
- return http_1.http.get(accountId, {
1
+ import { http } from '../http/index.js';
2
+ import { LOCALDEVAUTH_API_AUTH_PATH } from '../constants/endpoints.js';
3
+ export function fetchScopeData(accountId, scopeGroup) {
4
+ return http.get(accountId, {
28
5
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/check-scopes`,
29
6
  params: { scopeGroup },
30
7
  });
31
8
  }
32
- exports.fetchScopeData = fetchScopeData;
33
- async function fetchScopeAuthorizationData(accountId) {
34
- return http_1.http.get(accountId, {
9
+ export async function fetchScopeAuthorizationData(accountId) {
10
+ return http.get(accountId, {
35
11
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/scope-groups/authorized`,
36
12
  });
37
13
  }
38
- exports.fetchScopeAuthorizationData = fetchScopeAuthorizationData;
39
- function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGroups, optionalScopeGroups = []) {
40
- return http_1.http.post(portalId, {
14
+ export function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGroups, optionalScopeGroups = []) {
15
+ return http.post(portalId, {
41
16
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/install-info`,
42
17
  data: {
43
18
  portalId,
@@ -48,10 +23,8 @@ function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGrou
48
23
  },
49
24
  });
50
25
  }
51
- exports.fetchAppInstallationData = fetchAppInstallationData;
52
- async function fetchEnabledFeatures(accountId) {
53
- return http_1.http.get(accountId, {
26
+ export async function fetchEnabledFeatures(accountId) {
27
+ return http.get(accountId, {
54
28
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/enabled-features`,
55
29
  });
56
30
  }
57
- exports.fetchEnabledFeatures = fetchEnabledFeatures;
@@ -1,5 +1,5 @@
1
- import { Data, HubSpotPromise, QueryParams } from '../types/Http';
2
- import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
1
+ import { Data, HubSpotPromise, QueryParams } from '../types/Http.js';
2
+ import { GetValidationResultsResponse } from '../types/MarketplaceValidation.js';
3
3
  export declare function requestValidation(accountId: number, data?: Data): HubSpotPromise<number>;
4
4
  export declare function getValidationStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
5
5
  export declare function getValidationResults(accountId: number, params?: QueryParams): HubSpotPromise<GetValidationResultsResponse>;