strapi-plugin-hubspot 0.2.0 → 0.2.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.
package/README.md CHANGED
@@ -144,8 +144,16 @@ Create a **private app** in HubSpot with a read scope per object you list:
144
144
 
145
145
  An object the token can't read is **skipped, not fatal**: the picker keeps
146
146
  working for the others and explains which one is missing a scope. `oauth` is
147
- worth adding too — it exposes the portal id, which turns on the *view in HubSpot*
148
- links.
147
+ worth adding too — it exposes the portal id *and the portal's UI host*, which
148
+ turn on the *view in HubSpot* links.
149
+
150
+ ### Regions
151
+
152
+ The REST API is global: `api.hubapi.com` routes by token, whatever the portal's
153
+ hosting region. The **web app is not** — an EU-hosted portal lives on
154
+ `app-eu1.hubspot.com`. Deep links are built from the `uiDomain` HubSpot reports
155
+ for your portal rather than a hardcoded host, so they point at the right region
156
+ without any configuration.
149
157
 
150
158
  The key is resolved in this order, first match wins:
151
159
 
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-sOi9wC_y.js");
7
+ const index = require("./index-DgsAHPui.js");
8
8
  function _interopNamespace(e) {
9
9
  if (e && e.__esModule) return e;
10
10
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -88,7 +88,7 @@ const HubspotPropertyInput = React__namespace.forwardRef(
88
88
  }
89
89
  return hint;
90
90
  };
91
- const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://app.hubspot.com/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
91
+ const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://${schema.uiDomain || "app.hubspot.com"}/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
92
92
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name, error, hint: describe(), required, children: [
93
93
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
94
94
  !schema ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: "Chargement des propriétés HubSpot…" }) }) : schema.configured ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { Field, Flex, Loader, Combobox, ComboboxOption, Link } from "@strapi/design-system";
4
4
  import { useFetchClient, useField } from "@strapi/strapi/admin";
5
- import { P as PLUGIN_ID } from "./index-DIwNOVQ0.mjs";
5
+ import { P as PLUGIN_ID } from "./index-BpZtcsPM.mjs";
6
6
  const LABELS = {
7
7
  contact: "Contact",
8
8
  company: "Société",
@@ -68,7 +68,7 @@ const HubspotPropertyInput = React.forwardRef(
68
68
  }
69
69
  return hint;
70
70
  };
71
- const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://app.hubspot.com/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
71
+ const crmLink = schema?.portalId && value && schema.properties.some((p) => p.name === value) ? `https://${schema.uiDomain || "app.hubspot.com"}/property-settings/${schema.portalId}/properties?search=${encodeURIComponent(value)}` : null;
72
72
  return /* @__PURE__ */ jsxs(Field.Root, { name, error, hint: describe(), required, children: [
73
73
  /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
74
74
  !schema ? /* @__PURE__ */ jsx(Flex, { paddingTop: 2, paddingBottom: 2, children: /* @__PURE__ */ jsx(Loader, { small: true, children: "Chargement des propriétés HubSpot…" }) }) : schema.configured ? /* @__PURE__ */ jsx(
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { Box, Loader, Flex, Typography, Badge, Field, Button } from "@strapi/design-system";
4
4
  import { useFetchClient } from "@strapi/strapi/admin";
5
- import { P as PLUGIN_ID } from "./index-DIwNOVQ0.mjs";
5
+ import { P as PLUGIN_ID } from "./index-BpZtcsPM.mjs";
6
6
  const SOURCE_LABEL = {
7
7
  settings: "saisie ici",
8
8
  config: "config/plugins.ts",
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const admin = require("@strapi/strapi/admin");
7
- const index = require("./index-sOi9wC_y.js");
7
+ const index = require("./index-DgsAHPui.js");
8
8
  function _interopNamespace(e) {
9
9
  if (e && e.__esModule) return e;
10
10
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -14,7 +14,7 @@ const index = {
14
14
  defaultMessage: "Choisie dans les propriétés réelles du portail"
15
15
  },
16
16
  components: {
17
- Input: async () => import("./HubspotPropertyInput-D0gijgli.mjs")
17
+ Input: async () => import("./HubspotPropertyInput-C7Wcw8ee.mjs")
18
18
  },
19
19
  options: {}
20
20
  });
@@ -29,7 +29,7 @@ const index = {
29
29
  id: `${PLUGIN_ID}-settings`,
30
30
  to: `/settings/${PLUGIN_ID}`,
31
31
  permissions: [],
32
- Component: async () => (await import("./Settings-DuYUpD8L.mjs")).default
32
+ Component: async () => (await import("./Settings-B5w7LAsH.mjs")).default
33
33
  }
34
34
  ]
35
35
  );
@@ -15,7 +15,7 @@ const index = {
15
15
  defaultMessage: "Choisie dans les propriétés réelles du portail"
16
16
  },
17
17
  components: {
18
- Input: async () => Promise.resolve().then(() => require("./HubspotPropertyInput-BcdqfAfv.js"))
18
+ Input: async () => Promise.resolve().then(() => require("./HubspotPropertyInput-BVFRtt49.js"))
19
19
  },
20
20
  options: {}
21
21
  });
