@hubspot/local-dev-lib 5.10.3 → 5.11.0-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.
@@ -4,4 +4,4 @@ import { HubSpotPromise } from '../types/Http.js';
4
4
  export declare function fetchScopeData(accountId: number, scopeGroup: string): HubSpotPromise<ScopeData>;
5
5
  export declare function fetchScopeAuthorizationData(accountId: number): HubSpotPromise<ScopeAuthorizationResponse>;
6
6
  export declare function fetchAppInstallationData(portalId: number, projectId: number, appUid: string, requiredScopeGroups: Array<string>, optionalScopeGroups?: Array<string>): HubSpotPromise<PublicAppInstallationData>;
7
- export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any, {}, any>>;
7
+ export declare function fetchEnabledFeatures(accountId: number): Promise<import("axios").AxiosResponse<EnabledFeaturesResponse, any, {}>>;
package/errors/index.d.ts CHANGED
@@ -16,6 +16,8 @@ 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 hasGithubRateLimitError(err: unknown): boolean;
19
20
  export declare function isGithubError(err: unknown): boolean;
21
+ export declare function getHttpStatusFromError(err: unknown): number | undefined;
20
22
  export declare function isFileSystemError(err: unknown): err is FileSystemError;
21
23
  export declare function isHubSpotConfigError(err: unknown): err is HubSpotConfigError;
package/errors/index.js CHANGED
@@ -48,7 +48,27 @@ export function isGithubRateLimitError(err) {
48
48
  err.headers['x-ratelimit-remaining'] === '0' &&
49
49
  'x-github-request-id' in err.headers);
50
50
  }
51
+ export function hasGithubRateLimitError(err) {
52
+ return (hasGithubRateLimitSignal(err) ||
53
+ (err instanceof Error && hasGithubRateLimitSignal(err.cause)));
54
+ }
55
+ function hasGithubRateLimitSignal(err) {
56
+ if (isGithubRateLimitError(err)) {
57
+ return true;
58
+ }
59
+ if (isAxiosError(err)) {
60
+ const headers = err.response?.headers;
61
+ return (!!headers &&
62
+ String(headers['x-ratelimit-remaining']) === '0' &&
63
+ 'x-github-request-id' in headers);
64
+ }
65
+ return false;
66
+ }
51
67
  export function isGithubError(err) {
68
+ return (hasGithubErrorSignal(err) ||
69
+ (err instanceof Error && hasGithubErrorSignal(err.cause)));
70
+ }
71
+ function hasGithubErrorSignal(err) {
52
72
  if (isHubSpotHttpError(err)) {
53
73
  return !!err.headers && 'x-github-request-id' in err.headers;
54
74
  }
@@ -63,6 +83,22 @@ export function isGithubError(err) {
63
83
  }
64
84
  return false;
65
85
  }
86
+ export function getHttpStatusFromError(err) {
87
+ const status = getStatusCode(err);
88
+ if (status !== undefined) {
89
+ return status;
90
+ }
91
+ return err instanceof Error ? getStatusCode(err.cause) : undefined;
92
+ }
93
+ function getStatusCode(err) {
94
+ if (isHubSpotHttpError(err)) {
95
+ return err.status;
96
+ }
97
+ if (isAxiosError(err)) {
98
+ return err.status ?? err.response?.status;
99
+ }
100
+ return undefined;
101
+ }
66
102
  export function isFileSystemError(err) {
67
103
  return err instanceof Error && err.name === FilerSystemErrorName;
68
104
  }
package/lib/hubdb.d.ts CHANGED
@@ -8,7 +8,7 @@ export declare function createHubDbTable(accountId: number, src: string): Promis
8
8
  tableId: string;
9
9
  rowCount: number;
10
10
  }>;
11
- export declare function updateHubDbTable(accountId: number, tableId: string, src: string): Promise<AxiosResponse<Table, any, {}, any>>;
11
+ export declare function updateHubDbTable(accountId: number, tableId: string, src: string): Promise<AxiosResponse<Table, any, {}>>;
12
12
  export declare function downloadHubDbTable(accountId: number, tableId: string, dest: string): Promise<{
13
13
  filePath: string;
14
14
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "5.10.3",
3
+ "version": "5.11.0-beta.0",
4
4
  "type": "module",
5
5
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
6
6
  "files": [