@segment/action-destinations 3.287.0-staging-899be5944 → 3.287.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/dist/destinations/{mappings-two-test/index.d.ts → engage/sendgrid/destinationDefinition.d.ts} +1 -2
  2. package/dist/destinations/engage/sendgrid/destinationDefinition.js +70 -0
  3. package/dist/destinations/engage/sendgrid/destinationDefinition.js.map +1 -0
  4. package/dist/destinations/engage/sendgrid/generated-types.d.ts +1 -0
  5. package/dist/destinations/engage/sendgrid/generated-types.js +14 -0
  6. package/dist/destinations/engage/sendgrid/generated-types.js.map +1 -0
  7. package/dist/destinations/engage/sendgrid/index.d.ts +2 -0
  8. package/dist/destinations/engage/sendgrid/index.js +5 -0
  9. package/dist/destinations/engage/sendgrid/index.js.map +1 -0
  10. package/dist/destinations/engage/sendgrid/previewApiLookup/actionDefinition.d.ts +4 -0
  11. package/dist/destinations/engage/sendgrid/previewApiLookup/actionDefinition.js +28 -0
  12. package/dist/destinations/engage/sendgrid/previewApiLookup/actionDefinition.js.map +1 -0
  13. package/dist/destinations/engage/sendgrid/previewApiLookup/generated-types.d.ts +1 -0
  14. package/dist/destinations/engage/sendgrid/previewApiLookup/generated-types.js +14 -0
  15. package/dist/destinations/engage/sendgrid/previewApiLookup/generated-types.js.map +1 -0
  16. package/dist/destinations/engage/sendgrid/previewApiLookup/index.d.ts +1 -0
  17. package/dist/destinations/engage/sendgrid/previewApiLookup/index.js +14 -0
  18. package/dist/destinations/engage/sendgrid/previewApiLookup/index.js.map +1 -0
  19. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.d.ts +44 -0
  20. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js +419 -0
  21. package/dist/destinations/engage/sendgrid/sendEmail/SendEmailPerformer.js.map +1 -0
  22. package/dist/destinations/engage/sendgrid/sendEmail/UnlayerResponse.d.ts +12 -0
  23. package/dist/destinations/engage/sendgrid/sendEmail/UnlayerResponse.js +3 -0
  24. package/dist/destinations/engage/sendgrid/sendEmail/UnlayerResponse.js.map +1 -0
  25. package/dist/destinations/engage/sendgrid/sendEmail/actionDefinition.d.ts +4 -0
  26. package/dist/destinations/engage/sendgrid/sendEmail/actionDefinition.js +257 -0
  27. package/dist/destinations/engage/sendgrid/sendEmail/actionDefinition.js.map +1 -0
  28. package/dist/destinations/engage/sendgrid/sendEmail/generated-types.d.ts +1 -0
  29. package/dist/destinations/engage/sendgrid/sendEmail/generated-types.js +14 -0
  30. package/dist/destinations/engage/sendgrid/sendEmail/generated-types.js.map +1 -0
  31. package/dist/destinations/engage/sendgrid/sendEmail/index.d.ts +1 -0
  32. package/dist/destinations/engage/sendgrid/sendEmail/index.js +14 -0
  33. package/dist/destinations/engage/sendgrid/sendEmail/index.js.map +1 -0
  34. package/dist/destinations/engage/sendgrid/sendEmail/insertEmailPreviewText.d.ts +1 -0
  35. package/dist/destinations/engage/sendgrid/sendEmail/insertEmailPreviewText.js +23 -0
  36. package/dist/destinations/engage/sendgrid/sendEmail/insertEmailPreviewText.js.map +1 -0
  37. package/dist/destinations/engage/sendgrid/sendEmail/isRestrictedDomain.d.ts +1 -0
  38. package/dist/destinations/engage/sendgrid/sendEmail/isRestrictedDomain.js +14 -0
  39. package/dist/destinations/engage/sendgrid/sendEmail/isRestrictedDomain.js.map +1 -0
  40. package/dist/destinations/engage/twilio/destinationDefinition.d.ts +3 -0
  41. package/dist/destinations/engage/twilio/destinationDefinition.js +172 -0
  42. package/dist/destinations/engage/twilio/destinationDefinition.js.map +1 -0
  43. package/dist/destinations/engage/twilio/generated-types.d.ts +1 -0
  44. package/dist/destinations/engage/twilio/generated-types.js +14 -0
  45. package/dist/destinations/engage/twilio/generated-types.js.map +1 -0
  46. package/dist/destinations/engage/twilio/index.d.ts +2 -0
  47. package/dist/destinations/engage/twilio/index.js +5 -0
  48. package/dist/destinations/engage/twilio/index.js.map +1 -0
  49. package/dist/destinations/engage/twilio/sendMobilePush/PushSender.d.ts +28 -0
  50. package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js +151 -0
  51. package/dist/destinations/engage/twilio/sendMobilePush/PushSender.js.map +1 -0
  52. package/dist/destinations/engage/twilio/sendMobilePush/actionDefinition.d.ts +4 -0
  53. package/dist/destinations/engage/twilio/sendMobilePush/actionDefinition.js +250 -0
  54. package/dist/destinations/engage/twilio/sendMobilePush/actionDefinition.js.map +1 -0
  55. package/dist/destinations/engage/twilio/sendMobilePush/generated-types.d.ts +1 -0
  56. package/dist/destinations/engage/twilio/sendMobilePush/generated-types.js +14 -0
  57. package/dist/destinations/engage/twilio/sendMobilePush/generated-types.js.map +1 -0
  58. package/dist/destinations/engage/twilio/sendMobilePush/index.d.ts +1 -0
  59. package/dist/destinations/engage/twilio/sendMobilePush/index.js +14 -0
  60. package/dist/destinations/engage/twilio/sendMobilePush/index.js.map +1 -0
  61. package/dist/destinations/engage/twilio/sendSms/SmsMessageSender.d.ts +9 -0
  62. package/dist/destinations/engage/twilio/sendSms/SmsMessageSender.js +72 -0
  63. package/dist/destinations/engage/twilio/sendSms/SmsMessageSender.js.map +1 -0
  64. package/dist/destinations/{mappings-two-test/sendEvent/index.d.ts → engage/twilio/sendSms/actionDefinition.d.ts} +1 -2
  65. package/dist/destinations/engage/twilio/sendSms/actionDefinition.js +162 -0
  66. package/dist/destinations/engage/twilio/sendSms/actionDefinition.js.map +1 -0
  67. package/dist/destinations/engage/twilio/sendSms/generated-types.d.ts +1 -0
  68. package/dist/destinations/engage/twilio/sendSms/generated-types.js +14 -0
  69. package/dist/destinations/engage/twilio/sendSms/generated-types.js.map +1 -0
  70. package/dist/destinations/engage/twilio/sendSms/index.d.ts +1 -0
  71. package/dist/destinations/engage/twilio/sendSms/index.js +14 -0
  72. package/dist/destinations/engage/twilio/sendSms/index.js.map +1 -0
  73. package/dist/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.d.ts +9 -0
  74. package/dist/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.js +89 -0
  75. package/dist/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.js.map +1 -0
  76. package/dist/destinations/engage/twilio/sendWhatsApp/actionDefinition.d.ts +4 -0
  77. package/dist/destinations/engage/twilio/sendWhatsApp/actionDefinition.js +136 -0
  78. package/dist/destinations/engage/twilio/sendWhatsApp/actionDefinition.js.map +1 -0
  79. package/dist/destinations/engage/twilio/sendWhatsApp/generated-types.d.ts +1 -0
  80. package/dist/destinations/engage/twilio/sendWhatsApp/generated-types.js +14 -0
  81. package/dist/destinations/engage/twilio/sendWhatsApp/generated-types.js.map +1 -0
  82. package/dist/destinations/engage/twilio/sendWhatsApp/index.d.ts +1 -0
  83. package/dist/destinations/engage/twilio/sendWhatsApp/index.js +14 -0
  84. package/dist/destinations/engage/twilio/sendWhatsApp/index.js.map +1 -0
  85. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.d.ts +16 -0
  86. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js +71 -0
  87. package/dist/destinations/engage/twilio/utils/PhoneMessageSender.js.map +1 -0
  88. package/dist/destinations/engage/twilio/utils/TwilioMessageSender.d.ts +16 -0
  89. package/dist/destinations/engage/twilio/utils/TwilioMessageSender.js +115 -0
  90. package/dist/destinations/engage/twilio/utils/TwilioMessageSender.js.map +1 -0
  91. package/dist/destinations/engage/twilio/utils/index.d.ts +2 -0
  92. package/dist/destinations/engage/twilio/utils/index.js +15 -0
  93. package/dist/destinations/engage/twilio/utils/index.js.map +1 -0
  94. package/dist/destinations/engage/twilio/utils/types.d.ts +23 -0
  95. package/dist/destinations/engage/twilio/utils/types.js +3 -0
  96. package/dist/destinations/engage/twilio/utils/types.js.map +1 -0
  97. package/dist/destinations/engage/utils/AggregateError.d.ts +14 -0
  98. package/dist/destinations/engage/utils/AggregateError.js +26 -0
  99. package/dist/destinations/engage/utils/AggregateError.js.map +1 -0
  100. package/dist/destinations/engage/utils/EngageActionPerformer.d.ts +42 -0
  101. package/dist/destinations/engage/utils/EngageActionPerformer.js +148 -0
  102. package/dist/destinations/engage/utils/EngageActionPerformer.js.map +1 -0
  103. package/dist/destinations/engage/utils/EngageLogger.d.ts +18 -0
  104. package/dist/destinations/engage/utils/EngageLogger.js +52 -0
  105. package/dist/destinations/engage/utils/EngageLogger.js.map +1 -0
  106. package/dist/destinations/engage/utils/EngageStats.d.ts +18 -0
  107. package/dist/destinations/engage/utils/EngageStats.js +95 -0
  108. package/dist/destinations/engage/utils/EngageStats.js.map +1 -0
  109. package/dist/destinations/engage/utils/IntegrationErrorWrapper.d.ts +12 -0
  110. package/dist/destinations/engage/utils/IntegrationErrorWrapper.js +31 -0
  111. package/dist/destinations/engage/utils/IntegrationErrorWrapper.js.map +1 -0
  112. package/dist/destinations/engage/utils/MessageSendPerformer.d.ts +65 -0
  113. package/dist/destinations/engage/utils/MessageSendPerformer.js +211 -0
  114. package/dist/destinations/engage/utils/MessageSendPerformer.js.map +1 -0
  115. package/dist/destinations/engage/utils/Profile.d.ts +6 -0
  116. package/dist/destinations/engage/utils/Profile.js +3 -0
  117. package/dist/destinations/engage/utils/Profile.js.map +1 -0
  118. package/dist/destinations/engage/utils/ResponseError.d.ts +25 -0
  119. package/dist/destinations/engage/utils/ResponseError.js +22 -0
  120. package/dist/destinations/engage/utils/ResponseError.js.map +1 -0
  121. package/dist/destinations/engage/utils/apiLookups.d.ts +22 -0
  122. package/dist/destinations/engage/utils/apiLookups.js +189 -0
  123. package/dist/destinations/engage/utils/apiLookups.js.map +1 -0
  124. package/dist/destinations/engage/utils/getProfileApiEndpoint.d.ts +2 -0
  125. package/dist/destinations/engage/utils/getProfileApiEndpoint.js +10 -0
  126. package/dist/destinations/engage/utils/getProfileApiEndpoint.js.map +1 -0
  127. package/dist/destinations/engage/utils/index.d.ts +9 -0
  128. package/dist/destinations/engage/utils/index.js +22 -0
  129. package/dist/destinations/engage/utils/index.js.map +1 -0
  130. package/dist/destinations/engage/utils/isDestinationActionService.d.ts +1 -0
  131. package/dist/destinations/engage/utils/isDestinationActionService.js +8 -0
  132. package/dist/destinations/engage/utils/isDestinationActionService.js.map +1 -0
  133. package/dist/destinations/engage/utils/isRetryableError.d.ts +2 -0
  134. package/dist/destinations/engage/utils/isRetryableError.js +33 -0
  135. package/dist/destinations/engage/utils/isRetryableError.js.map +1 -0
  136. package/dist/destinations/engage/utils/operationTracking/GenericMethodDecorator.d.ts +1 -0
  137. package/dist/destinations/engage/utils/operationTracking/GenericMethodDecorator.js +3 -0
  138. package/dist/destinations/engage/utils/operationTracking/GenericMethodDecorator.js.map +1 -0
  139. package/dist/destinations/engage/utils/operationTracking/OperationDecorator.d.ts +46 -0
  140. package/dist/destinations/engage/utils/operationTracking/OperationDecorator.js +46 -0
  141. package/dist/destinations/engage/utils/operationTracking/OperationDecorator.js.map +1 -0
  142. package/dist/destinations/engage/utils/operationTracking/OperationDuration.d.ts +12 -0
  143. package/dist/destinations/engage/utils/operationTracking/OperationDuration.js +23 -0
  144. package/dist/destinations/engage/utils/operationTracking/OperationDuration.js.map +1 -0
  145. package/dist/destinations/engage/utils/operationTracking/OperationErrorHandler.d.ts +12 -0
  146. package/dist/destinations/engage/utils/operationTracking/OperationErrorHandler.js +35 -0
  147. package/dist/destinations/engage/utils/operationTracking/OperationErrorHandler.js.map +1 -0
  148. package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.d.ts +14 -0
  149. package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js +31 -0
  150. package/dist/destinations/engage/utils/operationTracking/OperationFinallyHooks.js.map +1 -0
  151. package/dist/destinations/engage/utils/operationTracking/OperationLogger.d.ts +31 -0
  152. package/dist/destinations/engage/utils/operationTracking/OperationLogger.js +104 -0
  153. package/dist/destinations/engage/utils/operationTracking/OperationLogger.js.map +1 -0
  154. package/dist/destinations/engage/utils/operationTracking/OperationStats.d.ts +39 -0
  155. package/dist/destinations/engage/utils/operationTracking/OperationStats.js +130 -0
  156. package/dist/destinations/engage/utils/operationTracking/OperationStats.js.map +1 -0
  157. package/dist/destinations/engage/utils/operationTracking/OperationTracker.test.d.ts +1 -0
  158. package/dist/destinations/engage/utils/operationTracking/OperationTracker.test.js +377 -0
  159. package/dist/destinations/engage/utils/operationTracking/OperationTracker.test.js.map +1 -0
  160. package/dist/destinations/engage/utils/operationTracking/OperationTree.d.ts +23 -0
  161. package/dist/destinations/engage/utils/operationTracking/OperationTree.js +49 -0
  162. package/dist/destinations/engage/utils/operationTracking/OperationTree.js.map +1 -0
  163. package/dist/destinations/engage/utils/operationTracking/TrackedError.d.ts +6 -0
  164. package/dist/destinations/engage/utils/operationTracking/TrackedError.js +3 -0
  165. package/dist/destinations/engage/utils/operationTracking/TrackedError.js.map +1 -0
  166. package/dist/destinations/engage/utils/operationTracking/index.d.ts +10 -0
  167. package/dist/destinations/engage/utils/operationTracking/index.js +23 -0
  168. package/dist/destinations/engage/utils/operationTracking/index.js.map +1 -0
  169. package/dist/destinations/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.d.ts +21 -0
  170. package/dist/destinations/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.js +99 -0
  171. package/dist/destinations/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.js.map +1 -0
  172. package/dist/destinations/engage/utils/testUtils.d.ts +6 -0
  173. package/dist/destinations/engage/utils/testUtils.js +26 -0
  174. package/dist/destinations/engage/utils/testUtils.js.map +1 -0
  175. package/dist/destinations/engage/utils/track.d.ts +52 -0
  176. package/dist/destinations/engage/utils/track.js +9 -0
  177. package/dist/destinations/engage/utils/track.js.map +1 -0
  178. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup.types.d.ts +16 -0
  179. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup.types.js +3 -0
  180. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup.types.js.map +1 -0
  181. package/dist/destinations/engage-messaging-sendgrid/sendEmail.types.d.ts +56 -0
  182. package/dist/destinations/{mappings-two-test/sendEvent/generated-types.js → engage-messaging-sendgrid/sendEmail.types.js} +1 -1
  183. package/dist/destinations/engage-messaging-sendgrid/sendEmail.types.js.map +1 -0
  184. package/dist/destinations/engage-messaging-twilio/sendMobilePush.types.d.ts +39 -0
  185. package/dist/destinations/engage-messaging-twilio/sendMobilePush.types.js +3 -0
  186. package/dist/destinations/engage-messaging-twilio/sendMobilePush.types.js.map +1 -0
  187. package/dist/destinations/engage-messaging-twilio/sendSms.types.d.ts +27 -0
  188. package/dist/destinations/{mappings-two-test/generated-types.js → engage-messaging-twilio/sendSms.types.js} +1 -1
  189. package/dist/destinations/engage-messaging-twilio/sendSms.types.js.map +1 -0
  190. package/dist/destinations/engage-messaging-twilio/sendWhatsApp.types.d.ts +25 -0
  191. package/dist/destinations/engage-messaging-twilio/sendWhatsApp.types.js +3 -0
  192. package/dist/destinations/engage-messaging-twilio/sendWhatsApp.types.js.map +1 -0
  193. package/dist/destinations/index.js +0 -1
  194. package/dist/destinations/index.js.map +1 -1
  195. package/dist/destinations/mixpanel/incrementProperties/__test__/__snapshots__/snapshot.test.js.snap +18 -0
  196. package/package.json +4 -4
  197. package/dist/destinations/mappings-two-test/generated-types.d.ts +0 -3
  198. package/dist/destinations/mappings-two-test/generated-types.js.map +0 -1
  199. package/dist/destinations/mappings-two-test/index.js +0 -30
  200. package/dist/destinations/mappings-two-test/index.js.map +0 -1
  201. package/dist/destinations/mappings-two-test/sendEvent/generated-types.d.ts +0 -6
  202. package/dist/destinations/mappings-two-test/sendEvent/generated-types.js.map +0 -1
  203. package/dist/destinations/mappings-two-test/sendEvent/index.js +0 -110
  204. package/dist/destinations/mappings-two-test/sendEvent/index.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionDefinition = void 0;
4
+ const SmsMessageSender_1 = require("./SmsMessageSender");
5
+ exports.actionDefinition = {
6
+ title: 'Send SMS',
7
+ description: 'Send SMS using Twilio',
8
+ defaultSubscription: 'type = "track" and event = "Audience Entered"',
9
+ fields: {
10
+ userId: {
11
+ label: 'User ID',
12
+ description: 'User ID in Segment',
13
+ type: 'string',
14
+ default: { '@path': '$.userId' }
15
+ },
16
+ toNumber: {
17
+ label: 'Test Number',
18
+ description: 'Number to send SMS to when testing',
19
+ type: 'string'
20
+ },
21
+ from: {
22
+ label: 'From',
23
+ description: 'The Twilio Phone Number, Short Code, or Messaging Service to send SMS from.',
24
+ type: 'string',
25
+ required: true
26
+ },
27
+ body: {
28
+ label: 'Message',
29
+ description: 'Message to send',
30
+ type: 'text',
31
+ required: false
32
+ },
33
+ media: {
34
+ label: 'Media Urls',
35
+ description: 'Media to attach to message',
36
+ type: 'string',
37
+ required: false,
38
+ multiple: true
39
+ },
40
+ contentSid: {
41
+ label: 'SMS content template SID',
42
+ description: 'Content template SID for Twilio Content API',
43
+ type: 'string',
44
+ required: false
45
+ },
46
+ customArgs: {
47
+ label: 'Custom Arguments',
48
+ description: 'Additional custom arguments that will be opaquely sent back on webhook events',
49
+ type: 'object',
50
+ required: false
51
+ },
52
+ connectionOverrides: {
53
+ label: 'Connection Overrides',
54
+ description: 'Connection overrides are configuration supported by twilio webhook services. Must be passed as fragments on the callback url',
55
+ type: 'string',
56
+ required: false
57
+ },
58
+ send: {
59
+ label: 'Send Message',
60
+ description: 'Whether or not the message should actually get sent.',
61
+ type: 'boolean',
62
+ required: false,
63
+ default: false
64
+ },
65
+ traitEnrichment: {
66
+ label: 'Trait Enrich',
67
+ description: 'Whether or not trait enrich from event (i.e without profile api call)',
68
+ type: 'boolean',
69
+ required: false,
70
+ default: true
71
+ },
72
+ sendBasedOnOptOut: {
73
+ label: 'Send OptOut',
74
+ description: 'Send to any subscription status other than unsubscribed',
75
+ type: 'boolean',
76
+ default: false
77
+ },
78
+ segmentComputationId: {
79
+ label: 'Segment Computation ID',
80
+ description: 'Segment computation ID',
81
+ type: 'string',
82
+ required: false,
83
+ default: {
84
+ '@path': '$.context.personas.computation_id'
85
+ }
86
+ },
87
+ externalIds: {
88
+ label: 'External IDs',
89
+ description: 'An array of user profile identity information.',
90
+ type: 'object',
91
+ multiple: true,
92
+ properties: {
93
+ id: {
94
+ label: 'ID',
95
+ description: 'A unique identifier for the collection.',
96
+ type: 'string'
97
+ },
98
+ type: {
99
+ label: 'type',
100
+ description: 'The external ID contact type.',
101
+ type: 'string'
102
+ },
103
+ channelType: {
104
+ label: 'type',
105
+ description: 'The external ID contact channel type (SMS, WHATSAPP, etc).',
106
+ type: 'string'
107
+ },
108
+ subscriptionStatus: {
109
+ label: 'ID',
110
+ description: 'The subscription status for the identity.',
111
+ type: 'string'
112
+ }
113
+ },
114
+ default: {
115
+ '@arrayPath': [
116
+ '$.external_ids',
117
+ {
118
+ id: {
119
+ '@path': '$.id'
120
+ },
121
+ type: {
122
+ '@path': '$.type'
123
+ },
124
+ channelType: {
125
+ '@path': '$.channelType'
126
+ },
127
+ subscriptionStatus: {
128
+ '@path': '$.isSubscribed'
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ traits: {
135
+ label: 'Traits',
136
+ description: "A user profile's traits",
137
+ type: 'object',
138
+ required: false,
139
+ default: { '@path': '$.properties' }
140
+ },
141
+ eventOccurredTS: {
142
+ label: 'Event Timestamp',
143
+ description: 'Time of when the actual event happened.',
144
+ type: 'string',
145
+ required: false,
146
+ default: {
147
+ '@path': '$.timestamp'
148
+ }
149
+ },
150
+ messageId: {
151
+ type: 'string',
152
+ required: false,
153
+ description: 'The Segment messageId',
154
+ label: 'MessageId',
155
+ default: { '@path': '$.messageId' }
156
+ }
157
+ },
158
+ perform: async (request, data) => {
159
+ return new SmsMessageSender_1.SmsMessageSender(request, data).perform();
160
+ }
161
+ };
162
+ //# sourceMappingURL=actionDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionDefinition.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendSms/actionDefinition.ts"],"names":[],"mappings":";;;AAIA,yDAAqD;AAExC,QAAA,gBAAgB,GAAwC;IACnE,KAAK,EA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AO,EAAE,gBAAgB;yBAC1B;qBACF;iBACF;aACF;SACF;QACD,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ;YACf,WAAW,EAAE,yBAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE;SACrC;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,yCAAyC;YACtD,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,uBAAuB;YACpC,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE;SACpC;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;QAC/B,OAAO,IAAI,mCAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAA;IACtD,CAAC;CACF,CAAA"}
@@ -0,0 +1 @@
1
+ export * from '../../../engage-messaging-twilio/sendSms.types';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("../../../engage-messaging-twilio/sendSms.types"), exports);
14
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendSms/generated-types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iFAA8D"}
@@ -0,0 +1 @@
1
+ export * from './actionDefinition';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./actionDefinition"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendSms/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkC"}
@@ -0,0 +1,9 @@
1
+ import type { Payload } from './generated-types';
2
+ import { PhoneMessageSender } from '../utils';
3
+ export declare class WhatsAppMessageSender extends PhoneMessageSender<Payload> {
4
+ get supportedTemplateTypes(): string[];
5
+ getChannelType(): string;
6
+ getBody(phone: string): Promise<URLSearchParams>;
7
+ private parsePhoneNumber;
8
+ private getVariables;
9
+ }
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.WhatsAppMessageSender = void 0;
10
+ const liquidjs_1 = require("liquidjs");
11
+ const actions_core_1 = require("@segment/actions-core");
12
+ const google_libphonenumber_1 = require("google-libphonenumber");
13
+ const utils_1 = require("../utils");
14
+ const utils_2 = require("../../utils");
15
+ const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
16
+ const Liquid = new liquidjs_1.Liquid();
17
+ class WhatsAppMessageSender extends utils_1.PhoneMessageSender {
18
+ get supportedTemplateTypes() {
19
+ throw new Error('Method not supported.');
20
+ }
21
+ getChannelType() {
22
+ return 'whatsapp';
23
+ }
24
+ async getBody(phone) {
25
+ if (!this.payload.contentSid) {
26
+ throw new actions_core_1.IntegrationError('A valid whatsApp Content SID was not provided.', `INVALID_CONTENT_SID`, 400);
27
+ }
28
+ const params = {
29
+ ContentSid: this.payload.contentSid,
30
+ From: this.payload.from,
31
+ To: this.parsePhoneNumber(phone)
32
+ };
33
+ const contentVariables = await this.getVariables();
34
+ if (contentVariables)
35
+ params['ContentVariables'] = contentVariables;
36
+ return new URLSearchParams(params);
37
+ }
38
+ parsePhoneNumber(phone) {
39
+ let parsedPhone;
40
+ try {
41
+ parsedPhone = phoneUtil.parse(phone, 'US');
42
+ if (!phoneUtil.isPossibleNumber(parsedPhone) || !phoneUtil.isValidNumber(parsedPhone)) {
43
+ parsedPhone = phoneUtil.parse('+' + phone, 'US');
44
+ }
45
+ parsedPhone = phoneUtil.format(parsedPhone, google_libphonenumber_1.PhoneNumberFormat.E164);
46
+ return `whatsapp:${parsedPhone}`;
47
+ }
48
+ catch (e) {
49
+ const underlyingError = e;
50
+ throw new actions_core_1.IntegrationError('Phone number must be able to be formatted to e164 for whatsapp. ' + underlyingError.message, `INVALID_PHONE`, 400);
51
+ }
52
+ }
53
+ async getVariables() {
54
+ if (!this.payload.traitEnrichment && this.payload.contentVariables)
55
+ return JSON.stringify(this.payload.contentVariables) ?? null;
56
+ if (!this.payload.contentVariables || !this.payload.traits)
57
+ return null;
58
+ const profile = {
59
+ profile: {
60
+ traits: this.payload.traits
61
+ }
62
+ };
63
+ const mapping = {};
64
+ for (const [key, val] of Object.entries(this.payload.contentVariables)) {
65
+ const parsed = await Liquid.parseAndRender(val, profile);
66
+ if (parsed?.length) {
67
+ mapping[key] = parsed;
68
+ }
69
+ }
70
+ return JSON.stringify(mapping);
71
+ }
72
+ }
73
+ __decorate([
74
+ utils_2.track()
75
+ ], WhatsAppMessageSender.prototype, "getBody", null);
76
+ __decorate([
77
+ utils_2.track()
78
+ ], WhatsAppMessageSender.prototype, "parsePhoneNumber", null);
79
+ __decorate([
80
+ utils_2.track({
81
+ wrapIntegrationError: () => [
82
+ `Unable to parse templating in content variables`,
83
+ `Content variables templating parse failure`,
84
+ 400
85
+ ]
86
+ })
87
+ ], WhatsAppMessageSender.prototype, "getVariables", null);
88
+ exports.WhatsAppMessageSender = WhatsAppMessageSender;
89
+ //# sourceMappingURL=WhatsAppMessageSender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WhatsAppMessageSender.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/WhatsAppMessageSender.ts"],"names":[],"mappings":";;;;;;;;;AACA,uCAA6C;AAE7C,wDAAwD;AACxD,iEAA0E;AAC1E,oCAA6C;AAC7C,uCAAmC;AAEnC,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAA;AAC/C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAE7B,MAAa,qBAAsB,SAAQ,0BAA2B;IACpE,IAAI,sBAAsB;QACxB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAA;IAC1C,CAAC;IACD,cAAc;QACZ,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,K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,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB;YAChE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,IAAI,CAAA;QAC9D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA;QAEvE,MAAM,OAAO,GAAG;YACd,OAAO,EAAE;gBACP,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;aAC5B;SACF,CAAA;QAED,MAAM,OAAO,GAA2B,EAAE,CAAA;QAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;YACtE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,GAAa,EAAE,OAAO,CAAC,CAAA;YAClE,IAAI,MAAM,EAAE,MAAM,EAAE;gBAClB,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;aACtB;SACF;QAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;CACF;AA3EC;IADC,aAAK,EAAE;oDAgBP;AAGD;IADC,aAAK,EAAE;6DAyBP;AASD;IAPC,aAAK,CAAC;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC;YAC1B,iDAAiD;YACjD,4CAA4C;YAC5C,GAAG;SACJ;KACF,CAAC;yDAwBD;AAnFH,sDAoFC"}
@@ -0,0 +1,4 @@
1
+ import type { ActionDefinition } from '@segment/actions-core';
2
+ import type { Settings } from '../generated-types';
3
+ import type { Payload } from './generated-types';
4
+ export declare const actionDefinition: ActionDefinition<Settings, Payload>;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.actionDefinition = void 0;
4
+ const WhatsAppMessageSender_1 = require("./WhatsAppMessageSender");
5
+ exports.actionDefinition = {
6
+ title: 'Send WhatsApp',
7
+ description: 'Send WhatsApp using Twilio',
8
+ defaultSubscription: 'type = "track" and event = "Audience Entered"',
9
+ fields: {
10
+ contentSid: {
11
+ label: 'WhatsApp template Content Sid',
12
+ description: 'The template you sending through WhatsApp',
13
+ type: 'string',
14
+ required: true
15
+ },
16
+ contentVariables: {
17
+ label: 'WhatsApp template variables',
18
+ description: 'Content personalization variables/merge tags for your WhatsApp message',
19
+ type: 'object',
20
+ required: false
21
+ },
22
+ toNumber: {
23
+ label: 'Test Number',
24
+ description: 'Number to send WhatsApp to when testing',
25
+ type: 'string'
26
+ },
27
+ from: {
28
+ label: 'From',
29
+ description: 'The Twilio Phone Number, Short Code, or Messaging Service to send WhatsApp from.',
30
+ type: 'string',
31
+ required: true
32
+ },
33
+ customArgs: {
34
+ label: 'Custom Arguments',
35
+ description: 'Additional custom arguments that will be opaquely sent back on webhook events',
36
+ type: 'object',
37
+ required: false
38
+ },
39
+ connectionOverrides: {
40
+ label: 'Connection Overrides',
41
+ description: 'Connection overrides are configuration supported by twilio webhook services. Must be passed as fragments on the callback url',
42
+ type: 'string',
43
+ required: false
44
+ },
45
+ send: {
46
+ label: 'Send Message',
47
+ description: 'Whether or not the message should actually get sent.',
48
+ type: 'boolean',
49
+ required: false,
50
+ default: false
51
+ },
52
+ traitEnrichment: {
53
+ label: 'Trait Enrich',
54
+ description: 'Whether or not trait enrich from event (i.e without profile api call)',
55
+ type: 'boolean',
56
+ required: false,
57
+ default: true
58
+ },
59
+ segmentComputationId: {
60
+ label: 'Segment Computation ID',
61
+ description: 'Segment computation ID',
62
+ type: 'string',
63
+ required: false,
64
+ default: {
65
+ '@path': '$.context.personas.computation_id'
66
+ }
67
+ },
68
+ externalIds: {
69
+ label: 'External IDs',
70
+ description: 'An array of user profile identity information.',
71
+ type: 'object',
72
+ multiple: true,
73
+ properties: {
74
+ id: {
75
+ label: 'ID',
76
+ description: 'A unique identifier for the collection.',
77
+ type: 'string'
78
+ },
79
+ type: {
80
+ label: 'type',
81
+ description: 'The external ID contact type.',
82
+ type: 'string'
83
+ },
84
+ channelType: {
85
+ label: 'type',
86
+ description: 'The external ID contact channel type (SMS, WHATSAPP, etc).',
87
+ type: 'string'
88
+ },
89
+ subscriptionStatus: {
90
+ label: 'ID',
91
+ description: 'The subscription status for the identity.',
92
+ type: 'string'
93
+ }
94
+ },
95
+ default: {
96
+ '@arrayPath': [
97
+ '$.external_ids',
98
+ {
99
+ id: {
100
+ '@path': '$.id'
101
+ },
102
+ type: {
103
+ '@path': '$.type'
104
+ },
105
+ channelType: {
106
+ '@path': '$.channelType'
107
+ },
108
+ subscriptionStatus: {
109
+ '@path': '$.isSubscribed'
110
+ }
111
+ }
112
+ ]
113
+ }
114
+ },
115
+ traits: {
116
+ label: 'Traits',
117
+ description: "A user profile's traits",
118
+ type: 'object',
119
+ required: false,
120
+ default: { '@path': '$.properties' }
121
+ },
122
+ eventOccurredTS: {
123
+ label: 'Event Timestamp',
124
+ description: 'Time of when the actual event happened.',
125
+ type: 'string',
126
+ required: false,
127
+ default: {
128
+ '@path': '$.timestamp'
129
+ }
130
+ }
131
+ },
132
+ perform: async (request, data) => {
133
+ return new WhatsAppMessageSender_1.WhatsAppMessageSender(request, data).perform();
134
+ }
135
+ };
136
+ //# sourceMappingURL=actionDefinition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionDefinition.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/actionDefinition.ts"],"names":[],"mappings":";;;AAIA,mEAA+D;AAElD,QAAA,gBAAgB,GAAwC;IACnE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,4BAA4B;IACzC,mBAAmB,EAAE,+CAA+C;IACpE,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,+BAA+B;YACtC,WAAW,EAAE,2CAA2C;YACxD,IAAI,EAAE,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 export * from '../../../engage-messaging-twilio/sendWhatsApp.types';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("../../../engage-messaging-twilio/sendWhatsApp.types"), exports);
14
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/generated-types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sFAAmE"}
@@ -0,0 +1 @@
1
+ export * from './actionDefinition';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./actionDefinition"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/destinations/engage/twilio/sendWhatsApp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAkC"}
@@ -0,0 +1,16 @@
1
+ import { TwilioMessageSender, TwilioPayloadBase } from './TwilioMessageSender';
2
+ import { ExtId } from '../../utils';
3
+ export declare abstract class PhoneMessageSender<Payload extends PhoneMessagePayload> extends TwilioMessageSender<Payload> {
4
+ private readonly EXTERNAL_ID_KEY;
5
+ private readonly DEFAULT_HOSTNAME;
6
+ private readonly DEFAULT_CONNECTION_OVERRIDES;
7
+ abstract getBody(phone: string): Promise<URLSearchParams>;
8
+ get twilioHostname(): string;
9
+ get twilioToken(): string;
10
+ sendToRecepient(recepient: ExtId<Payload>): Promise<import("@segment/actions-core/*").ModifiedResponse<unknown>>;
11
+ isSupportedExternalId(externalId: NonNullable<Payload['externalIds']>[number]): boolean;
12
+ getRecepients(): ExtId<Payload>[];
13
+ }
14
+ export interface PhoneMessagePayload extends TwilioPayloadBase {
15
+ toNumber?: string;
16
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PhoneMessageSender = void 0;
4
+ const TwilioMessageSender_1 = require("./TwilioMessageSender");
5
+ const utils_1 = require("../../utils");
6
+ class PhoneMessageSender extends TwilioMessageSender_1.TwilioMessageSender {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.EXTERNAL_ID_KEY = 'phone';
10
+ this.DEFAULT_HOSTNAME = 'api.twilio.com';
11
+ this.DEFAULT_CONNECTION_OVERRIDES = 'rp=all&rc=5';
12
+ }
13
+ get twilioHostname() {
14
+ return this.settings.twilioHostname ?? this.DEFAULT_HOSTNAME;
15
+ }
16
+ get twilioToken() {
17
+ return Buffer.from(`${this.settings.twilioApiKeySID}:${this.settings.twilioApiKeySecret}`).toString('base64');
18
+ }
19
+ async sendToRecepient(recepient) {
20
+ const phone = recepient.id;
21
+ const op = this.currentOperation;
22
+ this.currentOperation?.onFinally.push(() => {
23
+ const error = op.error;
24
+ if (error)
25
+ op.tags.push('not_sent_reason:error_operation_' + utils_1.OperationDecorator.getOperationName(error.trackedContext || op));
26
+ });
27
+ const body = await this.getBody(phone);
28
+ const webhookUrlWithParams = this.getWebhookUrlWithParams(this.EXTERNAL_ID_KEY, phone, this.DEFAULT_CONNECTION_OVERRIDES);
29
+ const tags = {
30
+ audience_id: this.payload.customArgs && this.payload.customArgs['audience_id'],
31
+ correlation_id: this.payload.customArgs && this.payload.customArgs['correlation_id'],
32
+ journey_name: this.payload.customArgs && this.payload.customArgs['journey_name'],
33
+ step_name: this.payload.customArgs && this.payload.customArgs['step_name'],
34
+ campaign_name: this.payload.customArgs && this.payload.customArgs['campaign_name'],
35
+ campaign_key: this.payload.customArgs && this.payload.customArgs['campaign_key'],
36
+ user_id: this.payload.customArgs && this.payload.customArgs['user_id'],
37
+ message_id: this.payload.customArgs && this.payload.customArgs['message_id'],
38
+ external_id_type: recepient.type,
39
+ external_id_value: phone
40
+ };
41
+ body.append('Tags', JSON.stringify(tags));
42
+ if (webhookUrlWithParams) {
43
+ body.append('StatusCallback', webhookUrlWithParams);
44
+ }
45
+ this.statsSet('message_body_size', body?.toString().length);
46
+ const response = await this.request(`https://${this.twilioHostname}/2010-04-01/Accounts/${this.settings.twilioAccountSID}/Messages.json`, {
47
+ method: 'POST',
48
+ headers: {
49
+ authorization: `Basic ${this.twilioToken}`
50
+ },
51
+ body
52
+ });
53
+ this.logDetails['twilio-request-id'] = response.headers?.get('twilio-request-id');
54
+ return response;
55
+ }
56
+ isSupportedExternalId(externalId) {
57
+ return externalId.type === 'phone' && externalId.channelType?.toLowerCase() === this.getChannelType();
58
+ }
59
+ getRecepients() {
60
+ if (this.payload.toNumber)
61
+ return [
62
+ {
63
+ id: this.payload.toNumber
64
+ }
65
+ ];
66
+ const res = super.getRecepients();
67
+ return res.length > 0 ? [res[0]] : res;
68
+ }
69
+ }
70
+ exports.PhoneMessageSender = PhoneMessageSender;
71
+ //# sourceMappingURL=PhoneMessageSender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PhoneMess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I,CAAC,cAAc,wBAAwB,IAAI,CAAC,QAAQ,CAAC,gBAAgB,gBAAgB,EACpG;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS,IAAI,CAAC,WAAW,EAAE;aAC3C;YACD,IAAI;SACL,CACF,CAAA;QAED,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,mBAAmB,CAAC,CAAA;QAEjF,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,qBAAqB,CAAC,UAAuD;QAC3E,OAAO,UAAU,CAAC,IAAI,KAAK,OAAO,IAAI,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,IAAI,CAAC,cAAc,EAAE,CAAA;IACvG,CAAC;IAED,aAAa;QACX,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ;YACvB,OAAO;gBACL;oBACE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;iBAC1B;aACF,CAAA;QAGH,MAAM,GAAG,GAAG,KAAK,CAAC,aAAa,EAAE,CAAA;QACjC,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACxC,CAAC;CACF;AAtFD,gDAsFC"}
@@ -0,0 +1,16 @@
1
+ import type { Settings } from '../generated-types';
2
+ import { ContentTemplateTypes, Profile } from './types';
3
+ import { MessageSendPerformer, MessagePayloadBase } from '../../utils';
4
+ export interface TwilioPayloadBase extends MessagePayloadBase {
5
+ contentSid?: string;
6
+ }
7
+ export declare abstract class TwilioMessageSender<TPayload extends TwilioPayloadBase> extends MessageSendPerformer<Settings, TPayload> {
8
+ getIntegrationStatsName(): string;
9
+ getDefaultSettingsRegion(): string;
10
+ abstract readonly supportedTemplateTypes: string[];
11
+ parseContent<R extends Record<string, string | string[] | undefined>>(content: R, profile: Profile): Promise<R>;
12
+ getContentTemplateTypes(): Promise<ContentTemplateTypes>;
13
+ private extractTemplateTypes;
14
+ getWebhookUrlWithParams(externalIdType?: string, externalIdValue?: string, defaultConnectionOverrides?: string): string | null;
15
+ beforePerform(): void;
16
+ }