@hubspot/local-dev-lib 0.2.4 → 0.2.5-experimental.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) 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 +16 -16
  15. package/api/fileTransport.d.ts +4 -0
  16. package/api/fileTransport.js +39 -0
  17. package/api/functions.d.ts +7 -7
  18. package/api/functions.js +13 -16
  19. package/api/github.d.ts +7 -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 -16
  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 +31 -24
  30. package/api/projects.js +163 -43
  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/CLIConfiguration.d.ts +15 -11
  40. package/config/CLIConfiguration.js +175 -90
  41. package/config/configFile.js +12 -18
  42. package/config/configUtils.d.ts +2 -21
  43. package/config/configUtils.js +5 -4
  44. package/config/config_DEPRECATED.d.ts +6 -8
  45. package/config/config_DEPRECATED.js +79 -25
  46. package/config/environment.js +5 -4
  47. package/config/getAccountIdentifier.d.ts +2 -0
  48. package/config/getAccountIdentifier.js +15 -0
  49. package/config/index.d.ts +14 -8
  50. package/config/index.js +106 -57
  51. package/constants/config.d.ts +18 -1
  52. package/constants/config.js +20 -3
  53. package/constants/environments.d.ts +1 -0
  54. package/constants/environments.js +1 -0
  55. package/constants/extensions.d.ts +2 -0
  56. package/constants/extensions.js +3 -1
  57. package/constants/files.d.ts +2 -2
  58. package/constants/files.js +3 -3
  59. package/errors/errors_DEPRECATED.d.ts +1 -5
  60. package/errors/errors_DEPRECATED.js +2 -2
  61. package/errors/index.d.ts +18 -0
  62. package/errors/index.js +63 -0
  63. package/http/addQueryParams.d.ts +2 -0
  64. package/http/addQueryParams.js +14 -0
  65. package/http/getAxiosConfig.d.ts +6 -3
  66. package/http/getAxiosConfig.js +49 -6
  67. package/http/index.d.ts +11 -12
  68. package/http/index.js +35 -41
  69. package/http/unauthed.d.ts +14 -0
  70. package/http/unauthed.js +38 -0
  71. package/lang/en.json +378 -386
  72. package/lib/archive.d.ts +2 -8
  73. package/lib/archive.js +34 -30
  74. package/lib/cms/functions.d.ts +7 -12
  75. package/lib/cms/functions.js +49 -51
  76. package/lib/cms/handleFieldsJS.js +16 -14
  77. package/lib/cms/modules.d.ts +4 -15
  78. package/lib/cms/modules.js +81 -78
  79. package/lib/cms/processFieldsJs.js +10 -33
  80. package/lib/cms/templates.d.ts +43 -3
  81. package/lib/cms/templates.js +53 -11
  82. package/lib/cms/uploadFolder.d.ts +3 -14
  83. package/lib/cms/uploadFolder.js +58 -42
  84. package/lib/cms/validate.js +1 -1
  85. package/lib/cms/watch.d.ts +2 -18
  86. package/lib/cms/watch.js +63 -68
  87. package/lib/customObjects.js +4 -15
  88. package/lib/fileManager.d.ts +2 -6
  89. package/lib/fileManager.js +54 -65
  90. package/lib/fileMapper.d.ts +4 -15
  91. package/lib/fileMapper.js +67 -88
  92. package/lib/fs.d.ts +1 -1
  93. package/lib/fs.js +10 -6
  94. package/lib/github.d.ts +12 -14
  95. package/lib/github.js +70 -35
  96. package/lib/gitignore.d.ts +2 -0
  97. package/lib/gitignore.js +21 -4
  98. package/lib/hubdb.d.ts +3 -2
  99. package/lib/hubdb.js +11 -9
  100. package/{utils → lib}/notify.js +2 -2
  101. package/lib/oauth.d.ts +2 -5
  102. package/lib/oauth.js +14 -25
  103. package/lib/path.d.ts +3 -0
  104. package/lib/path.js +46 -1
  105. package/lib/personalAccessKey.d.ts +8 -11
  106. package/lib/personalAccessKey.js +75 -38
  107. package/lib/portManager.d.ts +3 -5
  108. package/lib/portManager.js +18 -6
  109. package/lib/trackUsage.js +18 -11
  110. package/lib/urls.js +5 -1
  111. package/models/FileSystemError.d.ts +6 -0
  112. package/models/FileSystemError.js +47 -0
  113. package/models/HubSpotHttpError.d.ts +24 -0
  114. package/models/HubSpotHttpError.js +197 -0
  115. package/models/OAuth2Manager.d.ts +2 -27
  116. package/models/OAuth2Manager.js +20 -34
  117. package/package.json +34 -36
  118. package/types/Accounts.d.ts +103 -3
  119. package/types/Apps.d.ts +77 -0
  120. package/types/Archive.d.ts +9 -0
  121. package/types/Archive.js +2 -0
  122. package/types/Build.d.ts +4 -2
  123. package/types/ComponentStructure.d.ts +30 -10
  124. package/types/Config.d.ts +19 -2
  125. package/types/Deploy.d.ts +3 -2
  126. package/types/DesignManager.d.ts +10 -0
  127. package/types/DesignManager.js +2 -0
  128. package/types/Error.d.ts +9 -5
  129. package/types/FieldsJS.d.ts +1 -0
  130. package/types/FieldsJS.js +2 -0
  131. package/types/FileManager.d.ts +1 -1
  132. package/types/Files.d.ts +43 -4
  133. package/types/Functions.d.ts +52 -0
  134. package/types/Github.d.ts +13 -0
  135. package/types/Http.d.ts +12 -12
  136. package/types/Hubdb.d.ts +9 -0
  137. package/types/MarketplaceValidation.d.ts +7 -3
  138. package/types/Migration.d.ts +28 -0
  139. package/types/Migration.js +10 -0
  140. package/types/Modules.d.ts +11 -0
  141. package/types/PortManager.d.ts +7 -0
  142. package/types/Project.d.ts +30 -0
  143. package/types/ProjectLog.d.ts +9 -0
  144. package/types/ProjectLog.js +2 -0
  145. package/types/Sandbox.d.ts +37 -47
  146. package/types/Schemas.d.ts +56 -0
  147. package/types/Secrets.d.ts +3 -0
  148. package/types/Secrets.js +2 -0
  149. package/types/developerTestAccounts.d.ts +13 -0
  150. package/types/developerTestAccounts.js +2 -0
  151. package/utils/PortManagerServer.d.ts +6 -7
  152. package/utils/PortManagerServer.js +22 -16
  153. package/utils/{getAccountIdentifier.d.ts → accounts.d.ts} +0 -6
  154. package/utils/{getAccountIdentifier.js → accounts.js} +1 -13
  155. package/utils/cms/fieldsJS.d.ts +1 -2
  156. package/utils/cms/modules.js +2 -2
  157. package/utils/detectPort.js +3 -3
  158. package/utils/git.d.ts +1 -7
  159. package/utils/git.js +2 -18
  160. package/errors/apiErrors.d.ts +0 -16
  161. package/errors/apiErrors.js +0 -176
  162. package/errors/fileSystemErrors.d.ts +0 -6
  163. package/errors/fileSystemErrors.js +0 -35
  164. package/errors/standardErrors.d.ts +0 -21
  165. package/errors/standardErrors.js +0 -52
  166. package/lang/lang/en.json +0 -401
  167. package/lib/logging/git.d.ts +0 -2
  168. package/lib/logging/git.js +0 -54
  169. package/lib/logging/logs.d.ts +0 -22
  170. package/lib/logging/logs.js +0 -86
  171. package/lib/logging/table.d.ts +0 -3
  172. package/lib/logging/table.js +0 -47
  173. package/lib/sandboxes.d.ts +0 -14
  174. package/lib/sandboxes.js +0 -71
  175. package/models/HubSpotAuthError.d.ts +0 -12
  176. package/models/HubSpotAuthError.js +0 -20
  177. package/types/LogCallbacks.d.ts +0 -7
  178. package/utils/logger.d.ts +0 -5
  179. package/utils/logger.js +0 -23
  180. package/utils/objectUtils.d.ts +0 -8
  181. package/utils/objectUtils.js +0 -33
  182. /package/{utils → lib}/escapeRegExp.d.ts +0 -0
  183. /package/{utils → lib}/escapeRegExp.js +0 -0
  184. /package/lib/{logging/logger.d.ts → logger.d.ts} +0 -0
  185. /package/lib/{logging/logger.js → logger.js} +0 -0
  186. /package/{utils → lib}/notify.d.ts +0 -0
  187. /package/types/{LogCallbacks.js → Apps.js} +0 -0
