@hubspot/cms-dev-server 0.15.20 → 0.16.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/dist/run.js CHANGED
@@ -1014,14 +1014,17 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
1014
1014
  import { buildStaticEnvConfig } from "@hubspot/cms-components";
1015
1015
 
1016
1016
  // src/lib/trackUsage.ts
1017
- import cliHttp from "@hubspot/cli-lib/http.js";
1018
- import { getAccountConfig } from "@hubspot/cli-lib/lib/config.js";
1017
+ import localDevHttpImport from "@hubspot/local-dev-lib/http";
1018
+ import { getAccountConfig } from "@hubspot/local-dev-lib/config";
1019
+ import axios from "axios";
1020
+ import { getAxiosConfig } from "@hubspot/local-dev-lib/http/getAxiosConfig";
1019
1021
 
1020
1022
  // src/lib/debug.ts
1021
1023
  import { default as debugFactory } from "debug";
1022
1024
  var debug = debugFactory("cms-dev-server");
1023
1025
 
1024
1026
  // src/lib/trackUsage.ts
1027
+ var { default: hsCliHttp } = localDevHttpImport;
1025
1028
  var DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED = "/cms-dev-server-usage/v1/authenticated";
1026
1029
  var DEV_SERVER_USAGE_ENDPOINT = "/cms-dev-server-usage/v1";
1027
1030
  var EVENT_NAME = "dev-server-interaction";
@@ -1047,23 +1050,23 @@ function trackUsage(action) {
1047
1050
  eventName: EVENT_NAME,
1048
1051
  action,
1049
1052
  nodeVersion: getNodeVersionData(),
1050
- version: "0.15.20",
1053
+ version: "0.16.0",
1051
1054
  os: getPlatform()
1052
1055
  };
1053
- const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
1056
+ const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
1054
1057
  const baseRequestOptions = {
1055
- uri,
1056
- body: usageEvent,
1057
- resolveWithFullResponse: true
1058
+ url: url3,
1059
+ data: usageEvent
1058
1060
  };
1059
1061
  if (isAuthedWithPersonalAccessKey) {
1060
- return cliHttp.post(trackingAccountId, baseRequestOptions);
1062
+ return hsCliHttp.post(trackingAccountId, baseRequestOptions);
1061
1063
  }
1062
- const requestOptions = cliHttp.getRequestOptions(
1063
- { env: trackingEnv },
1064
- baseRequestOptions
1065
- );
1066
- return cliHttp.request.post(requestOptions);
1064
+ const config = getAxiosConfig({
1065
+ ...baseRequestOptions,
1066
+ env: trackingEnv,
1067
+ method: "POST"
1068
+ });
1069
+ return axios(config);
1067
1070
  }
1068
1071
  var setTrackingInfo = (accountId, env) => {
1069
1072
  trackingAccountId = accountId;
@@ -1246,10 +1249,11 @@ import { normalizePath as normalizePath3 } from "vite";
1246
1249
  import { join as joinPosix2 } from "path/posix";
1247
1250
  import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
1248
1251
  import * as cmsComponents2 from "@hubspot/cms-components";
1249
- import cliHttp3 from "@hubspot/cli-lib/http.js";
1252
+ import localDevHttpImport3 from "@hubspot/local-dev-lib/http";
1250
1253
 
1251
1254
  // src/lib/fetchModuleGraphQLData.ts
1252
- import cliHttp2 from "@hubspot/cli-lib/http.js";
1255
+ import localDevHttpImport2 from "@hubspot/local-dev-lib/http";
1256
+ var { default: hsCliHttp2 } = localDevHttpImport2;
1253
1257
  var graphQLCache = /* @__PURE__ */ new Map();
1254
1258
  async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pageUrl) {
1255
1259
  const { searchParams } = new URL(pageUrl);
@@ -1261,9 +1265,9 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
1261
1265
  return Promise.resolve(graphQLCache.get(compositeQueryKey));
1262
1266
  }
