@hubspot/local-dev-lib 5.0.0-beta.0 → 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 (46) hide show
  1. package/api/developerTestAccounts.d.ts +1 -3
  2. package/api/developerTestAccounts.js +0 -18
  3. package/api/fileMapper.d.ts +0 -1
  4. package/api/fileMapper.js +1 -1
  5. package/api/fireAlarm.d.ts +0 -1
  6. package/api/fireAlarm.js +1 -1
  7. package/api/localDevAuth.d.ts +1 -4
  8. package/api/localDevAuth.js +1 -20
  9. package/api/sandboxHubs.d.ts +1 -4
  10. package/api/sandboxHubs.js +0 -18
  11. package/config/defaultAccountOverride.d.ts +2 -1
  12. package/config/defaultAccountOverride.js +1 -3
  13. package/config/index.d.ts +1 -1
  14. package/config/index.js +2 -2
  15. package/constants/endpoints.d.ts +6 -0
  16. package/constants/endpoints.js +6 -0
  17. package/enums/build.d.ts +1 -0
  18. package/enums/build.js +1 -0
  19. package/errors/index.d.ts +1 -2
  20. package/errors/index.js +1 -9
  21. package/errors/isSystemError.d.ts +2 -0
  22. package/errors/isSystemError.js +9 -0
  23. package/http/client.js +1 -3
  24. package/lang/en.json +1 -1
  25. package/lib/archive.js +0 -1
  26. package/lib/crm.js +0 -1
  27. package/lib/environment.d.ts +1 -1
  28. package/lib/fileMapper.js +0 -2
  29. package/lib/personalAccessKey.d.ts +1 -3
  30. package/lib/personalAccessKey.js +1 -6
  31. package/lib/trackUsage.d.ts +0 -2
  32. package/lib/trackUsage.js +1 -4
  33. package/models/FileSystemError.js +1 -1
  34. package/package.json +4 -1
  35. package/types/Accounts.d.ts +2 -1
  36. package/types/Build.d.ts +1 -2
  37. package/types/Config.d.ts +1 -3
  38. package/types/Deploy.d.ts +1 -7
  39. package/types/Migration.d.ts +1 -1
  40. package/types/Project.d.ts +1 -19
  41. package/types/ProjectComponents.d.ts +24 -0
  42. package/types/ProjectComponents.js +1 -0
  43. package/utils/personalAccessKey.d.ts +8 -0
  44. package/utils/personalAccessKey.js +51 -0
  45. package/errors/errors_DEPRECATED.d.ts +0 -3
  46. package/errors/errors_DEPRECATED.js +0 -55
@@ -1,11 +1,9 @@
1
- import { DeveloperTestAccount, CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse, DeveloperTestAccountConfig, CreateDeveloperTestAccountV3Response, InstallOauthAppIntoDeveloperTestAccountResponse, TestPortalStatusResponse, GenerateDeveloperTestAccountPersonalAccessKeyResponse } from '../types/developerTestAccounts.js';
2
- import { Environment } from '../types/Config.js';
1
+ import { CreateDeveloperTestAccountResponse, FetchDeveloperTestAccountsResponse, DeveloperTestAccountConfig, CreateDeveloperTestAccountV3Response, InstallOauthAppIntoDeveloperTestAccountResponse, TestPortalStatusResponse, GenerateDeveloperTestAccountPersonalAccessKeyResponse } from '../types/developerTestAccounts.js';
3
2
  import { HubSpotPromise } from '../types/Http.js';
4
3
  export declare function fetchDeveloperTestAccounts(accountId: number): HubSpotPromise<FetchDeveloperTestAccountsResponse>;
5
4
  export declare function createDeveloperTestAccount(accountId: number, accountInfo: string): HubSpotPromise<CreateDeveloperTestAccountResponse>;
6
5
  export declare function createDeveloperTestAccount(accountId: number, accountInfo: DeveloperTestAccountConfig): HubSpotPromise<CreateDeveloperTestAccountV3Response>;
7
6
  export declare function deleteDeveloperTestAccount(accountId: number, testAccountId: number, useV3?: boolean): HubSpotPromise<void>;
8
- export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
9
7
  export declare function installOauthAppIntoDeveloperTestAccount(accountId: number, testAccountId: number, projectName: string, appUId: string): HubSpotPromise<InstallOauthAppIntoDeveloperTestAccountResponse>;
10
8
  export declare function fetchDeveloperTestAccountOauthAppInstallStatus(accountId: number, projectName: string, appUId: string): HubSpotPromise<TestPortalStatusResponse>;
11
9
  export declare function fetchDeveloperTestAccountGateSyncStatus(accountId: number, testAccountId: number): HubSpotPromise<TestPortalStatusResponse>;
@@ -1,7 +1,4 @@
1
- import { httpClient } from '../http/client.js';
2
1
  import { http } from '../http/index.js';
3
- import { getAxiosConfig } from '../http/getAxiosConfig.js';
4
- import { ENVIRONMENTS } from '../constants/environments.js';
5
2
  import { SANDBOX_TIMEOUT } from '../constants/api.js';
6
3
  const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
7
4
  const TEST_ACCOUNTS_API_PATH_V3 = 'integrators/test-portals/v3';
