@hubspot/local-dev-lib 0.3.14 → 1.0.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.
package/api/github.js CHANGED
@@ -16,7 +16,7 @@ const GITHUB_AUTH_HEADERS = {
16
16
  async function fetchRepoReleaseData(repoPath, tag = '') {
17
17
  const URL = `${GITHUB_REPOS_API}/${repoPath}/releases`;
18
18
  return axios_1.default.get(`${URL}/${tag ? `tags/${tag}` : 'latest'}`, {
19
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
19
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
20
20
  });
21
21
  }
22
22
  exports.fetchRepoReleaseData = fetchRepoReleaseData;
@@ -25,21 +25,21 @@ exports.fetchRepoReleaseData = fetchRepoReleaseData;
25
25
  async function fetchRepoAsZip(zipUrl) {
26
26
  return axios_1.default.get(zipUrl, {
27
27
  responseType: 'arraybuffer',
28
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
28
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
29
29
  });
30
30
  }
31
31
  exports.fetchRepoAsZip = fetchRepoAsZip;
32
32
  // Returns the raw file contents via the raw.githubusercontent endpoint
33
33
  async function fetchRepoFile(repoPath, filePath, ref) {
34
34
  return axios_1.default.get(`${GITHUB_RAW_CONTENT_API_PATH}/${repoPath}/${ref}/${filePath}`, {
35
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
35
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
36
36
  });
37
37
  }
38
38
  exports.fetchRepoFile = fetchRepoFile;
39
39
  // Returns the raw file contents via the raw.githubusercontent endpoint
40
40
  async function fetchRepoFileByDownloadUrl(downloadUrl) {
41
41
  return axios_1.default.get(downloadUrl, {
42
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
42
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
43
43
  });
44
44
  }
45
45
  exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
@@ -48,7 +48,7 @@ exports.fetchRepoFileByDownloadUrl = fetchRepoFileByDownloadUrl;
48
48
  async function fetchRepoContents(repoPath, path, ref) {
49
49
  const refQuery = ref ? `?ref=${ref}` : '';
50
50
  return axios_1.default.get(`${GITHUB_REPOS_API}/${repoPath}/contents/${path}${refQuery}`, {
51
- headers: { ...getAxiosConfig_1.DEFAULT_USER_AGENT_HEADERS, ...GITHUB_AUTH_HEADERS },
51
+ headers: { ...(0, getAxiosConfig_1.getDefaultUserAgentHeader)(), ...GITHUB_AUTH_HEADERS },
52
52
  });
53
53
  }
54
54
  exports.fetchRepoContents = fetchRepoContents;
@@ -1,6 +1,9 @@
1
1
  import { AxiosConfigOptions } from '../types/Http';
2
2
  import { AxiosRequestConfig } from 'axios';
3
- export declare const DEFAULT_USER_AGENT_HEADERS: {
3
+ export declare const USER_AGENTS: {
4
+ [key: string]: string;
5
+ };
6
+ export declare function getDefaultUserAgentHeader(): {
4
7
  'User-Agent': string;
5
8
  };
6
9
  export declare function getAxiosConfig(options: AxiosConfigOptions): AxiosRequestConfig;
@@ -1,12 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAxiosConfig = exports.DEFAULT_USER_AGENT_HEADERS = void 0;
3
+ exports.getAxiosConfig = exports.getDefaultUserAgentHeader = exports.USER_AGENTS = void 0;
4
4
  const package_json_1 = require("../package.json");
5
5
  const config_1 = require("../config");
6
6
  const urls_1 = require("../lib/urls");
7
- exports.DEFAULT_USER_AGENT_HEADERS = {
8
- 'User-Agent': `HubSpot Local Dev Lib/${package_json_1.version}`,
7
+ exports.USER_AGENTS = {
8
+ 'HubSpot Local Dev Lib': package_json_1.version,
9
9
  };
10
+ function getDefaultUserAgentHeader() {
11
+ let userAgentString = '';
12
+ Object.keys(exports.USER_AGENTS).forEach((userAgentKey, i) => {
13
+ userAgentString += `${i > 0 ? ', ' : ''}${userAgentKey}/${exports.USER_AGENTS[userAgentKey]}`;
14
+ });
15
+ return {
16
+ 'User-Agent': userAgentString,
17
+ };
18
+ }
19
+ exports.getDefaultUserAgentHeader = getDefaultUserAgentHeader;
10
20
  const DEFAULT_TRANSITIONAL = {
11
21
  clarifyTimeoutError: true,
12
22
  };
@@ -16,7 +26,7 @@ function getAxiosConfig(options) {
16
26
  return {
17
27
  baseURL: (0, urls_1.getHubSpotApiOrigin)(env, localHostOverride ? false : httpUseLocalhost),
18
28
  headers: {
19
- ...exports.DEFAULT_USER_AGENT_HEADERS,
29
+ ...getDefaultUserAgentHeader(),
20
30
  ...(headers || {}),
21
31
  },
22
32
  timeout: httpTimeout || 15000,
package/http/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { HttpOptions } from '../types/Http';
3
+ export declare function addUserAgentHeader(key: string, value: string): void;
3
4
  declare function getRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
4
5
  declare function postRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
5
6
  declare function putRequest<T>(accountId: number, options: HttpOptions): Promise<T>;
package/http/index.js CHANGED
@@ -3,6 +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.addUserAgentHeader = void 0;
6
7
  const path_1 = __importDefault(require("path"));
7
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
9
  const content_disposition_1 = __importDefault(require("content-disposition"));
@@ -15,6 +16,10 @@ const standardErrors_1 = require("../errors/standardErrors");
15
16
  const logger_1 = require("../lib/logger");
16
17
  const lang_1 = require("../utils/lang");
17
18
  const i18nKey = 'http.index';
19
+ function addUserAgentHeader(key, value) {
20
+ getAxiosConfig_1.USER_AGENTS[key] = value;
21
+ }
22
+ exports.addUserAgentHeader = addUserAgentHeader;
18
23
  async function withOauth(accountId, accountConfig, axiosConfig) {
19
24
  const { headers } = axiosConfig;
20
25
  const oauth = (0, oauth_1.getOauthManager)(accountId, accountConfig);
package/lang/en.json CHANGED
@@ -380,7 +380,7 @@
380
380
  "429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
381
381
  "503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
382
382
  "403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
383
- "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216.",
383
+ "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
384
384
  "500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
385
385
  "400Generic": "The {{ messageDetail }} failed due to a client error.",
386
386
  "generic": "The {{ messageDetail }} failed."
package/lang/lang/en.json CHANGED
@@ -380,7 +380,7 @@
380
380
  "429": "The {{ messageDetail }} surpassed the rate limit. Retry in one minute.",
381
381
  "503": "The {{ messageDetail }} could not be handled at this time. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
382
382
  "403ProjectMissingScope": "Couldn't run the project command because there are scopes missing in your production account. To update scopes, deactivate your current personal access key for {{ accountId }}, and generate a new one. Then run `hs auth` to update the CLI with the new key.",
383
- "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/whats-new/betas?productUpdateId=13860216.",
383
+ "403ProjectGating": "The current target account {{ accountId }} does not have access to HubSpot projects. To opt in to the CRM Development Beta and use projects, visit https://app.hubspot.com/l/product-updates/in-beta?update=13899236.",
384
384
  "500Generic": "The {{ messageDetail }} failed due to a server error. Please try again or visit https://help.hubspot.com/ to submit a ticket or contact HubSpot Support if the issue persists.",
385
385
  "400Generic": "The {{ messageDetail }} failed due to a client error.",
386
386
  "generic": "The {{ messageDetail }} failed."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/local-dev-lib",
3
- "version": "0.3.14",
3
+ "version": "1.0.0",
4
4
  "description": "Provides library functionality for HubSpot local development tooling, including the HubSpot CLI",
5
5
  "main": "lib/index.js",
6
6
  "repository": {