@particle-academy/hubspot-js 0.3.4 → 0.5.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 +61 -0
- package/README.md +218 -1
- package/art/fancified.svg +26 -0
- package/dist/chunk-SZT3VK7Z.js +1146 -0
- package/dist/chunk-SZT3VK7Z.js.map +1 -0
- package/dist/flow.cjs +1340 -13
- package/dist/flow.cjs.map +1 -1
- package/dist/flow.d.cts +19 -1
- package/dist/flow.d.ts +19 -1
- package/dist/flow.js +275 -5
- package/dist/flow.js.map +1 -1
- package/dist/index.cjs +1081 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +637 -2
- package/dist/index.d.ts +637 -2
- package/dist/index.js +1 -1
- package/package.json +4 -3
- package/dist/chunk-6HO2IP5Q.js +0 -104
- package/dist/chunk-6HO2IP5Q.js.map +0 -1
|
@@ -0,0 +1,1146 @@
|
|
|
1
|
+
import { callConnector, verifyDelivery } from '@particle-academy/fancy-connector-core';
|
|
2
|
+
|
|
3
|
+
// src/faker.ts
|
|
4
|
+
function fakeCompanyCreate({ config, fake }) {
|
|
5
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
6
|
+
return {
|
|
7
|
+
"id": boundRecordId,
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": "Acme",
|
|
10
|
+
"domain": "acme.example.test",
|
|
11
|
+
"hs_object_id": boundRecordId,
|
|
12
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
13
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
14
|
+
},
|
|
15
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
16
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
17
|
+
"archived": false
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function fakeCompanyGet({ config, fake }) {
|
|
21
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
22
|
+
return {
|
|
23
|
+
"id": boundRecordId,
|
|
24
|
+
"properties": {
|
|
25
|
+
"name": "Acme",
|
|
26
|
+
"domain": "acme.example.test",
|
|
27
|
+
"hs_object_id": boundRecordId,
|
|
28
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
29
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
30
|
+
},
|
|
31
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
32
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
33
|
+
"archived": false
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function fakeCompanyList({ config, fake }) {
|
|
37
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
38
|
+
return {
|
|
39
|
+
"results": [
|
|
40
|
+
{
|
|
41
|
+
"id": boundRecordId,
|
|
42
|
+
"properties": {
|
|
43
|
+
"name": "Acme",
|
|
44
|
+
"domain": "acme.example.test",
|
|
45
|
+
"hs_object_id": boundRecordId,
|
|
46
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
47
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
48
|
+
},
|
|
49
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
50
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
51
|
+
"archived": false
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"paging": {
|
|
55
|
+
"next": {
|
|
56
|
+
"after": "10",
|
|
57
|
+
"link": "?after=10"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function fakeCompanySearch({ config, fake }) {
|
|
63
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
64
|
+
return {
|
|
65
|
+
"total": 1,
|
|
66
|
+
"results": [
|
|
67
|
+
{
|
|
68
|
+
"id": boundRecordId,
|
|
69
|
+
"properties": {
|
|
70
|
+
"name": "Acme",
|
|
71
|
+
"domain": "acme.example.test",
|
|
72
|
+
"hs_object_id": boundRecordId,
|
|
73
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
74
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
75
|
+
},
|
|
76
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
77
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
78
|
+
"archived": false
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"paging": {
|
|
82
|
+
"next": {
|
|
83
|
+
"after": "10",
|
|
84
|
+
"link": "?after=10"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function fakeCompanyUpdate({ config, fake }) {
|
|
90
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
91
|
+
return {
|
|
92
|
+
"id": boundRecordId,
|
|
93
|
+
"properties": {
|
|
94
|
+
"name": "Acme",
|
|
95
|
+
"domain": "acme.example.test",
|
|
96
|
+
"hs_object_id": boundRecordId,
|
|
97
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
98
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
99
|
+
},
|
|
100
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
101
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
102
|
+
"archived": false
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function fakeContactCreate({ config, fake }) {
|
|
106
|
+
const boundContactId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
107
|
+
return {
|
|
108
|
+
"id": boundContactId,
|
|
109
|
+
"properties": {
|
|
110
|
+
"email": config.email !== void 0 && config.email !== null && config.email !== "" ? String(config.email) : null,
|
|
111
|
+
"firstname": config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? String(config.firstName) : null,
|
|
112
|
+
"lastname": config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? String(config.lastName) : null,
|
|
113
|
+
"company": config.company !== void 0 && config.company !== null && config.company !== "" ? String(config.company) : null,
|
|
114
|
+
"phone": config.phone !== void 0 && config.phone !== null && config.phone !== "" ? String(config.phone) : null,
|
|
115
|
+
"lifecyclestage": config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? String(config.lifecycleStage) : "lead",
|
|
116
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
117
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z",
|
|
118
|
+
"hs_object_id": boundContactId
|
|
119
|
+
},
|
|
120
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
121
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
122
|
+
"archived": false
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function fakeContactGet({ config, fake }) {
|
|
126
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
127
|
+
return {
|
|
128
|
+
"id": boundRecordId,
|
|
129
|
+
"properties": {
|
|
130
|
+
"email": "rosa@example.test",
|
|
131
|
+
"firstname": "Rosa",
|
|
132
|
+
"lastname": "Diaz",
|
|
133
|
+
"hs_object_id": boundRecordId,
|
|
134
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
135
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
136
|
+
},
|
|
137
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
138
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
139
|
+
"archived": false
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function fakeContactList({ config, fake }) {
|
|
143
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
144
|
+
return {
|
|
145
|
+
"results": [
|
|
146
|
+
{
|
|
147
|
+
"id": boundRecordId,
|
|
148
|
+
"properties": {
|
|
149
|
+
"email": "rosa@example.test",
|
|
150
|
+
"firstname": "Rosa",
|
|
151
|
+
"lastname": "Diaz",
|
|
152
|
+
"hs_object_id": boundRecordId,
|
|
153
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
154
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
155
|
+
},
|
|
156
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
157
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
158
|
+
"archived": false
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"paging": {
|
|
162
|
+
"next": {
|
|
163
|
+
"after": "10",
|
|
164
|
+
"link": "?after=10"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function fakeContactSearch({ config, fake }) {
|
|
170
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
171
|
+
return {
|
|
172
|
+
"total": 1,
|
|
173
|
+
"results": [
|
|
174
|
+
{
|
|
175
|
+
"id": boundRecordId,
|
|
176
|
+
"properties": {
|
|
177
|
+
"email": "rosa@example.test",
|
|
178
|
+
"firstname": "Rosa",
|
|
179
|
+
"lastname": "Diaz",
|
|
180
|
+
"hs_object_id": boundRecordId,
|
|
181
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
182
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
183
|
+
},
|
|
184
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
185
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
186
|
+
"archived": false
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"paging": {
|
|
190
|
+
"next": {
|
|
191
|
+
"after": "10",
|
|
192
|
+
"link": "?after=10"
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function fakeContactUpdate({ config, fake }) {
|
|
198
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
199
|
+
return {
|
|
200
|
+
"id": boundRecordId,
|
|
201
|
+
"properties": {
|
|
202
|
+
"email": "rosa@example.test",
|
|
203
|
+
"firstname": "Rosa",
|
|
204
|
+
"lastname": "Diaz",
|
|
205
|
+
"hs_object_id": boundRecordId,
|
|
206
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
207
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
208
|
+
},
|
|
209
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
210
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
211
|
+
"archived": false
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function fakeDealCreate({ config, fake }) {
|
|
215
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
216
|
+
return {
|
|
217
|
+
"id": boundRecordId,
|
|
218
|
+
"properties": {
|
|
219
|
+
"dealname": "Acme renewal",
|
|
220
|
+
"amount": "12000",
|
|
221
|
+
"dealstage": "appointmentscheduled",
|
|
222
|
+
"pipeline": "default",
|
|
223
|
+
"hs_object_id": boundRecordId,
|
|
224
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
225
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
226
|
+
},
|
|
227
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
228
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
229
|
+
"archived": false
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function fakeDealGet({ config, fake }) {
|
|
233
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
234
|
+
return {
|
|
235
|
+
"id": boundRecordId,
|
|
236
|
+
"properties": {
|
|
237
|
+
"dealname": "Acme renewal",
|
|
238
|
+
"amount": "12000",
|
|
239
|
+
"dealstage": "appointmentscheduled",
|
|
240
|
+
"pipeline": "default",
|
|
241
|
+
"hs_object_id": boundRecordId,
|
|
242
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
243
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
244
|
+
},
|
|
245
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
246
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
247
|
+
"archived": false
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function fakeDealList({ config, fake }) {
|
|
251
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
252
|
+
return {
|
|
253
|
+
"results": [
|
|
254
|
+
{
|
|
255
|
+
"id": boundRecordId,
|
|
256
|
+
"properties": {
|
|
257
|
+
"dealname": "Acme renewal",
|
|
258
|
+
"amount": "12000",
|
|
259
|
+
"dealstage": "appointmentscheduled",
|
|
260
|
+
"pipeline": "default",
|
|
261
|
+
"hs_object_id": boundRecordId,
|
|
262
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
263
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
264
|
+
},
|
|
265
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
266
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
267
|
+
"archived": false
|
|
268
|
+
}
|
|
269
|
+
],
|
|
270
|
+
"paging": {
|
|
271
|
+
"next": {
|
|
272
|
+
"after": "10",
|
|
273
|
+
"link": "?after=10"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function fakeDealSearch({ config, fake }) {
|
|
279
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
280
|
+
return {
|
|
281
|
+
"total": 1,
|
|
282
|
+
"results": [
|
|
283
|
+
{
|
|
284
|
+
"id": boundRecordId,
|
|
285
|
+
"properties": {
|
|
286
|
+
"dealname": "Acme renewal",
|
|
287
|
+
"amount": "12000",
|
|
288
|
+
"dealstage": "appointmentscheduled",
|
|
289
|
+
"pipeline": "default",
|
|
290
|
+
"hs_object_id": boundRecordId,
|
|
291
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
292
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
293
|
+
},
|
|
294
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
295
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
296
|
+
"archived": false
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
"paging": {
|
|
300
|
+
"next": {
|
|
301
|
+
"after": "10",
|
|
302
|
+
"link": "?after=10"
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function fakeDealUpdate({ config, fake }) {
|
|
308
|
+
const boundRecordId = Array.from({ length: 9 }, () => fake.int(0, 9)).join("");
|
|
309
|
+
return {
|
|
310
|
+
"id": boundRecordId,
|
|
311
|
+
"properties": {
|
|
312
|
+
"dealname": "Acme renewal",
|
|
313
|
+
"amount": "12000",
|
|
314
|
+
"dealstage": "appointmentscheduled",
|
|
315
|
+
"pipeline": "default",
|
|
316
|
+
"hs_object_id": boundRecordId,
|
|
317
|
+
"createdate": "2026-01-01T00:00:00.000Z",
|
|
318
|
+
"lastmodifieddate": "2026-01-01T00:00:00.000Z"
|
|
319
|
+
},
|
|
320
|
+
"createdAt": "2026-01-01T00:00:00.000Z",
|
|
321
|
+
"updatedAt": "2026-01-01T00:00:00.000Z",
|
|
322
|
+
"archived": false
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
function fakeOwnerList({ config, fake }) {
|
|
326
|
+
const boundOwnerId = Array.from({ length: 8 }, () => fake.int(0, 9)).join("");
|
|
327
|
+
return {
|
|
328
|
+
"results": [
|
|
329
|
+
{
|
|
330
|
+
"id": boundOwnerId,
|
|
331
|
+
"email": "rosa@example.test",
|
|
332
|
+
"firstName": "Rosa",
|
|
333
|
+
"lastName": "Diaz",
|
|
334
|
+
"userId": 4242,
|
|
335
|
+
"archived": false
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"paging": {
|
|
339
|
+
"next": {
|
|
340
|
+
"after": "10",
|
|
341
|
+
"link": "?after=10"
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function fakePipelineList({ config, fake }) {
|
|
347
|
+
return {
|
|
348
|
+
"results": [
|
|
349
|
+
{
|
|
350
|
+
"id": "default",
|
|
351
|
+
"label": "Sales pipeline",
|
|
352
|
+
"displayOrder": 0,
|
|
353
|
+
"archived": false,
|
|
354
|
+
"stages": [
|
|
355
|
+
{
|
|
356
|
+
"id": "appointmentscheduled",
|
|
357
|
+
"label": "Appointment scheduled",
|
|
358
|
+
"displayOrder": 0,
|
|
359
|
+
"metadata": {
|
|
360
|
+
"probability": "0.2"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"id": "closedwon",
|
|
365
|
+
"label": "Closed won",
|
|
366
|
+
"displayOrder": 1,
|
|
367
|
+
"metadata": {
|
|
368
|
+
"probability": "1.0"
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
]
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function fakePropertyList({ config, fake }) {
|
|
377
|
+
return {
|
|
378
|
+
"results": [
|
|
379
|
+
{
|
|
380
|
+
"name": "dealstage",
|
|
381
|
+
"label": "Deal Stage",
|
|
382
|
+
"type": "enumeration",
|
|
383
|
+
"fieldType": "select",
|
|
384
|
+
"groupName": "dealinformation",
|
|
385
|
+
"options": [
|
|
386
|
+
{
|
|
387
|
+
"label": "Appointment scheduled",
|
|
388
|
+
"value": "appointmentscheduled"
|
|
389
|
+
}
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
]
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function fakeCrmEvent({ config, fake }) {
|
|
396
|
+
return [
|
|
397
|
+
{
|
|
398
|
+
"eventId": 531833541,
|
|
399
|
+
"subscriptionId": 3923621,
|
|
400
|
+
"portalId": 48807704,
|
|
401
|
+
"appId": 16111050,
|
|
402
|
+
"occurredAt": 1752613920733,
|
|
403
|
+
"subscriptionType": "contact.creation",
|
|
404
|
+
"attemptNumber": 0,
|
|
405
|
+
"objectId": 138017612137,
|
|
406
|
+
"changeFlag": "CREATED",
|
|
407
|
+
"changeSource": "CRM_UI",
|
|
408
|
+
"sourceId": "userId:76023669"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"eventId": 531833542,
|
|
412
|
+
"subscriptionId": 3923622,
|
|
413
|
+
"portalId": 48807704,
|
|
414
|
+
"appId": 16111050,
|
|
415
|
+
"occurredAt": 1752613921e3,
|
|
416
|
+
"subscriptionType": "deal.propertyChange",
|
|
417
|
+
"attemptNumber": 0,
|
|
418
|
+
"objectId": 9876543210,
|
|
419
|
+
"propertyName": "dealstage",
|
|
420
|
+
"propertyValue": "closedwon",
|
|
421
|
+
"changeSource": "CRM_UI",
|
|
422
|
+
"sourceId": "userId:76023669"
|
|
423
|
+
}
|
|
424
|
+
];
|
|
425
|
+
}
|
|
426
|
+
var hubspotFaker = (operation, request) => {
|
|
427
|
+
switch (operation) {
|
|
428
|
+
case "company_create":
|
|
429
|
+
return fakeCompanyCreate(request);
|
|
430
|
+
case "company_get":
|
|
431
|
+
return fakeCompanyGet(request);
|
|
432
|
+
case "company_list":
|
|
433
|
+
return fakeCompanyList(request);
|
|
434
|
+
case "company_search":
|
|
435
|
+
return fakeCompanySearch(request);
|
|
436
|
+
case "company_update":
|
|
437
|
+
return fakeCompanyUpdate(request);
|
|
438
|
+
case "contact_create":
|
|
439
|
+
return fakeContactCreate(request);
|
|
440
|
+
case "contact_get":
|
|
441
|
+
return fakeContactGet(request);
|
|
442
|
+
case "contact_list":
|
|
443
|
+
return fakeContactList(request);
|
|
444
|
+
case "contact_search":
|
|
445
|
+
return fakeContactSearch(request);
|
|
446
|
+
case "contact_update":
|
|
447
|
+
return fakeContactUpdate(request);
|
|
448
|
+
case "deal_create":
|
|
449
|
+
return fakeDealCreate(request);
|
|
450
|
+
case "deal_get":
|
|
451
|
+
return fakeDealGet(request);
|
|
452
|
+
case "deal_list":
|
|
453
|
+
return fakeDealList(request);
|
|
454
|
+
case "deal_search":
|
|
455
|
+
return fakeDealSearch(request);
|
|
456
|
+
case "deal_update":
|
|
457
|
+
return fakeDealUpdate(request);
|
|
458
|
+
case "owner_list":
|
|
459
|
+
return fakeOwnerList(request);
|
|
460
|
+
case "pipeline_list":
|
|
461
|
+
return fakePipelineList(request);
|
|
462
|
+
case "property_list":
|
|
463
|
+
return fakePropertyList(request);
|
|
464
|
+
case "crm_event":
|
|
465
|
+
return fakeCrmEvent(request);
|
|
466
|
+
default:
|
|
467
|
+
throw new Error(
|
|
468
|
+
`hubspot: no fake response is defined for "${operation}". Add a fixture under provider/fixtures/ and regenerate \u2014 a connector without a faker cannot be developed against, tested, or demonstrated.`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// src/service.ts
|
|
474
|
+
var CONNECTOR_API_VERSION = 1;
|
|
475
|
+
var HUBSPOT_BASE_URLS = {
|
|
476
|
+
"live": "https://api.hubapi.com",
|
|
477
|
+
"sandbox": "https://api.hubapi.com"
|
|
478
|
+
};
|
|
479
|
+
var HUBSPOT_REQUIRES = [
|
|
480
|
+
"accessToken"
|
|
481
|
+
];
|
|
482
|
+
function hubspotAuthorize(credentials, request, _mode) {
|
|
483
|
+
request.headers.Authorization = `Bearer ${credentials.accessToken ?? ""}`;
|
|
484
|
+
}
|
|
485
|
+
var HUBSPOT = {
|
|
486
|
+
service: "hubspot",
|
|
487
|
+
title: "HubSpot",
|
|
488
|
+
sandbox: "separate-account",
|
|
489
|
+
baseUrls: { ...HUBSPOT_BASE_URLS },
|
|
490
|
+
requires: [...HUBSPOT_REQUIRES],
|
|
491
|
+
authorize: hubspotAuthorize,
|
|
492
|
+
faker: hubspotFaker
|
|
493
|
+
};
|
|
494
|
+
var COMPANY_CREATE_OPERATION = "company_create";
|
|
495
|
+
async function hubspotCompanyCreate(options) {
|
|
496
|
+
const config = options.config ?? {};
|
|
497
|
+
if (config.properties === void 0 || config.properties === null || config.properties === "") {
|
|
498
|
+
throw new Error(`company_create: "properties" is required (Properties).`);
|
|
499
|
+
}
|
|
500
|
+
return callConnector(HUBSPOT, {
|
|
501
|
+
operation: COMPANY_CREATE_OPERATION,
|
|
502
|
+
config,
|
|
503
|
+
input: options.input,
|
|
504
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
505
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
506
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
507
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
508
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
509
|
+
request: {
|
|
510
|
+
method: "POST",
|
|
511
|
+
path: "/crm/v3/objects/companies",
|
|
512
|
+
json: {
|
|
513
|
+
"properties": propertiesMap(config.properties),
|
|
514
|
+
"associations": []
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function propertiesMap(value) {
|
|
520
|
+
if (!value || typeof value !== "object") return {};
|
|
521
|
+
const out = {};
|
|
522
|
+
for (const [key, item] of Object.entries(value)) {
|
|
523
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
524
|
+
}
|
|
525
|
+
return out;
|
|
526
|
+
}
|
|
527
|
+
var COMPANY_GET_OPERATION = "company_get";
|
|
528
|
+
async function hubspotCompanyGet(options) {
|
|
529
|
+
const config = options.config ?? {};
|
|
530
|
+
if (config.companyId === void 0 || config.companyId === null || config.companyId === "") {
|
|
531
|
+
throw new Error(`company_get: "companyId" is required (Company id).`);
|
|
532
|
+
}
|
|
533
|
+
return callConnector(HUBSPOT, {
|
|
534
|
+
operation: COMPANY_GET_OPERATION,
|
|
535
|
+
config,
|
|
536
|
+
input: options.input,
|
|
537
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
538
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
539
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
540
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
541
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
542
|
+
request: {
|
|
543
|
+
method: "GET",
|
|
544
|
+
path: `/crm/v3/objects/companies/${encodeURIComponent(String(config.companyId))}`,
|
|
545
|
+
query: {
|
|
546
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
547
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
var COMPANY_LIST_OPERATION = "company_list";
|
|
553
|
+
async function hubspotCompanyList(options) {
|
|
554
|
+
const config = options.config ?? {};
|
|
555
|
+
{
|
|
556
|
+
const n = Number(config.limit);
|
|
557
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
558
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 100)) {
|
|
559
|
+
throw new Error(
|
|
560
|
+
`company_list: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
561
|
+
);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return callConnector(HUBSPOT, {
|
|
565
|
+
operation: COMPANY_LIST_OPERATION,
|
|
566
|
+
config,
|
|
567
|
+
input: options.input,
|
|
568
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
569
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
570
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
571
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
572
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
573
|
+
request: {
|
|
574
|
+
method: "GET",
|
|
575
|
+
path: "/crm/v3/objects/companies",
|
|
576
|
+
query: {
|
|
577
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
578
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {},
|
|
579
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
580
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
var COMPANY_SEARCH_OPERATION = "company_search";
|
|
586
|
+
async function hubspotCompanySearch(options) {
|
|
587
|
+
const config = options.config ?? {};
|
|
588
|
+
if (typeof config.filterGroups === "string" && config.filterGroups !== "") {
|
|
589
|
+
try {
|
|
590
|
+
JSON.parse(config.filterGroups);
|
|
591
|
+
} catch (error) {
|
|
592
|
+
throw new Error(`company_search: "filterGroups" must be JSON: ${error.message}`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
if (typeof config.sorts === "string" && config.sorts !== "") {
|
|
596
|
+
try {
|
|
597
|
+
JSON.parse(config.sorts);
|
|
598
|
+
} catch (error) {
|
|
599
|
+
throw new Error(`company_search: "sorts" must be JSON: ${error.message}`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
{
|
|
603
|
+
const n = Number(config.limit);
|
|
604
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
605
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 200)) {
|
|
606
|
+
throw new Error(
|
|
607
|
+
`company_search: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return callConnector(HUBSPOT, {
|
|
612
|
+
operation: COMPANY_SEARCH_OPERATION,
|
|
613
|
+
config,
|
|
614
|
+
input: options.input,
|
|
615
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
616
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
617
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
618
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
619
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
620
|
+
request: {
|
|
621
|
+
method: "POST",
|
|
622
|
+
path: "/crm/v3/objects/companies/search",
|
|
623
|
+
json: {
|
|
624
|
+
...config.filterGroups !== void 0 && config.filterGroups !== null && config.filterGroups !== "" ? { "filterGroups": typeof config.filterGroups === "string" ? JSON.parse(config.filterGroups) : config.filterGroups } : {},
|
|
625
|
+
...config.sorts !== void 0 && config.sorts !== null && config.sorts !== "" ? { "sorts": typeof config.sorts === "string" ? JSON.parse(config.sorts) : config.sorts } : {},
|
|
626
|
+
...config.query !== void 0 && config.query !== null && config.query !== "" ? { "query": String(config.query) } : {},
|
|
627
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": propertiesList(config.properties) } : {},
|
|
628
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
629
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
function propertiesList(value) {
|
|
635
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
636
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
637
|
+
}
|
|
638
|
+
var COMPANY_UPDATE_OPERATION = "company_update";
|
|
639
|
+
async function hubspotCompanyUpdate(options) {
|
|
640
|
+
const config = options.config ?? {};
|
|
641
|
+
if (config.companyId === void 0 || config.companyId === null || config.companyId === "") {
|
|
642
|
+
throw new Error(`company_update: "companyId" is required (Company id).`);
|
|
643
|
+
}
|
|
644
|
+
if (config.properties === void 0 || config.properties === null || config.properties === "") {
|
|
645
|
+
throw new Error(`company_update: "properties" is required (Properties).`);
|
|
646
|
+
}
|
|
647
|
+
return callConnector(HUBSPOT, {
|
|
648
|
+
operation: COMPANY_UPDATE_OPERATION,
|
|
649
|
+
config,
|
|
650
|
+
input: options.input,
|
|
651
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
652
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
653
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
654
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
655
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
656
|
+
request: {
|
|
657
|
+
method: "PATCH",
|
|
658
|
+
path: `/crm/v3/objects/companies/${encodeURIComponent(String(config.companyId))}`,
|
|
659
|
+
json: {
|
|
660
|
+
"properties": propertiesMap2(config.properties)
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
function propertiesMap2(value) {
|
|
666
|
+
if (!value || typeof value !== "object") return {};
|
|
667
|
+
const out = {};
|
|
668
|
+
for (const [key, item] of Object.entries(value)) {
|
|
669
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
670
|
+
}
|
|
671
|
+
return out;
|
|
672
|
+
}
|
|
673
|
+
var CONTACT_CREATE_OPERATION = "contact_create";
|
|
674
|
+
async function hubspotContactCreate(options) {
|
|
675
|
+
const config = options.config ?? {};
|
|
676
|
+
if (config.email === void 0 || config.email === null || config.email === "") {
|
|
677
|
+
throw new Error(`contact_create: "email" is required (Email).`);
|
|
678
|
+
}
|
|
679
|
+
return callConnector(HUBSPOT, {
|
|
680
|
+
operation: CONTACT_CREATE_OPERATION,
|
|
681
|
+
config,
|
|
682
|
+
input: options.input,
|
|
683
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
684
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
685
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
686
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
687
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
688
|
+
request: {
|
|
689
|
+
method: "POST",
|
|
690
|
+
path: "/crm/v3/objects/contacts",
|
|
691
|
+
json: nestFields({
|
|
692
|
+
"properties.email": String(config.email).trim(),
|
|
693
|
+
...config.firstName !== void 0 && config.firstName !== null && config.firstName !== "" ? { "properties.firstname": String(config.firstName) } : {},
|
|
694
|
+
...config.lastName !== void 0 && config.lastName !== null && config.lastName !== "" ? { "properties.lastname": String(config.lastName) } : {},
|
|
695
|
+
...config.company !== void 0 && config.company !== null && config.company !== "" ? { "properties.company": String(config.company) } : {},
|
|
696
|
+
...config.phone !== void 0 && config.phone !== null && config.phone !== "" ? { "properties.phone": String(config.phone) } : {},
|
|
697
|
+
...config.lifecycleStage !== void 0 && config.lifecycleStage !== null && config.lifecycleStage !== "" ? { "properties.lifecyclestage": String(config.lifecycleStage) } : {},
|
|
698
|
+
"associations": []
|
|
699
|
+
})
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
function nestFields(flat) {
|
|
704
|
+
const out = {};
|
|
705
|
+
for (const [path, value] of Object.entries(flat)) {
|
|
706
|
+
const parts = path.split(".");
|
|
707
|
+
let node = out;
|
|
708
|
+
while (parts.length > 1) {
|
|
709
|
+
const key = parts.shift();
|
|
710
|
+
const wantsArray = /^\d+$/.test(parts[0] ?? "");
|
|
711
|
+
if (typeof node[key] !== "object" || node[key] === null) node[key] = wantsArray ? [] : {};
|
|
712
|
+
node = node[key];
|
|
713
|
+
}
|
|
714
|
+
node[parts[0]] = value;
|
|
715
|
+
}
|
|
716
|
+
return out;
|
|
717
|
+
}
|
|
718
|
+
var CONTACT_GET_OPERATION = "contact_get";
|
|
719
|
+
async function hubspotContactGet(options) {
|
|
720
|
+
const config = options.config ?? {};
|
|
721
|
+
if (config.contactId === void 0 || config.contactId === null || config.contactId === "") {
|
|
722
|
+
throw new Error(`contact_get: "contactId" is required (Contact id).`);
|
|
723
|
+
}
|
|
724
|
+
return callConnector(HUBSPOT, {
|
|
725
|
+
operation: CONTACT_GET_OPERATION,
|
|
726
|
+
config,
|
|
727
|
+
input: options.input,
|
|
728
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
729
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
730
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
731
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
732
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
733
|
+
request: {
|
|
734
|
+
method: "GET",
|
|
735
|
+
path: `/crm/v3/objects/contacts/${encodeURIComponent(String(config.contactId))}`,
|
|
736
|
+
query: {
|
|
737
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
738
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
var CONTACT_LIST_OPERATION = "contact_list";
|
|
744
|
+
async function hubspotContactList(options) {
|
|
745
|
+
const config = options.config ?? {};
|
|
746
|
+
{
|
|
747
|
+
const n = Number(config.limit);
|
|
748
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
749
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 100)) {
|
|
750
|
+
throw new Error(
|
|
751
|
+
`contact_list: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return callConnector(HUBSPOT, {
|
|
756
|
+
operation: CONTACT_LIST_OPERATION,
|
|
757
|
+
config,
|
|
758
|
+
input: options.input,
|
|
759
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
760
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
761
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
762
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
763
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
764
|
+
request: {
|
|
765
|
+
method: "GET",
|
|
766
|
+
path: "/crm/v3/objects/contacts",
|
|
767
|
+
query: {
|
|
768
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
769
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {},
|
|
770
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
771
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
var CONTACT_SEARCH_OPERATION = "contact_search";
|
|
777
|
+
async function hubspotContactSearch(options) {
|
|
778
|
+
const config = options.config ?? {};
|
|
779
|
+
if (typeof config.filterGroups === "string" && config.filterGroups !== "") {
|
|
780
|
+
try {
|
|
781
|
+
JSON.parse(config.filterGroups);
|
|
782
|
+
} catch (error) {
|
|
783
|
+
throw new Error(`contact_search: "filterGroups" must be JSON: ${error.message}`);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
if (typeof config.sorts === "string" && config.sorts !== "") {
|
|
787
|
+
try {
|
|
788
|
+
JSON.parse(config.sorts);
|
|
789
|
+
} catch (error) {
|
|
790
|
+
throw new Error(`contact_search: "sorts" must be JSON: ${error.message}`);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
{
|
|
794
|
+
const n = Number(config.limit);
|
|
795
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
796
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 200)) {
|
|
797
|
+
throw new Error(
|
|
798
|
+
`contact_search: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return callConnector(HUBSPOT, {
|
|
803
|
+
operation: CONTACT_SEARCH_OPERATION,
|
|
804
|
+
config,
|
|
805
|
+
input: options.input,
|
|
806
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
807
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
808
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
809
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
810
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
811
|
+
request: {
|
|
812
|
+
method: "POST",
|
|
813
|
+
path: "/crm/v3/objects/contacts/search",
|
|
814
|
+
json: {
|
|
815
|
+
...config.filterGroups !== void 0 && config.filterGroups !== null && config.filterGroups !== "" ? { "filterGroups": typeof config.filterGroups === "string" ? JSON.parse(config.filterGroups) : config.filterGroups } : {},
|
|
816
|
+
...config.sorts !== void 0 && config.sorts !== null && config.sorts !== "" ? { "sorts": typeof config.sorts === "string" ? JSON.parse(config.sorts) : config.sorts } : {},
|
|
817
|
+
...config.query !== void 0 && config.query !== null && config.query !== "" ? { "query": String(config.query) } : {},
|
|
818
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": propertiesList2(config.properties) } : {},
|
|
819
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
820
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
function propertiesList2(value) {
|
|
826
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
827
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
828
|
+
}
|
|
829
|
+
var CONTACT_UPDATE_OPERATION = "contact_update";
|
|
830
|
+
async function hubspotContactUpdate(options) {
|
|
831
|
+
const config = options.config ?? {};
|
|
832
|
+
if (config.contactId === void 0 || config.contactId === null || config.contactId === "") {
|
|
833
|
+
throw new Error(`contact_update: "contactId" is required (Contact id).`);
|
|
834
|
+
}
|
|
835
|
+
if (config.properties === void 0 || config.properties === null || config.properties === "") {
|
|
836
|
+
throw new Error(`contact_update: "properties" is required (Properties).`);
|
|
837
|
+
}
|
|
838
|
+
return callConnector(HUBSPOT, {
|
|
839
|
+
operation: CONTACT_UPDATE_OPERATION,
|
|
840
|
+
config,
|
|
841
|
+
input: options.input,
|
|
842
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
843
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
844
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
845
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
846
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
847
|
+
request: {
|
|
848
|
+
method: "PATCH",
|
|
849
|
+
path: `/crm/v3/objects/contacts/${encodeURIComponent(String(config.contactId))}`,
|
|
850
|
+
json: {
|
|
851
|
+
"properties": propertiesMap3(config.properties)
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}
|
|
856
|
+
function propertiesMap3(value) {
|
|
857
|
+
if (!value || typeof value !== "object") return {};
|
|
858
|
+
const out = {};
|
|
859
|
+
for (const [key, item] of Object.entries(value)) {
|
|
860
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
861
|
+
}
|
|
862
|
+
return out;
|
|
863
|
+
}
|
|
864
|
+
var DEAL_CREATE_OPERATION = "deal_create";
|
|
865
|
+
async function hubspotDealCreate(options) {
|
|
866
|
+
const config = options.config ?? {};
|
|
867
|
+
if (config.properties === void 0 || config.properties === null || config.properties === "") {
|
|
868
|
+
throw new Error(`deal_create: "properties" is required (Properties).`);
|
|
869
|
+
}
|
|
870
|
+
return callConnector(HUBSPOT, {
|
|
871
|
+
operation: DEAL_CREATE_OPERATION,
|
|
872
|
+
config,
|
|
873
|
+
input: options.input,
|
|
874
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
875
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
876
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
877
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
878
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
879
|
+
request: {
|
|
880
|
+
method: "POST",
|
|
881
|
+
path: "/crm/v3/objects/deals",
|
|
882
|
+
json: {
|
|
883
|
+
"properties": propertiesMap4(config.properties),
|
|
884
|
+
"associations": []
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function propertiesMap4(value) {
|
|
890
|
+
if (!value || typeof value !== "object") return {};
|
|
891
|
+
const out = {};
|
|
892
|
+
for (const [key, item] of Object.entries(value)) {
|
|
893
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
894
|
+
}
|
|
895
|
+
return out;
|
|
896
|
+
}
|
|
897
|
+
var DEAL_GET_OPERATION = "deal_get";
|
|
898
|
+
async function hubspotDealGet(options) {
|
|
899
|
+
const config = options.config ?? {};
|
|
900
|
+
if (config.dealId === void 0 || config.dealId === null || config.dealId === "") {
|
|
901
|
+
throw new Error(`deal_get: "dealId" is required (Deal id).`);
|
|
902
|
+
}
|
|
903
|
+
return callConnector(HUBSPOT, {
|
|
904
|
+
operation: DEAL_GET_OPERATION,
|
|
905
|
+
config,
|
|
906
|
+
input: options.input,
|
|
907
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
908
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
909
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
910
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
911
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
912
|
+
request: {
|
|
913
|
+
method: "GET",
|
|
914
|
+
path: `/crm/v3/objects/deals/${encodeURIComponent(String(config.dealId))}`,
|
|
915
|
+
query: {
|
|
916
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
917
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
var DEAL_LIST_OPERATION = "deal_list";
|
|
923
|
+
async function hubspotDealList(options) {
|
|
924
|
+
const config = options.config ?? {};
|
|
925
|
+
{
|
|
926
|
+
const n = Number(config.limit);
|
|
927
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
928
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 100)) {
|
|
929
|
+
throw new Error(
|
|
930
|
+
`deal_list: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return callConnector(HUBSPOT, {
|
|
935
|
+
operation: DEAL_LIST_OPERATION,
|
|
936
|
+
config,
|
|
937
|
+
input: options.input,
|
|
938
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
939
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
940
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
941
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
942
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
943
|
+
request: {
|
|
944
|
+
method: "GET",
|
|
945
|
+
path: "/crm/v3/objects/deals",
|
|
946
|
+
query: {
|
|
947
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
948
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {},
|
|
949
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": String(config.properties) } : {},
|
|
950
|
+
...config.associations !== void 0 && config.associations !== null && config.associations !== "" ? { "associations": String(config.associations) } : {}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
var DEAL_SEARCH_OPERATION = "deal_search";
|
|
956
|
+
async function hubspotDealSearch(options) {
|
|
957
|
+
const config = options.config ?? {};
|
|
958
|
+
if (typeof config.filterGroups === "string" && config.filterGroups !== "") {
|
|
959
|
+
try {
|
|
960
|
+
JSON.parse(config.filterGroups);
|
|
961
|
+
} catch (error) {
|
|
962
|
+
throw new Error(`deal_search: "filterGroups" must be JSON: ${error.message}`);
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
if (typeof config.sorts === "string" && config.sorts !== "") {
|
|
966
|
+
try {
|
|
967
|
+
JSON.parse(config.sorts);
|
|
968
|
+
} catch (error) {
|
|
969
|
+
throw new Error(`deal_search: "sorts" must be JSON: ${error.message}`);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
{
|
|
973
|
+
const n = Number(config.limit);
|
|
974
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
975
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 200)) {
|
|
976
|
+
throw new Error(
|
|
977
|
+
`deal_search: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
978
|
+
);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
return callConnector(HUBSPOT, {
|
|
982
|
+
operation: DEAL_SEARCH_OPERATION,
|
|
983
|
+
config,
|
|
984
|
+
input: options.input,
|
|
985
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
986
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
987
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
988
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
989
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
990
|
+
request: {
|
|
991
|
+
method: "POST",
|
|
992
|
+
path: "/crm/v3/objects/deals/search",
|
|
993
|
+
json: {
|
|
994
|
+
...config.filterGroups !== void 0 && config.filterGroups !== null && config.filterGroups !== "" ? { "filterGroups": typeof config.filterGroups === "string" ? JSON.parse(config.filterGroups) : config.filterGroups } : {},
|
|
995
|
+
...config.sorts !== void 0 && config.sorts !== null && config.sorts !== "" ? { "sorts": typeof config.sorts === "string" ? JSON.parse(config.sorts) : config.sorts } : {},
|
|
996
|
+
...config.query !== void 0 && config.query !== null && config.query !== "" ? { "query": String(config.query) } : {},
|
|
997
|
+
...config.properties !== void 0 && config.properties !== null && config.properties !== "" ? { "properties": propertiesList3(config.properties) } : {},
|
|
998
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
999
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
function propertiesList3(value) {
|
|
1005
|
+
const items = Array.isArray(value) ? value.map(String) : typeof value === "string" ? value.split(",") : [];
|
|
1006
|
+
return items.map((item) => item.trim()).filter(Boolean);
|
|
1007
|
+
}
|
|
1008
|
+
var DEAL_UPDATE_OPERATION = "deal_update";
|
|
1009
|
+
async function hubspotDealUpdate(options) {
|
|
1010
|
+
const config = options.config ?? {};
|
|
1011
|
+
if (config.dealId === void 0 || config.dealId === null || config.dealId === "") {
|
|
1012
|
+
throw new Error(`deal_update: "dealId" is required (Deal id).`);
|
|
1013
|
+
}
|
|
1014
|
+
if (config.properties === void 0 || config.properties === null || config.properties === "") {
|
|
1015
|
+
throw new Error(`deal_update: "properties" is required (Properties).`);
|
|
1016
|
+
}
|
|
1017
|
+
return callConnector(HUBSPOT, {
|
|
1018
|
+
operation: DEAL_UPDATE_OPERATION,
|
|
1019
|
+
config,
|
|
1020
|
+
input: options.input,
|
|
1021
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
1022
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
1023
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
1024
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
1025
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
1026
|
+
request: {
|
|
1027
|
+
method: "PATCH",
|
|
1028
|
+
path: `/crm/v3/objects/deals/${encodeURIComponent(String(config.dealId))}`,
|
|
1029
|
+
json: {
|
|
1030
|
+
"properties": propertiesMap5(config.properties)
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
function propertiesMap5(value) {
|
|
1036
|
+
if (!value || typeof value !== "object") return {};
|
|
1037
|
+
const out = {};
|
|
1038
|
+
for (const [key, item] of Object.entries(value)) {
|
|
1039
|
+
if (item !== void 0 && item !== null && item !== "") out[key] = String(item);
|
|
1040
|
+
}
|
|
1041
|
+
return out;
|
|
1042
|
+
}
|
|
1043
|
+
var OWNER_LIST_OPERATION = "owner_list";
|
|
1044
|
+
async function hubspotOwnerList(options) {
|
|
1045
|
+
const config = options.config ?? {};
|
|
1046
|
+
{
|
|
1047
|
+
const n = Number(config.limit);
|
|
1048
|
+
const given = config.limit !== void 0 && config.limit !== null && config.limit !== "";
|
|
1049
|
+
if (given && !(Number.isInteger(n) && n >= 1 && n <= 100)) {
|
|
1050
|
+
throw new Error(
|
|
1051
|
+
`owner_list: "limit" must be a integer, got ${JSON.stringify(config.limit)}.`
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return callConnector(HUBSPOT, {
|
|
1056
|
+
operation: OWNER_LIST_OPERATION,
|
|
1057
|
+
config,
|
|
1058
|
+
input: options.input,
|
|
1059
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
1060
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
1061
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
1062
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
1063
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
1064
|
+
request: {
|
|
1065
|
+
method: "GET",
|
|
1066
|
+
path: "/crm/v3/owners",
|
|
1067
|
+
query: {
|
|
1068
|
+
...config.email !== void 0 && config.email !== null && config.email !== "" ? { "email": String(config.email) } : {},
|
|
1069
|
+
...config.limit !== void 0 && config.limit !== null && config.limit !== "" ? { "limit": Math.trunc(Number(config.limit)) } : {},
|
|
1070
|
+
...config.after !== void 0 && config.after !== null && config.after !== "" ? { "after": String(config.after) } : {}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
var PIPELINE_LIST_OPERATION = "pipeline_list";
|
|
1076
|
+
async function hubspotPipelineList(options) {
|
|
1077
|
+
const config = options.config ?? {};
|
|
1078
|
+
return callConnector(HUBSPOT, {
|
|
1079
|
+
operation: PIPELINE_LIST_OPERATION,
|
|
1080
|
+
config,
|
|
1081
|
+
input: options.input,
|
|
1082
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
1083
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
1084
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
1085
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
1086
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
1087
|
+
request: {
|
|
1088
|
+
method: "GET",
|
|
1089
|
+
path: "/crm/v3/pipelines/deals",
|
|
1090
|
+
query: {}
|
|
1091
|
+
}
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
var PROPERTY_LIST_OPERATION = "property_list";
|
|
1095
|
+
async function hubspotPropertyList(options) {
|
|
1096
|
+
const config = options.config ?? {};
|
|
1097
|
+
if (config.objectType === void 0 || config.objectType === null || config.objectType === "") {
|
|
1098
|
+
throw new Error(`property_list: "objectType" is required (Object).`);
|
|
1099
|
+
}
|
|
1100
|
+
return callConnector(HUBSPOT, {
|
|
1101
|
+
operation: PROPERTY_LIST_OPERATION,
|
|
1102
|
+
config,
|
|
1103
|
+
input: options.input,
|
|
1104
|
+
...options.credentials === void 0 ? {} : { credentials: options.credentials },
|
|
1105
|
+
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
1106
|
+
...options.connectionId === void 0 ? {} : { connectionId: options.connectionId },
|
|
1107
|
+
...options.attempts === void 0 ? {} : { attempts: options.attempts },
|
|
1108
|
+
...options.transport === void 0 ? {} : { transport: options.transport },
|
|
1109
|
+
request: {
|
|
1110
|
+
method: "GET",
|
|
1111
|
+
path: `/crm/v3/properties/${encodeURIComponent(String(config.objectType))}`,
|
|
1112
|
+
query: {}
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
}
|
|
1116
|
+
var HUBSPOT_CRM_EVENT_SIGNATURE_HEADER = "X-HubSpot-Signature-v3";
|
|
1117
|
+
var HUBSPOT_CRM_EVENT_TOLERANCE = 300;
|
|
1118
|
+
var HUBSPOT_CRM_EVENT_SCHEME = {
|
|
1119
|
+
algorithm: "SHA-256",
|
|
1120
|
+
payload: (raw, timestamp, _id, request) => `${request?.method ?? ""}${request?.uri ?? ""}${raw}${timestamp}`,
|
|
1121
|
+
tolerance: HUBSPOT_CRM_EVENT_TOLERANCE,
|
|
1122
|
+
timestampUnit: "ms",
|
|
1123
|
+
signsRequestLine: true,
|
|
1124
|
+
uri: "hubspot-v3",
|
|
1125
|
+
encoding: "base64"
|
|
1126
|
+
};
|
|
1127
|
+
var HUBSPOT_CRM_EVENT = {
|
|
1128
|
+
service: "hubspot",
|
|
1129
|
+
operation: "crm_event",
|
|
1130
|
+
delivery: "webhook",
|
|
1131
|
+
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.",
|
|
1132
|
+
verification: {
|
|
1133
|
+
signatureHeader: HUBSPOT_CRM_EVENT_SIGNATURE_HEADER,
|
|
1134
|
+
scheme: HUBSPOT_CRM_EVENT_SCHEME,
|
|
1135
|
+
timestampHeader: "X-HubSpot-Request-Timestamp"
|
|
1136
|
+
},
|
|
1137
|
+
route: { by: "portalId", path: "[].portalId" },
|
|
1138
|
+
faker: hubspotFaker
|
|
1139
|
+
};
|
|
1140
|
+
function verifyHubspotDelivery(delivery, clientSecret, now) {
|
|
1141
|
+
return verifyDelivery(HUBSPOT_CRM_EVENT, delivery, clientSecret, now);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
export { COMPANY_CREATE_OPERATION, COMPANY_GET_OPERATION, COMPANY_LIST_OPERATION, COMPANY_SEARCH_OPERATION, COMPANY_UPDATE_OPERATION, CONNECTOR_API_VERSION, CONTACT_CREATE_OPERATION, CONTACT_GET_OPERATION, CONTACT_LIST_OPERATION, CONTACT_SEARCH_OPERATION, CONTACT_UPDATE_OPERATION, DEAL_CREATE_OPERATION, DEAL_GET_OPERATION, DEAL_LIST_OPERATION, DEAL_SEARCH_OPERATION, DEAL_UPDATE_OPERATION, HUBSPOT, HUBSPOT_BASE_URLS, HUBSPOT_CRM_EVENT, HUBSPOT_CRM_EVENT_SCHEME, HUBSPOT_CRM_EVENT_SIGNATURE_HEADER, HUBSPOT_CRM_EVENT_TOLERANCE, HUBSPOT_REQUIRES, OWNER_LIST_OPERATION, PIPELINE_LIST_OPERATION, PROPERTY_LIST_OPERATION, hubspotAuthorize, hubspotCompanyCreate, hubspotCompanyGet, hubspotCompanyList, hubspotCompanySearch, hubspotCompanyUpdate, hubspotContactCreate, hubspotContactGet, hubspotContactList, hubspotContactSearch, hubspotContactUpdate, hubspotDealCreate, hubspotDealGet, hubspotDealList, hubspotDealSearch, hubspotDealUpdate, hubspotFaker, hubspotOwnerList, hubspotPipelineList, hubspotPropertyList, verifyHubspotDelivery };
|
|
1145
|
+
//# sourceMappingURL=chunk-SZT3VK7Z.js.map
|
|
1146
|
+
//# sourceMappingURL=chunk-SZT3VK7Z.js.map
|