@awell-health/awell-extensions 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/extensions/elation/constants.d.ts +1 -0
- package/dist/extensions/elation/constants.js +5 -0
- package/dist/extensions/elation/constants.js.map +1 -0
- package/dist/extensions/elation/types/webhooks/appointments.d.ts +69 -0
- package/dist/extensions/elation/types/webhooks/appointments.js +27 -0
- package/dist/extensions/elation/types/webhooks/appointments.js.map +1 -0
- package/dist/extensions/elation/types/webhooks/webhooks.test.d.ts +1 -0
- package/dist/extensions/elation/types/webhooks/webhooks.test.js +65 -0
- package/dist/extensions/elation/types/webhooks/webhooks.test.js.map +1 -0
- package/dist/extensions/elation/webhooks/appointmentCreatedOrUpdated.js +9 -3
- package/dist/extensions/elation/webhooks/appointmentCreatedOrUpdated.js.map +1 -1
- package/dist/extensions/markdown.json +1 -1
- package/dist/extensions/rest/actions/post/post.js +8 -5
- package/dist/extensions/rest/actions/post/post.js.map +1 -1
- package/dist/extensions/rest/actions/post/post.test.js +64 -8
- package/dist/extensions/rest/actions/post/post.test.js.map +1 -1
- package/dist/extensions/sfdc/actions/createLead/createLead.js +6 -8
- package/dist/extensions/sfdc/actions/createLead/createLead.js.map +1 -1
- package/dist/extensions/sfdc/actions/updateLead/updateLead.js +6 -8
- package/dist/extensions/sfdc/actions/updateLead/updateLead.js.map +1 -1
- package/dist/extensions/sfdc/api/client.js +3 -6
- package/dist/extensions/sfdc/api/client.js.map +1 -1
- package/dist/extensions/sfdc/lib/errors.d.ts +9 -4
- package/dist/extensions/sfdc/lib/errors.js +18 -24
- package/dist/extensions/sfdc/lib/errors.js.map +1 -1
- package/dist/extensions/twilio/lib/appendOptOutLanguage.d.ts +3 -0
- package/dist/extensions/twilio/lib/appendOptOutLanguage.js +18 -0
- package/dist/extensions/twilio/lib/appendOptOutLanguage.js.map +1 -0
- package/dist/extensions/twilio/lib/errors.d.ts +9 -0
- package/dist/extensions/twilio/lib/errors.js +23 -0
- package/dist/extensions/twilio/lib/errors.js.map +1 -0
- package/dist/extensions/twilio/lib/index.d.ts +1 -0
- package/dist/extensions/twilio/lib/index.js +6 -0
- package/dist/extensions/twilio/lib/index.js.map +1 -0
- package/dist/extensions/twilio/settings.d.ts +30 -0
- package/dist/extensions/twilio/settings.js +39 -0
- package/dist/extensions/twilio/settings.js.map +1 -1
- package/dist/extensions/twilio/tests/settings.test.d.ts +1 -0
- package/dist/extensions/twilio/tests/settings.test.js +24 -0
- package/dist/extensions/twilio/tests/settings.test.js.map +1 -0
- package/dist/extensions/twilio/v2/actions/createFlowExecution/config/actionSchema.d.ts +33 -0
- package/dist/extensions/twilio/v2/actions/getMessages/getMessages.test.js +12 -0
- package/dist/extensions/twilio/v2/actions/getMessages/getMessages.test.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js +11 -29
- package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSms/sendSms.test.js +19 -15
- package/dist/extensions/twilio/v2/actions/sendSms/sendSms.test.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.js +11 -30
- package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.test.js +25 -15
- package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.test.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js +10 -29
- package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js.map +1 -1
- package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.test.js +19 -15
- package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.test.js.map +1 -1
- package/dist/extensions/workramp/index.js +2 -2
- package/dist/extensions/workramp/index.js.map +1 -1
- package/dist/extensions/workramp/webhooks/EventWebhook.js +1 -1
- package/dist/extensions/workramp/webhooks/EventWebhook.js.map +1 -1
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
export declare const ELATION_SYSTEM = "https://www.elationhealth.com/";
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../extensions/elation/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,gCAAgC,CAAA"}
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import z from 'zod';
|
2
|
+
/**
|
3
|
+
* This is not the full payload, only the most interesting parts
|
4
|
+
*/
|
5
|
+
export declare const AppointmentsPayloadSchema: z.ZodObject<{
|
6
|
+
event_id: z.ZodNumber;
|
7
|
+
application_id: z.ZodString;
|
8
|
+
resource: z.ZodString;
|
9
|
+
action: z.ZodEnum<["saved", "deleted"]>;
|
10
|
+
data: z.ZodObject<{
|
11
|
+
id: z.ZodNumber;
|
12
|
+
scheduled_date: z.ZodDate;
|
13
|
+
duration: z.ZodNumber;
|
14
|
+
reason: z.ZodString;
|
15
|
+
mode: z.ZodString;
|
16
|
+
patient: z.ZodNumber;
|
17
|
+
physician: z.ZodNumber;
|
18
|
+
practice: z.ZodNumber;
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
20
|
+
duration: number;
|
21
|
+
id: number;
|
22
|
+
mode: string;
|
23
|
+
patient: number;
|
24
|
+
reason: string;
|
25
|
+
scheduled_date: Date;
|
26
|
+
physician: number;
|
27
|
+
practice: number;
|
28
|
+
}, {
|
29
|
+
duration: number;
|
30
|
+
id: number;
|
31
|
+
mode: string;
|
32
|
+
patient: number;
|
33
|
+
reason: string;
|
34
|
+
scheduled_date: Date;
|
35
|
+
physician: number;
|
36
|
+
practice: number;
|
37
|
+
}>;
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
39
|
+
data: {
|
40
|
+
duration: number;
|
41
|
+
id: number;
|
42
|
+
mode: string;
|
43
|
+
patient: number;
|
44
|
+
reason: string;
|
45
|
+
scheduled_date: Date;
|
46
|
+
physician: number;
|
47
|
+
practice: number;
|
48
|
+
};
|
49
|
+
resource: string;
|
50
|
+
action: "saved" | "deleted";
|
51
|
+
event_id: number;
|
52
|
+
application_id: string;
|
53
|
+
}, {
|
54
|
+
data: {
|
55
|
+
duration: number;
|
56
|
+
id: number;
|
57
|
+
mode: string;
|
58
|
+
patient: number;
|
59
|
+
reason: string;
|
60
|
+
scheduled_date: Date;
|
61
|
+
physician: number;
|
62
|
+
practice: number;
|
63
|
+
};
|
64
|
+
resource: string;
|
65
|
+
action: "saved" | "deleted";
|
66
|
+
event_id: number;
|
67
|
+
application_id: string;
|
68
|
+
}>;
|
69
|
+
export type AppointmentsPayload = z.infer<typeof AppointmentsPayloadSchema>;
|
@@ -0,0 +1,27 @@
|
|
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.AppointmentsPayloadSchema = void 0;
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
8
|
+
/**
|
9
|
+
* This is not the full payload, only the most interesting parts
|
10
|
+
*/
|
11
|
+
exports.AppointmentsPayloadSchema = zod_1.default.object({
|
12
|
+
event_id: zod_1.default.number(),
|
13
|
+
application_id: zod_1.default.string(),
|
14
|
+
resource: zod_1.default.string(),
|
15
|
+
action: zod_1.default.enum(['saved', 'deleted']),
|
16
|
+
data: zod_1.default.object({
|
17
|
+
id: zod_1.default.number(),
|
18
|
+
scheduled_date: zod_1.default.coerce.date(),
|
19
|
+
duration: zod_1.default.number(),
|
20
|
+
reason: zod_1.default.string(),
|
21
|
+
mode: zod_1.default.string(),
|
22
|
+
patient: zod_1.default.number(),
|
23
|
+
physician: zod_1.default.number(),
|
24
|
+
practice: zod_1.default.number(),
|
25
|
+
}),
|
26
|
+
});
|
27
|
+
//# sourceMappingURL=appointments.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"appointments.js","sourceRoot":"","sources":["../../../../../extensions/elation/types/webhooks/appointments.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAmB;AAEnB;;GAEG;AACU,QAAA,yBAAyB,GAAG,aAAC,CAAC,MAAM,CAAC;IAChD,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;IACpB,cAAc,EAAE,aAAC,CAAC,MAAM,EAAE;IAC1B,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,aAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,EAAE,aAAC,CAAC,MAAM,CAAC;QACb,EAAE,EAAE,aAAC,CAAC,MAAM,EAAE;QACd,cAAc,EAAE,aAAC,CAAC,MAAM,CAAC,IAAI,EAAE;QAC/B,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;QACpB,MAAM,EAAE,aAAC,CAAC,MAAM,EAAE;QAClB,IAAI,EAAE,aAAC,CAAC,MAAM,EAAE;QAChB,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE;QACnB,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE;QACrB,QAAQ,EAAE,aAAC,CAAC,MAAM,EAAE;KACrB,CAAC;CACH,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const appointments_1 = require("./appointments");
|
4
|
+
describe('appointments', () => {
|
5
|
+
it('Parses appointments payload without errors', () => {
|
6
|
+
const payload = {
|
7
|
+
event_id: 683401,
|
8
|
+
application_id: 'iGhPjb2udF4oVDa2MMTNX6gcDk1SR5nl0Vdx1Fhw',
|
9
|
+
resource: 'appointments',
|
10
|
+
action: 'saved',
|
11
|
+
data: {
|
12
|
+
id: 142508453527642,
|
13
|
+
scheduled_date: '2024-09-06T10:15:00Z',
|
14
|
+
duration: 15,
|
15
|
+
billing_details: null,
|
16
|
+
payment: null,
|
17
|
+
time_slot_type: 'appointment',
|
18
|
+
time_slot_status: null,
|
19
|
+
reason: 'Follow-Up',
|
20
|
+
mode: 'IN_PERSON',
|
21
|
+
description: '',
|
22
|
+
status: {
|
23
|
+
status: 'Scheduled',
|
24
|
+
room: null,
|
25
|
+
status_date: '2024-09-06T10:03:54Z',
|
26
|
+
status_detail: null,
|
27
|
+
},
|
28
|
+
patient: 141986488057857,
|
29
|
+
patient_forms: {
|
30
|
+
patient_can_receive_forms: false,
|
31
|
+
anonymous_url: null,
|
32
|
+
overrides: [],
|
33
|
+
short_code: null,
|
34
|
+
statuses: [],
|
35
|
+
hours_prior: null,
|
36
|
+
},
|
37
|
+
physician: 141377681883138,
|
38
|
+
practice: 141127173275652,
|
39
|
+
instructions: '',
|
40
|
+
recurring_event_schedule: null,
|
41
|
+
metadata: null,
|
42
|
+
created_date: '2024-09-06T10:03:54Z',
|
43
|
+
last_modified_date: '2024-09-06T10:03:54Z',
|
44
|
+
deleted_date: null,
|
45
|
+
service_location: {
|
46
|
+
id: 141127173341431,
|
47
|
+
name: 'Awell Test Account',
|
48
|
+
is_primary: true,
|
49
|
+
place_of_service: null,
|
50
|
+
address_line1: '1234 Elation Dr',
|
51
|
+
address_line2: 'Apt. 989',
|
52
|
+
city: 'San Francisco',
|
53
|
+
state: 'CA',
|
54
|
+
zip: '94114',
|
55
|
+
phone: '555555555555',
|
56
|
+
created_date: '2022-11-10T23:21:13Z',
|
57
|
+
deleted_date: null,
|
58
|
+
},
|
59
|
+
telehealth_details: null,
|
60
|
+
},
|
61
|
+
};
|
62
|
+
expect(() => appointments_1.AppointmentsPayloadSchema.parse(payload)).not.toThrow();
|
63
|
+
});
|
64
|
+
});
|
65
|
+
//# sourceMappingURL=webhooks.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"webhooks.test.js","sourceRoot":"","sources":["../../../../../extensions/elation/types/webhooks/webhooks.test.ts"],"names":[],"mappings":";;AAAA,iDAA0D;AAE1D,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,0CAA0C;YAC1D,QAAQ,EAAE,cAAc;YACxB,MAAM,EAAE,OAAO;YACf,IAAI,EAAE;gBACJ,EAAE,EAAE,eAAe;gBACnB,cAAc,EAAE,sBAAsB;gBACtC,QAAQ,EAAE,EAAE;gBACZ,eAAe,EAAE,IAAI;gBACrB,OAAO,EAAE,IAAI;gBACb,cAAc,EAAE,aAAa;gBAC7B,gBAAgB,EAAE,IAAI;gBACtB,MAAM,EAAE,WAAW;gBACnB,IAAI,EAAE,WAAW;gBACjB,WAAW,EAAE,EAAE;gBACf,MAAM,EAAE;oBACN,MAAM,EAAE,WAAW;oBACnB,IAAI,EAAE,IAAI;oBACV,WAAW,EAAE,sBAAsB;oBACnC,aAAa,EAAE,IAAI;iBACpB;gBACD,OAAO,EAAE,eAAe;gBACxB,aAAa,EAAE;oBACb,yBAAyB,EAAE,KAAK;oBAChC,aAAa,EAAE,IAAI;oBACnB,SAAS,EAAE,EAAE;oBACb,UAAU,EAAE,IAAI;oBAChB,QAAQ,EAAE,EAAE;oBACZ,WAAW,EAAE,IAAI;iBAClB;gBACD,SAAS,EAAE,eAAe;gBAC1B,QAAQ,EAAE,eAAe;gBACzB,YAAY,EAAE,EAAE;gBAChB,wBAAwB,EAAE,IAAI;gBAC9B,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,sBAAsB;gBACpC,kBAAkB,EAAE,sBAAsB;gBAC1C,YAAY,EAAE,IAAI;gBAClB,gBAAgB,EAAE;oBAChB,EAAE,EAAE,eAAe;oBACnB,IAAI,EAAE,oBAAoB;oBAC1B,UAAU,EAAE,IAAI;oBAChB,gBAAgB,EAAE,IAAI;oBACtB,aAAa,EAAE,iBAAiB;oBAChC,aAAa,EAAE,UAAU;oBACzB,IAAI,EAAE,eAAe;oBACrB,KAAK,EAAE,IAAI;oBACX,GAAG,EAAE,OAAO;oBACZ,KAAK,EAAE,cAAc;oBACrB,YAAY,EAAE,sBAAsB;oBACpC,YAAY,EAAE,IAAI;iBACnB;gBACD,kBAAkB,EAAE,IAAI;aACzB;SACF,CAAA;QAED,MAAM,CAAC,GAAG,EAAE,CAAC,wCAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;IACtE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.appointmentCreatedOrUpdated = void 0;
|
4
|
+
const constants_1 = require("../constants");
|
5
|
+
const appointments_1 = require("../types/webhooks/appointments");
|
4
6
|
const dataPoints = {
|
5
7
|
appointmentId: {
|
6
8
|
key: 'appointmentId',
|
@@ -11,8 +13,8 @@ exports.appointmentCreatedOrUpdated = {
|
|
11
13
|
key: 'appointmentCreatedOrUpdated',
|
12
14
|
dataPoints,
|
13
15
|
onWebhookReceived: async ({ payload, settings }, onSuccess, onError) => {
|
14
|
-
const {
|
15
|
-
// skip non 'saved'
|
16
|
+
const { action, resource, data: { id: appointmentId, patient: patientId }, } = appointments_1.AppointmentsPayloadSchema.parse(payload);
|
17
|
+
// skip non 'saved' actions for that webhook
|
16
18
|
if (action !== 'saved') {
|
17
19
|
return;
|
18
20
|
}
|
@@ -26,7 +28,11 @@ exports.appointmentCreatedOrUpdated = {
|
|
26
28
|
}
|
27
29
|
else {
|
28
30
|
await onSuccess({
|
29
|
-
data_points: { appointmentId: String(
|
31
|
+
data_points: { appointmentId: String(appointmentId) },
|
32
|
+
patient_identifier: {
|
33
|
+
system: constants_1.ELATION_SYSTEM,
|
34
|
+
value: String(patientId),
|
35
|
+
},
|
30
36
|
});
|
31
37
|
}
|
32
38
|
},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"appointmentCreatedOrUpdated.js","sourceRoot":"","sources":["../../../../extensions/elation/webhooks/appointmentCreatedOrUpdated.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"appointmentCreatedOrUpdated.js","sourceRoot":"","sources":["../../../../extensions/elation/webhooks/appointmentCreatedOrUpdated.ts"],"names":[],"mappings":";;;AAIA,4CAA6C;AAE7C,iEAA0E;AAE1E,MAAM,UAAU,GAAG;IACjB,aAAa,EAAE;QACb,GAAG,EAAE,eAAe;QACpB,SAAS,EAAE,QAAQ;KACpB;CAC4C,CAAA;AAElC,QAAA,2BAA2B,GAGpC;IACF,GAAG,EAAE,6BAA6B;IAClC,UAAU;IACV,iBAAiB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE;QACrE,MAAM,EACJ,MAAM,EACN,QAAQ,EACR,IAAI,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,GAChD,GAAG,wCAAyB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAE5C,6CAA6C;QAC7C,IAAI,MAAM,KAAK,OAAO,EAAE;YACtB,OAAM;SACP;QAED,IAAI,QAAQ,KAAK,cAAc,EAAE;YAC/B,MAAM,OAAO,CAAC;gBACZ,QAAQ,EAAE;oBACR,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,gCAAgC;iBAC1C;aACF,CAAC,CAAA;SACH;aAAM;YACL,MAAM,SAAS,CAAC;gBACd,WAAW,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,EAAE;gBACrD,kBAAkB,EAAE;oBAClB,MAAM,EAAE,0BAAc;oBACtB,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC;iBACzB;aACF,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
|
@@ -136,7 +136,7 @@
|
|
136
136
|
"changelog": "# Transform changelog\n\n## June 2024\n\n- Added \"Feet and inches to inches\" action\n## March 2024\n\n- Added \"Generate dynamic URL\" action\n\n## January 2024\n\n- Added \"Parse number to text with dictionary\" action"
|
137
137
|
},
|
138
138
|
"twilio": {
|
139
|
-
"readme": "---\ntitle: Twilio\ndescription: Twilio is a customer engagement platform used by hundreds of thousands of businesses and more than ten million developers worldwide to build unique, personalized experiences for their customers.\n---\n# Twilio\n\nTwilio is a customer engagement platform used by hundreds of thousands of businesses and more than ten million developers worldwide to build unique, personalized experiences for their customers.\n\nThey are known for democratizing channels like voice, text, chat, video, and email through APIs, making it easy for every organization to build meaningful interactions with customers on the channels they prefer.\n\n## Extension settings\n\nIn order to set up this extension, you will need:\n\n1. A Twilio API key or auth token which can be found in the Twilio console.\n2. Your account SID which can be found in the Twilio console.\n3. A phone number to send the message from. This must be a Twilio phone number that you own.\n\n## Custom Actions\n\n### Send SMS\n\nSend an SMS with Twilio to a recipient of your liking.\n\n### Get messages\n\nGet a list of text messages matching the given criteria. Only the last 50 messages are returned.\n\n## Send SMS during working hours\n\nThis action allows for the scheduling of SMS messages to be sent within the \"daily operational hours\" of 9 AM to 5 PM. It ensures that text messages are dispatched at appropriate times during the day, avoiding early morning or late-night disturbances to recipients.\n\n**Here's how it works:**\n\n- If the action is activate during business hours (9 AM to 5 PM), the SMS is sent immediately.\n- If activated before 9 AM, the SMS is scheduled to be sent at 9 AM on the same day.\n- If activated after 5 PM, the SMS is scheduled to be sent at 9 AM the following day.\n\nThis setup ensures that all messages reach your respondents during reasonable daytime hours, enhancing the likelihood of a timely and considerate communication. It's important to mention that messages will still be dispatched over the weekend, but they will adhere to the \"business hours\" schedule of 9 AM to 5 PM.\n\nNote that scheduling messages with Twilio is only possible if you send text messages using a MessagingServiceSid.\n\n\n\n\n\n\n",
|
139
|
+
"readme": "---\ntitle: Twilio\ndescription: Twilio is a customer engagement platform used by hundreds of thousands of businesses and more than ten million developers worldwide to build unique, personalized experiences for their customers.\n---\n# Twilio\n\nTwilio is a customer engagement platform used by hundreds of thousands of businesses and more than ten million developers worldwide to build unique, personalized experiences for their customers.\n\nThey are known for democratizing channels like voice, text, chat, video, and email through APIs, making it easy for every organization to build meaningful interactions with customers on the channels they prefer.\n\n## Extension settings\n\nIn order to set up this extension, you will need:\n\n1. A Twilio API key or auth token which can be found in the Twilio console.\n2. Your account SID which can be found in the Twilio console.\n3. A phone number to send the message from. This must be a Twilio phone number that you own.\n\n## User consent\n\nThe extension has some built-in mechanisms to enforce compliance with [Twilio's messaging policy](https://www.twilio.com/en-us/legal/messaging-policy).\n\n### Opt-out\n\nBy default, every text message will be appended with standard opt-out language (\"Reply STOP to unsubscribe.\"). You can specify custom opt-out language within the settings of the extension but make sure the opt-out keywords used are supported. STOP, UNSTOP, UNSUBSCRIBE or CANCEL are the default opt-out keywords supported but Twilio also supports defining custom stop keywords.\n\nIf you don't want to append opt-out language to your text messages, set the \"Add opt-out language\" setting to \"Off\".\n\nFor more information, please visit the Twilio docs.\n\n### Sending text messages to recipients that opted out\n\nIf you attempt to send a text message to a recipient who has opted out, the message will fail to be delivered and the action will be marked as failed. This is the default behavior of Twilio's API, which prevents sending texts to anyone who has chosen to opt out.\n\n## Custom Actions\n\n### Send SMS\n\nSend an SMS with Twilio to a recipient of your liking.\n\n### Get messages\n\nGet a list of text messages matching the given criteria. Only the last 50 messages are returned.\n\n## Send SMS during working hours\n\nThis action allows for the scheduling of SMS messages to be sent within the \"daily operational hours\" of 9 AM to 5 PM. It ensures that text messages are dispatched at appropriate times during the day, avoiding early morning or late-night disturbances to recipients.\n\n**Here's how it works:**\n\n- If the action is activate during business hours (9 AM to 5 PM), the SMS is sent immediately.\n- If activated before 9 AM, the SMS is scheduled to be sent at 9 AM on the same day.\n- If activated after 5 PM, the SMS is scheduled to be sent at 9 AM the following day.\n\nThis setup ensures that all messages reach your respondents during reasonable daytime hours, enhancing the likelihood of a timely and considerate communication. It's important to mention that messages will still be dispatched over the weekend, but they will adhere to the \"business hours\" schedule of 9 AM to 5 PM.\n\nNote that scheduling messages with Twilio is only possible if you send text messages using a MessagingServiceSid.\n\n\n\n\n\n\n",
|
140
140
|
"changelog": "# Twilio changelog\n\n## v2 2024-02-22\n\n1. Add capability to search for messages using all the allowed filters provided by Twilio API. Check here: https://www.twilio.com/docs/messaging/api/message-resource#read-multiple-message-resources\n\n## v2 2023-06-23\n\nFull description: https://github.com/awell-health/awell-extensions/issues/157\n\n1. \"Send SMS\" action\n 1. Change label from \"Send SMS\" to \"Send SMS (with from number)\"\n 2. Throw error when \"From\" number in both settings and in fields is not provided\n2. Add new action \"Send SMS (with Messaging Service)\"\n\n## v2\n\nCompared to v1 (pre-beta release), the extension only has one custom action \"Send SMS\" instead of two. The Custom Action allows for:\n\n1. Sending a text message to a recipient (phone number) stored in a data point, including patient profile data points.\n2. Sending a text message to a fixed recipient (phone number).\n"
|
141
141
|
},
|
142
142
|
"westFax": {
|
@@ -5,6 +5,7 @@ const extensions_core_1 = require("@awell-health/extensions-core");
|
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const zod_1 = require("zod");
|
7
7
|
const errors_1 = require("../../lib/errors");
|
8
|
+
const lodash_1 = require("lodash");
|
8
9
|
exports.post = {
|
9
10
|
key: 'post',
|
10
11
|
title: 'POST request',
|
@@ -35,12 +36,14 @@ exports.post = {
|
|
35
36
|
});
|
36
37
|
if (response.ok) {
|
37
38
|
const getResponseBody = async (response) => {
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
return
|
39
|
+
const res = await response.text();
|
40
|
+
try {
|
41
|
+
const jsonRes = JSON.parse(res);
|
42
|
+
return jsonRes;
|
43
|
+
}
|
44
|
+
catch (e) {
|
45
|
+
return (0, lodash_1.isEmpty)(res) ? 'No content' : res;
|
42
46
|
}
|
43
|
-
return await response.text();
|
44
47
|
};
|
45
48
|
const responseBody = await getResponseBody(response);
|
46
49
|
const statusCode = response.status;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.ts"],"names":[],"mappings":";;;AACA,mEAAkE;AAElE,qCAAqE;AACrE,6BAAuB;AACvB,6CAA6C;
|
1
|
+
{"version":3,"file":"post.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.ts"],"names":[],"mappings":";;;AACA,mEAAkE;AAElE,qCAAqE;AACrE,6BAAuB;AACvB,6CAA6C;AAC7C,mCAAgC;AAEnB,QAAA,IAAI,GAIb;IACF,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,qBAAqB;IAClC,QAAQ,EAAE,0BAAQ,CAAC,IAAI;IACvB,MAAM,EAAN,eAAM;IACN,UAAU,EAAV,mBAAU;IACV,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;;QACxD,MAAM,EACJ,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAC9D,GAAG,IAAA,0BAAQ,EAAC;YACX,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,MAAM,EAAE,+BAAsB;aAC/B,CAAC;YACF,OAAO;SACR,CAAC,CAAA;QAEF,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;gBACrC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,GAAG,OAAO;oBACV,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,GAAG,WAAW;oBACd,GAAG,iBAAiB;iBACrB,CAAC;aACH,CAAC,CAAA;YAEF,IAAI,QAAQ,CAAC,EAAE,EAAE;gBACf,MAAM,eAAe,GAAG,KAAK,EAC3B,QAAkB,EACQ,EA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aACH;iBAAM;gBACL,MAAM,WAAW,GAAG,KAAc,CAAA;gBAClC,MAAM,OAAO,CAAC;oBACZ,MAAM,EAAE;wBACN;4BACE,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;4BAC9B,IAAI,EAAE;gCACJ,EAAE,EAAE,MAAA,WAAW,CAAC,OAAO,mCAAI,kBAAkB;6BAC9C;4BACD,KAAK,EAAE;gCACL,QAAQ,EAAE,cAAc;gCACxB,OAAO,EAAE,MAAA,WAAW,CAAC,OAAO,mCAAI,kBAAkB;6BACnD;yBACF;qBACF;iBACF,CAAC,CAAA;aACH;SACF;IACH,CAAC;CACF,CAAA"}
|
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _1 = require(".");
|
4
4
|
const tests_1 = require("../../../../src/tests");
|
5
5
|
describe('REST - POST', () => {
|
6
|
-
const onComplete =
|
7
|
-
const onError = jest.fn();
|
6
|
+
const { onComplete, onError, helpers, extensionAction, clearMocks } = tests_1.TestHelpers.fromAction(_1.post);
|
8
7
|
beforeEach(() => {
|
9
8
|
jest.clearAllMocks();
|
10
9
|
jest.spyOn(global, 'fetch');
|
@@ -12,7 +11,7 @@ describe('REST - POST', () => {
|
|
12
11
|
afterEach(() => {
|
13
12
|
jest.restoreAllMocks();
|
14
13
|
});
|
15
|
-
test('Should work', async () => {
|
14
|
+
test('Should work with JSON response', async () => {
|
16
15
|
;
|
17
16
|
global.fetch.mockResolvedValue({
|
18
17
|
status: 200,
|
@@ -21,10 +20,10 @@ describe('REST - POST', () => {
|
|
21
20
|
headers: new Headers({
|
22
21
|
'Content-Type': 'application/json',
|
23
22
|
}),
|
24
|
-
|
23
|
+
text: jest.fn().mockResolvedValue(JSON.stringify({
|
25
24
|
success: true,
|
26
25
|
message: 'Data received successfully',
|
27
|
-
}),
|
26
|
+
})),
|
28
27
|
});
|
29
28
|
const jsonPayload = {
|
30
29
|
'key-1': 'value',
|
@@ -43,7 +42,12 @@ describe('REST - POST', () => {
|
|
43
42
|
},
|
44
43
|
settings: {},
|
45
44
|
});
|
46
|
-
await
|
45
|
+
await extensionAction.onEvent({
|
46
|
+
payload: mockOnActivityCreateParams,
|
47
|
+
onComplete,
|
48
|
+
onError,
|
49
|
+
helpers,
|
50
|
+
});
|
47
51
|
expect(global.fetch).toHaveBeenCalledWith('https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f', expect.objectContaining({
|
48
52
|
method: 'POST',
|
49
53
|
headers: {
|
@@ -62,6 +66,58 @@ describe('REST - POST', () => {
|
|
62
66
|
},
|
63
67
|
});
|
64
68
|
});
|
69
|
+
test('Should work with non)JSON response', async () => {
|
70
|
+
;
|
71
|
+
global.fetch.mockResolvedValue({
|
72
|
+
status: 200,
|
73
|
+
statusText: 'Ok',
|
74
|
+
ok: true,
|
75
|
+
headers: new Headers({
|
76
|
+
'Content-Type': 'application/json',
|
77
|
+
}),
|
78
|
+
text: jest.fn().mockResolvedValue(undefined),
|
79
|
+
});
|
80
|
+
const jsonPayload = {
|
81
|
+
'key-1': 'value',
|
82
|
+
};
|
83
|
+
const additionalPayload = {
|
84
|
+
'key-2': 'value',
|
85
|
+
};
|
86
|
+
const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
|
87
|
+
fields: {
|
88
|
+
endpoint: 'https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f',
|
89
|
+
headers: JSON.stringify({
|
90
|
+
Authorization: 'Bearer key',
|
91
|
+
}),
|
92
|
+
jsonPayload: JSON.stringify(jsonPayload),
|
93
|
+
additionalPayload: JSON.stringify(additionalPayload),
|
94
|
+
},
|
95
|
+
settings: {},
|
96
|
+
});
|
97
|
+
await extensionAction.onEvent({
|
98
|
+
payload: mockOnActivityCreateParams,
|
99
|
+
onComplete,
|
100
|
+
onError,
|
101
|
+
helpers,
|
102
|
+
});
|
103
|
+
expect(global.fetch).toHaveBeenCalledWith('https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f', expect.objectContaining({
|
104
|
+
method: 'POST',
|
105
|
+
headers: {
|
106
|
+
Authorization: 'Bearer key',
|
107
|
+
'Content-Type': 'application/json',
|
108
|
+
},
|
109
|
+
body: JSON.stringify({
|
110
|
+
...jsonPayload,
|
111
|
+
...additionalPayload,
|
112
|
+
}),
|
113
|
+
}));
|
114
|
+
expect(onComplete).toHaveBeenCalledWith({
|
115
|
+
data_points: {
|
116
|
+
response: 'No content',
|
117
|
+
statusCode: '200',
|
118
|
+
},
|
119
|
+
});
|
120
|
+
});
|
65
121
|
test('Should catch errors', async () => {
|
66
122
|
;
|
67
123
|
global.fetch.mockResolvedValue({
|
@@ -71,9 +127,9 @@ describe('REST - POST', () => {
|
|
71
127
|
headers: new Headers({
|
72
128
|
'Content-Type': 'application/json',
|
73
129
|
}),
|
74
|
-
|
130
|
+
text: jest.fn().mockResolvedValue(JSON.stringify({
|
75
131
|
message: 'Not found',
|
76
|
-
}),
|
132
|
+
})),
|
77
133
|
});
|
78
134
|
const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
|
79
135
|
fields: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"post.test.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.test.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,
|
1
|
+
{"version":3,"file":"post.test.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.test.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,iDAAwE;AAExE,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,GACjE,mBAAW,CAAC,UAAU,CAAC,OAAI,CAAC,CAAA;IAE9B,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;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C,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CACvC,2DAA2D,EAC3D,MAAM,CAAC,gBAAgB,CAAC;YACtB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;SACzB,CAAC,CACH,CAAA;QAED,MAAM,CAAC,OAAO,CAAC,CAAC,oBAAoB,CAAC;YACnC,MAAM,EAAE;gBACN,MAAM,CAAC,gBAAgB,CAAC;oBACtB,KAAK,EAAE;wBACL,QAAQ,EAAE,cAAc;wBACxB,OAAO,EAAE,gBAAgB;qBAC1B;oBACD,IAAI,EAAE;wBACJ,EAAE,EAAE,gBAAgB;qBACrB;iBACF,CAAC;aACH;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
@@ -4,7 +4,6 @@ exports.createLead = void 0;
|
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const lib_1 = require("../../lib");
|
7
|
-
const axios_1 = require("axios");
|
8
7
|
const errors_1 = require("../../lib/errors");
|
9
8
|
exports.createLead = {
|
10
9
|
key: 'createLead',
|
@@ -31,16 +30,15 @@ exports.createLead = {
|
|
31
30
|
});
|
32
31
|
}
|
33
32
|
catch (error) {
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
if ((0, errors_1.isSalesforceError)(error)) {
|
34
|
+
await onError({
|
35
|
+
events: [(0, errors_1.parseSalesforceError)(error)],
|
36
|
+
});
|
37
37
|
}
|
38
38
|
else {
|
39
|
-
|
39
|
+
// we handle ZodError and unknown errors in extension-server directly
|
40
|
+
throw error;
|
40
41
|
}
|
41
|
-
await onError({
|
42
|
-
events: [parsedError],
|
43
|
-
});
|
44
42
|
}
|
45
43
|
},
|
46
44
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,
|
1
|
+
{"version":3,"file":"createLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/createLead/createLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,6CAA0E;AAE7D,QAAA,UAAU,GAInB;IACF,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,yCAAyC;IACtD,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,EAAE;QACvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,oCAA8B,EAAC;YACxE,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QAEF,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,YAAY,CAAC;gBAC9C,OAAO,EAAE,MAAM;gBACf,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAA;YAEF,MAAM,UAAU,CAAC;gBACf,WAAW,EAAE;oBACX,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;iBAC9B;aACF,CAAC,CAAA;SACH;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,IAAA,0BAAiB,EAAC,KAAK,CAAC,EAAE;gBAC5B,MAAM,OAAO,CAAC;oBACZ,MAAM,EAAE,CAAC,IAAA,6BAAoB,EAAC,KAAK,CAAC,CAAC;iBACtC,CAAC,CAAA;aACH;iBAAM;gBACL,qEAAqE;gBACrE,MAAM,KAAK,CAAA;aACZ;SACF;IACH,CAAC;CACF,CAAA"}
|
@@ -4,7 +4,6 @@ exports.updateLead = void 0;
|
|
4
4
|
const extensions_core_1 = require("@awell-health/extensions-core");
|
5
5
|
const config_1 = require("./config");
|
6
6
|
const lib_1 = require("../../lib");
|
7
|
-
const axios_1 = require("axios");
|
8
7
|
const errors_1 = require("../../lib/errors");
|
9
8
|
exports.updateLead = {
|
10
9
|
key: 'updateLead',
|
@@ -28,16 +27,15 @@ exports.updateLead = {
|
|
28
27
|
await onComplete();
|
29
28
|
}
|
30
29
|
catch (error) {
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
if ((0, errors_1.isSalesforceError)(error)) {
|
31
|
+
await onError({
|
32
|
+
events: [(0, errors_1.parseSalesforceError)(error)],
|
33
|
+
});
|
34
34
|
}
|
35
35
|
else {
|
36
|
-
|
36
|
+
// we handle ZodError and unknown errors in extension-server directly
|
37
|
+
throw error;
|
37
38
|
}
|
38
|
-
await onError({
|
39
|
-
events: [parsedError],
|
40
|
-
});
|
41
39
|
}
|
42
40
|
},
|
43
41
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"updateLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/updateLead/updateLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,
|
1
|
+
{"version":3,"file":"updateLead.js","sourceRoot":"","sources":["../../../../../extensions/sfdc/actions/updateLead/updateLead.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AAErE,qCAAqE;AACrE,mCAA0D;AAC1D,6CAA0E;AAE7D,QAAA,UAAU,GAInB;IACF,GAAG,EAAE,YAAY;IACjB,QAAQ,EAAE,0BAAQ,CAAC,gBAAgB;IACnC,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,+CAA+C;IAC5D,MAAM,EAAN,eAAM;IACN,WAAW,EAAE,KAAK;IAClB,UAAU,EAAV,mBAAU;IACV,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAiB,EAAE;QACvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAA,oCAA8B,EAAC;YACxE,YAAY,EAAE,+BAAsB;YACpC,OAAO;SACR,CAAC,CAAA;QACF,IAAI;YACF,MAAM,gBAAgB,CAAC,YAAY,CAAC;gBAClC,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;aAClB,CAAC,CAAA;YAEF,MAAM,UAAU,EAAE,CAAA;SACnB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,IAAA,0BAAiB,EAAC,KAAK,CAAC,EAAE;gBAC5B,MAAM,OAAO,CAAC;oBACZ,MAAM,EAAE,CAAC,IAAA,6BAAoB,EAAC,KAAK,CAAC,CAAC;iBACtC,CAAC,CAAA;aACH;iBAAM;gBACL,qEAAqE;gBACrE,MAAM,KAAK,CAAA;aACZ;SACF;IACH,CAAC;CACF,CAAA"}
|
@@ -9,7 +9,7 @@ class SalesforceDataWrapper extends extensions_core_1.DataWrapper {
|
|
9
9
|
this.apiVersion = opts.apiVersion;
|
10
10
|
}
|
11
11
|
async createRecord(input) {
|
12
|
-
|
12
|
+
return await this.Request({
|
13
13
|
method: 'POST',
|
14
14
|
url: `/services/data/${this.apiVersion}/sobjects/${input.sObject}/`,
|
15
15
|
headers: {
|
@@ -17,10 +17,9 @@ class SalesforceDataWrapper extends extensions_core_1.DataWrapper {
|
|
17
17
|
},
|
18
18
|
data: JSON.stringify(input.data),
|
19
19
|
});
|
20
|
-
return res;
|
21
20
|
}
|
22
21
|
async updateRecord(input) {
|
23
|
-
|
22
|
+
return await this.Request({
|
24
23
|
method: 'PATCH',
|
25
24
|
url: `/services/data/${this.apiVersion}/sobjects/${input.sObject}/${input.sObjectId}`,
|
26
25
|
headers: {
|
@@ -28,17 +27,15 @@ class SalesforceDataWrapper extends extensions_core_1.DataWrapper {
|
|
28
27
|
},
|
29
28
|
data: JSON.stringify(input.data),
|
30
29
|
});
|
31
|
-
return res;
|
32
30
|
}
|
33
31
|
async getRecordShape(sObject) {
|
34
|
-
|
32
|
+
return await this.Request({
|
35
33
|
method: 'GET',
|
36
34
|
url: `/services/data/${this.apiVersion}/sobjects/${sObject}/describe`,
|
37
35
|
headers: {
|
38
36
|
'Content-Type': 'application/json',
|
39
37
|
},
|
40
38
|
});
|
41
|
-
return res;
|
42
39
|
}
|
43
40
|
}
|
44
41
|
exports.SalesforceDataWrapper = SalesforceDataWrapper;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../extensions/sfdc/api/client.ts"],"names":[],"mappings":";;;AAAA,mEASsC;AACtC,iDAAuD;AAQvD,MAAa,qBAAsB,SAAQ,6BAAW;IAGpD,YACE,KAAa,EACb,OAAe,EACf,IAEC;QAED,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../extensions/sfdc/api/client.ts"],"names":[],"mappings":";;;AAAA,mEASsC;AACtC,iDAAuD;AAQvD,MAAa,qBAAsB,SAAQ,6BAAW;IAGpD,YACE,KAAa,EACb,OAAe,EACf,IAEC;QAED,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAErB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,OAAO,MAAM,IAAI,CAAC,OAAO,CAA2B;YAClD,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,kBAAkB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC,OAAO,GAAG;YACnE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,E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EAAE;SAChB,CAAC,CAAA;QAvCK,SAAI,GAA2C,CACtD,KAAa,EACb,OAAe,EACf,EAAE,CACF,IAAI,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAqC1E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;IACnC,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;IACzE,CAAC;IAEM,KAAK,CAAC,YAAY,CACvB,KAA4B;QAE5B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAA;IACzE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,OAAe;QACzC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7E,CAAC;CACF;AA9DD,0DA8DC"}
|
@@ -1,4 +1,9 @@
|
|
1
|
-
import { ActivityEvent } from '@awell-health/extensions-core';
|
2
|
-
import { AxiosError } from 'axios';
|
3
|
-
|
4
|
-
|
1
|
+
import { type ActivityEvent } from '@awell-health/extensions-core';
|
2
|
+
import { type AxiosError } from 'axios';
|
3
|
+
type SalesforceError = Array<{
|
4
|
+
message: string;
|
5
|
+
errorCode: string;
|
6
|
+
}>;
|
7
|
+
export declare const isSalesforceError: (error: any) => error is AxiosError<SalesforceError, any>;
|
8
|
+
export declare const parseSalesforceError: (error: AxiosError<SalesforceError>) => ActivityEvent;
|
9
|
+
export {};
|