@segment/action-destinations 3.127.2-CHANNELS-329.3 → 3.127.3-brackets-stuff.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/braze-cohorts/syncAudiences/index.js +3 -3
- package/dist/destinations/braze-cohorts/syncAudiences/index.js.map +1 -1
- package/dist/destinations/customerio/createUpdateObject/generated-types.d.ts +1 -1
- package/dist/destinations/customerio/createUpdateObject/index.js +5 -5
- package/dist/destinations/customerio/createUpdateObject/index.js.map +1 -1
- package/dist/destinations/customerio/createUpdatePerson/index.js +2 -2
- package/dist/destinations/customerio/createUpdatePerson/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/index.js +1 -3
- package/dist/destinations/engage-messaging-twilio/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +104 -2
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/index.js +1 -1
- package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
- package/dist/destinations/heap/constants.d.ts +1 -1
- package/dist/destinations/heap/constants.js +2 -2
- package/dist/destinations/heap/constants.js.map +1 -1
- package/dist/destinations/heap/index.js +1 -1
- package/dist/destinations/heap/index.js.map +1 -1
- package/dist/destinations/heap/trackEvent/generated-types.d.ts +4 -2
- package/dist/destinations/heap/trackEvent/index.js +44 -15
- package/dist/destinations/heap/trackEvent/index.js.map +1 -1
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdateActivity/index.js +44 -17
- package/dist/destinations/pipedrive/createUpdateActivity/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdateDeal/index.js +35 -11
- package/dist/destinations/pipedrive/createUpdateDeal/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdateLead/generated-types.d.ts +3 -8
- package/dist/destinations/pipedrive/createUpdateLead/index.js +54 -27
- package/dist/destinations/pipedrive/createUpdateLead/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdateNote/generated-types.d.ts +1 -1
- package/dist/destinations/pipedrive/createUpdateNote/index.js +22 -13
- package/dist/destinations/pipedrive/createUpdateNote/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdateOrganization/index.js +8 -2
- package/dist/destinations/pipedrive/createUpdateOrganization/index.js.map +1 -1
- package/dist/destinations/pipedrive/createUpdatePerson/index.js +15 -3
- package/dist/destinations/pipedrive/createUpdatePerson/index.js.map +1 -1
- package/dist/destinations/pipedrive/index.d.ts +1 -1
- package/dist/destinations/pipedrive/index.js +22 -1
- package/dist/destinations/pipedrive/index.js.map +1 -1
- package/dist/destinations/pipedrive/pipedriveApi/leads.d.ts +5 -1
- package/dist/destinations/pipedrive/pipedriveApi/leads.js.map +1 -1
- package/dist/destinations/pipedrive/pipedriveApi/notes.d.ts +1 -1
- package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.d.ts +2 -1
- package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js +7 -1
- package/dist/destinations/pipedrive/pipedriveApi/pipedrive-client.js.map +1 -1
- package/dist/destinations/saleswings/api.d.ts +35 -0
- package/dist/destinations/saleswings/api.js +19 -0
- package/dist/destinations/saleswings/api.js.map +1 -0
- package/dist/destinations/saleswings/common.d.ts +5 -0
- package/dist/destinations/saleswings/common.js +37 -0
- package/dist/destinations/saleswings/common.js.map +1 -0
- package/dist/destinations/saleswings/converter.d.ts +12 -0
- package/dist/destinations/saleswings/converter.js +34 -0
- package/dist/destinations/saleswings/converter.js.map +1 -0
- package/dist/destinations/saleswings/fields.d.ts +12 -0
- package/dist/destinations/saleswings/fields.js +102 -0
- package/dist/destinations/saleswings/fields.js.map +1 -0
- package/dist/destinations/saleswings/generated-types.d.ts +3 -0
- package/dist/destinations/{engage-messaging-twilio/sendWhatsApp → saleswings}/generated-types.js +0 -0
- package/dist/destinations/saleswings/generated-types.js.map +1 -0
- package/dist/destinations/saleswings/index.d.ts +4 -0
- package/dist/destinations/saleswings/index.js +67 -0
- package/dist/destinations/saleswings/index.js.map +1 -0
- package/dist/destinations/saleswings/submitIdentifyEvent/generated-types.d.ts +14 -0
- package/dist/destinations/saleswings/submitIdentifyEvent/generated-types.js +3 -0
- package/dist/destinations/saleswings/submitIdentifyEvent/generated-types.js.map +1 -0
- package/dist/destinations/{engage-messaging-twilio/sendWhatsApp → saleswings/submitIdentifyEvent}/index.d.ts +0 -0
- package/dist/destinations/saleswings/submitIdentifyEvent/index.js +39 -0
- package/dist/destinations/saleswings/submitIdentifyEvent/index.js.map +1 -0
- package/dist/destinations/saleswings/submitPageEvent/generated-types.d.ts +8 -0
- package/dist/destinations/saleswings/submitPageEvent/generated-types.js +3 -0
- package/dist/destinations/saleswings/submitPageEvent/generated-types.js.map +1 -0
- package/dist/destinations/saleswings/submitPageEvent/index.d.ts +5 -0
- package/dist/destinations/saleswings/submitPageEvent/index.js +35 -0
- package/dist/destinations/saleswings/submitPageEvent/index.js.map +1 -0
- package/dist/destinations/saleswings/submitScreenEvent/generated-types.d.ts +14 -0
- package/dist/destinations/saleswings/submitScreenEvent/generated-types.js +3 -0
- package/dist/destinations/saleswings/submitScreenEvent/generated-types.js.map +1 -0
- package/dist/destinations/saleswings/submitScreenEvent/index.d.ts +5 -0
- package/dist/destinations/saleswings/submitScreenEvent/index.js +42 -0
- package/dist/destinations/saleswings/submitScreenEvent/index.js.map +1 -0
- package/dist/destinations/saleswings/submitTrackEvent/generated-types.d.ts +14 -0
- package/dist/destinations/saleswings/submitTrackEvent/generated-types.js +3 -0
- package/dist/destinations/saleswings/submitTrackEvent/generated-types.js.map +1 -0
- package/dist/destinations/saleswings/submitTrackEvent/index.d.ts +5 -0
- package/dist/destinations/saleswings/submitTrackEvent/index.js +42 -0
- package/dist/destinations/saleswings/submitTrackEvent/index.js.map +1 -0
- package/dist/destinations/saleswings/testing.d.ts +10 -0
- package/dist/destinations/saleswings/testing.js +55 -0
- package/dist/destinations/saleswings/testing.js.map +1 -0
- package/package.json +4 -6
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.d.ts +0 -15
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js +0 -66
- package/dist/destinations/engage-messaging-twilio/sendSms/sms-sender.js.map +0 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.d.ts +0 -23
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/generated-types.js.map +0 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js +0 -122
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/index.js.map +0 -1
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.d.ts +0 -15
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js +0 -66
- package/dist/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.js.map +0 -1
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.d.ts +0 -23
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.js +0 -97
- package/dist/destinations/engage-messaging-twilio/utils/message-sender.js.map +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WhatsAppMessageSender = void 0;
|
|
4
|
-
const liquidjs_1 = require("liquidjs");
|
|
5
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
6
|
-
const message_sender_1 = require("../utils/message-sender");
|
|
7
|
-
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
8
|
-
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
|
9
|
-
const Liquid = new liquidjs_1.Liquid();
|
|
10
|
-
class WhatsAppMessageSender extends message_sender_1.MessageSender {
|
|
11
|
-
constructor(request, payload, settings, statsClient, tags) {
|
|
12
|
-
super(request, payload, settings, statsClient, tags);
|
|
13
|
-
this.request = request;
|
|
14
|
-
this.payload = payload;
|
|
15
|
-
this.settings = settings;
|
|
16
|
-
this.statsClient = statsClient;
|
|
17
|
-
this.tags = tags;
|
|
18
|
-
this.getBody = async (phone) => {
|
|
19
|
-
let parsedPhone;
|
|
20
|
-
try {
|
|
21
|
-
parsedPhone = phoneUtil.parse(phone, 'US');
|
|
22
|
-
parsedPhone = phoneUtil.format(parsedPhone, google_libphonenumber_1.PhoneNumberFormat.E164);
|
|
23
|
-
parsedPhone = `whatsapp:${parsedPhone}`;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
this.tags?.push('type:invalid_phone_e164');
|
|
27
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.error', 1, this.tags);
|
|
28
|
-
throw new actions_core_1.IntegrationError('The string supplied did not seem to be a phone number. Phone number must be able to be formatted to e164 for whatsapp.', `INVALID_PHONE`, 400);
|
|
29
|
-
}
|
|
30
|
-
if (!this.payload.contentSid) {
|
|
31
|
-
throw new actions_core_1.IntegrationError('A valid whatsApp Content SID was not provided.', `INVALID_CONTENT_SID`, 400);
|
|
32
|
-
}
|
|
33
|
-
const params = {
|
|
34
|
-
ContentSid: this.payload.contentSid,
|
|
35
|
-
From: this.payload.from,
|
|
36
|
-
To: parsedPhone
|
|
37
|
-
};
|
|
38
|
-
const contentVariables = await this.getVariables();
|
|
39
|
-
if (contentVariables)
|
|
40
|
-
params['ContentVariables'] = contentVariables;
|
|
41
|
-
return new URLSearchParams(params);
|
|
42
|
-
};
|
|
43
|
-
this.getTwilioBase64Token = () => Buffer.from(`${this.settings.twilioAccountSID}:${this.settings.twilioApiKeySecret}`).toString('base64');
|
|
44
|
-
this.getVariables = async () => {
|
|
45
|
-
if (!this.payload.contentVariables || !this.payload.traits)
|
|
46
|
-
return null;
|
|
47
|
-
try {
|
|
48
|
-
const profile = {
|
|
49
|
-
profile: {
|
|
50
|
-
traits: this.payload.traits
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const mapping = {};
|
|
54
|
-
for (const [key, val] of Object.entries(this.payload.contentVariables)) {
|
|
55
|
-
mapping[key] = await Liquid.parseAndRender(val, profile);
|
|
56
|
-
}
|
|
57
|
-
return JSON.stringify(mapping);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
throw new actions_core_1.IntegrationError(`Unable to parse templating in content variables`, `Content variables templating parse failure`, 400);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.WhatsAppMessageSender = WhatsAppMessageSender;
|
|
66
|
-
//# sourceMappingURL=whatsapp-sender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/sendWhatsApp/whatsapp-sender.ts"],"names":[],"mappings":";;;AACA,uCAA6C;AAG7C,wDAAwD;AACxD,4DAAkE;AAClE,iEAA0E;AAG1E,MAAM,SAAS,GAAG,uCAAe,CAAC,WAAW,EAAE,CAAA;AAC/C,MAAM,MAAM,GAAG,IAAI,iBAAQ,EAAE,CAAA;AAE7B,MAAa,qBAAsB,SAAQ,8BAAsB;IAC/D,YACW,OAAkB,EAClB,OAAgB,EAChB,QAAkB,EAClB,WAAoC,EACpC,IAAsC;QAE/C,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,CAAA;QAN3C,YAAO,GAAP,OAAO,CAAW;QAClB,YAAO,GAAP,OAAO,CAAS;QAChB,aAAQ,GAAR,QAAQ,CAAU;QAClB,gBAAW,GAAX,WAAW,CAAyB;QACpC,SAAI,GAAJ,IAAI,CAAkC;QAKjD,YAAO,GAAG,KAAK,EAAE,KAAa,EAAE,EAAE;YAChC,IAAI,WAAW,CAAA;YAEf,IAAI;gBAIF,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;gBAC1C,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,yCAAiB,CAAC,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BACd,OAAO,EAAE;wBACP,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM;qBAC5B;iBACF,CAAA;gBAED,MAAM,OAAO,GAA2B,EAAE,CAAA;gBAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;oBACtE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,GAAa,EAAE,OAAO,CAAC,CAAA;iBACnE;gBAED,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;aAC/B;YAAC,OAAO,KAAc,EAAE;gBACvB,MAAM,IAAI,+BAAgB,CACxB,iDAAiD,EACjD,4CAA4C,EAC5C,GAAG,CACJ,CAAA;aACF;QACH,CAAC,CAAA;IAhED,CAAC;CAiEF;AA1ED,sDA0EC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from '@segment/actions-core';
|
|
2
|
-
import type { Settings } from '../generated-types';
|
|
3
|
-
import type { Payload } from '../sendSms/generated-types';
|
|
4
|
-
import { StatsClient, StatsContext } from '@segment/actions-core/src/destination-kit';
|
|
5
|
-
export declare type RequestFn = (url: string, options?: RequestOptions) => Promise<Response>;
|
|
6
|
-
declare type MinimalPayload = Pick<Payload, 'from' | 'toNumber' | 'customArgs' | 'externalIds' | 'traits' | 'send' | 'eventOccurredTS'>;
|
|
7
|
-
export declare abstract class MessageSender<SmsPayload extends MinimalPayload> {
|
|
8
|
-
readonly request: RequestFn;
|
|
9
|
-
readonly payload: SmsPayload;
|
|
10
|
-
readonly settings: Settings;
|
|
11
|
-
readonly statsClient: StatsClient | undefined;
|
|
12
|
-
readonly tags: StatsContext['tags'] | undefined;
|
|
13
|
-
private readonly EXTERNAL_ID_KEY;
|
|
14
|
-
private readonly DEFAULT_HOSTNAME;
|
|
15
|
-
private readonly DEFAULT_CONNECTION_OVERRIDES;
|
|
16
|
-
constructor(request: RequestFn, payload: SmsPayload, settings: Settings, statsClient: StatsClient | undefined, tags: StatsContext['tags'] | undefined);
|
|
17
|
-
send: () => Promise<Response | undefined>;
|
|
18
|
-
abstract getBody: (phone: string) => Promise<URLSearchParams>;
|
|
19
|
-
abstract getTwilioBase64Token: () => string;
|
|
20
|
-
private getSendabilityPayload;
|
|
21
|
-
private getWebhookUrlWithParams;
|
|
22
|
-
}
|
|
23
|
-
export {};
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageSender = void 0;
|
|
4
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
-
var SendabilityStatus;
|
|
6
|
-
(function (SendabilityStatus) {
|
|
7
|
-
SendabilityStatus["NoSenderPhone"] = "no_sender_phone";
|
|
8
|
-
SendabilityStatus["ShouldSend"] = "should_send";
|
|
9
|
-
SendabilityStatus["DoNotSend"] = "do_not_send";
|
|
10
|
-
SendabilityStatus["SendDisabled"] = "send_disabled";
|
|
11
|
-
SendabilityStatus["InvalidSubscriptionStatus"] = "invalid_subscription_status";
|
|
12
|
-
})(SendabilityStatus || (SendabilityStatus = {}));
|
|
13
|
-
class MessageSender {
|
|
14
|
-
constructor(request, payload, settings, statsClient, tags) {
|
|
15
|
-
this.request = request;
|
|
16
|
-
this.payload = payload;
|
|
17
|
-
this.settings = settings;
|
|
18
|
-
this.statsClient = statsClient;
|
|
19
|
-
this.tags = tags;
|
|
20
|
-
this.EXTERNAL_ID_KEY = 'phone';
|
|
21
|
-
this.DEFAULT_HOSTNAME = 'api.twilio.com';
|
|
22
|
-
this.DEFAULT_CONNECTION_OVERRIDES = 'rp=all&rc=5';
|
|
23
|
-
this.send = async () => {
|
|
24
|
-
const { phone, sendabilityStatus } = this.getSendabilityPayload();
|
|
25
|
-
if (sendabilityStatus !== SendabilityStatus.ShouldSend || !phone) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const body = await this.getBody(phone);
|
|
29
|
-
const webhookUrlWithParams = this.getWebhookUrlWithParams(phone);
|
|
30
|
-
if (webhookUrlWithParams)
|
|
31
|
-
body.append('StatusCallback', webhookUrlWithParams);
|
|
32
|
-
const twilioHostname = this.settings.twilioHostname ?? this.DEFAULT_HOSTNAME;
|
|
33
|
-
const twilioToken = this.getTwilioBase64Token();
|
|
34
|
-
const response = await this.request(`https://${twilioHostname}/2010-04-01/Accounts/${this.settings.twilioAccountSID}/Messages.json`, {
|
|
35
|
-
method: 'POST',
|
|
36
|
-
headers: {
|
|
37
|
-
authorization: `Basic ${twilioToken}`
|
|
38
|
-
},
|
|
39
|
-
body
|
|
40
|
-
});
|
|
41
|
-
this.tags?.push(`twilio_status_code:${response.status}`);
|
|
42
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.response', 1, this.tags);
|
|
43
|
-
if (this.payload.eventOccurredTS != undefined) {
|
|
44
|
-
this.statsClient?.histogram('actions-personas-messaging-twilio.eventDeliveryTS', Date.now() - new Date(this.payload.eventOccurredTS).getTime(), this.tags);
|
|
45
|
-
}
|
|
46
|
-
return response;
|
|
47
|
-
};
|
|
48
|
-
this.getSendabilityPayload = () => {
|
|
49
|
-
const nonSendableStatuses = ['unsubscribed', 'did not subscribed', 'false'];
|
|
50
|
-
const sendableStatuses = ['subscribed', 'true'];
|
|
51
|
-
const externalId = this.payload.externalIds?.find(({ type }) => type === 'phone');
|
|
52
|
-
let status;
|
|
53
|
-
if (!this.payload.send) {
|
|
54
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.send-disabled', 1, this.tags);
|
|
55
|
-
return { sendabilityStatus: SendabilityStatus.SendDisabled, phone: undefined };
|
|
56
|
-
}
|
|
57
|
-
if (!externalId?.subscriptionStatus || nonSendableStatuses.includes(externalId.subscriptionStatus)) {
|
|
58
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.notsubscribed', 1, this.tags);
|
|
59
|
-
status = SendabilityStatus.DoNotSend;
|
|
60
|
-
}
|
|
61
|
-
else if (sendableStatuses.includes(externalId.subscriptionStatus)) {
|
|
62
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.subscribed', 1, this.tags);
|
|
63
|
-
status = SendabilityStatus.ShouldSend;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.statsClient?.incr('actions-personas-messaging-twilio.twilio-error', 1, this.tags);
|
|
67
|
-
throw new actions_core_1.IntegrationError(`Failed to recognize the subscriptionStatus in the payload: "${externalId.subscriptionStatus}".`, 'Invalid subscriptionStatus value', 400);
|
|
68
|
-
}
|
|
69
|
-
const phone = this.payload.toNumber || externalId?.id;
|
|
70
|
-
if (!phone) {
|
|
71
|
-
status = SendabilityStatus.NoSenderPhone;
|
|
72
|
-
}
|
|
73
|
-
return { sendabilityStatus: status, phone };
|
|
74
|
-
};
|
|
75
|
-
this.getWebhookUrlWithParams = (phone) => {
|
|
76
|
-
const webhookUrl = this.settings.webhookUrl;
|
|
77
|
-
const connectionOverrides = this.settings.connectionOverrides;
|
|
78
|
-
const customArgs = {
|
|
79
|
-
...this.payload.customArgs,
|
|
80
|
-
space_id: this.settings.spaceId,
|
|
81
|
-
__segment_internal_external_id_key__: this.EXTERNAL_ID_KEY,
|
|
82
|
-
__segment_internal_external_id_value__: phone
|
|
83
|
-
};
|
|
84
|
-
if (webhookUrl && customArgs) {
|
|
85
|
-
const webhookUrlWithParams = new URL(webhookUrl);
|
|
86
|
-
for (const key of Object.keys(customArgs)) {
|
|
87
|
-
webhookUrlWithParams.searchParams.append(key, String(customArgs[key]));
|
|
88
|
-
}
|
|
89
|
-
webhookUrlWithParams.hash = connectionOverrides || this.DEFAULT_CONNECTION_OVERRIDES;
|
|
90
|
-
return webhookUrlWithParams.toString();
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
exports.MessageSender = MessageSender;
|
|
97
|
-
//# sourceMappingURL=message-sender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message-sender.js","sourceRoot":"","sources":["../../../../src/destinations/engage-messaging-twilio/utils/message-sender.ts"],"names":[],"mappings":";;;AAIA,wDAAwD;AAGxD,IAAK,iBAMJ;AAND,WAAK,iBAAiB;IACpB,sDAAiC,CAAA;IACjC,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,mDAA8B,CAAA;IAC9B,8EAAyD,CAAA;AAC3D,CAAC,EANI,iBAAiB,KAAjB,iBAAiB,QAMrB;AAWD,MAAsB,aAAa;IAKjC,YACW,OAAkB,EAClB,OAAmB,EACnB,QAAkB,EAClB,WAAoC,EACpC,IAAsC;QAJtC,YAAO,GAAP,OAAO,CAAW;QAClB,YAAO,GAAP,OAAO,CAAY;QACnB,aAAQ,GAAR,QAAQ,CAAU;QAClB,gBAAW,GAAX,WAAW,CAAyB;QACpC,SAAI,GAAJ,IAAI,CAAkC;QAThC,oBAAe,GAAG,OAAO,CAAA;QACzB,qBAAgB,GAAG,gBAAgB,CAAA;QACnC,iCAA4B,GAAG,aAAa,CAAA;QAU7D,SAAI,GAAG,KAAK,IAAI,EAAE;YAChB,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;YAEjE,IAAI,iBAAiB,KAAK,iBAAiB,CAAC,UAAU,IAAI,CAAC,KAAK,EAAE;gBAChE,OAAM;aACP;YAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YAEtC,MAAM,oBAAoB,GAAG,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAA;YAEhE,IAAI,oBAAoB;gBAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC,CAAA;YAE7E,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI,CAAC,gBAAgB,CAAA;YAC5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