@growth-operations/ui-shared 1.0.6 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-operations/ui-shared",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Shared HubSpot UI-extension modules (Home, Billing) for Growth Operations apps.",
5
5
  "license": "MIT",
6
6
  "private": false,
package/src/index.js CHANGED
@@ -27,6 +27,19 @@ export {
27
27
  } from "./lib/format";
28
28
  export { useStrictModeEffect } from "./lib/useStrictModeEffect";
29
29
 
30
+ // HubSpot URL builders (app.hubspot.com record/property/list links).
31
+ export {
32
+ buildContactUrl,
33
+ buildRecordUrl,
34
+ buildObjectListUrl,
35
+ buildContactListCreateUrl,
36
+ buildContactListEditUrl,
37
+ buildFormEditorUrl,
38
+ buildPropertySettingsUrl,
39
+ buildPropertyName,
40
+ buildPropertyNames,
41
+ } from "./lib/urls";
42
+
30
43
  // SDK — the token + API utility layer (see README "SDK" section and src/sdk/).
31
44
  export {
32
45
  // App backend
@@ -0,0 +1,53 @@
1
+ // Shared HubSpot URL builders for Growth Operations app UIs.
2
+ // Framework-agnostic (no React) — every app links out to HubSpot records,
3
+ // properties, and lists from the same app.hubspot.com URL shapes, so these are
4
+ // generic. Centralized here so a HubSpot URL-format change is fixed once.
5
+
6
+ const APP = "https://app.hubspot.com";
7
+
8
+ // A contact record. (Contacts are object type 0-1; see buildRecordUrl for the
9
+ // generic form.)
10
+ export function buildContactUrl(portalId, contactId) {
11
+ return `${APP}/contacts/${portalId}/contact/${contactId}`;
12
+ }
13
+
14
+ // Any CRM record by object type id (e.g. "0-1" contacts, a custom object id).
15
+ export function buildRecordUrl(portalId, objectTypeId, recordId) {
16
+ return `${APP}/contacts/${portalId}/record/${objectTypeId}/${recordId}`;
17
+ }
18
+
19
+ // A custom object's "all records" list view.
20
+ export function buildObjectListUrl(portalId, objectTypeId) {
21
+ return `${APP}/contacts/${portalId}/objects/${objectTypeId}/views/all/list`;
22
+ }
23
+
24
+ // The contact-list creation screen.
25
+ export function buildContactListCreateUrl(portalId) {
26
+ return `${APP}/contacts/${portalId}/objectLists/create`;
27
+ }
28
+
29
+ // A specific contact list's filter editor.
30
+ export function buildContactListEditUrl(portalId, listId) {
31
+ return `${APP}/contacts/${portalId}/objectLists/${listId}/filters`;
32
+ }
33
+
34
+ // A form's editor.
35
+ export function buildFormEditorUrl(portalId, formId) {
36
+ return `${APP}/forms/${portalId}/editor/${formId}/edit/form`;
37
+ }
38
+
39
+ // A property's settings/edit screen. objectTypeId defaults to contacts ("0-1").
40
+ export function buildPropertySettingsUrl(portalId, propertyName, objectTypeId = "0-1") {
41
+ return `${APP}/property-settings/${portalId}/properties?type=${objectTypeId}&action=edit&property=${propertyName}`;
42
+ }
43
+
44
+ // Prefix a property name with an app prefix (e.g. "a12005537"). No-op without a
45
+ // prefix. Useful when reading/writing app-namespaced custom properties.
46
+ export function buildPropertyName(appPrefix, propertyName) {
47
+ if (!appPrefix) return propertyName;
48
+ return `${appPrefix}_${propertyName}`;
49
+ }
50
+
51
+ export function buildPropertyNames(appPrefix, propertyNames = []) {
52
+ return propertyNames.map((name) => buildPropertyName(appPrefix, name));
53
+ }