package/api/github.js CHANGED
@@ -8,46 +8,64 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
9
9
  const GITHUB_REPOS_API = 'https://api.github.com/repos';
10
10
  const GITHUB_RAW_CONTENT_API_PATH = 'https://raw.githubusercontent.com';
11
- const GITHUB_AUTH_HEADERS = {
12
- authorization: global && global.githubToken ? `Bearer ${global.githubToken}` : null,
13
- };
11
+ function getAdditionalHeaders() {
12
+ const headers = {};
13
+ if (global && global.githubToken) {
14
+ headers.authorization = `Bearer ${global.githubToken}`;
15
+ }
16
+ else if (process.env.GITHUB_TOKEN) {
17
+ headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
18
+ }
19
+ return headers;
20
+ }
14
21
  // Returns information about the repo's releases. Defaults to "latest" if no tag is provided
15
22
  // https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release-by-tag-name
16
- async function fetchRepoReleaseData(repoPath, tag = '') {
23
+ function fetchRepoReleaseData(repoPath, tag = '') {
17
24
  const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
18
25
  return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, {
19
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
26
+ headers: {
27
+ ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
28
+ ...getAdditionalHeaders(),
29
+ },
20
30
  });
21
31
  }
22
32
  exports.fetchRepoReleaseData = fetchRepoReleaseData;
