@segment/action-destinations 3.296.1-staging-5b53a4222.0 → 3.297.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/README.md +1 -0
- package/dist/destinations/aws-s3/operations.js +14 -17
- package/dist/destinations/aws-s3/operations.js.map +1 -1
- package/dist/destinations/aws-s3/syncAudienceToCSV/generated-types.d.ts +2 -3
- package/dist/destinations/aws-s3/syncAudienceToCSV/index.js +4 -18
- package/dist/destinations/aws-s3/syncAudienceToCSV/index.js.map +1 -1
- package/dist/destinations/blend-ai/consts.d.ts +1 -0
- package/dist/destinations/blend-ai/consts.js +5 -0
- package/dist/destinations/blend-ai/consts.js.map +1 -0
- package/dist/destinations/blend-ai/index.js +12 -15
- package/dist/destinations/blend-ai/index.js.map +1 -1
- package/dist/destinations/blend-ai/sendData/index.js +2 -2
- package/dist/destinations/blend-ai/sendData/index.js.map +1 -1
- package/dist/destinations/blend-ai/trackEvents/generated-types.d.ts +14 -0
- package/dist/destinations/blend-ai/trackEvents/generated-types.js +3 -0
- package/dist/destinations/blend-ai/trackEvents/generated-types.js.map +1 -0
- package/dist/destinations/blend-ai/trackEvents/index.d.ts +5 -0
- package/dist/destinations/blend-ai/trackEvents/index.js +80 -0
- package/dist/destinations/blend-ai/trackEvents/index.js.map +1 -0
- package/dist/destinations/braze/index.js +2 -1
- package/dist/destinations/braze/index.js.map +1 -1
- package/dist/destinations/facebook-conversions-api/constants.d.ts +1 -1
- package/dist/destinations/facebook-conversions-api/constants.js +1 -1
- package/dist/destinations/hubspot/index.js +3 -1
- package/dist/destinations/hubspot/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertObject/common-fields.d.ts +2 -0
- package/dist/destinations/hubspot/upsertObject/common-fields.js +144 -0
- package/dist/destinations/hubspot/upsertObject/common-fields.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/constants.d.ts +9 -0
- package/dist/destinations/hubspot/upsertObject/constants.js +21 -0
- package/dist/destinations/hubspot/upsertObject/constants.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.d.ts +18 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.js +124 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/generated-types.d.ts +23 -0
- package/dist/destinations/hubspot/upsertObject/generated-types.js +3 -0
- package/dist/destinations/hubspot/upsertObject/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-api.d.ts +93 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-api.js +333 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-api.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/index.d.ts +5 -0
- package/dist/destinations/hubspot/upsertObject/index.js +96 -0
- package/dist/destinations/hubspot/upsertObject/index.js.map +1 -0
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/iterable-lists/constants.d.ts +6 -0
- package/dist/destinations/iterable-lists/constants.js +10 -0
- package/dist/destinations/iterable-lists/constants.js.map +1 -0
- package/dist/destinations/iterable-lists/generated-types.d.ts +8 -0
- package/dist/destinations/iterable-lists/generated-types.js +3 -0
- package/dist/destinations/iterable-lists/generated-types.js.map +1 -0
- package/dist/destinations/iterable-lists/index.d.ts +4 -0
- package/dist/destinations/iterable-lists/index.js +92 -0
- package/dist/destinations/iterable-lists/index.js.map +1 -0
- package/dist/destinations/iterable-lists/syncAudience/generated-types.d.ts +10 -0
- package/dist/destinations/iterable-lists/syncAudience/generated-types.js +3 -0
- package/dist/destinations/iterable-lists/syncAudience/generated-types.js.map +1 -0
- package/dist/destinations/iterable-lists/syncAudience/index.d.ts +5 -0
- package/dist/destinations/iterable-lists/syncAudience/index.js +87 -0
- package/dist/destinations/iterable-lists/syncAudience/index.js.map +1 -0
- package/dist/destinations/iterable-lists/syncAudience/iterable-client.d.ts +14 -0
- package/dist/destinations/iterable-lists/syncAudience/iterable-client.js +84 -0
- package/dist/destinations/iterable-lists/syncAudience/iterable-client.js.map +1 -0
- package/dist/destinations/iterable-lists/types.d.ts +21 -0
- package/dist/destinations/iterable-lists/types.js +3 -0
- package/dist/destinations/iterable-lists/types.js.map +1 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/generated-types.d.ts +4 -0
- package/dist/destinations/listrak/updateEmailContactProfileFields/index.js +47 -5
- package/dist/destinations/listrak/updateEmailContactProfileFields/index.js.map +1 -1
- package/dist/destinations/optimizely-advanced-audience-targeting/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_HUBSPOT_BATCH_SIZE = exports.SUPPORTED_HUBSPOT_OBJECT_TYPES = exports.INSERT_TYPES = void 0;
|
|
4
|
+
exports.INSERT_TYPES = [
|
|
5
|
+
{ label: 'Create', value: 'create' },
|
|
6
|
+
{ label: 'Update', value: 'update' },
|
|
7
|
+
{ label: 'Upsert', value: 'upsert' }
|
|
8
|
+
];
|
|
9
|
+
exports.SUPPORTED_HUBSPOT_OBJECT_TYPES = [
|
|
10
|
+
{ label: 'Contact', value: 'contact' },
|
|
11
|
+
{ label: 'Company', value: 'company' },
|
|
12
|
+
{ label: 'Deal', value: 'deal' },
|
|
13
|
+
{ label: 'Ticket', value: 'ticket' },
|
|
14
|
+
{ label: 'Calls', value: 'calls' },
|
|
15
|
+
{ label: 'Emails', value: 'email' },
|
|
16
|
+
{ label: 'Meetings', value: 'meetings' },
|
|
17
|
+
{ label: 'Postal Mail', value: 'postal_mail' },
|
|
18
|
+
{ label: 'Tasks', value: 'tasks' }
|
|
19
|
+
];
|
|
20
|
+
exports.MAX_HUBSPOT_BATCH_SIZE = 100;
|
|
21
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertObject/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACrC,CAAA;AAEY,QAAA,8BAA8B,GAAG;IAC5C,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;IACpC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAClC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;IACnC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC9C,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;CACnC,CAAA;AAEY,QAAA,sBAAsB,GAAG,GAAG,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { DynamicFieldResponse } from '@segment/actions-core';
|
|
3
|
+
export declare function dynamicReadIdFields(request: RequestClient, objectType: string): Promise<{
|
|
4
|
+
choices: {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[];
|
|
8
|
+
error?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
choices: never[];
|
|
11
|
+
error: {
|
|
12
|
+
message: string;
|
|
13
|
+
code: string;
|
|
14
|
+
};
|
|
15
|
+
}>;
|
|
16
|
+
export declare function dynamicReadPropertyGroups(request: RequestClient, objectType: string): Promise<DynamicFieldResponse>;
|
|
17
|
+
export declare function dynamicReadAssociationLabels(request: RequestClient, fromObjectType: string, toObjectType: string): Promise<DynamicFieldResponse>;
|
|
18
|
+
export declare function dynamicReadObjectTypes(request: RequestClient): Promise<DynamicFieldResponse>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamicReadObjectTypes = exports.dynamicReadAssociationLabels = exports.dynamicReadPropertyGroups = exports.dynamicReadIdFields = void 0;
|
|
4
|
+
const properties_1 = require("../properties");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
var AssociationCategory;
|
|
7
|
+
(function (AssociationCategory) {
|
|
8
|
+
AssociationCategory["HUBSPOT_DEFINED"] = "HUBSPOT_DEFINED";
|
|
9
|
+
AssociationCategory["USER_DEFINED"] = "USER_DEFINED";
|
|
10
|
+
AssociationCategory["INTEGRATOR_DEFINED"] = "INTEGRATOR_DEFINED";
|
|
11
|
+
})(AssociationCategory || (AssociationCategory = {}));
|
|
12
|
+
async function dynamicReadIdFields(request, objectType) {
|
|
13
|
+
try {
|
|
14
|
+
const response = await request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/${objectType}`, {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
skipResponseCloning: true
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
choices: [
|
|
20
|
+
{
|
|
21
|
+
label: 'Hubspot Record ID (updates only)',
|
|
22
|
+
value: 'hs_object_id'
|
|
23
|
+
},
|
|
24
|
+
...response.data.results
|
|
25
|
+
.filter((field) => field.hasUniqueValue && field.name != 'hs_unique_creation_key')
|
|
26
|
+
.map((field) => {
|
|
27
|
+
return {
|
|
28
|
+
label: field.label,
|
|
29
|
+
value: field.name
|
|
30
|
+
};
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return {
|
|
37
|
+
choices: [],
|
|
38
|
+
error: {
|
|
39
|
+
message: err?.response?.data?.message ?? 'Unknown error: getPropertyGroups',
|
|
40
|
+
code: err?.response?.data?.category ?? 'Unknown code'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.dynamicReadIdFields = dynamicReadIdFields;
|
|
46
|
+
async function dynamicReadPropertyGroups(request, objectType) {
|
|
47
|
+
try {
|
|
48
|
+
const response = await request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/${objectType}/groups`, {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
skipResponseCloning: true
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
choices: response.data.results
|
|
54
|
+
.filter((result) => !result.archived)
|
|
55
|
+
.map((result) => ({
|
|
56
|
+
label: result.label,
|
|
57
|
+
value: result.name
|
|
58
|
+
}))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
choices: [],
|
|
64
|
+
error: {
|
|
65
|
+
message: err?.response?.data?.message ?? 'Unknown error: getPropertyGroups',
|
|
66
|
+
code: err?.response?.data?.category ?? 'Unknown code'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.dynamicReadPropertyGroups = dynamicReadPropertyGroups;
|
|
72
|
+
async function dynamicReadAssociationLabels(request, fromObjectType, toObjectType) {
|
|
73
|
+
try {
|
|
74
|
+
const response = await request(`${properties_1.HUBSPOT_BASE_URL}/crm/v4/associations/${fromObjectType}/${toObjectType}/labels`, {
|
|
75
|
+
method: 'GET',
|
|
76
|
+
skipResponseCloning: true
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
choices: response?.data?.results?.map((res) => ({
|
|
80
|
+
label: !res.label
|
|
81
|
+
? `${fromObjectType} to ${toObjectType} (Type ${res.typeId})`
|
|
82
|
+
: `${fromObjectType} to ${toObjectType} ${res.label}`,
|
|
83
|
+
value: `${res.category}:${res.typeId}`
|
|
84
|
+
}))
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
return {
|
|
89
|
+
choices: [],
|
|
90
|
+
error: {
|
|
91
|
+
message: err?.response?.data?.message ?? 'Unknown error',
|
|
92
|
+
code: err?.response?.data?.category ?? 'Unknown code'
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.dynamicReadAssociationLabels = dynamicReadAssociationLabels;
|
|
98
|
+
async function dynamicReadObjectTypes(request) {
|
|
99
|
+
const defaultChoices = constants_1.SUPPORTED_HUBSPOT_OBJECT_TYPES;
|
|
100
|
+
try {
|
|
101
|
+
const response = await request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/schemas?archived=false`, {
|
|
102
|
+
method: 'GET',
|
|
103
|
+
skipResponseCloning: true
|
|
104
|
+
});
|
|
105
|
+
const choices = response.data.results.map((schema) => ({
|
|
106
|
+
label: `${schema.labels.plural} (Custom)`,
|
|
107
|
+
value: schema.fullyQualifiedName
|
|
108
|
+
}));
|
|
109
|
+
return {
|
|
110
|
+
choices: [...choices, ...defaultChoices]
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
return {
|
|
115
|
+
choices: [],
|
|
116
|
+
error: {
|
|
117
|
+
message: err?.response?.data?.message ?? 'Unknown error',
|
|
118
|
+
code: err?.response?.data?.category ?? 'Unknown code'
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.dynamicReadObjectTypes = dynamicReadObjectTypes;
|
|
124
|
+
//# sourceMappingURL=dynamic-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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E,QAAQ,IAAI,cAAc;aACxE;SACF,CAAA;KACF;AACH,CAAC;AAnCD,wDAmCC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
object_details: {
|
|
3
|
+
from_object_type: string;
|
|
4
|
+
from_id_field_name: string;
|
|
5
|
+
from_id_field_value: string;
|
|
6
|
+
from_property_group?: string;
|
|
7
|
+
from_record_id?: string;
|
|
8
|
+
};
|
|
9
|
+
properties?: {
|
|
10
|
+
[k: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
association_sync_mode: string;
|
|
13
|
+
associations?: {
|
|
14
|
+
to_object_type: string;
|
|
15
|
+
association_label: string;
|
|
16
|
+
to_id_field_name: string;
|
|
17
|
+
to_id_field_value: string;
|
|
18
|
+
to_record_id?: string;
|
|
19
|
+
from_record_id?: string;
|
|
20
|
+
}[];
|
|
21
|
+
enable_batching?: boolean;
|
|
22
|
+
batch_size: number;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertObject/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { RequestClient, ModifiedResponse } from '@segment/actions-core';
|
|
2
|
+
import type { Payload } from './generated-types';
|
|
3
|
+
interface Association {
|
|
4
|
+
to_object_type: string;
|
|
5
|
+
association_label: string;
|
|
6
|
+
to_id_field_name: string;
|
|
7
|
+
to_id_field_value: string;
|
|
8
|
+
to_record_id?: string;
|
|
9
|
+
from_record_id?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ReadPropertiesResultItem {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
fieldType: string;
|
|
15
|
+
hasUniqueValue: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PayloadPropertyItem {
|
|
18
|
+
name: string;
|
|
19
|
+
type: string | number | boolean | null;
|
|
20
|
+
}
|
|
21
|
+
declare enum AssociationCategory {
|
|
22
|
+
HUBSPOT_DEFINED = "HUBSPOT_DEFINED",
|
|
23
|
+
USER_DEFINED = "USER_DEFINED",
|
|
24
|
+
INTEGRATOR_DEFINED = "INTEGRATOR_DEFINED"
|
|
25
|
+
}
|
|
26
|
+
interface BatchObjReadReqBody {
|
|
27
|
+
idProperty: string;
|
|
28
|
+
properties: string[];
|
|
29
|
+
inputs: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
interface BatchObjUpsertReqBody {
|
|
34
|
+
inputs: Array<{
|
|
35
|
+
idProperty: string;
|
|
36
|
+
id: string;
|
|
37
|
+
properties: Record<string, string>;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
interface BatchObjCreateReqBody {
|
|
41
|
+
inputs: Array<{
|
|
42
|
+
idProperty: string;
|
|
43
|
+
properties: Record<string, string>;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
interface BatchObjResponse {
|
|
47
|
+
status: string;
|
|
48
|
+
results: Array<{
|
|
49
|
+
id: string;
|
|
50
|
+
properties: Record<string, string | null>;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
interface AssociationType {
|
|
54
|
+
associationCategory: AssociationCategory;
|
|
55
|
+
associationTypeId: string;
|
|
56
|
+
}
|
|
57
|
+
interface BatchAssociationsRequestBody {
|
|
58
|
+
inputs: {
|
|
59
|
+
types: AssociationType[];
|
|
60
|
+
from: {
|
|
61
|
+
id: string;
|
|
62
|
+
};
|
|
63
|
+
to: {
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
66
|
+
}[];
|
|
67
|
+
}
|
|
68
|
+
export declare type AssociationSyncMode = 'upsert' | 'read';
|
|
69
|
+
export declare type SyncMode = 'upsert' | 'add' | 'update';
|
|
70
|
+
export declare type HubspotSyncMode = 'upsert' | 'create' | 'update';
|
|
71
|
+
export declare class HubspotClient {
|
|
72
|
+
request: RequestClient;
|
|
73
|
+
fromObjectType: string;
|
|
74
|
+
fromIdFieldName: string;
|
|
75
|
+
associationSyncMode: AssociationSyncMode;
|
|
76
|
+
hubspotSyncMode: HubspotSyncMode;
|
|
77
|
+
fromPropertyGroup?: string;
|
|
78
|
+
constructor(request: RequestClient, fromObjectType: string, fromIdFieldName: string, syncMode: SyncMode, associationSyncMode: AssociationSyncMode, fromPropertyGroup: string | undefined);
|
|
79
|
+
mapHubspotSyncMode(syncMode: SyncMode): HubspotSyncMode;
|
|
80
|
+
propertiesFromHSchema(): Promise<ReadPropertiesResultItem[]>;
|
|
81
|
+
uniquePayloadsProperties(payloads: Payload[]): PayloadPropertyItem[];
|
|
82
|
+
propertiesToCreateInHSSchema(uniquePayloadProperties: PayloadPropertyItem[], hubspotProperties: ReadPropertiesResultItem[]): PayloadPropertyItem[];
|
|
83
|
+
ensurePropertiesInHSSchema(properties: PayloadPropertyItem[]): Promise<void>;
|
|
84
|
+
groupAssociations(associations: Association[], groupBy: (keyof Association)[]): Association[][];
|
|
85
|
+
getAssociationsFromPayloads(payloads: Payload[]): Association[];
|
|
86
|
+
batchObjectRequest(action: HubspotSyncMode | AssociationSyncMode, objectType: string, data: BatchObjReadReqBody | BatchObjUpsertReqBody | BatchObjCreateReqBody): Promise<ModifiedResponse<BatchObjResponse>>;
|
|
87
|
+
ensureToRecordsOnHubspot(associations: Association[]): Promise<Association[]>;
|
|
88
|
+
insertRecordIds(payloads: Payload[], response: ModifiedResponse<BatchObjResponse>): Payload[];
|
|
89
|
+
ensureFromRecordsOnHubspot(payloads: Payload[]): Promise<Payload[]>;
|
|
90
|
+
batchAssociationsRequest(body: BatchAssociationsRequestBody, toObjectType: string): Promise<ModifiedResponse<unknown>>;
|
|
91
|
+
ensureAssociations(associations: Association[]): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HubspotClient = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const properties_1 = require("../properties");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
var AssociationCategory;
|
|
8
|
+
(function (AssociationCategory) {
|
|
9
|
+
AssociationCategory["HUBSPOT_DEFINED"] = "HUBSPOT_DEFINED";
|
|
10
|
+
AssociationCategory["USER_DEFINED"] = "USER_DEFINED";
|
|
11
|
+
AssociationCategory["INTEGRATOR_DEFINED"] = "INTEGRATOR_DEFINED";
|
|
12
|
+
})(AssociationCategory || (AssociationCategory = {}));
|
|
13
|
+
class HubspotClient {
|
|
14
|
+
constructor(request, fromObjectType, fromIdFieldName, syncMode, associationSyncMode, fromPropertyGroup) {
|
|
15
|
+
this.request = request;
|
|
16
|
+
this.associationSyncMode = associationSyncMode;
|
|
17
|
+
this.fromObjectType = fromObjectType;
|
|
18
|
+
this.fromIdFieldName = fromIdFieldName;
|
|
19
|
+
this.hubspotSyncMode = this.mapHubspotSyncMode(syncMode);
|
|
20
|
+
this.fromPropertyGroup = fromPropertyGroup;
|
|
21
|
+
}
|
|
22
|
+
mapHubspotSyncMode(syncMode) {
|
|
23
|
+
switch (syncMode) {
|
|
24
|
+
case 'upsert':
|
|
25
|
+
return 'upsert';
|
|
26
|
+
case 'add':
|
|
27
|
+
return 'create';
|
|
28
|
+
case 'update':
|
|
29
|
+
return 'update';
|
|
30
|
+
default:
|
|
31
|
+
throw new Error('Invalid sync mode');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async propertiesFromHSchema() {
|
|
35
|
+
try {
|
|
36
|
+
const response = await this.request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/${this.fromObjectType}`, {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
skipResponseCloning: true
|
|
39
|
+
});
|
|
40
|
+
return response.data.results.map((item) => {
|
|
41
|
+
return {
|
|
42
|
+
name: item.name,
|
|
43
|
+
type: item.type,
|
|
44
|
+
fieldType: item.fieldType,
|
|
45
|
+
hasUniqueValue: item.hasUniqueValue
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
throw new actions_core_1.IntegrationError(`readProperties() failed: ${err?.response?.data?.message ?? 'Unknown error: readProperties() failed'}`, 'HUBSPOT_READ_PROPERTIES_FAILED', 400);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
uniquePayloadsProperties(payloads) {
|
|
54
|
+
return Object.values(payloads.reduce((acc, payload) => {
|
|
55
|
+
if (payload.properties) {
|
|
56
|
+
Object.keys(payload.properties).forEach((propName) => {
|
|
57
|
+
if (payload.properties) {
|
|
58
|
+
acc[propName] = {
|
|
59
|
+
name: propName,
|
|
60
|
+
type: typeof payload.properties[propName]
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return acc;
|
|
66
|
+
}, {}));
|
|
67
|
+
}
|
|
68
|
+
propertiesToCreateInHSSchema(uniquePayloadProperties, hubspotProperties) {
|
|
69
|
+
return uniquePayloadProperties.filter((prop) => !hubspotProperties.find((p) => p.name === prop.name));
|
|
70
|
+
}
|
|
71
|
+
async ensurePropertiesInHSSchema(properties) {
|
|
72
|
+
if (!this.fromPropertyGroup) {
|
|
73
|
+
throw new actions_core_1.PayloadValidationError('"Property Group" is a required field when creating properties on an Object Schema in Hubspot');
|
|
74
|
+
}
|
|
75
|
+
if (!properties || properties.length === 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const json = {
|
|
79
|
+
inputs: properties.map((prop) => {
|
|
80
|
+
switch (prop.type) {
|
|
81
|
+
case 'string':
|
|
82
|
+
return {
|
|
83
|
+
name: prop.name,
|
|
84
|
+
label: prop.name,
|
|
85
|
+
groupName: this.fromPropertyGroup,
|
|
86
|
+
type: 'string',
|
|
87
|
+
fieldType: 'text'
|
|
88
|
+
};
|
|
89
|
+
case 'number':
|
|
90
|
+
return {
|
|
91
|
+
name: prop.name,
|
|
92
|
+
label: prop.name,
|
|
93
|
+
groupName: this.fromPropertyGroup,
|
|
94
|
+
type: 'number',
|
|
95
|
+
fieldType: 'number'
|
|
96
|
+
};
|
|
97
|
+
case 'boolean':
|
|
98
|
+
return {
|
|
99
|
+
name: prop.name,
|
|
100
|
+
label: prop.name,
|
|
101
|
+
groupName: this.fromPropertyGroup,
|
|
102
|
+
type: 'enumeration',
|
|
103
|
+
fieldType: 'booleancheckbox',
|
|
104
|
+
options: [
|
|
105
|
+
{
|
|
106
|
+
label: 'true',
|
|
107
|
+
value: 'true',
|
|
108
|
+
hidden: false,
|
|
109
|
+
description: 'True',
|
|
110
|
+
displayOrder: 1
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: 'false',
|
|
114
|
+
value: 'false',
|
|
115
|
+
hidden: false,
|
|
116
|
+
description: 'False',
|
|
117
|
+
displayOrder: 2
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
};
|
|
124
|
+
await this.request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/${this.fromObjectType}/batch/create`, {
|
|
125
|
+
method: 'POST',
|
|
126
|
+
skipResponseCloning: true,
|
|
127
|
+
json
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
groupAssociations(associations, groupBy) {
|
|
131
|
+
const groupedAssociations = [];
|
|
132
|
+
const groups = associations.reduce((acc, association) => {
|
|
133
|
+
const key = groupBy.map((prop) => association[prop]).join('_');
|
|
134
|
+
if (!acc[key]) {
|
|
135
|
+
acc[key] = [];
|
|
136
|
+
}
|
|
137
|
+
acc[key].push(association);
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
for (const key in groups) {
|
|
141
|
+
const items = groups[key];
|
|
142
|
+
for (let i = 0; i < items.length; i += constants_1.MAX_HUBSPOT_BATCH_SIZE) {
|
|
143
|
+
groupedAssociations.push(items.slice(i, i + constants_1.MAX_HUBSPOT_BATCH_SIZE));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return groupedAssociations;
|
|
147
|
+
}
|
|
148
|
+
getAssociationsFromPayloads(payloads) {
|
|
149
|
+
const payloadsDeepCopy = JSON.parse(JSON.stringify(payloads));
|
|
150
|
+
const allAssociations = [];
|
|
151
|
+
payloadsDeepCopy.forEach((payload) => {
|
|
152
|
+
const associations = payload.associations ?? [];
|
|
153
|
+
associations.forEach((association) => {
|
|
154
|
+
association.from_record_id = payload.object_details.from_record_id;
|
|
155
|
+
allAssociations.push(association);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
return allAssociations;
|
|
159
|
+
}
|
|
160
|
+
async batchObjectRequest(action, objectType, data) {
|
|
161
|
+
return this.request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/${objectType}/batch/${action}`, {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
json: data
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async ensureToRecordsOnHubspot(associations) {
|
|
167
|
+
const associationsDeepCopy = JSON.parse(JSON.stringify(associations));
|
|
168
|
+
let requests;
|
|
169
|
+
let groupedAssociations;
|
|
170
|
+
switch (this.associationSyncMode) {
|
|
171
|
+
case 'upsert': {
|
|
172
|
+
groupedAssociations = this.groupAssociations(associationsDeepCopy, ['to_object_type']);
|
|
173
|
+
requests = groupedAssociations.map(async (associations) => {
|
|
174
|
+
const { to_object_type: toObjectType } = associations[0];
|
|
175
|
+
return await this.batchObjectRequest(this.associationSyncMode, toObjectType, {
|
|
176
|
+
inputs: associations.map((association) => {
|
|
177
|
+
return {
|
|
178
|
+
idProperty: association.to_id_field_name,
|
|
179
|
+
id: association.to_id_field_value,
|
|
180
|
+
properties: {
|
|
181
|
+
[association.to_id_field_name]: association.to_id_field_value
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
})
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'read': {
|
|
190
|
+
groupedAssociations = this.groupAssociations(associationsDeepCopy, ['to_object_type', 'to_id_field_name']);
|
|
191
|
+
requests = groupedAssociations.map(async (associations) => {
|
|
192
|
+
const { to_object_type: toObjectType, to_id_field_name: toIdFieldName } = associations[0];
|
|
193
|
+
return await this.batchObjectRequest(this.associationSyncMode, toObjectType, {
|
|
194
|
+
idProperty: toIdFieldName,
|
|
195
|
+
properties: [toIdFieldName],
|
|
196
|
+
inputs: associations.map((association) => {
|
|
197
|
+
return {
|
|
198
|
+
id: association.to_id_field_value
|
|
199
|
+
};
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const responses = await Promise.all(requests);
|
|
207
|
+
responses.forEach((response, index) => {
|
|
208
|
+
const associations = groupedAssociations[index];
|
|
209
|
+
response?.data?.results.forEach((result) => {
|
|
210
|
+
associations
|
|
211
|
+
.filter((association) => association.to_id_field_value == result.properties[association.to_id_field_name])
|
|
212
|
+
.forEach((association) => (association.to_record_id = result.id));
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
switch (this.associationSyncMode) {
|
|
216
|
+
case 'upsert': {
|
|
217
|
+
return groupedAssociations.flat().filter((association) => association.to_record_id);
|
|
218
|
+
}
|
|
219
|
+
case 'read': {
|
|
220
|
+
return groupedAssociations.flat();
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
insertRecordIds(payloads, response) {
|
|
225
|
+
const payloadsDeepCopy = JSON.parse(JSON.stringify(payloads));
|
|
226
|
+
response?.data?.results.forEach((result) => {
|
|
227
|
+
payloadsDeepCopy
|
|
228
|
+
.filter((p) => {
|
|
229
|
+
return (p.object_details.from_id_field_value == result.properties[p.object_details.from_id_field_name]);
|
|
230
|
+
})
|
|
231
|
+
.forEach((p) => {
|
|
232
|
+
return (p.object_details.from_record_id = result.id);
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
return payloadsDeepCopy;
|
|
236
|
+
}
|
|
237
|
+
async ensureFromRecordsOnHubspot(payloads) {
|
|
238
|
+
const payloadsDeepCopy = JSON.parse(JSON.stringify(payloads));
|
|
239
|
+
let response;
|
|
240
|
+
switch (this.hubspotSyncMode) {
|
|
241
|
+
case 'upsert': {
|
|
242
|
+
response = await this.batchObjectRequest(this.hubspotSyncMode, this.fromObjectType, {
|
|
243
|
+
inputs: payloadsDeepCopy.map(({ object_details: { from_id_field_value }, properties }) => {
|
|
244
|
+
return {
|
|
245
|
+
idProperty: this.fromIdFieldName,
|
|
246
|
+
id: from_id_field_value,
|
|
247
|
+
properties: { ...properties, [this.fromIdFieldName]: from_id_field_value }
|
|
248
|
+
};
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
return this.insertRecordIds(payloadsDeepCopy, response).filter((payload) => payload.object_details.from_id_field_value);
|
|
252
|
+
}
|
|
253
|
+
case 'update': {
|
|
254
|
+
const readResponse = await this.batchObjectRequest('read', this.fromObjectType, {
|
|
255
|
+
properties: [this.fromIdFieldName],
|
|
256
|
+
idProperty: this.fromIdFieldName,
|
|
257
|
+
inputs: payloadsDeepCopy.map((payload) => {
|
|
258
|
+
return { id: payload.object_details.from_id_field_value };
|
|
259
|
+
})
|
|
260
|
+
});
|
|
261
|
+
const existingRecords = this.insertRecordIds(payloadsDeepCopy, readResponse).filter((payload) => payload.object_details.from_record_id);
|
|
262
|
+
response = await this.batchObjectRequest(this.hubspotSyncMode, this.fromObjectType, {
|
|
263
|
+
inputs: existingRecords.map(({ object_details: { from_id_field_value }, properties }) => {
|
|
264
|
+
return {
|
|
265
|
+
idProperty: this.fromIdFieldName,
|
|
266
|
+
id: from_id_field_value,
|
|
267
|
+
properties: properties
|
|
268
|
+
};
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return this.insertRecordIds(existingRecords, response).filter((payload) => payload.object_details.from_id_field_value);
|
|
272
|
+
}
|
|
273
|
+
case 'create': {
|
|
274
|
+
const readResponse = await this.batchObjectRequest('read', this.fromObjectType, {
|
|
275
|
+
properties: [this.fromIdFieldName],
|
|
276
|
+
idProperty: this.fromIdFieldName,
|
|
277
|
+
inputs: payloadsDeepCopy.map((payload) => {
|
|
278
|
+
return { id: payload.object_details.from_id_field_value };
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
const nonExistingRecords = this.insertRecordIds(payloadsDeepCopy, readResponse).filter((payload) => !payload.object_details.from_record_id);
|
|
282
|
+
response = await this.batchObjectRequest(this.hubspotSyncMode, this.fromObjectType, {
|
|
283
|
+
inputs: nonExistingRecords.map(({ properties, object_details: { from_id_field_value: fromIdFieldValue } }) => {
|
|
284
|
+
return {
|
|
285
|
+
idProperty: this.fromIdFieldName,
|
|
286
|
+
properties: { ...properties, [this.fromIdFieldName]: fromIdFieldValue }
|
|
287
|
+
};
|
|
288
|
+
})
|
|
289
|
+
});
|
|
290
|
+
return this.insertRecordIds(nonExistingRecords, response).filter((payload) => payload.object_details.from_id_field_value);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async batchAssociationsRequest(body, toObjectType) {
|
|
295
|
+
return this.request(`${properties_1.HUBSPOT_BASE_URL}/crm/v4/associations/${this.fromObjectType}/${toObjectType}/batch/create`, {
|
|
296
|
+
method: 'POST',
|
|
297
|
+
json: body
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
async ensureAssociations(associations) {
|
|
301
|
+
const associationsDeepCopy = JSON.parse(JSON.stringify(associations));
|
|
302
|
+
const groupedAssociations = this.groupAssociations(associationsDeepCopy, ['to_object_type']);
|
|
303
|
+
function getAssociationType(associationLabel) {
|
|
304
|
+
const [associationCategory, associationTypeId] = associationLabel.split(':');
|
|
305
|
+
return { associationCategory, associationTypeId };
|
|
306
|
+
}
|
|
307
|
+
const requests = groupedAssociations.map(async (group) => {
|
|
308
|
+
const toObjectType = group[0].to_object_type;
|
|
309
|
+
const inputs = group.map((association) => {
|
|
310
|
+
const { associationCategory, associationTypeId } = getAssociationType(association.association_label);
|
|
311
|
+
const input = {
|
|
312
|
+
types: [
|
|
313
|
+
{
|
|
314
|
+
associationCategory,
|
|
315
|
+
associationTypeId
|
|
316
|
+
}
|
|
317
|
+
],
|
|
318
|
+
from: {
|
|
319
|
+
id: association.from_record_id ?? ''
|
|
320
|
+
},
|
|
321
|
+
to: {
|
|
322
|
+
id: association.to_record_id ?? ''
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
return input;
|
|
326
|
+
});
|
|
327
|
+
return this.batchAssociationsRequest({ inputs }, toObjectType);
|
|
328
|
+
});
|
|
329
|
+
await Promise.all(requests);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
exports.HubspotClient = HubspotClient;
|
|
333
|
+
//# sourceMappingURL=hubspot-api.js.map
|