@awell-health/awell-extensions 1.1.62 → 1.1.64

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/dist/extensions/markdown.json +1 -1
  2. package/dist/extensions/rest/actions/post/post.js +72 -28
  3. package/dist/extensions/rest/actions/post/post.js.map +1 -1
  4. package/dist/extensions/rest/actions/post/post.test.js +49 -0
  5. package/dist/extensions/rest/actions/post/post.test.js.map +1 -1
  6. package/dist/extensions/rest/lib/errors.d.ts +6 -0
  7. package/dist/extensions/rest/lib/errors.js +16 -0
  8. package/dist/extensions/rest/lib/errors.js.map +1 -0
  9. package/dist/extensions/sfdc/actions/createLead/createLead.js +6 -8
  10. package/dist/extensions/sfdc/actions/createLead/createLead.js.map +1 -1
  11. package/dist/extensions/sfdc/actions/updateLead/updateLead.js +6 -8
  12. package/dist/extensions/sfdc/actions/updateLead/updateLead.js.map +1 -1
  13. package/dist/extensions/sfdc/api/client.js +3 -6
  14. package/dist/extensions/sfdc/api/client.js.map +1 -1
  15. package/dist/extensions/sfdc/lib/errors.d.ts +9 -4
  16. package/dist/extensions/sfdc/lib/errors.js +18 -24
  17. package/dist/extensions/sfdc/lib/errors.js.map +1 -1
  18. package/dist/extensions/twilio/lib/appendOptOutLanguage.d.ts +3 -0
  19. package/dist/extensions/twilio/lib/appendOptOutLanguage.js +18 -0
  20. package/dist/extensions/twilio/lib/appendOptOutLanguage.js.map +1 -0
  21. package/dist/extensions/twilio/lib/errors.d.ts +9 -0
  22. package/dist/extensions/twilio/lib/errors.js +23 -0
  23. package/dist/extensions/twilio/lib/errors.js.map +1 -0
  24. package/dist/extensions/twilio/lib/index.d.ts +1 -0
  25. package/dist/extensions/twilio/lib/index.js +6 -0
  26. package/dist/extensions/twilio/lib/index.js.map +1 -0
  27. package/dist/extensions/twilio/settings.d.ts +30 -0
  28. package/dist/extensions/twilio/settings.js +39 -0
  29. package/dist/extensions/twilio/settings.js.map +1 -1
  30. package/dist/extensions/twilio/tests/settings.test.d.ts +1 -0
  31. package/dist/extensions/twilio/tests/settings.test.js +24 -0
  32. package/dist/extensions/twilio/tests/settings.test.js.map +1 -0
  33. package/dist/extensions/twilio/v2/actions/createFlowExecution/config/actionSchema.d.ts +33 -0
  34. package/dist/extensions/twilio/v2/actions/getMessages/getMessages.test.js +12 -0
  35. package/dist/extensions/twilio/v2/actions/getMessages/getMessages.test.js.map +1 -1
  36. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js +11 -29
  37. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.js.map +1 -1
  38. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.test.js +19 -15
  39. package/dist/extensions/twilio/v2/actions/sendSms/sendSms.test.js.map +1 -1
  40. package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.js +11 -30
  41. package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.js.map +1 -1
  42. package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.test.js +25 -15
  43. package/dist/extensions/twilio/v2/actions/sendSmsDuringBusinessHours/sendSmsDuringBusinessHours.test.js.map +1 -1
  44. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js +10 -29
  45. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.js.map +1 -1
  46. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.test.js +19 -15
  47. package/dist/extensions/twilio/v2/actions/sendSmsWithMessagingSid/sendSmsWithMessagingService.test.js.map +1 -1
  48. package/package.json +1 -1
@@ -140,7 +140,7 @@
140
140
  "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"
141
141
  },
142
142
  "twilio": {
143
- "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",
143
+ "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",
144
144
  "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"
145
145
  },
146
146
  "westFax": {
@@ -4,6 +4,7 @@ exports.post = void 0;
4
4
  const extensions_core_1 = require("@awell-health/extensions-core");
5
5
  const config_1 = require("./config");
6
6
  const zod_1 = require("zod");
7
+ const errors_1 = require("../../lib/errors");
7
8
  exports.post = {
8
9
  key: 'post',
9
10
  title: 'POST request',
@@ -13,41 +14,84 @@ exports.post = {
13
14
  dataPoints: config_1.dataPoints,
14
15
  previewable: true,
15
16
  onActivityCreated: async (payload, onComplete, onError) => {
17
+ var _a, _b;
16
18
  const { fields: { endpoint, headers, jsonPayload, additionalPayload }, } = (0, extensions_core_1.validate)({
17
19
  schema: zod_1.z.object({
18
20
  fields: config_1.FieldsValidationSchema,
19
21
  }),
20
22
  payload,
21
23
  });
22
- const response = await fetch(endpoint, {
23
- method: 'POST',
24
- headers: {
25
- ...headers,
26
- 'Content-Type': 'application/json',
27
- },
28
- body: JSON.stringify({
29
- ...jsonPayload,
30
- ...additionalPayload,
31
- }),
32
- });
33
- const getResponseBody = async (response) => {
34
- var _a;
35
- const contentType = (_a = response.headers.get('content-type')) !== null && _a !== void 0 ? _a : '';
36
- if (contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase().includes('application/json')) {
37
- return await response.json();
24
+ try {
25
+ const response = await fetch(endpoint, {
26
+ method: 'POST',
27
+ headers: {
28
+ ...headers,
29
+ 'Content-Type': 'application/json',
30
+ },
31
+ body: JSON.stringify({
32
+ ...jsonPayload,
33
+ ...additionalPayload,
34
+ }),
35
+ });
36
+ if (response.ok) {
37
+ const getResponseBody = async (response) => {
38
+ var _a, _b;
39
+ const contentType = (_b = (_a = response === null || response === void 0 ? void 0 : response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type')) !== null && _b !== void 0 ? _b : '';
40
+ if (contentType === null || contentType === void 0 ? void 0 : contentType.toLowerCase().includes('application/json')) {
41
+ return await response.json();
42
+ }
43
+ return await response.text();
44
+ };
45
+ const responseBody = await getResponseBody(response);
46
+ const statusCode = response.status;
47
+ await onComplete({
48
+ data_points: {
49
+ response: typeof responseBody === 'string'
50
+ ? responseBody
51
+ : JSON.stringify(responseBody),
52
+ statusCode: String(statusCode),
53
+ },
54
+ });
38
55
  }
39
- return await response.text();
40
- };
41
- const responseBody = await getResponseBody(response);
42
- const statusCode = response.status;
43
- await onComplete({
44
- data_points: {
45
- response: typeof responseBody === 'string'
46
- ? responseBody
47
- : JSON.stringify(responseBody),
48
- statusCode: String(statusCode),
49
- },
50
- });
56
+ else {
57
+ throw new errors_1.FetchError(response.status, response.statusText, response.body);
58
+ }
59
+ }
60
+ catch (error) {
61
+ if (error instanceof errors_1.FetchError) {
62
+ await onError({
63
+ events: [
64
+ {
65
+ date: new Date().toISOString(),
66
+ text: {
67
+ en: `${error.message} ${error.responseBody}`,
68
+ },
69
+ error: {
70
+ category: 'SERVER_ERROR',
71
+ message: `${error.message} ${error.responseBody}`,
72
+ },
73
+ },
74
+ ],
75
+ });
76
+ }
77
+ else {
78
+ const parsedError = error;
79
+ await onError({
80
+ events: [
81
+ {
82
+ date: new Date().toISOString(),
83
+ text: {
84
+ en: (_a = parsedError.message) !== null && _a !== void 0 ? _a : 'Unexpected error',
85
+ },
86
+ error: {
87
+ category: 'SERVER_ERROR',
88
+ message: (_b = parsedError.message) !== null && _b !== void 0 ? _b : 'Unexpected error',
89
+ },
90
+ },
91
+ ],
92
+ });
93
+ }
94
+ }
51
95
  },
52
96
  };
53
97
  //# sourceMappingURL=post.js.map
@@ -1 +1 @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,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE;6BAC7C;4BACD,KAAK,EAAE;gCACL,QAAQ,EAAE,cAAc;gCACxB,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE;6BAClD;yBACF;qBACF;iBACF,CAAC,CAAA;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"}
@@ -16,6 +16,11 @@ describe('REST - POST', () => {
16
16
  ;
17
17
  global.fetch.mockResolvedValue({
18
18
  status: 200,
19
+ statusText: 'Ok',
20
+ ok: true,
21
+ headers: new Headers({
22
+ 'Content-Type': 'application/json',
23
+ }),
19
24
  json: jest.fn().mockResolvedValue({
20
25
  success: true,
21
26
  message: 'Data received successfully',
@@ -57,5 +62,49 @@ describe('REST - POST', () => {
57
62
  },
58
63
  });
59
64
  });
65
+ test('Should catch errors', async () => {
66
+ ;
67
+ global.fetch.mockResolvedValue({
68
+ status: 404,
69
+ ok: false,
70
+ statusText: 'Not found',
71
+ headers: new Headers({
72
+ 'Content-Type': 'application/json',
73
+ }),
74
+ json: jest.fn().mockResolvedValue({
75
+ message: 'Not found',
76
+ }),
77
+ });
78
+ const mockOnActivityCreateParams = (0, tests_1.generateTestPayload)({
79
+ fields: {
80
+ endpoint: 'https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f',
81
+ headers: '{}',
82
+ jsonPayload: `{}`,
83
+ additionalPayload: `{}`,
84
+ },
85
+ settings: {},
86
+ });
87
+ await _1.post.onActivityCreated(mockOnActivityCreateParams, onComplete, onError);
88
+ expect(global.fetch).toHaveBeenCalledWith('https://webhook.site/bb853fec-9260-44e5-a944-17894d678a7f', expect.objectContaining({
89
+ method: 'POST',
90
+ headers: {
91
+ 'Content-Type': 'application/json',
92
+ },
93
+ body: JSON.stringify({}),
94
+ }));
95
+ expect(onError).toHaveBeenCalledWith({
96
+ events: [
97
+ expect.objectContaining({
98
+ error: {
99
+ category: 'SERVER_ERROR',
100
+ message: '404 Not found ',
101
+ },
102
+ text: {
103
+ en: '404 Not found ',
104
+ },
105
+ }),
106
+ ],
107
+ });
108
+ });
60
109
  });
61
110
  //# sourceMappingURL=post.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"post.test.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.test.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB,iDAA2D;AAE3D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,EAAE,CAAA;IAEzB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC7B,CAAC;QAAC,MAAM,CAAC,KAAmB,CAAC,iBAAiB,CAAC;YAC7C,MAAM,EAAE,GAAG;YACX,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;gBAChC,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,4BAA4B;aACtC,CAAC;SACH,CAAC,CAAA;QAEF,MAAM,WAAW,GAAG;YAClB,OAAO,EAAE,OAAO;SACjB,CAAA;QACD,MAAM,iBAAiB,GAAG;YACxB,OAAO,EAAE,OAAO;SACjB,CAAA;QAED,MAAM,0BAA0B,GAAG,IAAA,2BAAmB,EAAC;YACrD,MAAM,EAAE;gBACN,QAAQ,EAAE,2DAA2D;gBACrE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACtB,aAAa,EAAE,YAAY;iBAC5B,CAAC;gBACF,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;gBACxC,iBAAiB,EAAE,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;aACrD;YACD,QAAQ,EAAE,EAAE;SACb,CAAC,CAAA;QAEF,MAAM,OAAI,CAAC,iBAAiB,CAC1B,0BAA0B,EAC1B,UAAU,EACV,OAAO,CACR,CAAA;QAED,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CACvC,2DAA2D,EAC3D,MAAM,CAAC,gBAAgB,CAAC;YACtB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,YAAY;gBAC3B,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,GAAG,WAAW;gBACd,GAAG,iBAAiB;aACrB,CAAC;SACH,CAAC,CACH,CAAA;QAED,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC;YACtC,WAAW,EAAE;gBACX,QAAQ,EAAE,yDAAyD;gBACnE,UAAU,EAAE,KAAK;aAClB;SACF,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"post.test.js","sourceRoot":"","sources":["../../../../../extensions/rest/actions/post/post.test.ts"],"names":[],"mappings":";;AAAA,wBAAwB;AACxB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B,EAC1B,UAAU,EACV,OAAO,CACR,CAAA;QAED,MAAM,CAAC,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"}
@@ -0,0 +1,6 @@
1
+ export declare class FetchError extends Error {
2
+ statusCode: number;
3
+ statusText: string;
4
+ responseBody: string;
5
+ constructor(statusCode: number, statusText: string, responseBody?: unknown);
6
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FetchError = void 0;
4
+ const lodash_1 = require("lodash");
5
+ class FetchError extends Error {
6
+ constructor(statusCode, statusText, responseBody) {
7
+ super(`${statusCode} ${statusText}`);
8
+ this.statusCode = statusCode;
9
+ this.statusText = statusText;
10
+ this.responseBody = (0, lodash_1.isEmpty)(responseBody)
11
+ ? ''
12
+ : JSON.stringify(responseBody);
13
+ }
14
+ }
15
+ exports.FetchError = FetchError;
16
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../extensions/rest/lib/errors.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,MAAa,UAAW,SAAQ,KAAK;IAKnC,YAAY,UAAkB,EAAE,UAAkB,EAAE,YAAsB;QACxE,KAAK,CAAC,GAAG,UAAU,IAAI,UAAU,EAAE,CAAC,CAAA;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAO,EAAC,YAAY,CAAC;YACvC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;IAClC,CAAC;CACF;AAbD,gCAaC"}
@@ -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
- let parsedError;
35
- if ((0, axios_1.isAxiosError)(error)) {
36
- parsedError = (0, errors_1.parseAxiosError)(error);
33
+ if ((0, errors_1.isSalesforceError)(error)) {
34
+ await onError({
35
+ events: [(0, errors_1.parseSalesforceError)(error)],
36
+ });
37
37
  }
38
38
  else {
39
- parsedError = (0, errors_1.parseUnknowError)(error);
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,iCAAgD;AAChD,6CAAoE;AAEvD,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,WAAW,CAAA;YAEf,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE;gBACvB,WAAW,GAAG,IAAA,wBAAe,EAAC,KAAmB,CAAC,CAAA;aACnD;iBAAM;gBACL,WAAW,GAAG,IAAA,yBAAgB,EAAC,KAAc,CAAC,CAAA;aAC/C;YACD,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE,CAAC,WAAW,CAAC;aACtB,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
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
- let parsedError;
32
- if ((0, axios_1.isAxiosError)(error)) {
33
- parsedError = (0, errors_1.parseAxiosError)(error);
30
+ if ((0, errors_1.isSalesforceError)(error)) {
31
+ await onError({
32
+ events: [(0, errors_1.parseSalesforceError)(error)],
33
+ });
34
34
  }
35
35
  else {
36
- parsedError = (0, errors_1.parseUnknowError)(error);
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,iCAAgD;AAChD,6CAAoE;AAEvD,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;QAEF,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,WAAW,CAAA;YAEf,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE;gBACvB,WAAW,GAAG,IAAA,wBAAe,EAAC,KAAmB,CAAC,CAAA;aACnD;iBAAM;gBACL,WAAW,GAAG,IAAA,yBAAgB,EAAC,KAAc,CAAC,CAAA;aAC/C;YACD,MAAM,OAAO,CAAC;gBACZ,MAAM,EAAE,CAAC,WAAW,CAAC;aACtB,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAA"}
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
- const res = await this.Request({
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
- const res = await this.Request({
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
- const res = await this.Request({
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,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAA2B;YACvD,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,kBAAkB,IAAI,CAAC,UAAU,aAAa,KAAK,CAAC,OAAO,GAAG;YACnE,OAAO,EAAE;gBACP,cAAc,E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D;;uBAEG;oBACH,wCAAwC;iBACzC,CAAC,CAAA;aACH;YAED,OAAO,IAAI,wCAAsB,CAAC;gBAChC,QAAQ,EAAE,OAAO;gBACjB,cAAc,EAAE,aAGf;gBACD,YAAY,EAAE,qCAAsB;aACrC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,IAAI,EAAE,OAAO,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
- export declare const parseAxiosError: (error: AxiosError) => ActivityEvent;
4
- export declare const parseUnknowError: (error: Error) => ActivityEvent;
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 {};
@@ -1,17 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseUnknowError = exports.parseAxiosError = void 0;
4
- const parseAxiosError = (error) => {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
3
+ exports.parseSalesforceError = exports.isSalesforceError = void 0;
4
+ const isSalesforceError = (error) => {
5
+ return (typeof error === 'object' &&
6
+ error !== null &&
7
+ 'response' in error &&
8
+ typeof error.response === 'object' &&
9
+ error.response !== null &&
10
+ Array.isArray(error.response.data) &&
11
+ error.response.data.length > 0 &&
12
+ 'errorCode' in error.response.data[0] &&
13
+ 'message' in error.response.data[0]);
14
+ };
15
+ exports.isSalesforceError = isSalesforceError;
16
+ const parseSalesforceError = (error) => {
17
+ var _a;
6
18
  const category = 'BAD_REQUEST';
7
- let message = `${(_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : 'UNKNOWN_STATUS'}: ${error.message}`;
8
- // Check if it's a Salesforce error
9
- if (Array.isArray((_d = error === null || error === void 0 ? void 0 : error.response) === null || _d === void 0 ? void 0 : _d.data) &&
10
- ((_f = (_e = error === null || error === void 0 ? void 0 : error.response) === null || _e === void 0 ? void 0 : _e.data[0]) === null || _f === void 0 ? void 0 : _f.errorCode) &&
11
- ((_h = (_g = error === null || error === void 0 ? void 0 : error.response) === null || _g === void 0 ? void 0 : _g.data[0]) === null || _h === void 0 ? void 0 : _h.message)) {
12
- const salesforceError = (_j = error === null || error === void 0 ? void 0 : error.response) === null || _j === void 0 ? void 0 : _j.data[0];
13
- message = `${salesforceError.errorCode}: ${salesforceError.message}`;
14
- }
19
+ const salesforceError = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data[0];
20
+ const message = `${String(salesforceError === null || salesforceError === void 0 ? void 0 : salesforceError.errorCode)}: ${String(salesforceError === null || salesforceError === void 0 ? void 0 : salesforceError.message)}`;
15
21
  return {
16
22
  date: new Date().toISOString(),
17
23
  text: {
@@ -23,17 +29,5 @@ const parseAxiosError = (error) => {
23
29
  },
24
30
  };
25
31
  };
26
- exports.parseAxiosError = parseAxiosError;
27
- const parseUnknowError = (error) => {
28
- const message = error.message;
29
- return {
30
- date: new Date().toISOString(),
31
- text: { en: message },
32
- error: {
33
- category: 'SERVER_ERROR',
34
- message,
35
- },
36
- };
37
- };
38
- exports.parseUnknowError = parseUnknowError;
32
+ exports.parseSalesforceError = parseSalesforceError;
39
33
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../extensions/sfdc/lib/errors.ts"],"names":[],"mappings":";;;AAGO,MAAM,eAAe,GAAG,CAAC,KAAiB,EAAiB,EAAE;;IAClE,MAAM,QAAQ,GAAG,aAAa,CAAA;IAC9B,IAAI,OAAO,GAAG,GAAG,MAAA,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,MAAM,0CAAE,QAAQ,EAAE,mCAAI,gBAAgB,KACtE,KAAK,CAAC,OACR,EAAE,CAAA;IAEF,mCAAmC;IACnC,IACE,KAAK,CAAC,OAAO,CAAC,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC;SACpC,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,0CAAE,SAAS,CAAA;SACnC,MAAA,MAAA,KAAK,aAAL,KAAK,uBAAL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AAC,MAAM,GAAG,CAAC;QAC9B,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,SAAS,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CACpC,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,iBAAiB,qBAc7B;AAEM,MAAM,oBAAoB,GAAG,CAClC,KAAkC,EACnB,EAAE;;IACjB,MAAM,QAAQ,GAAG,aAAa,CAAA;IAC9B,MAAM,eAAe,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,0CAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IAChD,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,SAAS,CAAC,KAAK,MAAM,CAC9D,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,CACzB,EAAE,CAAA;IAEH,OAAO;QACL,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC9B,IAAI,EAAE;YACJ,EAAE,EAAE,OAAO;SACZ;QACD,KAAK,EAAE;YACL,QAAQ;YACR,OAAO;SACR;KACF,CAAA;AACH,CAAC,CAAA;AAnBY,QAAA,oBAAoB,wBAmBhC"}
@@ -0,0 +1,3 @@
1
+ type Language = 'en' | 'fr' | 'nl';
2
+ export declare const appendOptOutLanguage: (message: string, optOutLanguage?: string, language?: Language) => string;
3
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appendOptOutLanguage = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const DEFAULT_OPT_OUT_LANGUAGE = {
6
+ en: 'Reply STOP to unsubscribe.',
7
+ fr: 'Répondez STOP pour vous désabonner.',
8
+ nl: 'Antwoord STOP om geen communicate meer te ontvangen.',
9
+ };
10
+ const appendOptOutLanguage = (message, optOutLanguage, language) => {
11
+ const lang = language !== null && language !== void 0 ? language : 'en';
12
+ if ((0, lodash_1.isEmpty)(optOutLanguage) || optOutLanguage === undefined) {
13
+ return `${message}\n\n${DEFAULT_OPT_OUT_LANGUAGE[lang]}`;
14
+ }
15
+ return `${message}\n\n${optOutLanguage}`;
16
+ };
17
+ exports.appendOptOutLanguage = appendOptOutLanguage;
18
+ //# sourceMappingURL=appendOptOutLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appendOptOutLanguage.js","sourceRoot":"","sources":["../../../../extensions/twilio/lib/appendOptOutLanguage.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAIhC,MAAM,wBAAwB,GAA6B;IACzD,EAAE,EAAE,4BAA4B;IAChC,EAAE,EAAE,qCAAqC;IACzC,EAAE,EAAE,sDAAsD;CAC3D,CAAA;AAEM,MAAM,oBAAoB,GAAG,CAClC,OAAe,EACf,cAAuB,EACvB,QAAmB,EACX,EAAE;IACV,MAAM,IAAI,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAI,CAAA;IAE7B,IAAI,IAAA,gBAAO,EAAC,cAAc,CAAC,IAAI,cAAc,KAAK,SAAS,EAAE;QAC3D,OAAO,GAAG,OAAO,OAAO,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAA;KACzD;IAED,OAAO,GAAG,OAAO,OAAO,cAAc,EAAE,CAAA;AAC1C,CAAC,CAAA;AAZY,QAAA,oBAAoB,wBAYhC"}
@@ -0,0 +1,9 @@
1
+ import { type ActivityEvent } from '@awell-health/extensions-core';
2
+ export interface TwilioErrorResponse {
3
+ code: number;
4
+ message: string;
5
+ moreInfo: string;
6
+ status: number;
7
+ }
8
+ export declare const isTwilioErrorResponse: (data: any) => data is TwilioErrorResponse;
9
+ export declare const parseTwilioError: (error: TwilioErrorResponse) => ActivityEvent;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTwilioError = exports.isTwilioErrorResponse = void 0;
4
+ const isTwilioErrorResponse = (data) => {
5
+ return typeof (data === null || data === void 0 ? void 0 : data.moreInfo) === 'string';
6
+ };
7
+ exports.isTwilioErrorResponse = isTwilioErrorResponse;
8
+ const parseTwilioError = (error) => {
9
+ const category = 'BAD_REQUEST';
10
+ const message = `${error.code}: ${error.message} (${error.moreInfo})`;
11
+ return {
12
+ date: new Date().toISOString(),
13
+ text: {
14
+ en: message,
15
+ },
16
+ error: {
17
+ category,
18
+ message,
19
+ },
20
+ };
21
+ };
22
+ exports.parseTwilioError = parseTwilioError;
23
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../extensions/twilio/lib/errors.ts"],"names":[],"mappings":";;;AASO,MAAM,qBAAqB,GAAG,CACnC,IAAS,EACoB,EAAE;IAC/B,OAAO,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAA,KAAK,QAAQ,CAAA;AAC3C,CAAC,CAAA;AAJY,QAAA,qBAAqB,yBAIjC;AAEM,MAAM,gBAAgB,GAAG,CAAC,KAA0B,EAAiB,EAAE;IAC5E,MAAM,QAAQ,GAAG,aAAa,CAAA;IAC9B,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,GAAG,CAAA;IAErE,OAAO;QACL,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAC9B,IAAI,EAAE;YACJ,EAAE,EAAE,OAAO;SACZ;QACD,KAAK,EAAE;YACL,QAAQ;YACR,OAAO;SACR;KACF,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,gBAAgB,oBAc5B"}
@@ -0,0 +1 @@
1
+ export { appendOptOutLanguage } from './appendOptOutLanguage';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appendOptOutLanguage = void 0;
4
+ var appendOptOutLanguage_1 = require("./appendOptOutLanguage");
5
+ Object.defineProperty(exports, "appendOptOutLanguage", { enumerable: true, get: function () { return appendOptOutLanguage_1.appendOptOutLanguage; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../extensions/twilio/lib/index.ts"],"names":[],"mappings":";;;AAAA,+DAA6D;AAApD,4HAAA,oBAAoB,OAAA"}
@@ -28,20 +28,50 @@ export declare const settings: {
28
28
  required: false;
29
29
  description: string;
30
30
  };
31
+ addOptOutLanguage: {
32
+ label: string;
33
+ key: string;
34
+ obfuscated: false;
35
+ required: false;
36
+ description: string;
37
+ };
38
+ optOutLanguage: {
39
+ label: string;
40
+ key: string;
41
+ obfuscated: false;
42
+ required: false;
43
+ description: string;
44
+ };
45
+ language: {
46
+ label: string;
47
+ key: string;
48
+ obfuscated: false;
49
+ required: false;
50
+ description: string;
51
+ };
31
52
  };
32
53
  export declare const SettingsValidationSchema: z.ZodObject<{
33
54
  accountSid: z.ZodString;
34
55
  authToken: z.ZodString;
35
56
  fromNumber: z.ZodUnion<[z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, import("libphonenumber-js").PhoneNumber | import("libphonenumber-js").ParseError, string>, import("libphonenumber-js").PhoneNumber | import("libphonenumber-js").ParseError, string>, import("libphonenumber-js").E164Number, string>>, z.ZodEffects<z.ZodLiteral<"">, undefined, "">]>;
36
57
  messagingServiceSid: z.ZodOptional<z.ZodString>;
58
+ addOptOutLanguage: z.ZodEffects<z.ZodOptional<z.ZodString>, boolean, string | undefined>;
59
+ optOutLanguage: z.ZodOptional<z.ZodString>;
60
+ language: z.ZodEffects<z.ZodDefault<z.ZodUnion<[z.ZodEnum<["en", "fr", "nl"]>, z.ZodLiteral<"">]>>, "en" | "fr" | "nl", "" | "en" | "fr" | "nl" | undefined>;
37
61
  }, "strip", z.ZodTypeAny, {
62
+ language: "en" | "fr" | "nl";
38
63
  accountSid: string;
39
64
  authToken: string;
65
+ addOptOutLanguage: boolean;
40
66
  fromNumber?: import("libphonenumber-js").E164Number | undefined;
41
67
  messagingServiceSid?: string | undefined;
68
+ optOutLanguage?: string | undefined;
42
69
  }, {
43
70
  accountSid: string;
44
71
  authToken: string;
72
+ language?: "" | "en" | "fr" | "nl" | undefined;
45
73
  fromNumber?: string | undefined;
46
74
  messagingServiceSid?: string | undefined;
75
+ addOptOutLanguage?: string | undefined;
76
+ optOutLanguage?: string | undefined;
47
77
  }>;