@particle-academy/hubspot-js 0.5.0 → 0.7.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/CHANGELOG.md +60 -0
- package/README.md +4 -3
- package/dist/{chunk-SZT3VK7Z.js → chunk-AVMPFAVL.js} +62 -14
- package/dist/chunk-AVMPFAVL.js.map +1 -0
- package/dist/flow.cjs +60 -12
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.js +1 -1
- package/dist/index.cjs +60 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-SZT3VK7Z.js.map +0 -1
package/dist/flow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hubspotCompanyCreate, hubspotCompanyGet, hubspotCompanyList, hubspotCompanySearch, hubspotCompanyUpdate, hubspotContactCreate, hubspotContactGet, hubspotContactList, hubspotContactSearch, hubspotContactUpdate, hubspotDealCreate, hubspotDealGet, hubspotDealList, hubspotDealSearch, hubspotDealUpdate, hubspotOwnerList, hubspotPipelineList, hubspotPropertyList, HUBSPOT, HUBSPOT_CRM_EVENT } from './chunk-
|
|
1
|
+
import { hubspotCompanyCreate, hubspotCompanyGet, hubspotCompanyList, hubspotCompanySearch, hubspotCompanyUpdate, hubspotContactCreate, hubspotContactGet, hubspotContactList, hubspotContactSearch, hubspotContactUpdate, hubspotDealCreate, hubspotDealGet, hubspotDealList, hubspotDealSearch, hubspotDealUpdate, hubspotOwnerList, hubspotPipelineList, hubspotPropertyList, HUBSPOT, HUBSPOT_CRM_EVENT } from './chunk-AVMPFAVL.js';
|
|
2
2
|
import { resolveConnection, triggerEvent } from '@particle-academy/fancy-connector-core';
|
|
3
3
|
import { hubspotCompanyCreateKind, hubspotCompanyGetKind, hubspotCompanyListKind, hubspotCompanySearchKind, hubspotCompanyUpdateKind, hubspotContactCreateKind, hubspotContactGetKind, hubspotContactListKind, hubspotContactSearchKind, hubspotContactUpdateKind, hubspotDealCreateKind, hubspotDealGetKind, hubspotDealListKind, hubspotDealSearchKind, hubspotDealUpdateKind, hubspotOwnerListKind, hubspotPipelineListKind, hubspotPropertyListKind, hubspotCrmEventTriggerKind } from '@particle-academy/hubspot-ui';
|
|
4
4
|
|
package/dist/index.cjs
CHANGED
|
@@ -675,8 +675,44 @@ function propertiesMap2(value) {
|
|
|
675
675
|
var CONTACT_CREATE_OPERATION = "contact_create";
|
|
676
676
|
async function hubspotContactCreate(options) {
|
|
677
677
|
const config = options.config ?? {};
|
|
678
|
-
if (config.email === void 0 || config.email === null || config.email === "") {
|
|
679
|
-
throw new Error(`contact_create: "email" is required
|
|
678
|
+
if ((config.email === void 0 || config.email === null || config.email === "") && propertiesMap3(config.properties)["email"] === void 0) {
|
|
679
|
+
throw new Error(`contact_create: "email" is required \u2014 as Email, or as "email" in Properties.`);
|
|
680
|
+
}
|
|
681
|
+
{
|
|
682
|
+
const inMap = propertiesMap3(config.properties)["email"];
|
|
683
|
+
if (config.email !== void 0 && config.email !== null && config.email !== "" && inMap !== void 0 && inMap !== String(config.email).trim()) {
|
|
684
|
+
throw new Error(`contact_create: "email" was given twice with different values \u2014 as Email and as "email" in Properties.`);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
{
|
|
688
|
+
const inMap = propertiesMap3(config.properties)["firstname"];
|
|
689
|
+
if (config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" && inMap !== void 0 && inMap !== String(config.firstName)) {
|
|
690
|
+
throw new Error(`contact_create: "firstName" was given twice with different values \u2014 as First name and as "firstname" in Properties.`);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
{
|
|
694
|
+
const inMap = propertiesMap3(config.properties)["lastname"];
|
|
695
|
+
if (config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" && inMap !== void 0 && inMap !== String(config.lastName)) {
|
|
696
|
+
throw new Error(`contact_create: "lastName" was given twice with different values \u2014 as Last name and as "lastname" in Properties.`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
{
|
|
700
|
+
const inMap = propertiesMap3(config.properties)["company"];
|
|
701
|
+
if (config.company !== void 0 && config.company !== null && config.company !== "" && inMap !== void 0 && inMap !== String(config.company)) {
|
|
702
|
+
throw new Error(`contact_create: "company" was given twice with different values \u2014 as Company and as "company" in Properties.`);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
{
|
|
706
|
+
const inMap = propertiesMap3(config.properties)["phone"];
|
|
707
|
+
if (config.phone !== void 0 && config.phone !== null && config.phone !== "" && inMap !== void 0 && inMap !== String(config.phone)) {
|
|
708
|
+
throw new Error(`contact_create: "phone" was given twice with different values \u2014 as Phone and as "phone" in Properties.`);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
{
|
|
712
|
+
const inMap = propertiesMap3(config.properties)["lifecyclestage"];
|
|
713
|
+
if (config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" && inMap !== void 0 && inMap !== String(config.lifecycleStage)) {
|
|
714
|
+
throw new Error(`contact_create: "lifecycleStage" was given twice with different values \u2014 as Lifecycle stage and as "lifecyclestage" in Properties.`);
|
|
715
|
+
}
|
|
680
716
|
}
|
|
681
717
|
return fancyConnectorCore.callConnector(HUBSPOT, {
|
|
682
718
|
operation: CONTACT_CREATE_OPERATION,
|
|
@@ -690,15 +726,15 @@ async function hubspotContactCreate(options) {
|
|
|
690
726
|
request: {
|
|
691
727
|
method: "POST",
|
|
692
728
|
path: "/crm/v3/objects/contacts",
|
|
693
|
-
json: nestFields({
|
|
694
|
-
"properties.email": String(config.email).trim(),
|
|
729
|
+
json: mergeInto(nestFields({
|
|
730
|
+
...config.email !== void 0 && config.email !== null && config.email !== "" ? { "properties.email": String(config.email).trim() } : {},
|
|
695
731
|
...config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? { "properties.firstname": String(config.firstName) } : {},
|
|
696
732
|
...config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? { "properties.lastname": String(config.lastName) } : {},
|
|
697
733
|
...config.company !== void 0 && config.company !== null && config.company !== "" ? { "properties.company": String(config.company) } : {},
|
|
698
734
|
...config.phone !== void 0 && config.phone !== null && config.phone !== "" ? { "properties.phone": String(config.phone) } : {},
|
|
699
735
|
...config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? { "properties.lifecyclestage": String(config.lifecycleStage) } : {},
|
|
700
736
|
"associations": []
|
|
701
|
-
})
|
|
737
|
+
}), "properties", propertiesMap3(config.properties))
|
|
702
738
|
}
|
|
703
739
|
});
|
|
704
740
|
}
|
|
@@ -717,6 +753,18 @@ function nestFields(flat) {
|
|
|
717
753
|
}
|
|
718
754
|
return out;
|
|
719
755
|
}
|
|
756
|
+
function mergeInto(body, key, map) {
|
|
757
|
+
const named = body[key];
|
|
758
|
+
return { ...body, [key]: { ...map, ...named !== null && typeof named === "object" ? named : {} } };
|
|
759
|
+
}
|
|
760
|
+
function propertiesMap3(value) {
|
|
761
|
+
if (!value || typeof value !== "object") return {};
|
|
762
|
+
const out = {};
|
|
763
|
+
for (const [key, item] of Object.entries(value)) {
|
|
764
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
765
|
+
}
|
|
766
|
+
return out;
|
|
767
|
+
}
|
|
720
768
|
var CONTACT_GET_OPERATION = "contact_get";
|
|
721
769
|
async function hubspotContactGet(options) {
|
|
722
770
|
const config = options.config ?? {};
|
|
@@ -850,12 +898,12 @@ async function hubspotContactUpdate(options) {
|
|
|
850
898
|
method: "PATCH",
|
|
851
899
|
path: `/crm/v3/objects/contacts/${encodeURIComponent(String(config.contactId))}`,
|
|
852
900
|
json: {
|
|
853
|
-
"properties":
|
|
901
|
+
"properties": propertiesMap4(config.properties)
|
|
854
902
|
}
|
|
855
903
|
}
|
|
856
904
|
});
|
|
857
905
|
}
|
|
858
|
-
function
|
|
906
|
+
function propertiesMap4(value) {
|
|
859
907
|
if (!value || typeof value !== "object") return {};
|
|
860
908
|
const out = {};
|
|
861
909
|
for (const [key, item] of Object.entries(value)) {
|
|
@@ -882,13 +930,13 @@ async function hubspotDealCreate(options) {
|
|
|
882
930
|
method: "POST",
|
|
883
931
|
path: "/crm/v3/objects/deals",
|
|
884
932
|
json: {
|
|
885
|
-
"properties":
|
|
933
|
+
"properties": propertiesMap5(config.properties),
|
|
886
934
|
"associations": []
|
|
887
935
|
}
|
|
888
936
|
}
|
|
889
937
|
});
|
|
890
938
|
}
|
|
891
|
-
function
|
|
939
|
+
function propertiesMap5(value) {
|
|
892
940
|
if (!value || typeof value !== "object") return {};
|
|
893
941
|
const out = {};
|
|
894
942
|
for (const [key, item] of Object.entries(value)) {
|
|
@@ -1029,12 +1077,12 @@ async function hubspotDealUpdate(options) {
|
|
|
1029
1077
|
method: "PATCH",
|
|
1030
1078
|
path: `/crm/v3/objects/deals/${encodeURIComponent(String(config.dealId))}`,
|
|
1031
1079
|
json: {
|
|
1032
|
-
"properties":
|
|
1080
|
+
"properties": propertiesMap6(config.properties)
|
|
1033
1081
|
}
|
|
1034
1082
|
}
|
|
1035
1083
|
});
|
|
1036
1084
|
}
|
|
1037
|
-
function
|
|
1085
|
+
function propertiesMap6(value) {
|
|
1038
1086
|
if (!value || typeof value !== "object") return {};
|
|
1039
1087
|
const out = {};
|
|
1040
1088
|
for (const [key, item] of Object.entries(value)) {
|
|
@@ -1130,7 +1178,7 @@ var HUBSPOT_CRM_EVENT = {
|
|
|
1130
1178
|
service: "hubspot",
|
|
1131
1179
|
operation: "crm_event",
|
|
1132
1180
|
delivery: "webhook",
|
|
1133
|
-
setup: "In the HubSpot app's webhook settings, set the target URL to the route your host mounts for this trigger and subscribe to the deal, contact and company events you want. Deliveries are signed with the app's client secret, already on the connection as `clientSecret`. ONE URL serves every portal that installed the app, so route each event by its portalId, and only after the signature has verified: map portalId to the connection created when that portal installed, and drop an unmapped portalId with a 2xx and a log line, creating nothing.",
|
|
1181
|
+
setup: "In the HubSpot app's webhook settings, set the target URL to the route your host mounts for this trigger and subscribe to the deal, contact and company events you want. Deliveries are signed with the app's client secret, already on the connection as `clientSecret`. ONE URL serves every portal that installed the app, so route each event by its portalId, and only after the signature has verified: map portalId to the connection created when that portal installed, and drop an unmapped portalId with a 2xx and a log line, creating nothing. HubSpot retries a failed delivery, and eventId is not guaranteed to be unique, so never dedupe on eventId alone: a retry is the same event resent, differing only in attemptNumber, so compare every other field. This connector's scope list covers every action, read and write, and is not what your consent URL must ask for: HubSpot requires your app's required scopes in the authorize URL's `scope` parameter and shows an error otherwise, so build it from your own app's configuration. A read-only host asks for its read scopes only.",
|
|
1134
1182
|
verification: {
|
|
1135
1183
|
signatureHeader: HUBSPOT_CRM_EVENT_SIGNATURE_HEADER,
|
|
1136
1184
|
scheme: HUBSPOT_CRM_EVENT_SCHEME,
|