@@ -30,7 +30,7 @@ const index = {
30
30
  id: `${PLUGIN_ID}-settings`,
31
31
  to: `/settings/${PLUGIN_ID}`,
32
32
  permissions: [],
33
- Component: async () => (await Promise.resolve().then(() => require("./Settings-DedA0z6w.js"))).default
33
+ Component: async () => (await Promise.resolve().then(() => require("./Settings-TGB0MOHr.js"))).default
34
34
  }
35
35
  ]
36
36
  );
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-sOi9wC_y.js");
2
+ const index = require("../_chunks/index-DgsAHPui.js");
3
3
  module.exports = index.index;
@@ -1,4 +1,4 @@
1
- import { i } from "../_chunks/index-DIwNOVQ0.mjs";
1
+ import { i } from "../_chunks/index-BpZtcsPM.mjs";
2
2
  export {
3
3
  i as default
4
4
  };
@@ -39,12 +39,14 @@ async function fetchObject(apiKey, object) {
39
39
  group: p.groupName
40
40
  }));
41
41
  }
42
- async function fetchPortalId(apiKey) {
42
+ async function fetchAccount(apiKey) {
43
43
  try {
44
- const { portalId } = await hsGet(apiKey, "/account-info/v3/details");
45
- return portalId;
44
+ return await hsGet(
45
+ apiKey,
46
+ "/account-info/v3/details"
47
+ );
46
48
  } catch {
47
- return void 0;
49
+ return {};
48
50
  }
49
51
  }
50
52
  async function loadSchema(strapi, apiKey, objects, { force = false } = {}) {
@@ -79,11 +81,13 @@ async function loadSchema(strapi, apiKey, objects, { force = false } = {}) {
79
81
  properties.sort(
80
82
  (a, b) => a.object.localeCompare(b.object) || a.label.localeCompare(b.label)
81
83
  );
84
+ const account = await fetchAccount(apiKey);
82
85
  const schema = {
83
86
  properties,
84
87
  objects: available,
85
88
  unavailable,
86
- portalId: await fetchPortalId(apiKey)
89
+ portalId: account.portalId,
90
+ uiDomain: account.uiDomain
87
91
  };
88
92
  cache = { at: Date.now(), schema };
89
93
  return schema;
@@ -38,12 +38,14 @@ async function fetchObject(apiKey, object) {
38
38
  group: p.groupName
39
39
  }));
40
40
  }
41
- async function fetchPortalId(apiKey) {
41
+ async function fetchAccount(apiKey) {
42
42
  try {
43
- const { portalId } = await hsGet(apiKey, "/account-info/v3/details");
44
- return portalId;
43
+ return await hsGet(
44
+ apiKey,
45
+ "/account-info/v3/details"
46
+ );
45
47
  } catch {
46
- return void 0;
48
+ return {};
47
49
  }
48
50
  }
49
51
  async function loadSchema(strapi, apiKey, objects, { force = false } = {}) {
@@ -78,11 +80,13 @@ async function loadSchema(strapi, apiKey, objects, { force = false } = {}) {
78
80
  properties.sort(
79
81
  (a, b) => a.object.localeCompare(b.object) || a.label.localeCompare(b.label)
80
82
  );
83
+ const account = await fetchAccount(apiKey);
81
84
  const schema = {
82
85
  properties,
83
86
  objects: available,
84
87
  unavailable,
85
- portalId: await fetchPortalId(apiKey)
88
+ portalId: account.portalId,
89
+ uiDomain: account.uiDomain
86
90
  };
87
91
  cache = { at: Date.now(), schema };
88
92
  return schema;
@@ -29,6 +29,13 @@ export interface Schema {
29
29
  }[];
30
30
  /** Enables deep links into the CRM; derived from the token, never configured. */
31
31
  portalId?: number;
32
+ /**
33
+ * Region-specific UI host for this portal (`app-eu1.hubspot.com`…). The REST
34
+ * API is global — `api.hubapi.com` routes by token — but the web app is not,
35
+ * so a link built on `app.hubspot.com` lands on the wrong host for any portal
36
+ * hosted outside NA.
37
+ */
38
+ uiDomain?: string;
32
39
  }
33
40
  /**
34
41
  * Writable properties of every configured object, cached and de-duplicated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strapi-plugin-hubspot",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "HubSpot integration for Strapi — pick CRM properties from a searchable list filtered by object, and catch bad mappings before they reach the API.",
5
5
  "keywords": [
6
6
  "strapi",