@@ -34,21 +31,6 @@ export function deleteDeveloperTestAccount(accountId, testAccountId, useV3 = fal
34
31
  url: `${TEST_ACCOUNTS_API_PATH}/${testAccountId}`,
35
32
  });
36
33
  }
37
- export function fetchDeveloperTestAccountData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
38
- const axiosConfig = getAxiosConfig({
39
- env,
40
- url: `${TEST_ACCOUNTS_API_PATH}/self`,
41
- params: { portalId: accountId },
42
- });
43
- const reqWithToken = {
44
- ...axiosConfig,
45
- headers: {
46
- ...axiosConfig.headers,
47
- Authorization: `Bearer ${accessToken}`,
48
- },
49
- };
50
- return httpClient(reqWithToken);
51
- }
52
34
  export function installOauthAppIntoDeveloperTestAccount(accountId, testAccountId, projectName, appUId) {
53
35
  return http.post(accountId, {
54
36
  url: `${TEST_ACCOUNTS_API_PATH_V3}/install-apps`,
@@ -1,7 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { FileMapperNode, FileMapperOptions, FileTree } from '../types/Files.js';
3
3
  import { HubSpotPromise } from '../types/Http.js';
4
- export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
5
4
  export declare function createFileMapperNodeFromStreamResponse(filePath: string, response: Partial<AxiosResponse>): FileMapperNode;
6
5
  export declare function upload(accountId: number, src: string, dest: string, options?: FileMapperOptions): HubSpotPromise<void>;
7
6
  export declare function fetchModule(accountId: number, moduleId: number, options?: FileMapperOptions): HubSpotPromise<FileTree>;
package/api/fileMapper.js CHANGED
@@ -3,7 +3,7 @@ import path from 'path';
3
3
  import contentDisposition from 'content-disposition';
4
4
  import { http } from '../http/index.js';
5
5
  import { getCwd } from '../lib/path.js';
6
- export const FILE_MAPPER_API_PATH = 'content/filemapper/v1';
6
+ import { FILE_MAPPER_API_PATH } from '../constants/endpoints.js';
7
7
  export function createFileMapperNodeFromStreamResponse(filePath, response) {
8
8
  if (filePath[0] !== '/') {
9
9
  filePath = `/${filePath}`;
@@ -1,4 +1,3 @@
1
1
  import { FireAlarm } from '../types/FireAlarm.js';
2
2
  import { HubSpotPromise } from '../types/Http.js';
3
- export declare const FIREALARM_API_AUTH_PATH = "firealarm/v4/alarm";
4
3
  export declare function fetchFireAlarms(accountId: number): HubSpotPromise<Array<FireAlarm>>;
package/api/fireAlarm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { http } from '../http/index.js';
2
- export const FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
2
+ import { FIREALARM_API_AUTH_PATH } from '../constants/endpoints.js';
3
3
  export function fetchFireAlarms(accountId) {
4
4
  return http.get(accountId, {
5
5
  url: `${FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
@@ -1,9 +1,6 @@
1
- import { Environment } from '../types/Config.js';
2
- import { ScopeData, AccessTokenResponse, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts.js';
1
+ import { ScopeData, EnabledFeaturesResponse, ScopeAuthorizationResponse } from '../types/Accounts.js';
3
2
  import { PublicAppInstallationData } from '../types/Apps.js';
4
3
  import { HubSpotPromise } from '../types/Http.js';
5
- export declare const LOCALDEVAUTH_ACCESS_TOKEN_PATH = "localdevauth/v1/auth/refresh";
6
- export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
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,24 +1,5 @@
1
- import { getAxiosConfig } from '../http/getAxiosConfig.js';
2
1
  import { http } from '../http/index.js';
3
- import { ENVIRONMENTS } from '../constants/environments.js';
4
- import { httpClient } from '../http/client.js';
5
- const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
6
- export const LOCALDEVAUTH_ACCESS_TOKEN_PATH = `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`;
7
- export function fetchAccessToken(personalAccessKey, env = ENVIRONMENTS.PROD, portalId) {
8
- const axiosConfig = getAxiosConfig({
9
- env,
10
- localHostOverride: true,
11
- url: LOCALDEVAUTH_ACCESS_TOKEN_PATH,
12
- data: {
13
- encodedOAuthRefreshToken: personalAccessKey,
14
- },
15
- params: portalId ? { portalId } : {},
16
- });
17
- return httpClient({
18
- ...axiosConfig,
19
- method: 'post',
20
- });
21
- }
2
+ import { LOCALDEVAUTH_API_AUTH_PATH } from '../constants/endpoints.js';
22
3
  export function fetchScopeData(accountId, scopeGroup) {
23
4
  return http.get(accountId, {
24
5
  url: `${LOCALDEVAUTH_API_AUTH_PATH}/check-scopes`,
@@ -1,10 +1,7 @@
1
- import { AxiosPromise } from 'axios';
2
- import { Environment } from '../types/Config.js';
3
- import { SandboxPersonalAccessKey, SandboxHubData, SandboxResponse, SandboxUsageLimitsResponse, V2Sandbox } from '../types/Sandbox.js';
1
+ import { SandboxPersonalAccessKey, SandboxResponse, SandboxUsageLimitsResponse, V2Sandbox } from '../types/Sandbox.js';
4
2
  import { HubSpotPromise } from '../types/Http.js';
5
3
  export declare function createSandbox(accountId: number, name: string, type: 1 | 2): HubSpotPromise<SandboxResponse>;
6
4
  export declare function deleteSandbox(parentAccountId: number, sandboxAccountId: number): HubSpotPromise<void>;
7
5
  export declare function getSandboxUsageLimits(parentAccountId: number): HubSpotPromise<SandboxUsageLimitsResponse>;
8
- export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
9
6
  export declare function createV2Sandbox(accountId: number, name: string, type: 'STANDARD' | 'DEVELOPER', syncObjectRecords: boolean): HubSpotPromise<V2Sandbox>;
10
7
  export declare function getSandboxPersonalAccessKey(accountId: number, sandboxId: number): HubSpotPromise<SandboxPersonalAccessKey>;
@@ -1,7 +1,4 @@
1
- import { httpClient } from '../http/client.js';
2
1
  import { http } from '../http/index.js';
3
- import { getAxiosConfig } from '../http/getAxiosConfig.js';
4
- import { ENVIRONMENTS } from '../constants/environments.js';
5
2
  import { SANDBOX_TIMEOUT } from '../constants/api.js';
6
3
  const SANDBOX_API_PATH = 'sandbox-hubs/v1';
7
4
  const SANDBOX_API_PATH_V2 = 'sandbox-hubs/v2';
@@ -22,21 +19,6 @@ export function getSandboxUsageLimits(parentAccountId) {
22
19
  url: `${SANDBOX_API_PATH}/parent/${parentAccountId}/usage`,
23
20
  });
24
21
  }
25
- export function fetchSandboxHubData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
26
- const axiosConfig = getAxiosConfig({
27
- env,
28
- url: `${SANDBOX_API_PATH}/self`,
29
- params: { portalId: accountId },
30
- });
31
- const reqWithToken = {
32
- ...axiosConfig,
33
- headers: {
34
- ...axiosConfig.headers,
35
- Authorization: `Bearer ${accessToken}`,
36
- },
37
- };
38
- return httpClient(reqWithToken);
39
- }
40
22
  export function createV2Sandbox(accountId, name, type, syncObjectRecords) {
41
23
  return http.post(accountId, {
42
24
  url: `${SANDBOX_API_PATH_V2}/sandboxes`,
@@ -1,2 +1,3 @@
1
- export declare function getDefaultAccountOverrideAccountId(): number | null;
1
+ import { HubSpotConfigAccount } from '../types/Accounts.js';
2
+ export declare function getDefaultAccountOverrideAccountId(accounts: Array<HubSpotConfigAccount>): number | null;
2
3
  export declare function getDefaultAccountOverrideFilePath(): string | null;
@@ -4,9 +4,8 @@ import { getCwd } from '../lib/path.js';
4
4
  import { DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID, DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND, DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME, } from '../constants/config.js';
5
5
  import { i18n } from '../utils/lang.js';
6
6
  import { FileSystemError } from '../models/FileSystemError.js';
7
- import { getAllConfigAccounts } from './index.js';
8
7
  const i18nKey = 'config.defaultAccountOverride';
9
- export function getDefaultAccountOverrideAccountId() {
8
+ export function getDefaultAccountOverrideAccountId(accounts) {
10
9
  const defaultAccountOverrideFilePath = getDefaultAccountOverrideFilePath();
11
10
  if (!defaultAccountOverrideFilePath) {
12
11
  return null;
@@ -30,7 +29,6 @@ export function getDefaultAccountOverrideAccountId() {
30
29
  cause: DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID,
31
30
  });
32
31
  }
33
- const accounts = getAllConfigAccounts();
34
32
  const account = accounts?.find(account => account.accountId === accountId);
35
33
  if (!account) {
36
34
  throw new Error(i18n(`${i18nKey}.getDefaultAccountOverrideAccountId.errorHeader`, {
package/config/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HubSpotConfigAccount } from '../types/Accounts.js';
2
2
  import { HubSpotConfig, ConfigFlag, HubSpotConfigValidationResult } from '../types/Config.js';
3
3
  import { CmsPublishMode } from '../types/Files.js';
4
- import { Environment } from '../types/Config.js';
4
+ import { Environment } from '../types/Accounts.js';
5
5
  export declare function getGlobalConfigFilePath(): string;
6
6
  export declare function getLocalConfigFilePathIfExists(cwd?: string): string | null;
7
7
  export declare function localConfigFileExists(): boolean;
package/config/index.js CHANGED
@@ -155,7 +155,7 @@ export function getConfigDefaultAccount() {
155
155
  const currentConfigPath = getConfigFilePath();
156
156
  const globalConfigPath = getGlobalConfigFilePath();
157
157
  if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
158
- const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId();
158
+ const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
159
159
  defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
160
160
  }
161
161
  if (!defaultAccountToUse) {
@@ -176,7 +176,7 @@ export function getConfigDefaultAccountIfExists() {
176
176
  const currentConfigPath = getConfigFilePath();
177
177
  const globalConfigPath = getGlobalConfigFilePath();
178
178
  if (currentConfigPath === globalConfigPath && globalConfigFileExists()) {
179
- const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId();
179
+ const defaultAccountOverrideAccountId = getDefaultAccountOverrideAccountId(accounts);
180
180
  defaultAccountToUse = defaultAccountOverrideAccountId || defaultAccount;
181
181
  }
182
182
  if (!defaultAccountToUse) {
@@ -0,0 +1,6 @@
1
+ export declare const LOCALDEVAUTH_API_AUTH_PATH = "localdevauth/v1/auth";
2
+ export declare const LOCALDEVAUTH_ACCESS_TOKEN_PATH = "localdevauth/v1/auth/refresh";
3
+ export declare const FIREALARM_API_AUTH_PATH = "firealarm/v4/alarm";
4
+ export declare const FILE_MAPPER_API_PATH = "content/filemapper/v1";
5
+ export declare const CMS_CLI_USAGE_PATH = "content/filemapper/v1/cms-cli-usage";
6
+ export declare const VSCODE_USAGE_PATH = "content/filemapper/v1/vscode-extension-usage";
@@ -0,0 +1,6 @@
1
+ export const LOCALDEVAUTH_API_AUTH_PATH = 'localdevauth/v1/auth';
2
+ export const LOCALDEVAUTH_ACCESS_TOKEN_PATH = `${LOCALDEVAUTH_API_AUTH_PATH}/refresh`;
3
+ export const FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
4
+ export const FILE_MAPPER_API_PATH = 'content/filemapper/v1';
5
+ export const CMS_CLI_USAGE_PATH = `${FILE_MAPPER_API_PATH}/cms-cli-usage`;
6
+ export const VSCODE_USAGE_PATH = `${FILE_MAPPER_API_PATH}/vscode-extension-usage`;
package/enums/build.d.ts CHANGED
@@ -19,6 +19,7 @@ export declare const DEPLOYABLE_STATES: {
19
19
  export declare const COMPONENT_TYPES: {
20
20
  readonly APP: "APP";
21
21
  readonly PRIVATE_APP: "PRIVATE_APP";
22
+ readonly PUBLIC_APP: "PUBLIC_APP";
22
23
  readonly THEME: "THEME";
23
24
  readonly REACT_THEME: "REACT_THEME";
24
25
  };
package/enums/build.js CHANGED
@@ -19,6 +19,7 @@ export const DEPLOYABLE_STATES = {
19
19
  export const COMPONENT_TYPES = {
20
20
  APP: 'APP',
21
21
  PRIVATE_APP: 'PRIVATE_APP',
22
+ PUBLIC_APP: 'PUBLIC_APP',
22
23
  THEME: 'THEME',
23
24
  REACT_THEME: 'REACT_THEME',
24
25
  };
package/errors/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { HubSpotHttpError } from '../models/HubSpotHttpError.js';
2
- import { BaseError } from '../types/Error.js';
3
2
  import { FileSystemError } from '../models/FileSystemError.js';
4
3
  import { HubSpotConfigError } from '../models/HubSpotConfigError.js';
4
+ export { isSystemError } from './isSystemError.js';
5
5
  export declare function isSpecifiedError(err: unknown, { statusCode, category, subCategory, errorType, code, }: {
6
6
  statusCode?: number;
7
7
  category?: string;
@@ -16,6 +16,5 @@ export declare function isAuthError(err: unknown): err is HubSpotHttpError;
16
16
  export declare function isValidationError(err: unknown): err is HubSpotHttpError;
17
17
  export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
18
18
  export declare function isGithubRateLimitError(err: unknown): err is HubSpotHttpError;
19
- export declare function isSystemError(err: unknown): err is BaseError;
20
19
  export declare function isFileSystemError(err: unknown): err is FileSystemError;
21
20
  export declare function isHubSpotConfigError(err: unknown): err is HubSpotConfigError;
package/errors/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { HubSpotHttpErrorName, } from '../models/HubSpotHttpError.js';
2
2
  import { FilerSystemErrorName, } from '../models/FileSystemError.js';
3
3
  import { HubSpotConfigError } from '../models/HubSpotConfigError.js';
4
+ export { isSystemError } from './isSystemError.js';
4
5
  export function isSpecifiedError(err, { statusCode, category, subCategory, errorType, code, }) {
5
6
  if (!isHubSpotHttpError(err)) {
6
7
  return false;
@@ -46,15 +47,6 @@ export function isGithubRateLimitError(err) {
46
47
  err.headers['x-ratelimit-remaining'] === '0' &&
47
48
  'x-github-request-id' in err.headers);
48
49
  }
49
- export function isSystemError(err) {
50
- return (err instanceof Error &&
51
- 'errno' in err &&
52
- err.errno != null &&
53
- 'code' in err &&
54
- err.code != null &&
55
- 'syscall' in err &&
56
- err.syscall != null);
57
- }
58
50
  export function isFileSystemError(err) {
59
51
  return err instanceof Error && err.name === FilerSystemErrorName;
60
52
  }
@@ -0,0 +1,2 @@
1
+ import { BaseError } from '../types/Error.js';
2
+ export declare function isSystemError(err: unknown): err is BaseError;
@@ -0,0 +1,9 @@
1
+ export function isSystemError(err) {
2
+ return (err instanceof Error &&
3
+ 'errno' in err &&
4
+ err.errno != null &&
5
+ 'code' in err &&
6
+ err.code != null &&
7
+ 'syscall' in err &&
8
+ err.syscall != null);
9
+ }
package/http/client.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import axios, { isAxiosError } from 'axios';
2
2
  import { HubSpotHttpError } from '../models/HubSpotHttpError.js';
3
3
  import { logger } from '../lib/logger.js';
4
- import { LOCALDEVAUTH_ACCESS_TOKEN_PATH } from '../api/localDevAuth.js';
5
- import { FIREALARM_API_AUTH_PATH } from '../api/fireAlarm.js';
6
4
  import * as util from 'util';
7
- import { CMS_CLI_USAGE_PATH, VSCODE_USAGE_PATH } from '../lib/trackUsage.js';
5
+ import { LOCALDEVAUTH_ACCESS_TOKEN_PATH, FIREALARM_API_AUTH_PATH, CMS_CLI_USAGE_PATH, VSCODE_USAGE_PATH, } from '../constants/endpoints.js';
8
6
  // Create an isolated axios instance for this copy of local-dev-lib.
9
7
  // This prevents issues when multiple copies are loaded and share the global
10
8
  // axios, where each copy would register interceptors on the shared instance
package/lang/en.json CHANGED
@@ -316,7 +316,7 @@
316
316
  },
317
317
  "buildConfigFromEnvironment": {
318
318
  "missingAccountId": "HUBSPOT_ACCOUNT_ID is required, but not currently set",
319
- "invalidAuthType": "Auth type is invalid. Use HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, and HUBSPOT_REFRESH_TOKEN to authenticate with Oauth2, PERSONAL_ACCESS_KEY to authenticate with Personal Access Key, or API_KEY to authenticate with API Key."
319
+ "invalidAuthType": "Auth type is invalid. Use HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, and HUBSPOT_REFRESH_TOKEN to authenticate with Oauth2, HUBSPOT_PERSONAL_ACCESS_KEY to authenticate with Personal Access Key, or API_KEY to authenticate with API Key."
320
320
  }
321
321
  },
322
322
  "defaultAccountOverride": {
package/lib/archive.js CHANGED
@@ -121,7 +121,6 @@ async function cleanupTempDir(tmpDir) {
121
121
  return;
122
122
  try {
123
123
  await fs.remove(tmpDir);
124
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
125
124
  }
126
125
  catch (e) {
127
126
  logger.debug(i18n(`${i18nKey}.cleanupTempDir.error`, { tmpDir }));
package/lib/crm.js CHANGED
@@ -39,7 +39,6 @@ function fileExists(_path) {
39
39
  if (!isFile) {
40
40
  return false;
41
41
  }
42
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
42
  }
44
43
  catch (e) {
45
44
  return false;
@@ -1,2 +1,2 @@
1
- import { Environment } from '../types/Config.js';
1
+ import { Environment } from '../types/Accounts.js';
2
2
  export declare function getValidEnv(env?: string | null, maskedProductionValue?: Environment): Environment;
package/lib/fileMapper.js CHANGED
@@ -61,7 +61,6 @@ function validateFileMapperNode(node) {
61
61
  let json;
62
62
  try {
63
63
  json = JSON.stringify(node, null, 2);
64
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
64
  }
66
65
  catch (err) {
67
66
  json = node;
@@ -156,7 +155,6 @@ async function writeFileMapperNode(accountId, filepath, node, cmsPublishMode, op
156
155
  try {
157
156
  await fetchAndWriteFileStream(accountId, node.path, localFilepath, cmsPublishMode, options);
158
157
  return true;
159
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
160
158
  }
161
159
  catch (err) {
162
160
  return false;
@@ -1,5 +1,4 @@
1
- import { PersonalAccessKeyConfigAccount, ScopeGroupAuthorization } from '../types/Accounts.js';
2
- import { Environment } from '../types/Config.js';
1
+ import { PersonalAccessKeyConfigAccount, Environment } from '../types/Accounts.js';
3
2
  import { AccessToken } from '../types/Accounts.js';
4
3
  export declare function getAccessToken(personalAccessKey: string, env?: Environment, accountId?: number): Promise<AccessToken>;
5
4
  export declare function accessTokenForPersonalAccessKey(accountId: number, forceRefresh?: boolean): Promise<string | undefined>;
@@ -7,5 +6,4 @@ export declare function enabledFeaturesForPersonalAccessKey(accountId: number):
7
6
  [key: string]: number;
8
7
  } | undefined>;
9
8
  export declare function scopesOnAccessToken(accountId: number): Promise<Array<string>>;
10
- export declare function authorizedScopesForPortalAndUser(accountId: number): Promise<Array<ScopeGroupAuthorization>>;
11
9
  export declare function updateConfigWithAccessToken(token: AccessToken, personalAccessKey: string, env?: Environment, name?: string, makeDefault?: boolean): Promise<PersonalAccessKeyConfigAccount>;
@@ -1,11 +1,9 @@
1
1
  import moment from 'moment';
2
2
  import { ENVIRONMENTS } from '../constants/environments.js';
3
3
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD } from '../constants/auth.js';
4
- import { fetchAccessToken, fetchScopeAuthorizationData, } from '../api/localDevAuth.js';
5
- import { fetchSandboxHubData } from '../api/sandboxHubs.js';
4
+ import { fetchAccessToken, fetchSandboxHubData, fetchDeveloperTestAccountData, } from '../utils/personalAccessKey.js';
6
5
  import { getConfigAccountById, getConfigAccountIfExists, updateConfigAccount, addConfigAccount, setConfigAccountAsDefault, } from '../config/index.js';
7
6
  import { HUBSPOT_ACCOUNT_TYPES } from '../constants/config.js';
8
- import { fetchDeveloperTestAccountData } from '../api/developerTestAccounts.js';
9
7
  import { logger } from './logger.js';
10
8
  import { i18n } from '../utils/lang.js';
11
9
  import { isHubSpotHttpError } from '../errors/index.js';
@@ -105,9 +103,6 @@ export async function enabledFeaturesForPersonalAccessKey(accountId) {
105
103
  export async function scopesOnAccessToken(accountId) {
106
104
  return (await getNewAccessTokenByAccountId(accountId)).scopeGroups;
107
105
  }
108
- export async function authorizedScopesForPortalAndUser(accountId) {
109
- return (await fetchScopeAuthorizationData(accountId)).data.results;
110
- }
111
106
  export async function updateConfigWithAccessToken(token, personalAccessKey, env, name, makeDefault = false) {
112
107
  const { portalId, accessToken, expiresAt, accountType } = token;
113
108
  const account = getConfigAccountIfExists(portalId);
@@ -1,3 +1 @@
1
- export declare const CMS_CLI_USAGE_PATH = "content/filemapper/v1/cms-cli-usage";
2
- export declare const VSCODE_USAGE_PATH = "content/filemapper/v1/vscode-extension-usage";
3
1
  export declare function trackUsage(eventName: string, eventClass: string, meta?: {}, accountId?: number): Promise<void>;
package/lib/trackUsage.js CHANGED
@@ -3,12 +3,10 @@ import { getAxiosConfig } from '../http/getAxiosConfig.js';
3
3
  import { logger } from './logger.js';
4
4
  import { http } from '../http/index.js';
5
5
  import { getConfigAccountById, getConfigAccountEnvironment, } from '../config/index.js';
6
- import { FILE_MAPPER_API_PATH } from '../api/fileMapper.js';
6
+ import { FILE_MAPPER_API_PATH, CMS_CLI_USAGE_PATH, VSCODE_USAGE_PATH, } from '../constants/endpoints.js';
7
7
  import { i18n } from '../utils/lang.js';
8
8
  import { getValidEnv } from './environment.js';
9
9
  const i18nKey = 'lib.trackUsage';
10
- export const CMS_CLI_USAGE_PATH = `${FILE_MAPPER_API_PATH}/cms-cli-usage`;
11
- export const VSCODE_USAGE_PATH = `${FILE_MAPPER_API_PATH}/vscode-extension-usage`;
12
10
  export async function trackUsage(eventName, eventClass, meta = {}, accountId) {
13
11
  const usageEvent = {
14
12
  accountId,
@@ -41,7 +39,6 @@ export async function trackUsage(eventName, eventClass, meta = {}, accountId) {
41
39
  resolveWithFullResponse: true,
42
40
  });
43
41
  return;
44
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
45
42
  }
46
43
  catch (e) {
47
44
  logger.debug(i18n(`${i18nKey}.retryingEventUnauthenticated`));
@@ -1,5 +1,5 @@
1
1
  import { i18n } from '../utils/lang.js';
2
- import { isSystemError } from '../errors/index.js';
2
+ import { isSystemError } from '../errors/isSystemError.js';
3
3
  const i18nKey = 'errors.fileSystemErrors';
4
4
  export const FilerSystemErrorName = 'FilerSystemError';
5
5
  export class FileSystemError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.0.0-beta.1",
4
4
  "type": "module",
5
5
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
6
6
  "repository": {
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "tsx ./scripts/build.ts",
16
+ "circular-deps": "yarn madge --circular --extensions ts --exclude 'dist/.*' .",
16
17
  "lint": "eslint --max-warnings=0 . && prettier . --check",
17
18
  "local-dev": "yarn build && cd dist && yarn link && cd .. && tsc --watch --rootDir . --outdir dist",
18
19
  "prettier:write": "prettier . --write",
@@ -37,6 +38,7 @@
37
38
  "eslint": "^9.38.0",
38
39
  "eslint-plugin-import": "^2.31.0",
39
40
  "husky": "^8.0.0",
41
+ "madge": "^8.0.0",
40
42
  "open": "^8.4.2",
41
43
  "tsx": "^4.20.6",
42
44
  "typescript": "^5.9.3",
@@ -55,6 +57,7 @@
55
57
  "./config/state": "./config/state.js",
56
58
  "./config": "./config/index.js",
57
59
  "./constants/*": "./constants/*.js",
60
+ "./enums/*": "./enums/*.js",
58
61
  "./models/*": "./models/*.js",
59
62
  "./types/*": {
60
63
  "types": "./types/*.d.ts",
@@ -1,8 +1,9 @@
1
1
  import { HUBSPOT_ACCOUNT_TYPES } from '../constants/config.js';
2
+ import { ENVIRONMENTS } from '../constants/environments.js';
2
3
  import { CmsPublishMode } from './Files.js';
3
- import { Environment } from './Config.js';
4
4
  import { ValueOf } from './Utils.js';
5
5
  import { PERSONAL_ACCESS_KEY_AUTH_METHOD, OAUTH_AUTH_METHOD, API_KEY_AUTH_METHOD } from '../constants/auth.js';
6
+ export type Environment = ValueOf<typeof ENVIRONMENTS> | '';
6
7
  export type AuthType = 'personalaccesskey' | 'apikey' | 'oauth2';
7
8
  interface BaseHubSpotConfigAccount {
8
9
  name: string;
package/types/Build.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { ValueOf } from './Utils.js';
2
2
  import { BUILD_STATUS, SUBBUILD_TYPES, DEPLOYABLE_STATES } from '../enums/build.js';
3
3
  import { ActivitySource } from './Activity.js';
4
- import { DeployStatusTaskLocator } from './Deploy.js';
5
- import { ProjectStandardError } from './Project.js';
4
+ import { DeployStatusTaskLocator, ProjectStandardError } from './ProjectComponents.js';
6
5
  export type SubbuildStatus = {
7
6
  buildName: string;
8
7
  buildType: ValueOf<typeof SUBBUILD_TYPES>;
package/types/Config.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { CONFIG_FLAGS, HUBSPOT_CONFIG_ERROR_TYPES, HUBSPOT_CONFIG_OPERATIONS } from '../constants/config.js';
2
- import { ENVIRONMENTS } from '../constants/environments.js';
3
- import { DeprecatedHubSpotConfigAccountFields, HubSpotConfigAccount } from './Accounts.js';
2
+ import { DeprecatedHubSpotConfigAccountFields, Environment, HubSpotConfigAccount } from './Accounts.js';
4
3
  import { CmsPublishMode } from './Files.js';
5
4
  import { ValueOf } from './Utils.js';
6
5
  export interface HubSpotConfig {
@@ -22,7 +21,6 @@ export type DeprecatedHubSpotConfigFields = {
22
21
  defaultPortal?: string;
23
22
  defaultMode?: CmsPublishMode;
24
23
  };
25
- export type Environment = ValueOf<typeof ENVIRONMENTS> | '';
26
24
  export type GitInclusionResult = {
27
25
  inGit: boolean;
28
26
  configIgnored: boolean;
package/types/Deploy.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ValueOf } from './Utils.js';
2
2
  import { ACTIVITY_SOURCE } from '../enums/project.js';
3
3
  import { DEPLOY_ACTION, DEPLOY_STATUS } from '../enums/deploy.js';
4
4
  import { COMPONENT_TYPES, SUBCOMPONENT_TYPES } from '../enums/build.js';
5
- import { ProjectStandardError } from './Project.js';
5
+ import { ProjectStandardError } from './ProjectComponents.js';
6
6
  export type DeployStatus = ValueOf<typeof DEPLOY_STATUS>;
7
7
  export type SubdeployStatus = {
8
8
  action: ValueOf<typeof DEPLOY_ACTION>;
@@ -29,12 +29,6 @@ export type Deploy = {
29
29
  userId: number;
30
30
  source: ValueOf<typeof ACTIVITY_SOURCE>;
31
31
  };
32
- export type DeployStatusTaskLocator = {
33
- id: string;
34
- links: Array<{
35
- status: string;
36
- }>;
37
- };
38
32
  export type SubdeployValidationIssue = {
39
33
  uid: string;
40
34
  componentTypeName: string;
@@ -1,5 +1,5 @@
1
1
  import { ValueOf } from './Utils.js';
2
- import { ProjectStandardError } from './Project.js';
2
+ import { ProjectStandardError } from './ProjectComponents.js';
3
3
  export declare const MIGRATION_STATUS: {
4
4
  readonly BUILDING: "BUILDING";
5
5
  readonly FAILURE: "FAILURE";
@@ -1,4 +1,4 @@
1
- import { Build } from './Build.js';
1
+ import type { Build } from './Build.js';
2
2
  import { GithubSourceData } from './Github.js';
3
3
  import { ProjectLog } from './ProjectLog.js';
4
4
  export type Project = {
@@ -45,24 +45,6 @@ export type FetchPlatformVersionResponse = {
45
45
  defaultPlatformVersion: string;
46
46
  activePlatformVersions: Array<string>;
47
47
  };
48
- export type ProjectStandardError = {
49
- status: string;
50
- id?: string;
51
- category: string;
52
- subCategory?: string;
53
- message?: string;
54
- errors?: Array<{
55
- message: string;
56
- in?: string;
57
- code?: string;
58
- subcateogy?: string;
59
- context: object;
60
- }>;
61
- context: object;
62
- links: {
63
- [key: string]: string;
64
- };
65
- };
66
48
  export type WarnLogsResponse = {
67
49
  logs: Array<ProjectLog>;
68
50
  };
@@ -0,0 +1,24 @@
1
+ export type DeployStatusTaskLocator = {
2
+ id: string;
3
+ links: Array<{
4
+ status: string;
5
+ }>;
6
+ };
7
+ export type ProjectStandardError = {
8
+ status: string;
9
+ id?: string;
10
+ category: string;
11
+ subCategory?: string;
12
+ message?: string;
13
+ errors?: Array<{
14
+ message: string;
15
+ in?: string;
16
+ code?: string;
17
+ subcateogy?: string;
18
+ context: object;
19
+ }>;
20
+ context: object;
21
+ links: {
22
+ [key: string]: string;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { AxiosPromise } from 'axios';
2
+ import { AccessTokenResponse, Environment } from '../types/Accounts.js';
3
+ import { DeveloperTestAccount } from '../types/developerTestAccounts.js';
4
+ import { SandboxHubData } from '../types/Sandbox.js';
5
+ import { HubSpotPromise } from '../types/Http.js';
6
+ export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
7
+ export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
8
+ export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
@@ -0,0 +1,51 @@
1
+ import { httpClient } from '../http/client.js';
2
+ import { getAxiosConfig } from '../http/getAxiosConfig.js';
3
+ import { ENVIRONMENTS } from '../constants/environments.js';
4
+ import { LOCALDEVAUTH_ACCESS_TOKEN_PATH } from '../constants/endpoints.js';
5
+ const SANDBOX_API_PATH = 'sandbox-hubs/v1';
6
+ const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
7
+ export function fetchAccessToken(personalAccessKey, env = ENVIRONMENTS.PROD, portalId) {
8
+ const axiosConfig = getAxiosConfig({
9
+ env,
10
+ localHostOverride: true,
11
+ url: LOCALDEVAUTH_ACCESS_TOKEN_PATH,
12
+ data: {
13
+ encodedOAuthRefreshToken: personalAccessKey,
14
+ },
15
+ params: portalId ? { portalId } : {},
16
+ });
17
+ return httpClient({
18
+ ...axiosConfig,
19
+ method: 'post',
20
+ });
21
+ }
22
+ export function fetchSandboxHubData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
23
+ const axiosConfig = getAxiosConfig({
24
+ env,
25
+ url: `${SANDBOX_API_PATH}/self`,
26
+ params: { portalId: accountId },
27
+ });
28
+ const reqWithToken = {
29
+ ...axiosConfig,
30
+ headers: {
31
+ ...axiosConfig.headers,
32
+ Authorization: `Bearer ${accessToken}`,
33
+ },
34
+ };
35
+ return httpClient(reqWithToken);
36
+ }
37
+ export function fetchDeveloperTestAccountData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
38
+ const axiosConfig = getAxiosConfig({
39
+ env,
40
+ url: `${TEST_ACCOUNTS_API_PATH}/self`,
41
+ params: { portalId: accountId },
42
+ });
43
+ const reqWithToken = {
44
+ ...axiosConfig,
45
+ headers: {
46
+ ...axiosConfig.headers,
47
+ Authorization: `Bearer ${accessToken}`,
48
+ },
49
+ };
50
+ return httpClient(reqWithToken);
51
+ }
@@ -1,3 +0,0 @@
1
- import { BaseError, FileSystemErrorContext, ErrorContext } from '../types/Error.js';
2
- export declare function logErrorInstance(error: BaseError, context?: ErrorContext): void;
3
- export declare function logFileSystemErrorInstance(error: BaseError, context: FileSystemErrorContext): void;
@@ -1,55 +0,0 @@
1
- function isSystemError(err) {
2
- return err.errno != null && err.code != null && err.syscall != null;
3
- }
4
- function debugErrorAndContext(error, context) {
5
- console.debug('Error: %o', error);
6
- console.debug('Context: %o', context);
7
- }
8
- export function logErrorInstance(error, context) {
9
- // SystemError
10
- if (isSystemError(error)) {
11
- console.error(`A system error has occurred: ${error.message}`);
12
- debugErrorAndContext(error, context);
13
- return;
14
- }
15
- if (error instanceof Error ||
16
- error.message ||
17
- error.reason) {
18
- // Error or Error subclass
19
- const name = error.name || 'Error';
20
- const message = [`A ${name} has occurred.`];
21
- [error.message, error.reason].forEach(msg => {
22
- if (msg) {
23
- message.push(msg);
24
- }
25
- });
26
- console.error(message.join(' '));
27
- }
28
- else {
29
- // Unknown errors
30
- console.error(`An unknown error has occurred.`);
31
- }
32
- debugErrorAndContext(error, context);
33
- }
34
- export function logFileSystemErrorInstance(error, context) {
35
- let fileAction = '';
36
- if (context.operation === 'read') {
37
- fileAction = 'reading from';
38
- }
39
- else if (context.operation === 'write') {
40
- fileAction = 'writing to';
41
- }
42
- else {
43
- fileAction = 'accessing';
44
- }
45
- const filepath = context.filepath
46
- ? `"${context.filepath}"`
47
- : 'a file or folder';
48
- const message = [`An error occurred while ${fileAction} ${filepath}.`];
49
- // Many `fs` errors will be `SystemError`s
50
- if (isSystemError(error)) {
51
- message.push(`This is the result of a system error: ${error.message}`);
52
- }
53
- console.error(message.join(' '));
54
- debugErrorAndContext(error, context);
55
- }