23
33
  // Returns the entire repo content as a zip, using the zipball_url from fetchRepoReleaseData()
24
34
  // https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-zip
25
- async function fetchRepoAsZip(zipUrl) {
35
+ function fetchRepoAsZip(zipUrl) {
26
36
  return axios_1.default.get(zipUrl, {
27
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
37
+ responseType: 'arraybuffer',
38
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
28
39
  });
29
40
  }
30
41
  exports.fetchRepoAsZip = fetchRepoAsZip;
31
42
  // Returns the raw file contents via the raw.githubusercontent endpoint
32
- async function fetchRepoFile(repoPath, filePath, ref) {
43
+ function fetchRepoFile(repoPath, filePath, ref) {
33
44
  return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, {
34
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
45
+ headers: {
46
+ ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
47
+ ...getAdditionalHeaders(),
48
+ },
35
49
  });
36
50
  }
37
51
  exports.fetchRepoFile = fetchRepoFile;
38
52
  // Returns the raw file contents via the raw.githubusercontent endpoint
39
- async function fetchRepoFileByDownloadUrl(downloadUrl) {
53
+ function fetchRepoFileByDownloadUrl(downloadUrl) {
40
54
  return axios_1.default.get(downloadUrl, {
41
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
55
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...getAdditionalHeaders() },
56
+ responseType: 'arraybuffer',
42
57
  });
43
58
  }
44
59
  exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
45
60
  // Returns the contents of a file or directory in a repository by path
46
61
  // https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#get-repository-content
47
- async function fetchRepoContents(repoPath, path, ref) {
62
+ function fetchRepoContents(repoPath, path, ref) {
48
63
  const refQuery = ref ? `?ref=${ref}` : '';
49
64
  return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, {
50
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
65
+ headers: {
66
+ ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(),
67
+ ...getAdditionalHeaders(),
68
+ },
51
69
  });
52
70
  }
53
71
  exports.fetchRepoContents = fetchRepoContents;
package/api/hubdb.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { QueryParams } from '../types/Http';
2
- import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table } from '../types/Hubdb';
3
- export declare function fetchTable(accountId: number, tableId: string): Promise<Table>;
4
- export declare function createTable(accountId: number, schema: Schema): Promise<Table>;
5
- export declare function updateTable(accountId: number, tableId: string, schema: Schema): Promise<unknown>;
6
- export declare function publishTable(accountId: number, tableId: string): Promise<Table>;
7
- export declare function deleteTable(accountId: number, tableId: string): Promise<void>;
8
- export declare function createRows(accountId: number, tableId: string, rows: Array<Row>): Promise<CreateRowsResponse>;
9
- export declare function fetchRows(accountId: number, tableId: string, query?: QueryParams): Promise<FetchRowsResponse>;
10
- export declare function deleteRows(accountId: number, tableId: string, rowIds: Array<string>): Promise<void>;
1
+ import { HubSpotPromise, QueryParams } from '../types/Http';
2
+ import { CreateRowsResponse, FetchRowsResponse, Row, Schema, Table, FetchTablesResponse } from '../types/Hubdb';
3
+ export declare function fetchTables(accountId: number): HubSpotPromise<FetchTablesResponse>;
4
+ export declare function fetchTable(accountId: number, tableId: string): HubSpotPromise<Table>;
5
+ export declare function createTable(accountId: number, schema: Schema): HubSpotPromise<Table>;
6
+ export declare function updateTable(accountId: number, tableId: string, schema: Schema): HubSpotPromise<Table>;
7
+ export declare function publishTable(accountId: number, tableId: string): HubSpotPromise<Table>;
8
+ export declare function deleteTable(accountId: number, tableId: string): HubSpotPromise<void>;
9
+ export declare function createRows(accountId: number, tableId: string, rows: Array<Row>): HubSpotPromise<CreateRowsResponse>;
10
+ export declare function fetchRows(accountId: number, tableId: string, params?: QueryParams): HubSpotPromise<FetchRowsResponse>;
11
+ export declare function deleteRows(accountId: number, tableId: string, rowIds: Array<string>): HubSpotPromise<void>;
package/api/hubdb.js CHANGED
@@ -1,59 +1,65 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deleteRows = exports.fetchRows = exports.createRows = exports.deleteTable = exports.publishTable = exports.updateTable = exports.createTable = exports.fetchTable = void 0;
7
- const http_1 = __importDefault(require("../http"));
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");
8
5
  const HUBDB_API_PATH = 'cms/v3/hubdb';