1263
1267
  try {
1264
- dataQueryResult = await cliHttp2.post(accountId, {
1265
- uri: "/collector/v3/graphql",
1266
- body: {
1268
+ dataQueryResult = await hsCliHttp2.post(accountId, {
1269
+ url: "/collector/v3/graphql",
1270
+ data: {
1267
1271
  query
1268
1272
  }
1269
1273
  });
@@ -1275,6 +1279,7 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
1275
1279
  }
1276
1280
 
1277
1281
  // src/lib/renderModule.ts
1282
+ var { default: hsCliHttp3 } = localDevHttpImport3;
1278
1283
  var { filterToModuleDataDepsIncludedIn, getModuleDataDependecyTypeFrom } = cmsComponents2;
1279
1284
  var getApplyFieldsValidationToRenderContext = (portalId, fieldsJSON, requestedModulePath) => {
1280
1285
  return async (renderResult) => {
@@ -1284,21 +1289,17 @@ var getApplyFieldsValidationToRenderContext = (portalId, fieldsJSON, requestedMo
1284
1289
  WARNING: "warn"
1285
1290
  };
1286
1291
  let validationRequest;
1287
- let fieldValidationErrors = [];
1288
1292
  try {
1289
- validationRequest = await cliHttp3.post(portalId, {
1290
- uri: "/designmanager/v1/modules/validate-fields",
1291
- body: fieldsJSON,
1293
+ validationRequest = await hsCliHttp3.post(portalId, {
1294
+ url: "/designmanager/v1/modules/validate-fields",
1295
+ data: fieldsJSON,
1292
1296
  resolveWithFullResponse: true
1293
1297
  });
1294
1298
  } catch {
1295
1299
  console.log("Failed to validate module fields for", requestedModulePath);
1296
1300
  }
1297
- if (validationRequest) {
1298
- fieldValidationErrors = validationRequest.body;
1299
- }
1300
- if (fieldValidationErrors.length) {
1301
- fieldValidationErrors.forEach((fieldValidationError) => {
1301
+ if (validationRequest.length) {
1302
+ validationRequest.forEach((fieldValidationError) => {
1302
1303
  renderContext.criticalDevErrors.push({
1303
1304
  message: `Field Validation Error in ${requestedModulePath}: ${fieldValidationError.message}`,
1304
1305
  error: new Error(fieldValidationError.message),
@@ -1559,8 +1560,9 @@ var module_default = moduleRouteHandler;
1559
1560
  // src/proxyPage/fetchContentMetadata.ts
1560
1561
  import http from "http";
1561
1562
  import https from "https";
1562
- import { get as hsGet } from "@hubspot/cli-lib/http.js";
1563
- import { getAccountId } from "@hubspot/cli-lib/lib/config.js";
1563
+ import localDevHttpImport4 from "@hubspot/local-dev-lib/http";
1564
+ import { getAccountId } from "@hubspot/local-dev-lib/config";
1565
+ var { default: hsCliHttp4 } = localDevHttpImport4;
1564
1566
  async function requestContentPreview(url3, portalId) {
1565
1567
  const urlObject = new URL(url3);
1566
1568
  const proxiedQueryParams = {};
@@ -1573,12 +1575,11 @@ async function requestContentPreview(url3, portalId) {
1573
1575
  }
1574
1576
  }
1575
1577
  const accountId = getAccountId(portalId);
1576
- const response = await hsGet(accountId, {
1577
- baseUrl: urlObject.origin,
1578
- uri: urlObject.pathname,
1579
- query: proxiedQueryParams,
1580
- json: false,
1581
- resolveWithFullResponse: true
1578
+ const response = await hsCliHttp4.get(accountId, {
1579
+ baseURL: urlObject.origin,
1580
+ url: urlObject.pathname,
1581
+ params: proxiedQueryParams,
1582
+ responseType: "text"
1582
1583
  });
1583
1584
  return response;
1584
1585
  }
@@ -1660,8 +1661,8 @@ async function fetchContentMetadata(url3, portalId) {
1660
1661
  // src/proxyPage/proxyPage.ts
1661
1662
  import path5 from "path";
1662
1663
  import { normalizePath as normalizePath4 } from "vite";
1663
- import { getAccountId as getAccountId2, getEnv } from "@hubspot/cli-lib/lib/config.js";
1664
- import { get as hsGet3 } from "@hubspot/cli-lib/http.js";
1664
+ import { getAccountId as getAccountId2, getEnv } from "@hubspot/local-dev-lib/config";
1665
+ import localDevHttpImport6 from "@hubspot/local-dev-lib/http";
1665
1666
 
1666
1667
  // src/lib/proxyHelpers.ts
1667
1668
  import fs2 from "fs";
@@ -1843,7 +1844,8 @@ var renderLocalError_default = (path10, error) => {
1843
1844
  };
1844
1845
 
1845
1846
  // src/proxyPage/fetchPreviewInfo.ts
1846
- import { get as hsGet2 } from "@hubspot/cli-lib/http.js";
1847
+ import localDevHttpImport5 from "@hubspot/local-dev-lib/http";
1848
+ var { default: hsCliHttp5 } = localDevHttpImport5;
1847
1849
  var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
1848
1850
  if (!contentId) {
1849
1851
  throw new Error(
@@ -1851,10 +1853,10 @@ var fetchPreviewInfo_default = async (accountId, portalId, contentId) => {
1851
1853
  );
1852
1854
  }
1853
1855
  try {
1854
- const content = await hsGet2(accountId, {
1855
- uri: `/content/api/v4/contents/${contentId}`,
1856
- query: { portalId },
1857
- json: true
1856
+ const content = await hsCliHttp5.get(accountId, {
1857
+ url: `/content/api/v4/contents/${contentId}`,
1858
+ params: { portalId },
1859
+ responseType: "json"
1858
1860
  });
1859
1861
  return {
1860
1862
  previewDomain: content.previewDomain ?? content.resolvedDomain,
@@ -1890,6 +1892,7 @@ import {
1890
1892
  isDebugUrlString as isDebugUrlString3,
1891
1893
  mergeServerRequestData_internal
1892
1894
  } from "@hubspot/cms-components";
1895
+ var { default: hsCliHttp6 } = localDevHttpImport6;
1893
1896
  var getEntryPointBasePathFromProxyRequest = (request2) => {
1894
1897
  if (!request2) {
1895
1898
  return "";
@@ -1916,7 +1919,7 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1916
1919
  const url3 = new URL(urlToProxy);
1917
1920
  const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
1918
1921
  let proxiedQueryParams = {};
1919
- let baseUrl = url3.origin;
1922
+ let baseURL = url3.origin;
1920
1923
  let pathname = url3.pathname;
1921
1924
  const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
1922
1925
  const queryKeys = Array.from(url3.searchParams.keys()).filter(
@@ -1940,30 +1943,30 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1940
1943
  };
1941
1944
  if (renderPreviewLocally) {
1942
1945
  proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
1943
- baseUrl = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
1946
+ baseURL = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
1944
1947
  pathname = `/cos-rendering/v1/public${url3.pathname}`;
1945
1948
  }
1946
1949
  console.log(
1947
- `Proxying request to ${baseUrl}${pathname}?${new URLSearchParams({
1950
+ `Proxying request to ${baseURL}${pathname}?${new URLSearchParams({
1948
1951
  ...proxiedQueryParams,
1949
1952
  previewKey,
1950
1953
  contentId
1951
1954
  }).toString()}`
1952
1955
  );
1953
- const result = hsGet3(accountId, {
1954
- baseUrl,
1955
- uri: pathname,
1956
- query: proxiedQueryParams,
1957
- json: false,
1958
- useQuerystring: true,
1956
+ const result = hsCliHttp6.get(accountId, {
1957
+ baseURL,
1958
+ url: pathname,
1959
+ params: proxiedQueryParams,
1960
+ responseType: "text",
1961
+ // Maybe we can remove the user agent?
1959
1962
  headers: {
1960
1963
  COOKIE: cookieHeader,
1961
1964
  "User-Agent": "HubSpot CMS Dev Server"
1962
1965
  }
1963
1966
  });
1964
1967
  return result.catch((error) => {
1965
- if (error.statusCode >= 400 && error.statusCode < 500 && !!error.response.body) {
1966
- return error.response.body;
1968
+ if (error.status >= 400 && error.status < 500 && !!error.response.data) {
1969
+ return error.response.data;
1967
1970
  } else {
1968
1971
  throw error;
1969
1972
  }
@@ -2554,8 +2557,8 @@ function proxyServerlessRequest(req, res, next) {
2554
2557
  import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
2555
2558
  import path6 from "path";
2556
2559
  import { normalizePath as normalizePath5 } from "vite";
2557
- import hsHttp from "@hubspot/cli-lib/http.js";
2558
- var { post: hsPost } = hsHttp;
2560
+ import localDevHttpImport7 from "@hubspot/local-dev-lib/http";
2561
+ var { default: hsCliHttp7 } = localDevHttpImport7;
2559
2562
  async function modulePreviewRouteHandler(request2, response) {
2560
2563
  sendTrackingRequest("view-module-preview-route");
2561
2564
  const {
@@ -2631,8 +2634,8 @@ async function modulePreviewRouteHandler(request2, response) {
2631
2634
  });
2632
2635
  const currentHubApiDomainOverride = process.env.HUBAPI_DOMAIN_OVERRIDE;
2633
2636
  process.env.HUBAPI_DOMAIN_OVERRIDE = `api.hubspot${authedEnv === "qa" ? "qa" : ""}`;
2634
- const templatePreviewPromise = hsPost(authedPortalId, {
2635
- uri: `/api/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
2637
+ const templatePreviewPromise = hsCliHttp7.post(authedPortalId, {
2638
+ url: `/api/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
2636
2639
  headers: {
2637
2640
  ["content-type"]: "application/x-www-form-urlencoded",
2638
2641
  ["Accept"]: "text/html",
@@ -2640,7 +2643,7 @@ async function modulePreviewRouteHandler(request2, response) {
2640
2643
  cookie: request2.get("COOKIE"),
2641
2644
  "User-Agent": "HubSpot CMS Dev Server"
2642
2645
  },
2643
- body: `module=${encodeURIComponent(JSON.stringify(localModule))}`
2646
+ data: `module=${encodeURIComponent(JSON.stringify(localModule))}`
2644
2647
  });
2645
2648
  if (currentHubApiDomainOverride) {
2646
2649
  process.env.HUBAPI_DOMAIN_OVERRIDE = currentHubApiDomainOverride;
@@ -2762,7 +2765,7 @@ import express from "express";
2762
2765
 
2763
2766
  // src/shadowDevServer/createShadowDevServerRoutes.ts
2764
2767
  import { Router as Router2 } from "express";
2765
- import { getAccountId as getAccountId3, getEnv as getEnv2 } from "@hubspot/cli-lib/lib/config.js";
2768
+ import { getAccountId as getAccountId3, getEnv as getEnv2 } from "@hubspot/local-dev-lib/config";
2766
2769
  import cors from "cors";
2767
2770
  import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
2768
2771
  function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
@@ -3017,7 +3020,7 @@ function createHttpsRedirectingServer(opts, handler) {
3017
3020
  }
3018
3021
 
3019
3022
  // src/lib/getJSRenderingGates.ts
3020
- import unAuth from "@hubspot/cli-lib/api/localDevAuth/unauthenticated.js";
3023
+ import { fetchAccessToken } from "@hubspot/local-dev-lib/api/localDevAuth";
3021
3024
 
3022
3025
  // src/lib/gates.ts
3023
3026
  function getGatesFromEnv() {
@@ -3035,7 +3038,7 @@ var mapEnabledFeaturesToGates = (enabledFeatures) => {
3035
3038
  }, []);
3036
3039
  };
3037
3040
  async function getJsRenderingGates(portalId, env, personalAccessKey) {
3038
- const { enabledFeatures = {} } = await unAuth.fetchAccessToken(
3041
+ const { enabledFeatures = {} } = await fetchAccessToken(
3039
3042
  personalAccessKey,
3040
3043
  env,
3041
3044
  portalId
@@ -3054,11 +3057,11 @@ import {
3054
3057
  getAccountConfig as getAccountConfig2,
3055
3058
  loadConfig,
3056
3059
  validateConfig
3057
- } from "@hubspot/cli-lib/lib/config.js";
3058
- import { fetchSecrets } from "@hubspot/cli-lib/api/secrets.js";
3060
+ } from "@hubspot/local-dev-lib/config";
3061
+ import { fetchSecrets } from "@hubspot/local-dev-lib/api/secrets";
3059
3062
 
3060
3063
  // src/proxyPage/fetchDomains.ts
3061
- import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
3064
+ import localDevHttpImport8 from "@hubspot/local-dev-lib/http";
3062
3065
 
3063
3066
  // src/lib/errors.ts
3064
3067
  var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
@@ -3114,12 +3117,13 @@ function handleSecretsError(error) {
3114
3117
  }
3115
3118
 
3116
3119
  // src/proxyPage/fetchDomains.ts
3120
+ var { default: hsCliHttp8 } = localDevHttpImport8;
3117
3121
  async function fetchDomains(portalId) {
3118
3122
  try {
3119
- const result = await hsGet4(portalId, {
3120
- uri: `/cms/v3/domains`,
3121
- query: { portalId },
3122
- json: true
3123
+ const result = await hsCliHttp8.get(portalId, {
3124
+ url: `/cms/v3/domains`,
3125
+ params: { portalId },
3126
+ responseType: "json"
3123
3127
  });
3124
3128
  return result.results;
3125
3129
  } catch (error) {
@@ -3142,7 +3146,8 @@ async function fetchWebsiteDomainNames(portalId) {
3142
3146
  import path7 from "path";
3143
3147
  import fs3 from "fs";
3144
3148
  import select from "@inquirer/select";
3145
- import { get as hsGet5 } from "@hubspot/cli-lib/http.js";
3149
+ import localDevHttpImport9 from "@hubspot/local-dev-lib/http";
3150
+ var { default: hsCliHttp9 } = localDevHttpImport9;
3146
3151
  var HSPROJECT_JSON = "hsproject.json";
3147
3152
  function checkFileExists(filePath) {
3148
3153
  return fs3.existsSync(filePath) && fs3.statSync(filePath).isFile();
@@ -3176,9 +3181,9 @@ async function validateHSPlatform(projectConfigPath, portalId) {
3176
3181
  const { platformVersion } = hsProjectJSONData;
3177
3182
  let platformVersionResult;
3178
3183
  try {
3179
- platformVersionResult = await hsGet5(portalId, {
3180
- uri: `developer/projects/v1/platformVersion`,
3181
- json: true
3184
+ platformVersionResult = await hsCliHttp9.get(portalId, {
3185
+ url: `developer/projects/v1/platformVersion`,
3186
+ responseType: "json"
3182
3187
  });
3183
3188
  } catch (e) {
3184
3189
  console.error(e.message);
@@ -3216,7 +3221,7 @@ async function validateHSPlatform(projectConfigPath, portalId) {
3216
3221
  }
3217
3222
 
3218
3223
  // src/createDevServer.ts
3219
- import { get as hsGet6 } from "@hubspot/cli-lib/http.js";
3224
+ import localDevHttpImport10 from "@hubspot/local-dev-lib/http";
3220
3225
 
3221
3226
  // ../cms-js-internal/dist/buildFieldsTypes.js
3222
3227
  import { writeFileSync } from "fs";
@@ -3573,6 +3578,7 @@ var startFieldsTypeGenWatcher = (viteServer, projectRoot) => {
3573
3578
  };
3574
3579
 
3575
3580
  // src/createDevServer.ts
3581
+ var { default: hsCliHttp10 } = localDevHttpImport10;
3576
3582
  var BASE_PATH = "/";
3577
3583
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
3578
3584
  var SHADOW_PORT = 1442;
@@ -3608,7 +3614,13 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
3608
3614
  }
3609
3615
  if (validateConfig()) {
3610
3616
  authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
3611
- authedEnv = getEnv3(hubspotCliAccountNameOption2);
3617
+ const env = getEnv3(hubspotCliAccountNameOption2);
3618
+ if (!env) {
3619
+ throw new Error(
3620
+ `No environment found for account ${hubspotCliAccountNameOption2} from hubspot.config.yaml`
3621
+ );
3622
+ }
3623
+ authedEnv = env;
3612
3624
  personalAccessKey = getAccountConfig2(authedPortalId) && getAccountConfig2(authedPortalId).personalAccessKey;
3613
3625
  if (!authedPortalId && hubspotCliAccountNameOption2) {
3614
3626
  console.error(
@@ -3680,8 +3692,8 @@ Local proxy functionality and module preview routes will not work without settin
3680
3692
  }
3681
3693
  let authedHublet;
3682
3694
  try {
3683
- const accountInformation = await hsGet6(authedPortalId, {
3684
- uri: "/account-info/v3/details"
3695
+ const accountInformation = await hsCliHttp10.get(authedPortalId, {
3696
+ url: "/account-info/v3/details"
3685
3697
  });
3686
3698
  authedHublet = accountInformation.dataHostingLocation;
3687
3699
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.15.20",
3
+ "version": "0.16.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -25,8 +25,8 @@
25
25
  "publint": "publint --level warning --prod"
26
26
  },
27
27
  "dependencies": {
28
- "@hubspot/cli-lib": "^3.0.12",
29
- "@hubspot/cms-components": "^0.15.20",
28
+ "@hubspot/cms-components": "^0.16.0",
29
+ "@hubspot/local-dev-lib": "^1.9.0",
30
30
  "@inquirer/select": "^2.0.0",
31
31
  "@originjs/vite-plugin-commonjs": "^1.0.3",
32
32
  "@storybook/addon-actions": "7.1.1",
@@ -108,5 +108,5 @@
108
108
  "publishConfig": {
109
109
  "access": "public"
110
110
  },
111
- "gitHead": "87575197c7aee7567539e524458114a3ed873dd6"
111
+ "gitHead": "94e33a0713c66a56bb8f9e7b7b83eb119a2bcd70"
112
112
  }
@@ -1,2 +0,0 @@
1
- import { setupIslandHydration } from '@hubspot/cms-js-internal/island-runtime';
2
- export { setupIslandHydration };