@hubspot/local-dev-lib 4.0.0-beta.0 → 4.0.1-beta.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.
@@ -1,3 +1,4 @@
1
1
  import { FireAlarm } from '../types/FireAlarm';
2
2
  import { HubSpotPromise } from '../types/Http';
3
+ export declare const FIREALARM_API_AUTH_PATH = "firealarm/v4/alarm";
3
4
  export declare function fetchFireAlarms(accountId: number): HubSpotPromise<Array<FireAlarm>>;
package/api/fireAlarm.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchFireAlarms = void 0;
3
+ exports.fetchFireAlarms = exports.FIREALARM_API_AUTH_PATH = void 0;
4
4
  const http_1 = require("../http");
5
- const FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
5
+ exports.FIREALARM_API_AUTH_PATH = 'firealarm/v4/alarm';
6
6
  function fetchFireAlarms(accountId) {
7
7
  return http_1.http.get(accountId, {
8
- url: `${FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
8
+ url: `${exports.FIREALARM_API_AUTH_PATH}/hubspot-cli/${accountId}`,
9
9
  });
10
10
  }
11
11
  exports.fetchFireAlarms = fetchFireAlarms;
package/api/projects.d.ts CHANGED
@@ -4,7 +4,7 @@ import { HubSpotPromise, QueryParams } from '../types/Http';
4
4
  import { Project, FetchProjectResponse, UploadProjectResponse, ProjectSettings, FetchPlatformVersionResponse, WarnLogsResponse, UploadIRResponse } from '../types/Project';
5
5
  import { Build, FetchProjectBuildsResponse } from '../types/Build';
6
6
  import { ComponentStructureResponse, ProjectComponentsMetadata } from '../types/ComponentStructure';
7
- import { Deploy, ProjectDeployResponse } from '../types/Deploy';
7
+ import { Deploy, ProjectDeployResponse, ProjectDeployResponseV1 } from '../types/Deploy';
8
8
  import { MigrateAppResponse, CloneAppResponse, PollAppResponse } from '../types/Migration';
9
9
  export declare function fetchProjects(accountId: number): HubSpotPromise<FetchProjectResponse>;
10
10
  export declare function createProject(accountId: number, name: string): HubSpotPromise<Project>;
@@ -17,7 +17,12 @@ export declare function fetchPlatformVersions(accountId: number): HubSpotPromise
17
17
  export declare function fetchProjectBuilds(accountId: number, projectName: string, params?: QueryParams): HubSpotPromise<FetchProjectBuildsResponse>;
18
18
  export declare function getBuildStatus(accountId: number, projectName: string, buildId: number): HubSpotPromise<Build>;
19
19
  export declare function getBuildStructure(accountId: number, projectName: string, buildId: number): HubSpotPromise<ComponentStructureResponse>;
20
+ /**
21
+ * @deprecated Use the separate deployProjectV1 and deployProjectV2
22
+ */
20
23
  export declare function deployProject(accountId: number, projectName: string, buildId: number, useNewDeployApi?: boolean, force?: boolean): HubSpotPromise<ProjectDeployResponse>;
24
+ export declare function deployProjectV1(accountId: number, projectName: string, buildId: number, force?: boolean): HubSpotPromise<ProjectDeployResponseV1>;
25
+ export declare function deployProjectV2(accountId: number, projectName: string, buildId: number, force?: boolean): HubSpotPromise<ProjectDeployResponse>;
21
26
  export declare function getDeployStatus(accountId: number, projectName: string, deployId: number): HubSpotPromise<Deploy>;
22
27
  export declare function getDeployStructure(accountId: number, projectName: string, deployId: number): HubSpotPromise<ComponentStructureResponse>;
23
28
  export declare function fetchProjectSettings(accountId: number, projectName: string): HubSpotPromise<ProjectSettings>;
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.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProjectComponentsMetadata = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
6
+ exports.downloadClonedProject = exports.checkCloneStatus = exports.cloneApp = exports.checkMigrationStatus = exports.migrateApp = exports.fetchDeployWarnLogs = exports.fetchBuildWarnLogs = exports.cancelStagedBuild = exports.deleteFileFromBuild = exports.uploadFileToBuild = exports.queueBuild = exports.provisionBuild = exports.fetchProjectSettings = exports.getDeployStructure = exports.getDeployStatus = exports.deployProjectV2 = exports.deployProjectV1 = exports.deployProject = exports.getBuildStructure = exports.getBuildStatus = exports.fetchProjectBuilds = exports.fetchPlatformVersions = exports.deleteProject = exports.downloadProject = exports.fetchProjectComponentsMetadata = exports.fetchProject = exports.uploadProject = exports.createProject = exports.fetchProjects = void 0;
7
7
  const http_1 = require("../http");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const PROJECTS_API_PATH = 'dfs/v1/projects';
@@ -116,6 +116,9 @@ function getBuildStructure(accountId, projectName, buildId) {
116
116
  });
117
117
  }
118
118
  exports.getBuildStructure = getBuildStructure;
119
+ /**
120
+ * @deprecated Use the separate deployProjectV1 and deployProjectV2
121
+ */
119
122
  function deployProject(accountId, projectName, buildId, useNewDeployApi = false, force = false) {
120
123
  if (useNewDeployApi) {
121
124
  return http_1.http.post(accountId, {
@@ -137,6 +140,28 @@ function deployProject(accountId, projectName, buildId, useNewDeployApi = false,
137
140
  });
138
141
  }
139
142
  exports.deployProject = deployProject;
143
+ function deployProjectV1(accountId, projectName, buildId, force = false) {
144
+ return http_1.http.post(accountId, {
145
+ url: `${PROJECTS_DEPLOY_API_PATH}/deploys/queue/async`,
146
+ data: {
147
+ projectName,
148
+ buildId,
149
+ skipRemovalWarning: force,
150
+ },
151
+ });
152
+ }
153
+ exports.deployProjectV1 = deployProjectV1;
154
+ function deployProjectV2(accountId, projectName, buildId, force = false) {
155
+ return http_1.http.post(accountId, {
156
+ url: `${PROJECTS_DEPLOY_API_PATH_V3}/deploys/queue/async`,
157
+ data: {
158
+ projectName,
159
+ targetBuildId: buildId,
160
+ ignoreWarnings: force,
161
+ },
162
+ });
163
+ }
164
+ exports.deployProjectV2 = deployProjectV2;
140
165
  function getDeployStatus(accountId, projectName, deployId) {
141
166
  return http_1.http.get(accountId, {
142
167
  url: `${PROJECTS_DEPLOY_API_PATH}/deploy-status/projects/${encodeURIComponent(projectName)}/deploys/${deployId}`,
package/config/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { HubSpotConfig, ConfigFlag, HubSpotConfigValidationResult } from '../typ
3
3
  import { CmsPublishMode } from '../types/Files';
4
4
  import { Environment } from '../types/Config';
5
5
  export declare function getGlobalConfigFilePath(): string;
6
- export declare function getLocalConfigFilePathIfExists(): string | null;
6
+ export declare function getLocalConfigFilePathIfExists(cwd?: string): string | null;
7
7
  export declare function localConfigFileExists(): boolean;
8
8
  export declare function globalConfigFileExists(): boolean;
9
9
  export declare function configFileExists(): boolean;
package/config/index.js CHANGED
@@ -22,11 +22,11 @@ function getGlobalConfigFilePath() {
22
22
  return config_1.GLOBAL_CONFIG_PATH;
23
23
  }
24
24
  exports.getGlobalConfigFilePath = getGlobalConfigFilePath;
25
- function getLocalConfigFilePathIfExists() {
25
+ function getLocalConfigFilePathIfExists(cwd) {
26
26
  return (0, findup_sync_1.default)([
27
27
  config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
28
28
  config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME.replace('.yml', '.yaml'),
29
- ], { cwd: (0, path_1.getCwd)() });
29
+ ], { cwd: cwd || (0, path_1.getCwd)() });
30
30
  }
31
31
  exports.getLocalConfigFilePathIfExists = getLocalConfigFilePathIfExists;
32
32
  function localConfigFileExists() {
package/errors/index.d.ts CHANGED
@@ -13,9 +13,9 @@ export declare function isMissingScopeError(err: unknown): err is HubSpotHttpErr
13
13
  export declare function isGatingError(err: unknown): err is HubSpotHttpError;
14
14
  export declare function isTimeoutError(err: unknown): err is HubSpotHttpError;
15
15
  export declare function isAuthError(err: unknown): err is HubSpotHttpError;
16
- export declare function isValidationError(err: unknown): boolean;
16
+ export declare function isValidationError(err: unknown): err is HubSpotHttpError;
17
17
  export declare function isHubSpotHttpError(error?: unknown): error is HubSpotHttpError;
18
- export declare function isGithubRateLimitError(err: unknown): boolean;
18
+ export declare function isGithubRateLimitError(err: unknown): err is HubSpotHttpError;
19
19
  export declare function isSystemError(err: unknown): err is BaseError;
20
20
  export declare function isFileSystemError(err: unknown): err is FileSystemError;
21
21
  export declare function isHubSpotConfigError(err: unknown): err is HubSpotConfigError;
package/errors/index.js CHANGED
@@ -45,7 +45,7 @@ function isValidationError(err) {
45
45
  }
46
46
  exports.isValidationError = isValidationError;
47
47
  function isHubSpotHttpError(error) {
48
- return !!error && error instanceof HubSpotHttpError_1.HubSpotHttpError;
48
+ return (!!error && error instanceof Error && error.name === HubSpotHttpError_1.HubSpotHttpErrorName);
49
49
  }
50
50
  exports.isHubSpotHttpError = isHubSpotHttpError;
51
51
  function isGithubRateLimitError(err) {
@@ -68,7 +68,7 @@ function isSystemError(err) {
68
68
  }
69
69
  exports.isSystemError = isSystemError;
70
70
  function isFileSystemError(err) {
71
- return err instanceof FileSystemError_1.FileSystemError;
71
+ return err instanceof Error && err.name === FileSystemError_1.FilerSystemErrorName;
72
72
  }
73
73
  exports.isFileSystemError = isFileSystemError;
74
74
  function isHubSpotConfigError(err) {
@@ -6,4 +6,6 @@ export declare const USER_AGENTS: {
6
6
  export declare function getDefaultUserAgentHeader(): {
7
7
  'User-Agent': string;
8
8
  };
9
+ export declare function hostnameMatchesNoProxyPattern(hostname: string, pattern: string): boolean;
10
+ export declare function shouldUseProxy(baseURL: string): boolean;
9
11
  export declare function getAxiosConfig(options: HttpOptions): AxiosRequestConfig;
@@ -3,12 +3,14 @@ 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.getAxiosConfig = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
6
+ exports.getAxiosConfig = exports.shouldUseProxy = exports.hostnameMatchesNoProxyPattern = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
7
7
  const package_json_1 = require("../package.json");
8
8
  const config_1 = require("../config");
9
9
  const urls_1 = require("../lib/urls");
10
- const https_1 = __importDefault(require("https"));
11
10
  const http_1 = __importDefault(require("http"));
11
+ const https_1 = __importDefault(require("https"));
12
+ const http_proxy_agent_1 = require("http-proxy-agent");
13
+ const https_proxy_agent_1 = require("https-proxy-agent");
12
14
  // Total number of sockets across all hosts
13
15
  const MAX_TOTAL_SOCKETS = 25;
14
16
  // Total number of sockets per each host
@@ -23,6 +25,39 @@ const httpsAgent = new https_1.default.Agent({
23
25
  maxTotalSockets: MAX_TOTAL_SOCKETS,
24
26
  maxSockets: MAX_SOCKETS_PER_HOST,
25
27
  });
28
+ function getHttpProxyEnvVariable() {
29
+ return process.env.HTTP_PROXY || process.env.http_proxy;
30
+ }
31
+ function getHttpsProxyEnvVariable() {
32
+ return process.env.HTTPS_PROXY || process.env.https_proxy;
33
+ }
34
+ function getAllProxyEnvVariable() {
35
+ return process.env.ALL_PROXY || process.env.all_proxy;
36
+ }
37
+ function getHttpProxyAgent() {
38
+ const proxyUrl = getHttpProxyEnvVariable() || getAllProxyEnvVariable();
39
+ if (!proxyUrl) {
40
+ return httpAgent;
41
+ }
42
+ return new http_proxy_agent_1.HttpProxyAgent(proxyUrl, {
43
+ keepAlive: true,
44
+ maxTotalSockets: MAX_TOTAL_SOCKETS,
45
+ maxSockets: MAX_SOCKETS_PER_HOST,
46
+ });
47
+ }
48
+ function getHttpsProxyAgent() {
49
+ const proxyUrl = getHttpProxyEnvVariable() ||
50
+ getHttpsProxyEnvVariable() ||
51
+ getAllProxyEnvVariable();
52
+ if (!proxyUrl) {
53
+ return httpsAgent;
54
+ }
55
+ return new https_proxy_agent_1.HttpsProxyAgent(proxyUrl, {
56
+ keepAlive: true,
57
+ maxTotalSockets: MAX_TOTAL_SOCKETS,
58
+ maxSockets: MAX_SOCKETS_PER_HOST,
59
+ });
60
+ }
26
61
  exports.USER_AGENTS = {
27
62
  'HubSpot Local Dev Lib': package_json_1.version,
28
63
  };
@@ -39,6 +74,37 @@ exports.getDefaultUserAgentHeader = getDefaultUserAgentHeader;
39
74
  const DEFAULT_TRANSITIONAL = {
40
75
  clarifyTimeoutError: true,
41
76
  };
77
+ function hostnameMatchesNoProxyPattern(hostname, pattern) {
78
+ const hostnameNormalized = hostname.toLowerCase();
79
+ const patternNormalized = pattern.trim().toLowerCase();
80
+ if (patternNormalized === '*') {
81
+ return true;
82
+ }
83
+ if (patternNormalized.startsWith('.')) {
84
+ return hostnameNormalized.endsWith(patternNormalized);
85
+ }
86
+ return (hostnameNormalized === patternNormalized || // exact match (e.g. "api.hubapi.com" matches "api.hubapi.com")
87
+ hostnameNormalized.endsWith(`.${patternNormalized}`) // domain suffix match (e.g. "api.hubapi.com" matches ".hubapi.com")
88
+ );
89
+ }
90
+ exports.hostnameMatchesNoProxyPattern = hostnameMatchesNoProxyPattern;
91
+ function shouldUseProxy(baseURL) {
92
+ if (!getHttpProxyEnvVariable() &&
93
+ !getHttpsProxyEnvVariable() &&
94
+ !getAllProxyEnvVariable()) {
95
+ return false;
96
+ }
97
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy;
98
+ if (noProxy) {
99
+ const hostname = new URL(baseURL).hostname;
100
+ const noProxyList = noProxy.split(',').filter(Boolean);
101
+ if (noProxyList.some(pattern => hostnameMatchesNoProxyPattern(hostname, pattern))) {
102
+ return false;
103
+ }
104
+ }
105
+ return true;
106
+ }
107
+ exports.shouldUseProxy = shouldUseProxy;
42
108
  function getAxiosConfig(options) {
43
109
  const { env, localHostOverride, headers, ...rest } = options;
44
110
  let config;
@@ -56,16 +122,19 @@ function getAxiosConfig(options) {
56
122
  if (config && config.httpUseLocalhost) {
57
123
  httpUseLocalhost = config.httpUseLocalhost;
58
124
  }
125
+ const baseURL = (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost);
59
126
  return {
60
- baseURL: (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost),
127
+ baseURL,
61
128
  headers: {
62
129
  ...getDefaultUserAgentHeader(),
63
130
  ...(headers || {}),
64
131
  },
65
132
  timeout: httpTimeout,
66
133
  transitional: DEFAULT_TRANSITIONAL,
67
- httpAgent,
68
- httpsAgent,
134
+ // Disable axios's built-in proxy handling - we use custom agents instead
135
+ proxy: false,
136
+ httpAgent: shouldUseProxy(baseURL) ? getHttpProxyAgent() : httpAgent,
137
+ httpsAgent: shouldUseProxy(baseURL) ? getHttpsProxyAgent() : httpsAgent,
69
138
  ...rest,
70
139
  };
71
140
  }
package/http/index.js CHANGED
@@ -41,6 +41,7 @@ const lang_1 = require("../utils/lang");
41
41
  const HubSpotHttpError_1 = require("../models/HubSpotHttpError");
42
42
  const auth_1 = require("../constants/auth");
43
43
  const localDevAuth_1 = require("../api/localDevAuth");
44
+ const fireAlarm_1 = require("../api/fireAlarm");
44
45
  const util = __importStar(require("util"));
45
46
  const trackUsage_1 = require("../lib/trackUsage");
46
47
  const i18nKey = 'http.index';
@@ -48,14 +49,15 @@ const IGNORE_URLS_NETWORK_DEBUG = [
48
49
  localDevAuth_1.LOCALDEVAUTH_ACCESS_TOKEN_PATH,
49
50
  trackUsage_1.CMS_CLI_USAGE_PATH,
50
51
  trackUsage_1.VSCODE_USAGE_PATH,
52
+ fireAlarm_1.FIREALARM_API_AUTH_PATH,
51
53
  ];
52
54
  function logRequest(response) {
53
55
  try {
54
56
  if (!process.env.HUBSPOT_NETWORK_LOGGING) {
55
57
  return;
56
58
  }
57
- if (response?.config?.url &&
58
- IGNORE_URLS_NETWORK_DEBUG.includes(response.config.url)) {
59
+ if (!process.env.HUBSPOT_DEBUG_LOGGING_VERBOSE &&
60
+ IGNORE_URLS_NETWORK_DEBUG.some(url => response?.config?.url && response.config.url.includes(url))) {
59
61
  return;
60
62
  }
61
63
  logger_1.logger.debug(util.inspect({
@@ -1,4 +1,4 @@
1
- import { RequestPortsData } from '../types/PortManager';
1
+ import { RequestPortsData, ServerPortMap } from '../types/PortManager';
2
2
  export declare const BASE_URL: string;
3
3
  export declare function isPortManagerPortAvailable(): Promise<boolean>;
4
4
  export declare function isPortManagerServerRunning(): Promise<boolean>;
@@ -7,6 +7,7 @@ export declare function stopPortManagerServer(): Promise<void>;
7
7
  export declare function requestPorts(portData: Array<RequestPortsData>): Promise<{
8
8
  [instanceId: string]: number;
9
9
  }>;
10
+ export declare function getActiveServers(): Promise<ServerPortMap>;
10
11
  export declare function getServerPortByInstanceId(serverInstanceId: string): Promise<number>;
11
12
  export declare function deleteServerInstance(serverInstanceId: string): Promise<void>;
12
13
  export declare function portManagerHasActiveServers(): Promise<boolean>;
@@ -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.portManagerHasActiveServers = exports.deleteServerInstance = exports.getServerPortByInstanceId = exports.requestPorts = exports.stopPortManagerServer = exports.startPortManagerServer = exports.isPortManagerServerRunning = exports.isPortManagerPortAvailable = exports.BASE_URL = void 0;
6
+ exports.portManagerHasActiveServers = exports.deleteServerInstance = exports.getServerPortByInstanceId = exports.getActiveServers = exports.requestPorts = exports.stopPortManagerServer = exports.startPortManagerServer = exports.isPortManagerServerRunning = exports.isPortManagerPortAvailable = exports.BASE_URL = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
8
  const PortManagerServer_1 = require("../utils/PortManagerServer");
9
9
  const ports_1 = require("../constants/ports");
@@ -45,6 +45,11 @@ async function requestPorts(portData) {
45
45
  return data.ports;
46
46
  }
47
47
  exports.requestPorts = requestPorts;
48
+ async function getActiveServers() {
49
+ const { data } = await axios_1.default.get(`${exports.BASE_URL}/servers`);
50
+ return data.servers;
51
+ }
52
+ exports.getActiveServers = getActiveServers;
48
53
  async function getServerPortByInstanceId(serverInstanceId) {
49
54
  const { data } = await axios_1.default.get(`${exports.BASE_URL}/servers/${serverInstanceId}`);
50
55
  return data.port;
@@ -1,4 +1,5 @@
1
1
  import { FileSystemErrorContext } from '../types/Error';
2
+ export declare const FilerSystemErrorName = "FilerSystemError";
2
3
  export declare class FileSystemError extends Error {
3
4
  private context;
4
5
  constructor(options?: ErrorOptions, context?: FileSystemErrorContext);
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileSystemError = void 0;
3
+ exports.FileSystemError = exports.FilerSystemErrorName = void 0;
4
4
  const lang_1 = require("../utils/lang");
5
5
  const errors_1 = require("../errors");
6
6
  const i18nKey = 'errors.fileSystemErrors';
7
+ exports.FilerSystemErrorName = 'FilerSystemError';
7
8
  class FileSystemError extends Error {
8
9
  context;
9
10
  constructor(options, context) {
10
11
  super('', options);
11
- this.name = 'FileSystemError';
12
+ this.name = exports.FilerSystemErrorName;
12
13
  this.context = context;
13
14
  if (context) {
14
15
  let fileAction = '';
@@ -1,4 +1,5 @@
1
1
  import { HubSpotHttpErrorContext } from '../types/Error';
2
+ export declare const HubSpotHttpErrorName = "HubSpotHttpError";
2
3
  export declare class HubSpotHttpError<T = any> extends Error {
3
4
  status?: number;
4
5
  code?: string;
@@ -17,7 +18,7 @@ export declare class HubSpotHttpError<T = any> extends Error {
17
18
  timeout?: number;
18
19
  correlationId?: string;
19
20
  constructor(message?: string, options?: ErrorOptions, context?: HubSpotHttpErrorContext);
20
- updateContext(context: Partial<HubSpotHttpErrorContext>): void;
21
+ updateContext(context: Partial<HubSpotHttpErrorContext>, additionalDebugContext?: string): void;
21
22
  toString(): string;
22
23
  formattedValidationErrors(): string;
23
24
  private extractDerivedContext;
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HubSpotHttpError = void 0;
3
+ exports.HubSpotHttpError = exports.HubSpotHttpErrorName = void 0;
4
4
  const axios_1 = require("axios");
5
5
  const api_1 = require("../constants/api");
6
6
  const lang_1 = require("../utils/lang");
7
+ exports.HubSpotHttpErrorName = 'HubSpotHttpError';
7
8
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
9
  class HubSpotHttpError extends Error {
9
10
  status;
@@ -22,7 +23,7 @@ class HubSpotHttpError extends Error {
22
23
  correlationId;
23
24
  constructor(message, options, context) {
24
25
  super(message, options);
25
- this.name = 'HubSpotHttpError';
26
+ this.name = exports.HubSpotHttpErrorName;
26
27
  this.context = context;
27
28
  this.cause = options?.cause;
28
29
  if (options && (0, axios_1.isAxiosError)(options.cause)) {
@@ -60,11 +61,11 @@ class HubSpotHttpError extends Error {
60
61
  this.message = messages.join(' ');
61
62
  }
62
63
  }
63
- updateContext(context) {
64
+ updateContext(context, additionalDebugContext) {
64
65
  this.context = { ...this.context, ...context };
65
66
  // Update the error messages when the context is updated
66
67
  if ((0, axios_1.isAxiosError)(this.cause)) {
67
- this.message = this.joinErrorMessages(this.cause, this.context);
68
+ this.message = this.joinErrorMessages(this.cause, this.context, additionalDebugContext);
68
69
  }
69
70
  }
70
71
  toString() {
@@ -137,8 +138,7 @@ class HubSpotHttpError extends Error {
137
138
  }
138
139
  this.validationErrors = errorMessages;
139
140
  }
140
- joinErrorMessages(error, context = {}) {
141
- const i18nKey = 'errors.apiErrors';
141
+ joinErrorMessages(error, context = {}, additionalDebugContext) {
142
142
  const status = error.response?.status;
143
143
  const method = error.config?.method;
144
144
  let messageDetail;
@@ -149,48 +149,68 @@ class HubSpotHttpError extends Error {
149
149
  const requestName = context.request
150
150
  ? `${action} ${preposition} '${context.request}'`
151
151
  : action;
152
- messageDetail = (0, lang_1.i18n)(`${i18nKey}.messageDetail`, {
152
+ messageDetail = (0, lang_1.i18n)(`errors.apiErrors.messageDetail`, {
153
153
  accountId: context.accountId,
154
154
  requestName,
155
155
  });
156
156
  }
157
157
  else {
158
- messageDetail = (0, lang_1.i18n)(`${i18nKey}.genericMessageDetail`);
158
+ messageDetail = (0, lang_1.i18n)(`errors.apiErrors.genericMessageDetail`);
159
159
  }
160
160
  const errorMessage = [];
161
161
  if ((method === 'put' || method === 'post') && context.payload) {
162
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.unableToUpload`, { payload: context.payload }));
162
+ errorMessage.push((0, lang_1.i18n)(`errors.apiErrors.unableToUpload`, { payload: context.payload }));
163
163
  }
