@hubspot/local-dev-lib 0.3.2 → 0.3.4

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.
@@ -1,3 +1,4 @@
1
+ import { QueryParams } from '../types/Http';
1
2
  type FetchThemesResponse = {
2
3
  objects: Array<{
3
4
  theme: {
@@ -5,7 +6,7 @@ type FetchThemesResponse = {
5
6
  };
6
7
  }>;
7
8
  };
8
- export declare function fetchThemes(accountId: number, query?: {}): Promise<FetchThemesResponse>;
9
+ export declare function fetchThemes(accountId: number, params?: QueryParams): Promise<FetchThemesResponse>;
9
10
  type FetchBuiltinMappingResponse = {
10
11
  [key: string]: string;
11
12
  };
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.fetchBuiltinMapping = exports.fetchThemes = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const DESIGN_MANAGER_API_PATH = 'designmanager/v1';
9
- async function fetchThemes(accountId, query = {}) {
9
+ async function fetchThemes(accountId, params = {}) {
10
10
  return http_1.default.get(accountId, {
11
11
  url: `${DESIGN_MANAGER_API_PATH}/themes/combined`,
12
- query,
12
+ params,
13
13
  });
14
14
  }
15
15
  exports.fetchThemes = fetchThemes;
@@ -0,0 +1,6 @@
1
+ import { DeveloperTestAccount, FetchDeveloperTestAccountsResponse } from '../types/developerTestAccounts';
2
+ import { Environment } from '../types/Config';
3
+ export declare function fetchDeveloperTestAccounts(accountId: number): Promise<FetchDeveloperTestAccountsResponse>;
4
+ export declare function createDeveloperTestAccount(accountId: number, accountName: string): Promise<DeveloperTestAccount>;
5
+ export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): Promise<void>;
6
+ export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): Promise<DeveloperTestAccount>;
@@ -0,0 +1,49 @@
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.fetchDeveloperTestAccountData = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = exports.fetchDeveloperTestAccounts = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const http_1 = __importDefault(require("../http"));
9
+ const getAxiosConfig_1 = require("../http/getAxiosConfig");
10
+ const environments_1 = require("../constants/environments");
11
+ const api_1 = require("../constants/api");
12
+ const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
13
+ async function fetchDeveloperTestAccounts(accountId) {
14
+ return http_1.default.get(accountId, {
15
+ url: TEST_ACCOUNTS_API_PATH,
16
+ });
17
+ }
18
+ exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
19
+ async function createDeveloperTestAccount(accountId, accountName) {
20
+ return http_1.default.post(accountId, {
21
+ url: TEST_ACCOUNTS_API_PATH,
22
+ data: { accountName, generatePersonalAccessKey: true },
23
+ timeout: api_1.SANDBOX_TIMEOUT,
24
+ });
25
+ }
26
+ exports.createDeveloperTestAccount = createDeveloperTestAccount;
27
+ async function deleteDeveloperTestAccount(accountId, testAccountId) {
28
+ return http_1.default.delete(accountId, {
29
+ url: `${TEST_ACCOUNTS_API_PATH}/${testAccountId}`,
30
+ });
31
+ }
32
+ exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
33
+ async function fetchDeveloperTestAccountData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
34
+ const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
35
+ env,
36
+ url: `${TEST_ACCOUNTS_API_PATH}/self`,
37
+ params: { portalId: accountId },
38
+ });
39
+ const reqWithToken = {
40
+ ...axiosConfig,
41
+ headers: {
42
+ ...axiosConfig.headers,
43
+ Authorization: `Bearer ${accessToken}`,
44
+ },
45
+ };
46
+ const { data } = await (0, axios_1.default)(reqWithToken);
47
+ return data;
48
+ }
49
+ exports.fetchDeveloperTestAccountData = fetchDeveloperTestAccountData;
@@ -42,7 +42,7 @@ exports.fetchStat = fetchStat;
42
42
  async function fetchFiles(accountId, folderId, offset, archived) {
43
43
  return http_1.default.get(accountId, {
44
44
  url: `${FILE_MANAGER_V2_API_PATH}/files/`,
45
- query: {
45
+ params: {
46
46
  hidden: 0,
47
47
  offset: offset,
48
48
  folder_id: folderId,
@@ -54,7 +54,7 @@ exports.fetchFiles = fetchFiles;
54
54
  async function fetchFolders(accountId, folderId) {
55
55
  return http_1.default.get(accountId, {
56
56
  url: `${FILE_MANAGER_V2_API_PATH}/folders/`,
57
- query: {
57
+ params: {
58
58
  hidden: 0,
59
59
  parent_folder_id: folderId,
60
60
  },
@@ -1,7 +1,7 @@
1
1
  import { QueryParams } from '../types/Http';
2
2
  import { GetBuildStatusResponse, GetRoutesResponse } from '../types/Functions';
3
3
  export declare function getRoutes(accountId: number): Promise<GetRoutesResponse>;
4
- export declare function getFunctionLogs(accountId: number, route: string, query?: QueryParams): Promise<unknown>;
4
+ export declare function getFunctionLogs(accountId: number, route: string, params?: QueryParams): Promise<unknown>;
5
5
  export declare function getLatestFunctionLog(accountId: number, route: string): Promise<unknown>;
6
6
  export declare function buildPackage(accountId: number, folderPath: string): Promise<string>;
7
7
  export declare function getBuildStatus(accountId: number, buildId: number): Promise<GetBuildStatusResponse>;
package/api/functions.js CHANGED
@@ -12,11 +12,11 @@ async function getRoutes(accountId) {
12
12
  });
13
13
  }
14
14
  exports.getRoutes = getRoutes;
15
- async function getFunctionLogs(accountId, route, query = {}) {
16
- const { limit = 5 } = query;
15
+ async function getFunctionLogs(accountId, route, params = {}) {
16
+ const { limit = 5 } = params;
17
17
  return http_1.default.get(accountId, {
18
18
  url: `${FUNCTION_API_PATH}/results/by-route/${encodeURIComponent(route)}`,
19
- query: { ...query, limit },
19
+ params: { ...params, limit },
20
20
  });
21
21
  }
22
22
  exports.getFunctionLogs = getFunctionLogs;
package/api/hubdb.d.ts CHANGED
@@ -6,5 +6,5 @@ export declare function updateTable(accountId: number, tableId: string, schema:
6
6
  export declare function publishTable(accountId: number, tableId: string): Promise<Table>;
7
7
  export declare function deleteTable(accountId: number, tableId: string): Promise<void>;
8
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>;
9
+ export declare function fetchRows(accountId: number, tableId: string, params?: QueryParams): Promise<FetchRowsResponse>;
10
10
  export declare function deleteRows(accountId: number, tableId: string, rowIds: Array<string>): Promise<void>;
package/api/hubdb.js CHANGED
@@ -48,10 +48,10 @@ async function createRows(accountId, tableId, rows) {
48
48
  });
49
49
  }
50
50
  exports.createRows = createRows;
51
- async function fetchRows(accountId, tableId, query = {}) {
51
+ async function fetchRows(accountId, tableId, params = {}) {
52
52
  return http_1.default.get(accountId, {
53
53
  url: `${HUBDB_API_PATH}/tables/${tableId}/rows/draft`,
54
- query,
54
+ params,
55
55
  });
56
56
  }
57
57
  exports.fetchRows = fetchRows;
@@ -1,5 +1,5 @@
1
1
  import { Data, QueryParams } from '../types/Http';
2
2
  import { GetLighthouseScoreResponse, RequestLighthouseScoreResponse } from '../types/Lighthouse';
3
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>;
4
+ export declare function getLighthouseScoreStatus(accountId: number, params?: QueryParams): Promise<string>;
5
+ export declare function getLighthouseScore(accountId: number, params?: QueryParams): Promise<GetLighthouseScoreResponse>;
@@ -13,17 +13,17 @@ async function requestLighthouseScore(accountId, data = {}) {
13
13
  });
14
14
  }
15
15
  exports.requestLighthouseScore = requestLighthouseScore;
16
- async function getLighthouseScoreStatus(accountId, query = {}) {
16
+ async function getLighthouseScoreStatus(accountId, params = {}) {
17
17
  return http_1.default.get(accountId, {
18
18
  url: `${LIGHTHOUSE_SCORE_API_BASE}/status`,
19
- query,
19
+ params,
20
20
  });
21
21
  }
22
22
  exports.getLighthouseScoreStatus = getLighthouseScoreStatus;
23
- async function getLighthouseScore(accountId, query = {}) {
23
+ async function getLighthouseScore(accountId, params = {}) {
24
24
  return http_1.default.get(accountId, {
25
25
  url: `${LIGHTHOUSE_SCORE_API_BASE}/scores`,
26
- query,
26
+ params,
27
27
  });
28
28
  }
29
29
  exports.getLighthouseScore = getLighthouseScore;
@@ -10,7 +10,6 @@ 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
12
  async function fetchAccessToken(personalAccessKey, env = environments_1.ENVIRONMENTS.PROD, portalId) {
13
- const query = portalId ? { portalId } : {};
14
13
  const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
15
14
  env,
16
15
  localHostOverride: true,
@@ -18,7 +17,7 @@ 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
22
  const { data } = await (0, axios_1.default)({
24
23
  ...axiosConfig,
@@ -30,9 +29,7 @@ exports.fetchAccessToken = fetchAccessToken;
30
29
  async function fetchScopeData(accountId, scopeGroup) {
31
30
  return http_1.default.get(accountId, {
32
31
  url: `localdevauth/v1/auth/check-scopes`,
33
- query: {
34
- scopeGroup,
35
- },
32
+ params: { scopeGroup },
36
33
  });
37
34
  }
38
35
  exports.fetchScopeData = fetchScopeData;
@@ -1,5 +1,5 @@
1
1
  import { Data, QueryParams } from '../types/Http';
2
2
  import { GetValidationResultsResponse } from '../types/MarketplaceValidation';
3
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>;
4
+ export declare function getValidationStatus(accountId: number, params?: QueryParams): Promise<string>;
5
+ export declare function getValidationResults(accountId: number, params?: QueryParams): Promise<GetValidationResultsResponse>;
@@ -13,17 +13,17 @@ function requestValidation(accountId, data = {}) {
13
13
  });
14
14
  }
15
15
  exports.requestValidation = requestValidation;
16
- function getValidationStatus(accountId, query = {}) {
16
+ function getValidationStatus(accountId, params = {}) {
17
17
  return http_1.default.get(accountId, {
18
18
  url: `${VALIDATION_API_BASE}/status`,
19
- query,
19
+ params,
20
20
  });
21
21
  }
22
22
  exports.getValidationStatus = getValidationStatus;
23
- function getValidationResults(accountId, query = {}) {
23
+ function getValidationResults(accountId, params = {}) {
24
24
  return http_1.default.get(accountId, {
25
25
  url: `${VALIDATION_API_BASE}/results`,
26
- query,
26
+ params,
27
27
  });
28
28
  }
29
29
  exports.getValidationResults = getValidationResults;
package/api/projects.d.ts CHANGED
@@ -15,7 +15,7 @@ type FetchPlatformVersionResponse = {
15
15
  activePlatformVersions: Array<string>;
16
16
  };
17
17
  export declare function fetchPlatformVersions(accountId: number): Promise<FetchPlatformVersionResponse>;
18
- export declare function fetchProjectBuilds(accountId: number, projectName: string, query: QueryParams): Promise<FetchProjectBuildsResponse>;
18
+ export declare function fetchProjectBuilds(accountId: number, projectName: string, params?: QueryParams): Promise<FetchProjectBuildsResponse>;
19
19
  export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): Promise<Build>;
20
20
  export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): Promise<ComponentStructureResponse>;
21
21
  export declare function deployProject(accountId: number, projectName: string, buildId: number): Promise<ProjectDeployResponse>;
@@ -23,5 +23,9 @@ export declare function getDeployStatus(accountId: number, projectName: string,
23
23
  export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): Promise<ComponentStructureResponse>;
24
24
  export declare function fetchProjectSettings(accountId: number, projectName: string): Promise<ProjectSettings>;
25
25
  export declare function fetchDeployComponentsMetadata(accountId: number, projectId: number): Promise<ComponentMetadataResponse>;
26
+ export declare function provisionBuild(accountId: number, projectName: string, platformVersion?: string): Promise<Build>;
27
+ export declare function queueBuild(accountId: number, projectName: string, platformVersion?: string): Promise<void>;
28
+ export declare function uploadFileToBuild(accountId: number, projectName: string, filePath: string, path: string): Promise<void>;
29
+ export declare function deleteFileFromBuild(accountId: number, projectName: string, path: string): Promise<void>;
26
30
  export declare function cancelStagedBuild(accountId: number, projectName: string): Promise<void>;
27
31
  export {};
package/api/projects.js CHANGED
@@ -3,7 +3,7 @@ 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.cancelStagedBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
6
+ exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchDeployComponentsMetadata = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
7
7
  const http_1 = __importDefault(require("../http"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const PROJECTS_API_PATH = 'dfs/v1/projects';
@@ -49,7 +49,7 @@ exports.fetchProject = fetchProject;
49
49
  async function downloadProject(accountId, projectName, buildId) {
50
50
  return http_1.default.get(accountId, {
51
51
  url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/${buildId}/archive-full`,
52
- encoding: null,
52
+ responseType: 'arraybuffer',
53
53
  headers: { accept: 'application/zip', 'Content-Type': 'application/json' },
54
54
  });
55
55
  }
@@ -66,10 +66,10 @@ async function fetchPlatformVersions(accountId) {
66
66
  });
67
67
  }
68
68
  exports.fetchPlatformVersions = fetchPlatformVersions;
69
- async function fetchProjectBuilds(accountId, projectName, query) {
69
+ async function fetchProjectBuilds(accountId, projectName, params = {}) {
70
70
  return http_1.default.get(accountId, {
71
71
  url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds`,
72
- query,
72
+ params,
73
73
  });
74
74
  }
75
75
  exports.fetchProjectBuilds = fetchProjectBuilds;
@@ -119,9 +119,43 @@ async function fetchDeployComponentsMetadata(accountId, projectId) {
119
119
  });
120
120
  }
121
121
  exports.fetchDeployComponentsMetadata = fetchDeployComponentsMetadata;
122
+ async function provisionBuild(accountId, projectName, platformVersion) {
123
+ return http_1.default.post(accountId, {
124
+ url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/provision`,
125
+ params: { platformVersion },
126
+ headers: { 'Content-Type': 'application/json' },
127
+ timeout: 50000,
128
+ });
129
+ }
130
+ exports.provisionBuild = provisionBuild;
131
+ async function queueBuild(accountId, projectName, platformVersion) {
132
+ return http_1.default.post(accountId, {
133
+ url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/queue`,
134
+ params: { platformVersion },
135
+ headers: { 'Content-Type': 'application/json' },
136
+ });
137
+ }
138
+ exports.queueBuild = queueBuild;
139
+ async function uploadFileToBuild(accountId, projectName, filePath, path) {
140
+ return http_1.default.put(accountId, {
141
+ url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/files/${encodeURIComponent(path)}`,
142
+ data: {
143
+ file: fs_1.default.createReadStream(filePath),
144
+ },
145
+ headers: { 'Content-Type': 'multipart/form-data' },
146
+ });
147
+ }
148
+ exports.uploadFileToBuild = uploadFileToBuild;
149
+ async function deleteFileFromBuild(accountId, projectName, path) {
150
+ return http_1.default.delete(accountId, {
151
+ url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/files/${encodeURIComponent(path)}`,
152
+ });
153
+ }
154
+ exports.deleteFileFromBuild = deleteFileFromBuild;
122
155
  async function cancelStagedBuild(accountId, projectName) {
123
156
  return http_1.default.post(accountId, {
124
157
  url: `${PROJECTS_API_PATH}/${encodeURIComponent(projectName)}/builds/staged/cancel`,
158
+ headers: { 'Content-Type': 'application/json' },
125
159
  });
126
160
  }
127
161
  exports.cancelStagedBuild = cancelStagedBuild;
@@ -3,4 +3,4 @@ import { SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse } from '../
3
3
  export declare function createSandbox(accountId: number, name: string, type: 1 | 2): Promise<SandboxResponse>;
4
4
  export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): Promise<void>;
5
5
  export declare function getSandboxUsageLimits(parentAccountId: number): Promise<SandboxUsageLimitsResponse>;
6
- export declare function fetchSandboxHubData(accessToken: string, portalId: number, env?: Environment): Promise<SandboxHubData>;
6
+ export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): Promise<SandboxHubData>;
@@ -31,11 +31,11 @@ async function getSandboxUsageLimits(parentAccountId) {
31
31
  });
32
32
  }
33
33
  exports.getSandboxUsageLimits = getSandboxUsageLimits;
34
- async function fetchSandboxHubData(accessToken, portalId, env = environments_1.ENVIRONMENTS.PROD) {
34
+ async function fetchSandboxHubData(accessToken, accountId, env = environments_1.ENVIRONMENTS.PROD) {
35
35
  const axiosConfig = (0, getAxiosConfig_1.getAxiosConfig)({
36
36
  env,
37
37
  url: `${SANDBOX_API_PATH}/self`,
38
- params: { portalId },
38
+ params: { portalId: accountId },
39
39
  });
40
40
  const reqWithToken = {
41
41
  ...axiosConfig,
@@ -130,6 +130,13 @@ class CLIConfiguration {
130
130
  }
131
131
  accountNamesMap[accountConfig.name] = true;
132
132
  }
133
+ if (!accountConfig.accountType) {
134
+ this.updateAccount({
135
+ ...accountConfig,
136
+ accountId: accountConfig.accountId,
137
+ accountType: this.getAccountType(undefined, accountConfig.sandboxAccountType),
138
+ });
139
+ }
133
140
  accountIdsMap[accountConfig.accountId] = true;
134
141
  return true;
135
142
  });
@@ -225,7 +232,7 @@ class CLIConfiguration {
225
232
  }
226
233
  if (typeof sandboxAccountType === 'string') {
227
234
  if (sandboxAccountType.toUpperCase() === 'DEVELOPER') {
228
- return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX;
235
+ return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
229
236
  }
230
237
  if (sandboxAccountType.toUpperCase() === 'STANDARD') {
231
238
  return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
@@ -249,7 +256,7 @@ class CLIConfiguration {
249
256
  return null;
250
257
  }
251
258
  const currentAccountConfig = this.getAccount(accountId);
252
- let auth = {};
259
+ let auth = (currentAccountConfig && currentAccountConfig.auth) || {};
253
260
  if (clientId || clientSecret || scopes || tokenInfo) {
254
261
  auth = {
255
262
  ...(currentAccountConfig ? currentAccountConfig.auth : {}),
@@ -105,6 +105,14 @@ function validateConfig() {
105
105
  }
106
106
  accountNamesHash[cfg.name] = cfg;
107
107
  }
108
+ if (!cfg.accountType) {
109
+ updateAccountConfig({
110
+ ...cfg,
111
+ portalId: accountId,
112
+ accountType: getAccountType(undefined, cfg.sandboxAccountType),
113
+ });
114
+ writeConfig();
115
+ }
108
116
  accountIdsHash[accountId] = cfg;
109
117
  return true;
110
118
  });
@@ -294,7 +302,7 @@ function getAccountType(accountType, sandboxAccountType) {
294
302
  }
295
303
  if (typeof sandboxAccountType === 'string') {
296
304
  if (sandboxAccountType.toUpperCase() === 'DEVELOPER') {
297
- return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX;
305
+ return config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
298
306
  }
299
307
  if (sandboxAccountType.toUpperCase() === 'STANDARD') {
300
308
  return config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
@@ -360,7 +368,7 @@ function removeSandboxAccountFromConfig(nameOrId) {
360
368
  }
361
369
  const accountConfig = getAccountConfig(accountId);
362
370
  const accountType = getAccountType(accountConfig?.accountType, accountConfig?.sandboxAccountType);
363
- const isSandboxAccount = accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX ||
371
+ const isSandboxAccount = accountType === config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX ||
364
372
  accountType === config_1.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
365
373
  if (!isSandboxAccount)
366
374
  return promptDefaultAccount;
@@ -387,7 +395,7 @@ function updateAccountConfig(configOptions) {
387
395
  }
388
396
  const config = getAndLoadConfigIfNeeded();
389
397
  const accountConfig = getAccountConfig(portalId);
390
- let auth = undefined;
398
+ let auth = accountConfig && accountConfig.auth;
391
399
  if (clientId || clientSecret || scopes || tokenInfo) {
392
400
  auth = {
393
401
  ...(accountConfig ? accountConfig.auth : {}),
@@ -3,9 +3,16 @@ export declare const HUBSPOT_CONFIGURATION_FOLDER = ".hubspot";
3
3
  export declare const HUBSPOT_CONFIGURATION_FILE = "config.yml";
4
4
  export declare const MIN_HTTP_TIMEOUT = 3000;
5
5
  export declare const HUBSPOT_ACCOUNT_TYPES: {
6
- readonly DEVELOPER_SANDBOX: "DEVELOPER_SANDBOX";
6
+ readonly DEVELOPMENT_SANDBOX: "DEVELOPMENT_SANDBOX";
7
7
  readonly DEVELOPER_TEST: "DEVELOPER_TEST";
8
- readonly DEVELOPER: "DEVELOPER";
8
+ readonly APP_DEVELOPER: "APP_DEVELOPER";
9
9
  readonly STANDARD_SANDBOX: "STANDARD_SANDBOX";
10
10
  readonly STANDARD: "STANDARD";
11
11
  };
12
+ export declare const HUBSPOT_ACCOUNT_TYPE_STRINGS: {
13
+ readonly DEVELOPMENT_SANDBOX: string;
14
+ readonly STANDARD_SANDBOX: string;
15
+ readonly DEVELOPER_TEST: string;
16
+ readonly APP_DEVELOPER: string;
17
+ readonly STANDARD: string;
18
+ };
@@ -1,14 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
3
+ exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = exports.HUBSPOT_ACCOUNT_TYPES = exports.MIN_HTTP_TIMEOUT = exports.HUBSPOT_CONFIGURATION_FILE = exports.HUBSPOT_CONFIGURATION_FOLDER = exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = void 0;
4
+ const lang_1 = require("../utils/lang");
4
5
  exports.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME = 'hubspot.config.yml';
5
6
  exports.HUBSPOT_CONFIGURATION_FOLDER = '.hubspot';
6
7
  exports.HUBSPOT_CONFIGURATION_FILE = 'config.yml';
7
8
  exports.MIN_HTTP_TIMEOUT = 3000;
8
9
  exports.HUBSPOT_ACCOUNT_TYPES = {
9
- DEVELOPER_SANDBOX: 'DEVELOPER_SANDBOX',
10
+ DEVELOPMENT_SANDBOX: 'DEVELOPMENT_SANDBOX',
10
11
  DEVELOPER_TEST: 'DEVELOPER_TEST',
11
- DEVELOPER: 'DEVELOPER',
12
+ APP_DEVELOPER: 'APP_DEVELOPER',
12
13
  STANDARD_SANDBOX: 'STANDARD_SANDBOX',
13
14
  STANDARD: 'STANDARD',
14
15
  };
16
+ exports.HUBSPOT_ACCOUNT_TYPE_STRINGS = {
17
+ DEVELOPMENT_SANDBOX: (0, lang_1.i18n)('lib.accountTypes.developmentSandbox'),
18
+ STANDARD_SANDBOX: (0, lang_1.i18n)('lib.accountTypes.standardSandbox'),
19
+ DEVELOPER_TEST: (0, lang_1.i18n)('lib.accountTypes.developerTest'),
20
+ APP_DEVELOPER: (0, lang_1.i18n)('lib.accountTypes.appDeveloper'),
21
+ STANDARD: (0, lang_1.i18n)('lib.accountTypes.standard'),
22
+ };
package/http/index.js CHANGED
@@ -84,8 +84,8 @@ function addQueryParams(configOptions, queryParams = {}) {
84
84
  };
85
85
  }
86
86
  async function getRequest(accountId, options) {
87
- const { query, ...rest } = options;
88
- const axiosConfig = addQueryParams(rest, query);
87
+ const { params, ...rest } = options;
88
+ const axiosConfig = addQueryParams(rest, params);
89
89
  const configWithAuth = await withAuth(accountId, axiosConfig);
90
90
  const { data } = await (0, axios_1.default)(configWithAuth);
91
91
  return data;
@@ -112,8 +112,8 @@ async function deleteRequest(accountId, options) {
112
112
  }
113
113
  function createGetRequestStream(contentType) {
114
114
  return async (accountId, options, destPath) => {
115
- const { query, ...rest } = options;
116
- const axiosConfig = addQueryParams(rest, query);
115
+ const { params, ...rest } = options;
116
+ const axiosConfig = addQueryParams(rest, params);
117
117
  // eslint-disable-next-line no-async-promise-executor
118
118
  return new Promise(async (resolve, reject) => {
119
119
  try {
package/lang/en.json CHANGED
@@ -238,6 +238,13 @@
238
238
  "invalidFetchFolderRequest": "Invalid request for folder: \"{{ src }}\"",
239
239
  "incompleteFetch": "Not all files in folder \"{{ src }}\" were successfully fetched. Re-run the last command to try again"
240
240
  }
241
+ },
242
+ "accountTypes": {
243
+ "developmentSandbox": "development sandbox",
244
+ "standardSandbox": "standard sandbox",
245
+ "developerTest": "developer test account",
246
+ "appDeveloper": "app developer account",
247
+ "standard": "production account"
241
248
  }
242
249
  },
243
250
  "config": {
package/lang/lang/en.json CHANGED
@@ -238,6 +238,13 @@
238
238
  "invalidFetchFolderRequest": "Invalid request for folder: \"{{ src }}\"",
239
239
  "incompleteFetch": "Not all files in folder \"{{ src }}\" were successfully fetched. Re-run the last command to try again"
240
240
  }
241
+ },
242
+ "accountTypes": {
243
+ "developmentSandbox": "development sandbox",
244
+ "standardSandbox": "standard sandbox",
245
+ "developerTest": "developer test account",
246
+ "appDeveloper": "app developer account",
247
+ "standard": "production account"
241
248
  }
242
249
  },
243
250
  "config": {
@@ -0,0 +1,4 @@
1
+ import { DeveloperTestAccount } from '../types/developerTestAccounts';
2
+ export declare function createDeveloperTestAccount(accountId: number, accountName: string): Promise<DeveloperTestAccount>;
3
+ export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number): Promise<void>;
4
+ export declare function fetchDeveloperTestAccounts(accountId: number): Promise<DeveloperTestAccount[]>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchDeveloperTestAccounts = exports.deleteDeveloperTestAccount = exports.createDeveloperTestAccount = void 0;
4
+ const developerTestAccounts_1 = require("../api/developerTestAccounts");
5
+ const apiErrors_1 = require("../errors/apiErrors");
6
+ async function createDeveloperTestAccount(accountId, accountName) {
7
+ try {
8
+ const resp = await (0, developerTestAccounts_1.createDeveloperTestAccount)(accountId, accountName);
9
+ return resp;
10
+ }
11
+ catch (err) {
12
+ (0, apiErrors_1.throwApiError)(err);
13
+ }
14
+ }
15
+ exports.createDeveloperTestAccount = createDeveloperTestAccount;
16
+ async function deleteDeveloperTestAccount(accountId, testAccountId) {
17
+ try {
18
+ const resp = await (0, developerTestAccounts_1.deleteDeveloperTestAccount)(accountId, testAccountId);
19
+ return resp;
20
+ }
21
+ catch (err) {
22
+ (0, apiErrors_1.throwApiError)(err);
23
+ }
24
+ }
25
+ exports.deleteDeveloperTestAccount = deleteDeveloperTestAccount;
26
+ async function fetchDeveloperTestAccounts(accountId) {
27
+ try {
28
+ const resp = await (0, developerTestAccounts_1.fetchDeveloperTestAccounts)(accountId);
29
+ return resp.results;
30
+ }
31
+ catch (err) {
32
+ (0, apiErrors_1.throwApiError)(err);
33
+ }
34
+ }
35
+ exports.fetchDeveloperTestAccounts = fetchDeveloperTestAccounts;
@@ -12,6 +12,7 @@ const localDevAuth_1 = require("../api/localDevAuth");
12
12
  const sandboxHubs_1 = require("../api/sandboxHubs");
13
13
  const config_1 = require("../config");
14
14
  const config_2 = require("../constants/config");
15
+ const developerTestAccounts_1 = require("../api/developerTestAccounts");
15
16
  const i18nKey = 'lib.personalAccessKey';
16
17
  const refreshRequests = new Map();
17
18
  function getRefreshKey(personalAccessKey, expiration) {
@@ -95,22 +96,18 @@ exports.accessTokenForPersonalAccessKey = accessTokenForPersonalAccessKey;
95
96
  async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
96
97
  const { portalId, accessToken, expiresAt } = token;
97
98
  const accountEnv = env || (0, config_1.getEnv)(name);
98
- let hubInfo;
99
- try {
100
- hubInfo = await (0, sandboxHubs_1.fetchSandboxHubData)(accessToken, portalId, accountEnv);
101
- }
102
- catch (err) {
103
- // Ignore error, returns 404 if account is not a sandbox
104
- }
105
99
  let accountType = config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD;
106
100
  let sandboxAccountType = null;
107
101
  let parentAccountId;
108
- if (hubInfo) {
109
- if (hubInfo.type !== undefined) {
110
- const sandboxHubType = hubInfo.type ? hubInfo.type.toUpperCase() : null;
111
- switch (sandboxHubType) {
102
+ try {
103
+ const sandboxDataResponse = await (0, sandboxHubs_1.fetchSandboxHubData)(accessToken, portalId, accountEnv);
104
+ if (sandboxDataResponse) {
105
+ const hubType = sandboxDataResponse.type
106
+ ? sandboxDataResponse.type.toUpperCase()
107
+ : null;
108
+ switch (hubType) {
112
109
  case 'DEVELOPER':
113
- accountType = config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_SANDBOX;
110
+ accountType = config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
114
111
  sandboxAccountType = 'DEVELOPER';
115
112
  break;
116
113
  case 'STANDARD':
@@ -122,11 +119,26 @@ async function updateConfigWithAccessToken(token, personalAccessKey, env, name,
122
119
  sandboxAccountType = 'STANDARD';
123
120
  break;
124
121
  }
122
+ if (sandboxDataResponse.parentHubId) {
123
+ parentAccountId = sandboxDataResponse.parentHubId;
124
+ }
125
125
  }
126
- if (hubInfo.parentHubId) {
127
- parentAccountId = hubInfo.parentHubId;
126
+ }
127
+ catch (err) {
128
+ // Ignore error, returns 404 if account is not a sandbox
129
+ }
130
+ try {
131
+ if (accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD) {
132
+ const developerTestAccountResponse = await (0, developerTestAccounts_1.fetchDeveloperTestAccountData)(accessToken, portalId, accountEnv);
133
+ if (developerTestAccountResponse) {
134
+ accountType = config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
135
+ parentAccountId = developerTestAccountResponse.parentPortalId;
136
+ }
128
137
  }
129
138
  }
139
+ catch (err) {
140
+ // Ignore error, returns 404 if account is not a test account
141
+ }
130
142
  const updatedConfig = (0, config_1.updateAccountConfig)({
131
143
  accountId: portalId,
132
144
  accountType,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
package/types/Http.d.ts CHANGED
@@ -21,9 +21,9 @@ export type FormData = {
21
21
  [key: string]: string | ReadStream;
22
22
  };
23
23
  export type HttpOptions = AxiosConfigOptions & {
24
- query?: QueryParams;
24
+ params?: QueryParams;
25
25
  timeout?: number;
26
- encoding?: string | null;
26
+ responseType?: string;
27
27
  headers?: {
28
28
  [header: string]: string | string[] | undefined;
29
29
  };
@@ -0,0 +1,11 @@
1
+ export type DeveloperTestAccount = {
2
+ testPortalId: number;
3
+ parentPortalId: number;
4
+ accountName: string;
5
+ createdAt: string;
6
+ updatedAt: string;
7
+ status: string;
8
+ };
9
+ export type FetchDeveloperTestAccountsResponse = {
10
+ results: DeveloperTestAccount[];
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });