@awell-health/awell-extensions 2.0.215 → 2.0.216
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/dist/extensions/hubspot/actions/createOrUpdateContact/config/datapoints.d.ts +10 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/datapoints.js +14 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/datapoints.js.map +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/fields.d.ts +59 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/fields.js +88 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/fields.js.map +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/index.d.ts +2 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/index.js +9 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/config/index.js.map +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/createOrUpdateContact.d.ts +4 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/createOrUpdateContact.js +97 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/createOrUpdateContact.js.map +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/helpers.d.ts +11 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/helpers.js +37 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/helpers.js.map +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/index.d.ts +1 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/index.js +6 -0
- package/dist/extensions/hubspot/actions/createOrUpdateContact/index.js.map +1 -0
- package/dist/extensions/hubspot/actions/index.d.ts +60 -0
- package/dist/extensions/hubspot/actions/index.js +2 -0
- package/dist/extensions/hubspot/actions/index.js.map +1 -1
- package/dist/extensions/markdown.json +1 -1
- package/package.json +1 -1
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.dataPoints = void 0;
|
4
|
+
exports.dataPoints = {
|
5
|
+
hubspotContactId: {
|
6
|
+
key: 'hubspotContactId',
|
7
|
+
valueType: 'string',
|
8
|
+
},
|
9
|
+
contactResource: {
|
10
|
+
key: 'contactResource',
|
11
|
+
valueType: 'json',
|
12
|
+
},
|
13
|
+
};
|
14
|
+
//# sourceMappingURL=datapoints.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"datapoints.js","sourceRoot":"","sources":["../../../../../../extensions/hubspot/actions/createOrUpdateContact/config/datapoints.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG;IACxB,gBAAgB,EAAE;QAChB,GAAG,EAAE,kBAAkB;QACvB,SAAS,EAAE,QAAQ;KACpB;IACD,eAAe,EAAE;QACf,GAAG,EAAE,iBAAiB;QACtB,SAAS,EAAE,MAAM;KAClB;CAC4C,CAAA"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { FieldType, StringType } from '@awell-health/extensions-core';
|
2
|
+
import z from 'zod';
|
3
|
+
export declare const fields: {
|
4
|
+
email: {
|
5
|
+
id: string;
|
6
|
+
label: string;
|
7
|
+
description: string;
|
8
|
+
type: FieldType.STRING;
|
9
|
+
required: true;
|
10
|
+
};
|
11
|
+
firstName: {
|
12
|
+
id: string;
|
13
|
+
label: string;
|
14
|
+
description: string;
|
15
|
+
type: FieldType.STRING;
|
16
|
+
required: false;
|
17
|
+
};
|
18
|
+
lastName: {
|
19
|
+
id: string;
|
20
|
+
label: string;
|
21
|
+
description: string;
|
22
|
+
type: FieldType.STRING;
|
23
|
+
required: false;
|
24
|
+
};
|
25
|
+
phone: {
|
26
|
+
id: string;
|
27
|
+
label: string;
|
28
|
+
description: string;
|
29
|
+
type: FieldType.STRING;
|
30
|
+
stringType: StringType.PHONE;
|
31
|
+
required: false;
|
32
|
+
};
|
33
|
+
customProperties: {
|
34
|
+
id: string;
|
35
|
+
label: string;
|
36
|
+
description: string;
|
37
|
+
type: FieldType.JSON;
|
38
|
+
required: true;
|
39
|
+
};
|
40
|
+
};
|
41
|
+
export declare const FieldsValidationSchema: z.ZodObject<{
|
42
|
+
email: z.ZodString;
|
43
|
+
firstName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
44
|
+
lastName: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
45
|
+
phone: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>;
|
46
|
+
customProperties: z.ZodEffects<z.ZodOptional<z.ZodString>, Record<string, unknown> | undefined, string | undefined>;
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
48
|
+
email: string;
|
49
|
+
firstName?: string | undefined;
|
50
|
+
lastName?: string | undefined;
|
51
|
+
phone?: string | undefined;
|
52
|
+
customProperties?: Record<string, unknown> | undefined;
|
53
|
+
}, {
|
54
|
+
email: string;
|
55
|
+
firstName?: string | undefined;
|
56
|
+
lastName?: string | undefined;
|
57
|
+
phone?: string | undefined;
|
58
|
+
customProperties?: string | undefined;
|
59
|
+
}>;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.FieldsValidationSchema = exports.fields = void 0;
|
7
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
8
|
+
const lodash_1 = require("lodash");
|
9
|
+
const zod_1 = __importDefault(require("zod"));
|
10
|
+
exports.fields = {
|
11
|
+
email: {
|
12
|
+
id: 'email',
|
13
|
+
label: 'Email',
|
14
|
+
description: 'The email of the contact',
|
15
|
+
type: extensions_core_1.FieldType.STRING,
|
16
|
+
required: true,
|
17
|
+
},
|
18
|
+
firstName: {
|
19
|
+
id: 'firstName',
|
20
|
+
label: 'First name',
|
21
|
+
description: 'The first name of the contact',
|
22
|
+
type: extensions_core_1.FieldType.STRING,
|
23
|
+
required: false,
|
24
|
+
},
|
25
|
+
lastName: {
|
26
|
+
id: 'lastName',
|
27
|
+
label: 'Last name',
|
28
|
+
description: 'The last name of the contact',
|
29
|
+
type: extensions_core_1.FieldType.STRING,
|
30
|
+
required: false,
|
31
|
+
},
|
32
|
+
phone: {
|
33
|
+
id: 'phone',
|
34
|
+
label: 'Phone',
|
35
|
+
description: 'The phone number of the contact',
|
36
|
+
type: extensions_core_1.FieldType.STRING,
|
37
|
+
stringType: extensions_core_1.StringType.PHONE,
|
38
|
+
required: false,
|
39
|
+
},
|
40
|
+
customProperties: {
|
41
|
+
id: 'customProperties',
|
42
|
+
label: 'Custom properties',
|
43
|
+
description: 'An object of key-values pairs of custom properties of the contact',
|
44
|
+
type: extensions_core_1.FieldType.JSON,
|
45
|
+
required: true,
|
46
|
+
},
|
47
|
+
};
|
48
|
+
exports.FieldsValidationSchema = zod_1.default.object({
|
49
|
+
email: zod_1.default.string().min(1).email(),
|
50
|
+
firstName: zod_1.default
|
51
|
+
.string()
|
52
|
+
.optional()
|
53
|
+
.transform((val) => ((0, lodash_1.isEmpty)(val) ? undefined : val)),
|
54
|
+
lastName: zod_1.default
|
55
|
+
.string()
|
56
|
+
.optional()
|
57
|
+
.transform((val) => ((0, lodash_1.isEmpty)(val) ? undefined : val)),
|
58
|
+
phone: zod_1.default
|
59
|
+
.string()
|
60
|
+
.optional()
|
61
|
+
.transform((val) => ((0, lodash_1.isEmpty)(val) ? undefined : val)),
|
62
|
+
customProperties: zod_1.default
|
63
|
+
.string()
|
64
|
+
.optional()
|
65
|
+
.transform((str, ctx) => {
|
66
|
+
if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
|
67
|
+
return undefined;
|
68
|
+
try {
|
69
|
+
const parsedJson = JSON.parse(str);
|
70
|
+
if ((0, lodash_1.isEmpty)(parsedJson)) {
|
71
|
+
return undefined;
|
72
|
+
}
|
73
|
+
if (typeof parsedJson !== 'object' || Array.isArray(parsedJson)) {
|
74
|
+
ctx.addIssue({
|
75
|
+
code: 'custom',
|
76
|
+
message: 'The value should represent an object',
|
77
|
+
});
|
78
|
+
return zod_1.default.NEVER;
|
79
|
+
}
|
80
|
+
return parsedJson;
|
81
|
+
}
|
82
|
+
catch (e) {
|
83
|
+
ctx.addIssue({ code: 'custom', message: 'Invalid JSON.' });
|
84
|
+
return zod_1.default.NEVER;
|
85
|
+
}
|
86
|
+
}),
|
87
|
+
});
|
88
|
+
//# sourceMappingURL=fields.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../../../extensions/hubspot/actions/createOrUpdateContact/config/fields.ts"],"names":[],"mappings":";;;;;;AAAA,mEAIsC;AACtC,mCAAuC;AACvC,8CAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,0BAA0B;QACvC,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,IAAI;KACf;IACD,SAAS,EAAE;QACT,EAAE,EAAE,WAAW;QACf,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,KAAK;KAChB;IACD,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU;QACd,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,8BAA8B;QAC3C,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,QAAQ,EAAE,KAAK;KAChB;IACD,KAAK,EAAE;QACL,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,iCAAiC;QAC9C,IAAI,EAAE,2BAAS,CAAC,MAAM;QACtB,UAAU,EAAE,4BAAU,CAAC,KAAK;QAC5B,QAAQ,EAAE,KAAK;KAChB;IACD,gBAAgB,EAAE;Q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AAA,gBAAO,EAAC,UAAU,CAAC,EAAE,CAAC;gBACxB,OAAO,SAAS,CAAA;YAClB,CAAC;YAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;gBAChE,GAAG,CAAC,QAAQ,CAAC;oBACX,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,sCAAsC;iBAChD,CAAC,CAAA;gBACF,OAAO,aAAC,CAAC,KAAK,CAAA;YAChB,CAAC;YAED,OAAO,UAAU,CAAA;QACnB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAA;YAC1D,OAAO,aAAC,CAAC,KAAK,CAAA;QAChB,CAAC;IACH,CAAC,CAAC;CAC6C,CAAC,CAAA"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.dataPoints = exports.FieldsValidationSchema = exports.fields = void 0;
|
4
|
+
var fields_1 = require("./fields");
|
5
|
+
Object.defineProperty(exports, "fields", { enumerable: true, get: function () { return fields_1.fields; } });
|
6
|
+
Object.defineProperty(exports, "FieldsValidationSchema", { enumerable: true, get: function () { return fields_1.FieldsValidationSchema; } });
|
7
|
+
var datapoints_1 = require("./datapoints");
|
8
|
+
Object.defineProperty(exports, "dataPoints", { enumerable: true, get: function () { return datapoints_1.dataPoints; } });
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../extensions/hubspot/actions/createOrUpdateContact/config/index.ts"],"names":[],"mappings":";;;AAAA,mCAAyD;AAAhD,gGAAA,MAAM,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AACvC,2CAAyC;AAAhC,wGAAA,UAAU,OAAA"}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createOrUpdateContact = void 0;
|
4
|
+
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
|
+
const lib_1 = require("../../lib");
|
6
|
+
const config_1 = require("./config");
|
7
|
+
const lodash_1 = require("lodash");
|
8
|
+
const addEventLog_1 = require("../../../../src/lib/awell/addEventLog");
|
9
|
+
const helpers_1 = require("./helpers");
|
10
|
+
exports.createOrUpdateContact = {
|
11
|
+
key: 'createOrUpdateContact',
|
12
|
+
category: extensions_core_1.Category.CUSTOMER_SUPPORT,
|
13
|
+
title: 'Create or update contact',
|
14
|
+
description: 'Create or update a contact in HubSpot',
|
15
|
+
fields: config_1.fields,
|
16
|
+
previewable: false,
|
17
|
+
dataPoints: config_1.dataPoints,
|
18
|
+
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
19
|
+
const eventLogs = [];
|
20
|
+
const { hubSpotSdk, fields } = await (0, lib_1.validatePayloadAndCreateSdks)({
|
21
|
+
fieldsSchema: config_1.FieldsValidationSchema,
|
22
|
+
payload,
|
23
|
+
});
|
24
|
+
const createOrUpdateProperties = {
|
25
|
+
/**
|
26
|
+
* Default Hubspot properties
|
27
|
+
* Available in every Hubspot account
|
28
|
+
*/
|
29
|
+
email: fields.email,
|
30
|
+
...(!(0, lodash_1.isNil)(fields.firstName) && { firstname: fields.firstName }),
|
31
|
+
...(!(0, lodash_1.isNil)(fields.lastName) && { lastname: fields.lastName }),
|
32
|
+
...(!(0, lodash_1.isNil)(fields.phone) && { phone: fields.phone }),
|
33
|
+
/**
|
34
|
+
* Custom properties
|
35
|
+
*/
|
36
|
+
...(!(0, lodash_1.isNil)(fields.customProperties) && fields.customProperties),
|
37
|
+
};
|
38
|
+
try {
|
39
|
+
// Try retrieving an existing contact
|
40
|
+
const existingContact = await (0, helpers_1.getExistingContact)(hubSpotSdk, fields.email);
|
41
|
+
if (!(0, lodash_1.isNil)(existingContact)) {
|
42
|
+
eventLogs.push((0, addEventLog_1.addActivityEventLog)({
|
43
|
+
message: `Existing contact found in Hubspot with email ${fields.email}. Contact ID: ${existingContact.id}`,
|
44
|
+
}), (0, addEventLog_1.addActivityEventLog)({
|
45
|
+
message: `Existing contact details: ${JSON.stringify(existingContact, null, 2)}`,
|
46
|
+
}));
|
47
|
+
// Update the existing contact
|
48
|
+
const updatedContact = await (0, helpers_1.updateContact)(hubSpotSdk, existingContact.id, createOrUpdateProperties);
|
49
|
+
await onComplete({
|
50
|
+
data_points: {
|
51
|
+
hubspotContactId: updatedContact.id,
|
52
|
+
contactResource: JSON.stringify(updatedContact),
|
53
|
+
},
|
54
|
+
events: [
|
55
|
+
...eventLogs,
|
56
|
+
(0, addEventLog_1.addActivityEventLog)({
|
57
|
+
message: `Updated contact:\n${JSON.stringify(updatedContact, null, 2)}`,
|
58
|
+
}),
|
59
|
+
],
|
60
|
+
});
|
61
|
+
return;
|
62
|
+
}
|
63
|
+
// Contact not found, create a new one
|
64
|
+
eventLogs.push((0, addEventLog_1.addActivityEventLog)({
|
65
|
+
message: `No existing contact found in Hubspot with email ${fields.email}.`,
|
66
|
+
}));
|
67
|
+
const newContact = await (0, helpers_1.createContact)(hubSpotSdk, createOrUpdateProperties);
|
68
|
+
await onComplete({
|
69
|
+
data_points: {
|
70
|
+
hubspotContactId: newContact.id,
|
71
|
+
contactResource: JSON.stringify(newContact),
|
72
|
+
},
|
73
|
+
events: [
|
74
|
+
...eventLogs,
|
75
|
+
(0, addEventLog_1.addActivityEventLog)({
|
76
|
+
message: `Contact created in Hubspot with email ${fields.email}. Contact ID: ${newContact.id}`,
|
77
|
+
}),
|
78
|
+
(0, addEventLog_1.addActivityEventLog)({
|
79
|
+
message: `New contact:\n${JSON.stringify(newContact, null, 2)}`,
|
80
|
+
}),
|
81
|
+
],
|
82
|
+
});
|
83
|
+
}
|
84
|
+
catch (err) {
|
85
|
+
const typedError = err;
|
86
|
+
await onError({
|
87
|
+
events: [
|
88
|
+
...eventLogs,
|
89
|
+
(0, addEventLog_1.addActivityEventLog)({
|
90
|
+
message: `Error in Hubspot operation: ${typedError.code}: ${typedError.message}\n${JSON.stringify(typedError.body, null, 2)}`,
|
91
|
+
}),
|
92
|
+
],
|
93
|
+
});
|
94
|
+
}
|
95
|
+
},
|
96
|
+
};
|
97
|
+
//# sourceMappingURL=createOrUpdateContact.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"createOrUpdateContact.js","sourceRoot":"","sources":["../../../../../extensions/hubspot/actions/createOrUpdateContact/createOrUpdateContact.ts"],"names":[],"mappings":";;;AAAA,mEAIsC;AACtC,mCAAwD;AAExD,qCAAqE;AACrE,mCAA8B;AAC9B,uEAA2E;AAE3E,uCAA4E;AAE/D,QAAA,qBAAqB,GAI9B;IACF,GAAG,EAAE,uBAAuB;IAC5B,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,0BAA0B;IACjC,WAAW,EAAE,uCAAuC;IACpD,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAiB,EAAE;QAC1E,MAAM,SAAS,GAAoB,EAAE,CAAA;QAErC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,kCAA4B,EAAC;YAChE,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,MAAM,wBAAwB,GAAG;YAC/B;;;eAGG;YACH,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,CAAC,CAAC,IAAA,cAAK,EAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;YAChE,GAAG,CAAC,CAAC,IAAA,cAAK,EAAC,MAAM,CAAC,QAAQ,CAA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CAAA;gBACF,OAAM;YACR,CAAC;YAED,sCAAsC;YACtC,SAAS,CAAC,IAAI,CACZ,IAAA,iCAAmB,EAAC;gBAClB,OAAO,EAAE,mDAAmD,MAAM,CAAC,KAAK,GAAG;aAC5E,CAAC,CACH,CAAA;YAED,MAAM,UAAU,GAAG,MAAM,IAAA,uBAAa,EACpC,UAAU,EACV,wBAAwB,CACzB,CAAA;YAED,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,gBAAgB,EAAE,UAAU,CAAC,EAAE;oBAC/B,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;iBAC5C;gBACD,MAAM,EAAE;oBACN,GAAG,SAAS;oBACZ,IAAA,iCAAmB,EAAC;wBAClB,OAAO,EAAE,yCAAyC,MAAM,CAAC,KAAK,iBAAiB,UAAU,CAAC,EAAE,EAAE;qBAC/F,CAAC;oBACF,IAAA,iCAAmB,EAAC;wBAClB,OAAO,EAAE,iBAAiB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;qBAChE,CAAC;iBACH;aACF,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,GAA4B,CAAA;YAC/C,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE;oBACN,GAAG,SAAS;oBACZ,IAAA,iCAAmB,EAAC;wBAClB,OAAO,EAAE,+BAA+B,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,KAAK,IAAI,CAAC,SAAS,CAC/F,UAAU,CAAC,IAAI,EACf,IAAI,EACJ,CAAC,CACF,EAAE;qBACJ,CAAC;iBACH;aACF,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF,CAAA"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { type Client } from '@hubspot/api-client';
|
2
|
+
import { type SimplePublicObjectWithAssociations, type SimplePublicObject } from '@hubspot/api-client/lib/codegen/crm/contacts';
|
3
|
+
export declare const getExistingContact: (hubSpotSdk: Client, email: string) => Promise<SimplePublicObjectWithAssociations | null>;
|
4
|
+
/**
|
5
|
+
* Updates an existing contact in HubSpot.
|
6
|
+
*/
|
7
|
+
export declare const updateContact: (hubSpotSdk: Client, contactId: string, properties: Record<string, string>) => Promise<SimplePublicObject>;
|
8
|
+
/**
|
9
|
+
* Creates a new contact in HubSpot.
|
10
|
+
*/
|
11
|
+
export declare const createContact: (hubSpotSdk: Client, properties: Record<string, string>) => Promise<SimplePublicObject>;
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createContact = exports.updateContact = exports.getExistingContact = void 0;
|
4
|
+
const getExistingContact = async (hubSpotSdk, email) => {
|
5
|
+
try {
|
6
|
+
const includeArchived = false;
|
7
|
+
return await hubSpotSdk.crm.contacts.basicApi.getById(email, undefined, undefined, undefined, includeArchived, 'email');
|
8
|
+
}
|
9
|
+
catch (err) {
|
10
|
+
const typedError = err;
|
11
|
+
if (typedError.code === 404) {
|
12
|
+
return null; // Contact does not exist
|
13
|
+
}
|
14
|
+
throw typedError; // Other errors should propagate
|
15
|
+
}
|
16
|
+
};
|
17
|
+
exports.getExistingContact = getExistingContact;
|
18
|
+
/**
|
19
|
+
* Updates an existing contact in HubSpot.
|
20
|
+
*/
|
21
|
+
const updateContact = async (hubSpotSdk, contactId, properties) => {
|
22
|
+
return await hubSpotSdk.crm.contacts.basicApi.update(contactId, {
|
23
|
+
properties,
|
24
|
+
});
|
25
|
+
};
|
26
|
+
exports.updateContact = updateContact;
|
27
|
+
/**
|
28
|
+
* Creates a new contact in HubSpot.
|
29
|
+
*/
|
30
|
+
const createContact = async (hubSpotSdk, properties) => {
|
31
|
+
return await hubSpotSdk.crm.contacts.basicApi.create({
|
32
|
+
associations: [],
|
33
|
+
properties,
|
34
|
+
});
|
35
|
+
};
|
36
|
+
exports.createContact = createContact;
|
37
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../extensions/hubspot/actions/createOrUpdateContact/helpers.ts"],"names":[],"mappings":";;;AAOO,MAAM,kBAAkB,GAAG,KAAK,EACrC,UAAkB,EAClB,KAAa,EACuC,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,KAAK,CAAA;QAE7B,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CACnD,KAAK,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,eAAe,EACf,OAAO,CACR,CAAA;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,UAAU,GAAG,GAA4B,CAAA;QAC/C,IAAI,UAAU,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAA,CAAC,yBAAyB;QACvC,CAAC;QACD,MAAM,UAAU,CAAA,CAAC,gCAAgC;IACnD,CAAC;AACH,CAAC,CAAA;AAtBY,QAAA,kBAAkB,sBAsB9B;AAED;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,UAAkB,EAClB,SAAiB,EACjB,UAAkC,EACL,EAAE;IAC/B,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE;QAC9D,UAAU;KACX,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,aAAa,iBAQzB;AAED;;GAEG;AACI,MAAM,aAAa,GAAG,KAAK,EAChC,UAAkB,EAClB,UAAkC,EACL,EAAE;IAC/B,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QACnD,YAAY,EAAE,EAAE;QAChB,UAAU;KACX,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,aAAa,iBAQzB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { createOrUpdateContact } from './createOrUpdateContact';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createOrUpdateContact = void 0;
|
4
|
+
var createOrUpdateContact_1 = require("./createOrUpdateContact");
|
5
|
+
Object.defineProperty(exports, "createOrUpdateContact", { enumerable: true, get: function () { return createOrUpdateContact_1.createOrUpdateContact; } });
|
6
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../extensions/hubspot/actions/createOrUpdateContact/index.ts"],"names":[],"mappings":";;;AAAA,iEAA+D;AAAtD,8HAAA,qBAAqB,OAAA"}
|
@@ -1,4 +1,64 @@
|
|
1
1
|
declare const actions: {
|
2
|
+
createOrUpdateContact: import("@awell-health/extensions-core").Action<{
|
3
|
+
email: {
|
4
|
+
id: string;
|
5
|
+
label: string;
|
6
|
+
description: string;
|
7
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
8
|
+
required: true;
|
9
|
+
};
|
10
|
+
firstName: {
|
11
|
+
id: string;
|
12
|
+
label: string;
|
13
|
+
description: string;
|
14
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
15
|
+
required: false;
|
16
|
+
};
|
17
|
+
lastName: {
|
18
|
+
id: string;
|
19
|
+
label: string;
|
20
|
+
description: string;
|
21
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
22
|
+
required: false;
|
23
|
+
};
|
24
|
+
phone: {
|
25
|
+
id: string;
|
26
|
+
label: string;
|
27
|
+
description: string;
|
28
|
+
type: import("@awell-health/extensions-core").FieldType.STRING;
|
29
|
+
stringType: import("@awell-health/extensions-core").StringType.PHONE;
|
30
|
+
required: false;
|
31
|
+
};
|
32
|
+
customProperties: {
|
33
|
+
id: string;
|
34
|
+
label: string;
|
35
|
+
description: string;
|
36
|
+
type: import("@awell-health/extensions-core").FieldType.JSON;
|
37
|
+
required: true;
|
38
|
+
};
|
39
|
+
}, {
|
40
|
+
accessToken: {
|
41
|
+
key: string;
|
42
|
+
label: string;
|
43
|
+
obfuscated: false;
|
44
|
+
required: true;
|
45
|
+
description: string;
|
46
|
+
};
|
47
|
+
smtpUsername: {
|
48
|
+
key: string;
|
49
|
+
label: string;
|
50
|
+
obfuscated: false;
|
51
|
+
required: false;
|
52
|
+
description: string;
|
53
|
+
};
|
54
|
+
smtpPassword: {
|
55
|
+
key: string;
|
56
|
+
label: string;
|
57
|
+
obfuscated: true;
|
58
|
+
required: false;
|
59
|
+
description: string;
|
60
|
+
};
|
61
|
+
}, "hubspotContactId" | "contactResource">;
|
2
62
|
getcontact: import("@awell-health/extensions-core").Action<{
|
3
63
|
contactId: {
|
4
64
|
id: string;
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getContact_1 = require("./getContact");
|
4
4
|
const sendEmailWithSmtp_1 = require("./sendEmailWithSmtp");
|
5
5
|
const sendEmailWithSingleSendApi_1 = require("./sendEmailWithSingleSendApi");
|
6
|
+
const createOrUpdateContact_1 = require("./createOrUpdateContact");
|
6
7
|
const actions = {
|
8
|
+
createOrUpdateContact: createOrUpdateContact_1.createOrUpdateContact,
|
7
9
|
getcontact: getContact_1.getcontact,
|
8
10
|
sendEmailWithSmtp: sendEmailWithSmtp_1.sendEmailWithSmtp,
|
9
11
|
sendEmailWithSingleSendApi: sendEmailWithSingleSendApi_1.sendEmailWithSingleSendApi,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/hubspot/actions/index.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AACzC,2DAAuD;AACvD,6EAAyE;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/hubspot/actions/index.ts"],"names":[],"mappings":";;AAAA,6CAAyC;AACzC,2DAAuD;AACvD,6EAAyE;AACzE,mEAA+D;AAE/D,MAAM,OAAO,GAAG;IACd,qBAAqB,EAArB,6CAAqB;IACrB,UAAU,EAAV,uBAAU;IACV,iBAAiB,EAAjB,qCAAiB;IACjB,0BAA0B,EAA1B,uDAA0B;CAC3B,CAAA;AAED,kBAAe,OAAO,CAAA"}
|
@@ -92,7 +92,7 @@
|
|
92
92
|
"changelog": "# Hello world changelog"
|
93
93
|
},
|
94
94
|
"hubspot": {
|
95
|
-
"readme": "---\ntitle: Hubspot\ndescription: HubSpot is a customer relationship management (CRM) platform that provides a suite of tools for marketing, sales, customer service, and content management.\n---\n\n## Hubspot\n\nHubSpot is a customer relationship management (CRM) platform that offers a comprehensive suite of tools for marketing, sales, customer service, and content management. It is widely recognized for its user-friendly interface and inbound marketing methodology, which focuses on attracting customers through valuable content and experiences instead of traditional advertising.\n\nHubSpot provides features like email marketing, social media management, lead generation, analytics, and automation to help businesses attract, engage, and delight customers.\n\n## Settings and Setup\n\nTo use the HubSpot extension, you need an access token to authenticate with the HubSpot API. We recommend creating a [private app](https://developers.hubspot.com/docs/api/private-apps) in your HubSpot account for Awell and using the provided access token. You should only provide the minimum scopes necessary for the actions you intend to use. The required scopes for each action are listed in the documentation below.\n\n### SMTP Authentication\n\nIf you plan to use the \"Send email with SMTP\" action, you will need to provide your username and password to authenticate requests to HubSpot's SMTP server.\n\n### Add-ons\n\nSending transactional emails via HubSpot requires you to add the [corresponding add-ons](https://knowledge.hubspot.com/marketing-email/how-to-use-transactional-email-in-hubspot) to your HubSpot account.\n\n## Actions\n\n### Get contact\n\nRetrieve the details of a contact based on the provided contact ID.\n\nScope: `crm.objects.contacts.read`\n\n### Send email with SMTP\n\nSend an email using HubSpot's SMTP server.\n\nSending emails via SMTP has some limitations. The most significant drawback is that you cannot use templates or apply styling when sending emails through SMTP. SMTP is generally more manual and less integrated with HubSpot's smart content and template features.\n\nScope: N/A\n\n### Send email with Single Send API\n\nThe Single Send API is the recommended method for sending transactional emails with HubSpot. You can create email templates in your HubSpot account and use this action to send emails to recipients. This method allows you to take advantage of features like smart content and personalization.\n\nScope: `transactional-email`\n",
|
95
|
+
"readme": "---\ntitle: Hubspot\ndescription: HubSpot is a customer relationship management (CRM) platform that provides a suite of tools for marketing, sales, customer service, and content management.\n---\n\n## Hubspot\n\nHubSpot is a customer relationship management (CRM) platform that offers a comprehensive suite of tools for marketing, sales, customer service, and content management. It is widely recognized for its user-friendly interface and inbound marketing methodology, which focuses on attracting customers through valuable content and experiences instead of traditional advertising.\n\nHubSpot provides features like email marketing, social media management, lead generation, analytics, and automation to help businesses attract, engage, and delight customers.\n\n## Settings and Setup\n\nTo use the HubSpot extension, you need an access token to authenticate with the HubSpot API. We recommend creating a [private app](https://developers.hubspot.com/docs/api/private-apps) in your HubSpot account for Awell and using the provided access token. You should only provide the minimum scopes necessary for the actions you intend to use. The required scopes for each action are listed in the documentation below.\n\n### SMTP Authentication\n\nIf you plan to use the \"Send email with SMTP\" action, you will need to provide your username and password to authenticate requests to HubSpot's SMTP server.\n\n### Add-ons\n\nSending transactional emails via HubSpot requires you to add the [corresponding add-ons](https://knowledge.hubspot.com/marketing-email/how-to-use-transactional-email-in-hubspot) to your HubSpot account.\n\n## Actions\n\n### Create or update contact\n\nCreates or updates a contact in HubSpot using the provided information. The patient is matched based on their email address—if a match is found, the existing contact is updated (PATCH); otherwise, a new contact is created.\n\nScope: `crm.objects.contacts.write`\n\n### Get contact\n\nRetrieve the details of a contact based on the provided contact ID.\n\nScope: `crm.objects.contacts.read`\n\n### Send email with SMTP\n\nSend an email using HubSpot's SMTP server.\n\nSending emails via SMTP has some limitations. The most significant drawback is that you cannot use templates or apply styling when sending emails through SMTP. SMTP is generally more manual and less integrated with HubSpot's smart content and template features.\n\nScope: N/A\n\n### Send email with Single Send API\n\nThe Single Send API is the recommended method for sending transactional emails with HubSpot. You can create email templates in your HubSpot account and use this action to send emails to recipients. This method allows you to take advantage of features like smart content and personalization.\n\nScope: `transactional-email`\n",
|
96
96
|
"changelog": "# Hubspot changelog"
|
97
97
|
},
|
98
98
|
"identityVerification": {
|