164
+ let statusBasedMessage;
164
165
  switch (status) {
165
166
  case 400:
166
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400`, { messageDetail }));
167
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.400`, {
168
+ messageDetail,
169
+ });
167
170
  break;
168
171
  case 401:
169
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.401`, { messageDetail }));
172
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.401`, {
173
+ messageDetail,
174
+ });
170
175
  break;
171
176
  case 403:
172
177
  break;
173
178
  case 404:
174
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.404`, { messageDetail }));
179
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.404`, {
180
+ messageDetail,
181
+ });
175
182
  break;
176
183
  case 429:
177
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.429`, { messageDetail }));
184
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.429`, {
185
+ messageDetail,
186
+ });
178
187
  break;
179
188
  case 503:
180
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.503`, { messageDetail }));
189
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.503`, {
190
+ messageDetail,
191
+ });
181
192
  break;
182
193
  default:
183
194
  if (status && status >= 500 && status < 600) {
184
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.500Generic`, { messageDetail }));
195
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.500Generic`, {
196
+ messageDetail,
197
+ });
185
198
  }
186
199
  else if (status && status >= 400 && status < 500) {
187
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.400Generic`, { messageDetail }));
200
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.400Generic`, {
201
+ messageDetail,
202
+ });
188
203
  }
189
204
  else {
190
- errorMessage.push((0, lang_1.i18n)(`${i18nKey}.codes.generic`, { messageDetail }));
205
+ statusBasedMessage = (0, lang_1.i18n)(`errors.apiErrors.codes.generic`, {
206
+ messageDetail,
207
+ });
191
208
  }