9
- async function fetchTable(accountId, tableId) {
10
- return http_1.default.get(accountId, {
6
+ function fetchTables(accountId) {
7
+ return http_1.http.get(accountId, {
8
+ url: `${HUBDB_API_PATH}/tables`,
9
+ });
10
+ }
11
+ exports.fetchTables = fetchTables;
12
+ function fetchTable(accountId, tableId) {
13
+ return http_1.http.get(accountId, {
11
14
  url: `${HUBDB_API_PATH}/tables/${tableId}`,
12
15
  });
13
16
  }
14
17
  exports.fetchTable = fetchTable;
15
- async function createTable(accountId, schema) {
16
- return http_1.default.post(accountId, {
18
+ function createTable(accountId, schema) {
19
+ return http_1.http.post(accountId, {
17
20
  url: `${HUBDB_API_PATH}/tables`,
18
21
  data: schema,
19
22
  });
20
23
  }
21
24
  exports.createTable = createTable;
22
- async function updateTable(accountId, tableId, schema) {
23
- return http_1.default.patch(accountId, {
25
+ function updateTable(accountId, tableId, schema) {
26
+ return http_1.http.patch(accountId, {
24
27
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft`,
25
28
  data: schema,
26
29
  });
27
30
  }
28
31
  exports.updateTable = updateTable;
29
- async function publishTable(accountId, tableId) {
30
- return http_1.default.post(accountId, {
32
+ function publishTable(accountId, tableId) {
33
+ return http_1.http.post(accountId, {
31
34
  url: `${HUBDB_API_PATH}/tables/${tableId}/draft/publish`,
35
+ headers: {
36
+ 'Content-Type': 'application/json',
37
+ },
32
38
  });
33
39
  }
34
40
  exports.publishTable = publishTable;
35
- async function deleteTable(accountId, tableId) {
36
- return http_1.default.delete(accountId, {
41
+ function deleteTable(accountId, tableId) {
42
+ return http_1.http.delete(accountId, {
37
43
  url: `${HUBDB_API_PATH}/tables/${tableId}`,
38
44
  });
39
45
  }
40
46
  exports.deleteTable = deleteTable;
41
- async function createRows(accountId, tableId, rows) {
42
- return http_1.default.post(accountId, {
47
+ function createRows(accountId, tableId, rows) {
48
+ return http_1.http.post(accountId, {
43
49
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/create`,
44
50
  data: { inputs: rows },
45
51
  });
46
52
  }
47
53
  exports.createRows = createRows;
48
- async function fetchRows(accountId, tableId, query = {}) {
49
- return http_1.default.get(accountId, {
54
+ function fetchRows(accountId, tableId, params = {}) {
55
+ return http_1.http.get(accountId, {
50
56
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft`,
51
- query,
57
+ params,
52
58
  });
53
59
  }
54
60
  exports.fetchRows = fetchRows;
55
- async function deleteRows(accountId, tableId, rowIds) {
56
- return http_1.default.post(accountId, {
61
+ function deleteRows(accountId, tableId, rowIds) {
62
+ return http_1.http.post(accountId, {
57
63
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft/batch/purge`,
58
64
  data: { inputs: rowIds },
59
65
  });
@@ -1,5 +1,5 @@
1
- import { Data, QueryParams } from '../types/Http';
1
+ import { Data, HubSpotPromise, QueryParams } from '../types/Http';
2
2
  import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
3
- export declare function requestLighthouseScore(accountId: number, data?: Data): Promise<RequestLighthouseScoreResponse>;
4
- export declare function getLighthouseScoreStatus(accountId: number, query?: QueryParams): Promise<string>;
5
- export declare function getLighthouseScore(accountId: number, query?: QueryParams): Promise<GetLighthouseScoreResponse>;
3
+ export declare function requestLighthouseScore(accountId: number, data?: Data): HubSpotPromise<RequestLighthouseScoreResponse>;
4
+ export declare function getLighthouseScoreStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
5
+ export declare function getLighthouseScore(accountId: number, params?: QueryParams): HubSpotPromise<GetLighthouseScoreResponse>;
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getLighthouseScore = exports.getLighthouseScoreStatus = exports.requestLighthouseScore = void 0;
7
- const http_1 = __importDefault(require("../http"));
4
+ const http_1 = require("../http");
8
5
  const LIGHTHOUSE_SCORE_API_BASE = 'quality-engine/v1/lighthouse';
9
- async function requestLighthouseScore(accountId, data = {}) {
10
- return http_1.default.post(accountId, {
6
+ function requestLighthouseScore(accountId, data = {}) {
7
+ return http_1.http.post(accountId, {
11
8
  url: `${LIGHTHOUSE_SCORE_API_BASE}/request`,
12
9
  data,
13
10
  });
14
11
  }
15
12
  exports.requestLighthouseScore = requestLighthouseScore;
16
- async function getLighthouseScoreStatus(accountId, query = {}) {
17
- return http_1.default.get(accountId, {
13
+ function getLighthouseScoreStatus(accountId, params = {}) {
14
+ return http_1.http.get(accountId, {
18
15
  url: `${LIGHTHOUSE_SCORE_API_BASE}/status`,
19
- query,
16
+ params,
20
17
  });
21
18
  }
22
19
  exports.getLighthouseScoreStatus = getLighthouseScoreStatus;
23
- async function getLighthouseScore(accountId, query = {}) {
24
- return http_1.default.get(accountId, {
20
+ function getLighthouseScore(accountId, params = {}) {
21
+ return http_1.http.get(accountId, {
25
22
  url: `${LIGHTHOUSE_SCORE_API_BASE}/scores`,
26
- query,
23
+ params,
27
24
  });
28
25
  }
29
26
  exports.getLighthouseScore = getLighthouseScore;
@@ -1,17 +1,9 @@
1
1
  import { Environment } from '../types/Config';
2
- import { ScopeData } from '../types/Accounts';
3
- type AccessTokenResponse = {
4
- hubId: number;
5
- userId: number;
6
- oauthAccessToken: string;
7
- expiresAtMillis: number;
8
- enabledFeatures?: {
9
- [key: string]: number;
10
- };
11
- scopeGroups: Array<string>;
12
- encodedOAuthRefreshToken: string;
13
- hubName: string;
14
- };
15
- export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): Promise<AccessTokenResponse>;
16
- export declare function fetchScopeData(accountId: number, scopeGroup: string): Promise<ScopeData>;
17
- export {};
2
+ import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts';
3
+ import { PublicAppInstallationData } from '../types/Apps';
4
+ import { HubSpotPromise } from '../types/Http';
5
+ export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
6
+ export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
7
+ export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
8
+ export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
9
+ export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any>>;
@@ -3,14 +3,13 @@ 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.fetchScopeData = exports.fetchAccessToken = void 0;
6
+ exports.fetchEnabledFeatures = exports.fetchAppInstallationData = exports.fetchScopeAuthorizationData = exports.fetchScopeData = exports.fetchAccessToken = void 0;
7
7
  const getAxiosConfig_1 = require("../http/getAxiosConfig");
8
- const http_1 = __importDefault(require("../http"));
8
+ const http_1 = require("../http");
9
9
  const environments_1 = require("../constants/environments");
10
10
  const axios_1 = __importDefault(require("axios"));
11
11
  const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
12
- async function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
13
- const query = portalId ? { portalId } : {};
12
+ function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
14
13
  const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
15
14
  env,
16
15
  localHostOverride: true,
@@ -18,21 +17,43 @@ async function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONM
18
17
  data: {
19
18
  encodedOAuthRefreshToken: personalAccessKey,
20
19
  },
21
- params: query,
20
+ params: portalId ? { portalId } : {},
22
21
  });
23
- const { data } = await (0, axios_1.default)({
22
+ return (0, axios_1.default)({
24
23
  ...axiosConfig,
25
24
  method: 'post',
26
25
  });
27
- return data;
28
26
  }
29
27
  exports.fetchAccessToken = fetchAccessToken;
30
- async function fetchScopeData(accountId, scopeGroup) {
31
- return http_1.default.get(accountId, {
32
- url: `localdevauth/v1/auth/check-scopes`,
33
- query: {
34
- scopeGroup,
35
- },
28
+ function fetchScopeData(accountId, scopeGroup) {
29
+ return http_1.http.get(accountId, {
30
+ url: `${LOCALDEVAUTH_API_AUTH_PATH}/check-scopes`,
31
+ params: { scopeGroup },
36
32
  });
37
33
  }
38
34
  exports.fetchScopeData = fetchScopeData;
35
+ async function fetchScopeAuthorizationData(accountId) {
36
+ return http_1.http.get(accountId, {
37
+ url: `${LOCALDEVAUTH_API_AUTH_PATH}/scope-groups/authorized`,
38
+ });
39
+ }
40
+ exports.fetchScopeAuthorizationData = fetchScopeAuthorizationData;
41
+ function fetchAppInstallationData(portalId, projectId, appUid, requiredScopeGroups, optionalScopeGroups = []) {
42
+ return http_1.http.post(portalId, {
43
+ url: `${LOCALDEVAUTH_API_AUTH_PATH}/install-info`,
44
+ data: {
45
+ portalId,
46
+ projectId,
47
+ sourceId: appUid,
48
+ requiredScopeGroups,
49
+ optionalScopeGroups,
50
+ },
51
+ });
52
+ }
53
+ exports.fetchAppInstallationData = fetchAppInstallationData;
54
+ async function fetchEnabledFeatures(accountId) {
55
+ return http_1.http.get(accountId, {
56
+ url: `${LOCALDEVAUTH_API_AUTH_PATH}/enabled-features`,
57
+ });
58
+ }
59
+ exports.fetchEnabledFeatures = fetchEnabledFeatures;
@@ -1,5 +1,5 @@
1
- import { Data, QueryParams } from '../types/Http';
1
+ import { Data, HubSpotPromise, QueryParams } from '../types/Http';
2
2
  import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
3
- export declare function requestValidation(accountId: number, data?: Data): Promise<number>;
4
- export declare function getValidationStatus(accountId: number, query?: QueryParams): Promise<string>;
5
- export declare function getValidationResults(accountId: number, query?: QueryParams): Promise<GetValidationResultsResponse>;
3
+ export declare function requestValidation(accountId: number, data?: Data): HubSpotPromise<number>;
4
+ export declare function getValidationStatus(accountId: number, params?: QueryParams): HubSpotPromise<string>;
5
+ export declare function getValidationResults(accountId: number, params?: QueryParams): HubSpotPromise<GetValidationResultsResponse>;
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.getValidationResults = exports.getValidationStatus = exports.requestValidation = void 0;
7
- const http_1 = __importDefault(require("../http"));
4
+ const http_1 = require("../http");
8
5
  const VALIDATION_API_BASE = 'quality-engine/v1/validation';
9
6
  function requestValidation(accountId, data = {}) {
10
- return http_1.default.post(accountId, {
7
+ return http_1.http.post(accountId, {
11
8
  url: `${VALIDATION_API_BASE}/request`,
12
9
  data,
13
10
  });
14
11
  }
15
12
  exports.requestValidation = requestValidation;
16
- function getValidationStatus(accountId, query = {}) {
17
- return http_1.default.get(accountId, {
13
+ function getValidationStatus(accountId, params = {}) {
14
+ return http_1.http.get(accountId, {
18
15
  url: `${VALIDATION_API_BASE}/status`,
19
- query,
16
+ params,
20
17
  });
21
18
  }
22
19
  exports.getValidationStatus = getValidationStatus;
23
- function getValidationResults(accountId, query = {}) {
24
- return http_1.default.get(accountId, {
20
+ function getValidationResults(accountId, params = {}) {
21
+ return http_1.http.get(accountId, {
25
22
  url: `${VALIDATION_API_BASE}/results`,
26
- query,
23
+ params,
27
24
  });
28
25
  }
29
26
  exports.getValidationResults = getValidationResults;
package/api/projects.d.ts CHANGED
@@ -1,27 +1,34 @@
1
1
  /// <reference types="node" />
2
- import { QueryParams } from '../types/Http';
3
- import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings } from '../types/Project';
2
+ import { HubSpotPromise, QueryParams } from '../types/Http';
3
+ import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } from '../types/Project';
4
4
  import { Build, FetchProjectBuildsResponse } from '../types/Build';
5
- import { ComponentMetadataResponse, ComponentStructureResponse } from '../types/ComponentStructure';
5
+ import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure';
6
6
  import { Deploy, ProjectDeployResponse } from '../types/Deploy';
7
- export declare function fetchProjects(accountId: number): Promise<FetchProjectResponse>;
8
- export declare function createProject(accountId: number, name: string): Promise<Project>;
9
- export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string): Promise<UploadProjectResponse>;
10
- export declare function fetchProject(accountId: number, projectName: string): Promise<Project>;
11
- export declare function downloadProject(accountId: number, projectName: string, buildId: number): Promise<Buffer>;
12
- export declare function deleteProject(accountId: number, projectName: string): Promise<void>;
13
- type FetchPlatformVersionResponse = {
14
- defaultPlatformVersion: string;
15
- activePlatformVersions: Array<string>;
16
- };
17
- export declare function fetchPlatformVersions(accountId: number): Promise<FetchPlatformVersionResponse>;
18
- export declare function fetchProjectBuilds(accountId: number, projectName: string, query: QueryParams): Promise<FetchProjectBuildsResponse>;
19
- export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): Promise<Build>;
20
- export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): Promise<ComponentStructureResponse>;
21
- export declare function deployProject(accountId: number, projectName: string, buildId: number): Promise<ProjectDeployResponse>;
22
- export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): Promise<Deploy>;
23
- export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): Promise<ComponentStructureResponse>;
24
- export declare function fetchProjectSettings(accountId: number, projectName: string): Promise<ProjectSettings>;
25
- export declare function fetchDeployComponentsMetadata(accountId: number, projectId: number): Promise<ComponentMetadataResponse>;
26
- export declare function cancelStagedBuild(accountId: number, projectName: string): Promise<void>;
27
- export {};
7
+ import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration';
8
+ export declare function fetchProjects(accountId: number): HubSpotPromise<FetchProjectResponse>;
9
+ export declare function createProject(accountId: number, name: string): HubSpotPromise<Project>;
10
+ export declare function uploadProject(accountId: number, projectName: string, projectFile: string, uploadMessage: string, platformVersion?: string, intermediateRepresentation?: unknown): HubSpotPromise<UploadProjectResponse | UploadIRResponse>;
11
+ export declare function fetchProject(accountId: number, projectName: string): HubSpotPromise<Project>;
12
+ export declare function fetchProjectComponentsMetadata(accountId: number, projectId: number): HubSpotPromise<ProjectComponentsMetadata>;
13
+ export declare function downloadProject(accountId: number, projectName: string, buildId: number): HubSpotPromise<Buffer>;
14
+ export declare function deleteProject(accountId: number, projectName: string): HubSpotPromise<void>;
15
+ export declare function fetchPlatformVersions(accountId: number): HubSpotPromise<FetchPlatformVersionResponse>;
16
+ export declare function fetchProjectBuilds(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchProjectBuildsResponse>;
17
+ export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): HubSpotPromise<Build>;
18
+ export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): HubSpotPromise<ComponentStructureResponse>;
19
+ export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean): HubSpotPromise<ProjectDeployResponse>;
20
+ export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): HubSpotPromise<Deploy>;
21
+ export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): HubSpotPromise<ComponentStructureResponse>;
22
+ export declare function fetchProjectSettings(accountId: number, projectName: string): HubSpotPromise<ProjectSettings>;
23
+ export declare function provisionBuild(accountId: number, projectName: string, platformVersion?: string): HubSpotPromise<Build>;
24
+ export declare function queueBuild(accountId: number, projectName: string, platformVersion?: string): HubSpotPromise<void>;
25
+ export declare function uploadFileToBuild(accountId: number, projectName: string, filePath: string, path: string): HubSpotPromise<void>;
26
+ export declare function deleteFileFromBuild(accountId: number, projectName: string, path: string): HubSpotPromise<void>;
27
+ export declare function cancelStagedBuild(accountId: number, projectName: string): HubSpotPromise<void>;
28
+ export declare function fetchBuildWarnLogs(accountId: number, projectName: string, buildId: number): HubSpotPromise<WarnLogsResponse>;
29
+ export declare function fetchDeployWarnLogs(accountId: number, projectName: string, deployId: number): HubSpotPromise<WarnLogsResponse>;
30
+ export declare function migrateApp(accountId: number, appId: number, projectName: string): HubSpotPromise<MigrateAppResponse>;
31
+ export declare function checkMigrationStatus(accountId: number, id: number): HubSpotPromise<PollAppResponse>;
32
+ export declare function cloneApp(accountId: number, appId: number): HubSpotPromise<CloneAppResponse>;
33
+ export declare function checkCloneStatus(accountId: number, exportId: number): HubSpotPromise<CloneAppResponse>;
34
+ export declare function downloadClonedProject(accountId: number, exportId: number): HubSpotPromise<Buffer>;