192
209
  break;
193
210
  }
211
+ if (statusBasedMessage) {
212
+ errorMessage.push(`${statusBasedMessage}${additionalDebugContext ? ` ${additionalDebugContext}` : ''}`);
213
+ }
194
214
  if (error?.response?.data) {
195
215
  const { message, errors } = error.response.data;
196
216
  if (message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.1-beta.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "repository": {
6
6
  "type": "git",
@@ -73,6 +73,8 @@
73
73
  "findup-sync": "5.0.0",
74
74
  "form-data": "^4.0.4",
75
75
  "fs-extra": "11.2.0",
76
+ "http-proxy-agent": "7.0.2",
77
+ "https-proxy-agent": "7.0.6",
76
78
  "ignore": "5.3.1",
77
79
  "js-yaml": "4.1.0",
78
80
  "moment": "2.30.1",
package/types/Deploy.d.ts CHANGED
@@ -35,13 +35,6 @@ export type DeployStatusTaskLocator = {
35
35
  status: string;
36
36
  }>;
37
37
  };
38
- export type ProjectDeployResponseQueued = {
39
- id: string;
40
- buildResultType: 'DEPLOY_QUEUED';
41
- links: {
42
- status: string;
43
- };
44
- };
45
38
  export type SubdeployValidationIssue = {
46
39
  uid: string;
47
40
  componentTypeName: string;
@@ -51,8 +44,20 @@ export type SubdeployValidationIssue = {
51
44
  isWarning: boolean;
52
45
  }[];
53
46
  };
47
+ export type DeployResponseLinks = {
48
+ status: string;
49
+ };
50
+ export type ProjectDeployResponseQueued = {
51
+ id: string;
52
+ buildResultType: 'DEPLOY_QUEUED';
53
+ links: DeployResponseLinks;
54
+ };
54
55
  export type ProjectDeployResponseBlocked = {
55
56
  buildResultType: 'DEPLOY_BLOCKED';
56
57
  issues: SubdeployValidationIssue[];
57
58
  };
58
59
  export type ProjectDeployResponse = ProjectDeployResponseQueued | ProjectDeployResponseBlocked;
60
+ export type ProjectDeployResponseV1 = {
61
+ id: string;
62
+ links: DeployResponseLinks;
63
+ };
package/utils/git.js CHANGED
@@ -12,8 +12,9 @@ const GITIGNORE_FILE = '.gitignore';
12
12
  function makeComparisonDir(filepath) {
13
13
  if (typeof filepath !== 'string')
14
14
  return null;
15
+ let dir = path_1.default.dirname(path_1.default.resolve(filepath)).toLowerCase();
15
16
  // Append sep to make comparisons easier e.g. 'foos'.startsWith('foo')
16
- return path_1.default.dirname(path_1.default.resolve(filepath)).toLowerCase() + path_1.default.sep;
17
+ return dir + (!dir.endsWith(path_1.default.sep) ? path_1.default.sep : '');
17
18
  }
18
19
  function getGitComparisonDir() {
19
20
  return makeComparisonDir((0, findup_sync_1.default)('.git'));