@segment/action-destinations 3.345.2 → 3.345.6-staging
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/accoil-analytics/postToAccoil/generated-types.d.ts +5 -0
- package/dist/destinations/accoil-analytics/postToAccoil/generated-types.js +3 -0
- package/dist/destinations/accoil-analytics/postToAccoil/generated-types.js.map +1 -0
- package/dist/destinations/accoil-analytics/postToAccoil/index.d.ts +5 -0
- package/dist/destinations/accoil-analytics/postToAccoil/index.js +28 -0
- package/dist/destinations/accoil-analytics/postToAccoil/index.js.map +1 -0
- package/dist/destinations/attentive/customEvents/generated-types.d.ts +14 -0
- package/dist/destinations/attentive/customEvents/generated-types.js +3 -0
- package/dist/destinations/attentive/customEvents/generated-types.js.map +1 -0
- package/dist/destinations/attentive/customEvents/index.d.ts +5 -0
- package/dist/destinations/attentive/customEvents/index.js +124 -0
- package/dist/destinations/attentive/customEvents/index.js.map +1 -0
- package/dist/destinations/attentive/customEvents/types.d.ts +15 -0
- package/dist/destinations/attentive/customEvents/types.js +3 -0
- package/dist/destinations/attentive/customEvents/types.js.map +1 -0
- package/dist/destinations/attentive/generated-types.d.ts +3 -0
- package/dist/destinations/attentive/generated-types.js +3 -0
- package/dist/destinations/attentive/generated-types.js.map +1 -0
- package/dist/destinations/attentive/index.d.ts +4 -0
- package/dist/destinations/attentive/index.js +54 -0
- package/dist/destinations/attentive/index.js.map +1 -0
- package/dist/destinations/braze/createAliasV2.types.d.ts +5 -0
- package/dist/destinations/braze/createAliasV2.types.js +3 -0
- package/dist/destinations/braze/createAliasV2.types.js.map +1 -0
- package/dist/destinations/braze/identifyUserV2.types.d.ts +8 -0
- package/dist/destinations/braze/identifyUserV2.types.js +3 -0
- package/dist/destinations/braze/identifyUserV2.types.js.map +1 -0
- package/dist/destinations/campaign-manager-360/common-fields.d.ts +3 -0
- package/dist/destinations/campaign-manager-360/common-fields.js +306 -0
- package/dist/destinations/campaign-manager-360/common-fields.js.map +1 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.d.ts +45 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js +3 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/generated-types.js.map +1 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.d.ts +5 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js +86 -0
- package/dist/destinations/campaign-manager-360/conversionAdjustmentUpload/index.js.map +1 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.d.ts +50 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js +3 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/generated-types.js.map +1 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/index.d.ts +5 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/index.js +131 -0
- package/dist/destinations/campaign-manager-360/conversionUpload/index.js.map +1 -0
- package/dist/destinations/campaign-manager-360/generated-types.d.ts +5 -0
- package/dist/destinations/campaign-manager-360/generated-types.js +3 -0
- package/dist/destinations/campaign-manager-360/generated-types.js.map +1 -0
- package/dist/destinations/campaign-manager-360/index.d.ts +4 -0
- package/dist/destinations/campaign-manager-360/index.js +63 -0
- package/dist/destinations/campaign-manager-360/index.js.map +1 -0
- package/dist/destinations/campaign-manager-360/types.d.ts +116 -0
- package/dist/destinations/campaign-manager-360/types.js +23 -0
- package/dist/destinations/campaign-manager-360/types.js.map +1 -0
- package/dist/destinations/campaign-manager-360/utils.d.ts +21 -0
- package/dist/destinations/campaign-manager-360/utils.js +175 -0
- package/dist/destinations/campaign-manager-360/utils.js.map +1 -0
- package/dist/destinations/drip/identify/index.js +1 -1
- package/dist/destinations/drip/identify/index.js.map +1 -1
- package/dist/destinations/drip/index.js +1 -1
- package/dist/destinations/drip/index.js.map +1 -1
- package/dist/destinations/first-party-dv360/addToList/generated-types.d.ts +2 -0
- package/dist/destinations/first-party-dv360/addToList/generated-types.js +3 -0
- package/dist/destinations/first-party-dv360/addToList/generated-types.js.map +1 -0
- package/dist/destinations/first-party-dv360/addToList/index.d.ts +5 -0
- package/dist/destinations/first-party-dv360/addToList/index.js +11 -0
- package/dist/destinations/first-party-dv360/addToList/index.js.map +1 -0
- package/dist/destinations/first-party-dv360/addToList.types.d.ts +9 -0
- package/dist/destinations/first-party-dv360/addToList.types.js +3 -0
- package/dist/destinations/first-party-dv360/addToList.types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/functions.js +6 -2
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/userList/index.js +2 -1
- package/dist/destinations/google-enhanced-conversions/userList/index.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/dynamic-fields.d.ts +5 -0
- package/dist/destinations/hubspot/customEvent/dynamic-fields.js +112 -0
- package/dist/destinations/hubspot/customEvent/dynamic-fields.js.map +1 -0
- package/dist/destinations/hubspot/customEvent/event-completion.d.ts +3 -0
- package/dist/destinations/hubspot/customEvent/event-completion.js +17 -0
- package/dist/destinations/hubspot/customEvent/event-completion.js.map +1 -0
- package/dist/destinations/hubspot/customEvent/functions/dynamic-field-functions.js +1 -1
- package/dist/destinations/hubspot/customEvent/functions/dynamic-field-functions.js.map +1 -1
- package/dist/destinations/hubspot/customEvent/schema-functions.d.ts +3 -0
- package/dist/destinations/hubspot/customEvent/schema-functions.js +30 -0
- package/dist/destinations/hubspot/customEvent/schema-functions.js.map +1 -0
- package/dist/destinations/hubspot/customEvent/utils.d.ts +14 -0
- package/dist/destinations/hubspot/customEvent/utils.js +303 -0
- package/dist/destinations/hubspot/customEvent/utils.js.map +1 -0
- package/dist/destinations/hubspot/customEvent/validation-functions.d.ts +3 -0
- package/dist/destinations/hubspot/customEvent/validation-functions.js +66 -0
- package/dist/destinations/hubspot/customEvent/validation-functions.js.map +1 -0
- package/dist/destinations/hubspot/customEvent/validation.d.ts +3 -0
- package/dist/destinations/hubspot/customEvent/validation.js +66 -0
- package/dist/destinations/hubspot/customEvent/validation.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/association-functions.d.ts +5 -0
- package/dist/destinations/hubspot/upsertObject/association-functions.js +136 -0
- package/dist/destinations/hubspot/upsertObject/association-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/cache-functions.d.ts +3 -0
- package/dist/destinations/hubspot/upsertObject/cache-functions.js +20 -0
- package/dist/destinations/hubspot/upsertObject/cache-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.d.ts +7 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.js +222 -0
- package/dist/destinations/hubspot/upsertObject/dynamic-fields.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-association-functions.d.ts +5 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-association-functions.js +136 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-association-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-properties-functions.d.ts +4 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-properties-functions.js +159 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-properties-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-record-functions.d.ts +4 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-record-functions.js +100 -0
- package/dist/destinations/hubspot/upsertObject/hubspot-record-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/schema-functions.d.ts +3 -0
- package/dist/destinations/hubspot/upsertObject/schema-functions.js +80 -0
- package/dist/destinations/hubspot/upsertObject/schema-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/send-from-record-functions.d.ts +4 -0
- package/dist/destinations/hubspot/upsertObject/send-from-record-functions.js +100 -0
- package/dist/destinations/hubspot/upsertObject/send-from-record-functions.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/utils.d.ts +13 -0
- package/dist/destinations/hubspot/upsertObject/utils.js +547 -0
- package/dist/destinations/hubspot/upsertObject/utils.js.map +1 -0
- package/dist/destinations/hubspot/upsertObject/validation-functions.d.ts +2 -0
- package/dist/destinations/hubspot/upsertObject/validation-functions.js +67 -0
- package/dist/destinations/hubspot/upsertObject/validation-functions.js.map +1 -0
- package/dist/destinations/klaviyo/addProfileToList/index.js +10 -1
- package/dist/destinations/klaviyo/addProfileToList/index.js.map +1 -1
- package/dist/destinations/klaviyo/functions.d.ts +22 -4
- package/dist/destinations/klaviyo/functions.js +130 -8
- package/dist/destinations/klaviyo/functions.js.map +1 -1
- package/dist/destinations/klaviyo/properties.js +2 -1
- package/dist/destinations/klaviyo/properties.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfile/index.js +12 -2
- package/dist/destinations/klaviyo/removeProfile/index.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfileFromList/index.js +10 -1
- package/dist/destinations/klaviyo/removeProfileFromList/index.js.map +1 -1
- package/dist/destinations/klaviyo/subscribeProfile/index.js +2 -1
- package/dist/destinations/klaviyo/subscribeProfile/index.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +23 -3
- package/dist/destinations/klaviyo/types.js.map +1 -1
- package/dist/destinations/klaviyo/unsubscribeProfile/index.js +2 -1
- package/dist/destinations/klaviyo/unsubscribeProfile/index.js.map +1 -1
- package/dist/destinations/klaviyo/upsertProfile/index.js +43 -19
- package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
- package/dist/destinations/responsys/shared_properties.d.ts +3 -0
- package/dist/destinations/responsys/shared_properties.js +19 -0
- package/dist/destinations/responsys/shared_properties.js.map +1 -0
- package/dist/destinations/rokt-audiences/constants.js +1 -1
- package/dist/destinations/rokt-audiences/constants.js.map +1 -1
- package/dist/destinations/rokt-audiences/generated-types.d.ts +3 -1
- package/dist/destinations/rokt-audiences/index.js +26 -10
- package/dist/destinations/rokt-audiences/index.js.map +1 -1
- package/dist/destinations/rokt-audiences/upsertCustomAudiences/custom-audience-operations.d.ts +2 -1
- package/dist/destinations/rokt-audiences/upsertCustomAudiences/custom-audience-operations.js +4 -3
- package/dist/destinations/rokt-audiences/upsertCustomAudiences/custom-audience-operations.js.map +1 -1
- package/dist/destinations/rokt-audiences/upsertCustomAudiences/index.js +4 -4
- package/dist/destinations/rokt-audiences/upsertCustomAudiences/index.js.map +1 -1
- package/dist/destinations/s3/client.d.ts +2 -1
- package/dist/destinations/s3/client.js.map +1 -1
- package/dist/destinations/s3/functions.d.ts +2 -1
- package/dist/destinations/s3/functions.js +14 -22
- package/dist/destinations/s3/functions.js.map +1 -1
- package/dist/destinations/s3/index.js +1 -1
- package/dist/destinations/s3/syncAudienceToS3/generated-types.d.ts +53 -0
- package/dist/destinations/s3/syncAudienceToS3/generated-types.js +3 -0
- package/dist/destinations/s3/syncAudienceToS3/generated-types.js.map +1 -0
- package/dist/destinations/s3/syncAudienceToS3/index.d.ts +5 -0
- package/dist/destinations/s3/syncAudienceToS3/index.js +22 -0
- package/dist/destinations/s3/syncAudienceToS3/index.js.map +1 -0
- package/dist/destinations/s3/syncEventsToS3/generated-types.d.ts +44 -0
- package/dist/destinations/s3/syncEventsToS3/generated-types.js +3 -0
- package/dist/destinations/s3/syncEventsToS3/generated-types.js.map +1 -0
- package/dist/destinations/s3/syncEventsToS3/index.d.ts +5 -0
- package/dist/destinations/s3/syncEventsToS3/index.js +19 -0
- package/dist/destinations/s3/syncEventsToS3/index.js.map +1 -0
- package/dist/destinations/s3/syncToS3.types.d.ts +44 -0
- package/dist/destinations/s3/syncToS3.types.js +3 -0
- package/dist/destinations/s3/syncToS3.types.js.map +1 -0
- package/dist/destinations/salesforce/lead/index.js +9 -0
- package/dist/destinations/salesforce/lead/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js +17 -1
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js +17 -1
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/constants.d.ts +1 -0
- package/dist/destinations/sendgrid-audiences/constants.js +2 -1
- package/dist/destinations/sendgrid-audiences/constants.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.d.ts +4 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.js +33 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/dynamic-fields.js.map +1 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/fields.js +117 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/fields.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/generated-types.d.ts +13 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/index.js +8 -0
- package/dist/destinations/sendgrid-audiences/syncAudience/index.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/utils.js +16 -1
- package/dist/destinations/sendgrid-audiences/syncAudience/utils.js.map +1 -1
- package/dist/destinations/sendgrid-audiences/types.d.ts +11 -0
- package/dist/destinations/singlestore/sendData/generated-types.d.ts +2 -0
- package/dist/destinations/singlestore/sendData/generated-types.js +3 -0
- package/dist/destinations/singlestore/sendData/generated-types.js.map +1 -0
- package/dist/destinations/singlestore/sendData/index.d.ts +5 -0
- package/dist/destinations/singlestore/sendData/index.js +65 -0
- package/dist/destinations/singlestore/sendData/index.js.map +1 -0
- package/dist/destinations/singlestore/utils.d.ts +0 -0
- package/dist/destinations/singlestore/utils.js +2 -0
- package/dist/destinations/singlestore/utils.js.map +1 -0
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js +6 -3
- package/dist/destinations/stackadapt-audiences/forwardAudienceEvent/functions.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js +11 -0
- package/dist/destinations/stackadapt-audiences/forwardProfile/functions.js.map +1 -1
- package/dist/destinations/stackadapt-audiences/index.js +29 -0
- package/dist/destinations/stackadapt-audiences/index.js.map +1 -1
- package/dist/destinations/twilio-messaging/generated-types.d.ts +6 -0
- package/dist/destinations/twilio-messaging/generated-types.js +3 -0
- package/dist/destinations/twilio-messaging/generated-types.js.map +1 -0
- package/dist/destinations/twilio-messaging/index.d.ts +4 -0
- package/dist/destinations/twilio-messaging/index.js +61 -0
- package/dist/destinations/twilio-messaging/index.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/constants.d.ts +45 -0
- package/dist/destinations/twilio-messaging/sendMessage/constants.js +99 -0
- package/dist/destinations/twilio-messaging/sendMessage/constants.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.d.ts +11 -0
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js +209 -0
- package/dist/destinations/twilio-messaging/sendMessage/dynamic-fields.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/fields.d.ts +2 -0
- package/dist/destinations/twilio-messaging/sendMessage/fields.js +261 -0
- package/dist/destinations/twilio-messaging/sendMessage/fields.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/generated-types.d.ts +24 -0
- package/dist/destinations/twilio-messaging/sendMessage/generated-types.js +3 -0
- package/dist/destinations/twilio-messaging/sendMessage/generated-types.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/index.d.ts +5 -0
- package/dist/destinations/twilio-messaging/sendMessage/index.js +42 -0
- package/dist/destinations/twilio-messaging/sendMessage/index.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/types.d.ts +34 -0
- package/dist/destinations/twilio-messaging/sendMessage/types.js +3 -0
- package/dist/destinations/twilio-messaging/sendMessage/types.js.map +1 -0
- package/dist/destinations/twilio-messaging/sendMessage/utils.d.ts +6 -0
- package/dist/destinations/twilio-messaging/sendMessage/utils.js +154 -0
- package/dist/destinations/twilio-messaging/sendMessage/utils.js.map +1 -0
- package/dist/destinations/webhook-extensible/index.js +39 -11
- package/dist/destinations/webhook-extensible/index.js.map +1 -1
- package/dist/destinations/webhook-extensible/types.d.ts +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fields = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
exports.fields = {
|
|
6
|
+
channel: {
|
|
7
|
+
label: 'Channel',
|
|
8
|
+
description: 'The channel to send the message on.',
|
|
9
|
+
type: 'string',
|
|
10
|
+
required: true,
|
|
11
|
+
choices: [
|
|
12
|
+
{ label: 'SMS', value: constants_1.CHANNELS.SMS },
|
|
13
|
+
{ label: 'MMS', value: constants_1.CHANNELS.MMS },
|
|
14
|
+
{ label: 'WhatsApp', value: constants_1.CHANNELS.WHATSAPP },
|
|
15
|
+
{ label: 'Facebook Messenger', value: constants_1.CHANNELS.MESSENGER }
|
|
16
|
+
],
|
|
17
|
+
default: constants_1.CHANNELS.MMS,
|
|
18
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
19
|
+
},
|
|
20
|
+
senderType: {
|
|
21
|
+
label: 'Sender Type',
|
|
22
|
+
description: "The Sender type to use for the message. Depending on the selected 'Channel' this can be a phone number, messaging service, or Messenger sender ID.",
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: true,
|
|
25
|
+
dynamic: true
|
|
26
|
+
},
|
|
27
|
+
contentTemplateType: {
|
|
28
|
+
label: 'Content Template Type',
|
|
29
|
+
description: 'The Content Template type to use for the message. Selecting "Inline" will allow you to define the message body directly. For all other options a Content Template must be pre-defined in Twilio.',
|
|
30
|
+
type: 'string',
|
|
31
|
+
required: true,
|
|
32
|
+
dynamic: true
|
|
33
|
+
},
|
|
34
|
+
toPhoneNumber: {
|
|
35
|
+
label: 'To Phone Number',
|
|
36
|
+
description: 'The number to send the message to (E.164 format).',
|
|
37
|
+
type: 'string',
|
|
38
|
+
required: false,
|
|
39
|
+
default: undefined,
|
|
40
|
+
depends_on: {
|
|
41
|
+
match: 'all',
|
|
42
|
+
conditions: [
|
|
43
|
+
{
|
|
44
|
+
fieldKey: 'channel',
|
|
45
|
+
operator: 'is_not',
|
|
46
|
+
value: constants_1.CHANNELS.MESSENGER
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
toMessengerPageUserId: {
|
|
52
|
+
label: 'To Messenger Page or User ID',
|
|
53
|
+
description: 'A valid Facebook Messenger Page Id or Messenger User Id to send the message to.',
|
|
54
|
+
type: 'string',
|
|
55
|
+
required: false,
|
|
56
|
+
default: undefined,
|
|
57
|
+
depends_on: {
|
|
58
|
+
match: 'all',
|
|
59
|
+
conditions: [
|
|
60
|
+
{
|
|
61
|
+
fieldKey: 'channel',
|
|
62
|
+
operator: 'is',
|
|
63
|
+
value: constants_1.CHANNELS.MESSENGER
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
fromPhoneNumber: {
|
|
69
|
+
label: 'From Phone Number',
|
|
70
|
+
description: "The Twilio phone number (E.164 format) or Short Code. If not in the dropdown, enter it directly. Please ensure the number supports the selected 'Channel' type.",
|
|
71
|
+
type: 'string',
|
|
72
|
+
dynamic: true,
|
|
73
|
+
required: false,
|
|
74
|
+
default: undefined,
|
|
75
|
+
depends_on: {
|
|
76
|
+
match: 'all',
|
|
77
|
+
conditions: [
|
|
78
|
+
{
|
|
79
|
+
fieldKey: 'senderType',
|
|
80
|
+
operator: 'is',
|
|
81
|
+
value: constants_1.SENDER_TYPE.PHONE_NUMBER
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
fromMessengerSenderId: {
|
|
87
|
+
label: 'From Messenger Sender ID',
|
|
88
|
+
description: "The unique identifier for your Facebook Page, used to send messages via Messenger. You can find this in your Facebook Page settings.",
|
|
89
|
+
type: 'string',
|
|
90
|
+
required: false,
|
|
91
|
+
default: undefined,
|
|
92
|
+
depends_on: {
|
|
93
|
+
match: 'all',
|
|
94
|
+
conditions: [
|
|
95
|
+
{
|
|
96
|
+
fieldKey: 'senderType',
|
|
97
|
+
operator: 'is',
|
|
98
|
+
value: constants_1.SENDER_TYPE.MESSENGER_SENDER_ID
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
messagingServiceSid: {
|
|
104
|
+
label: 'Messaging Service SID',
|
|
105
|
+
description: 'The SID of the messaging service to use. If not in the dropdown, enter it directly.',
|
|
106
|
+
type: 'string',
|
|
107
|
+
dynamic: true,
|
|
108
|
+
required: false,
|
|
109
|
+
default: undefined,
|
|
110
|
+
allowNull: false,
|
|
111
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
|
|
112
|
+
depends_on: {
|
|
113
|
+
match: 'all',
|
|
114
|
+
conditions: [
|
|
115
|
+
{
|
|
116
|
+
fieldKey: 'senderType',
|
|
117
|
+
operator: 'is',
|
|
118
|
+
value: constants_1.SENDER_TYPE.MESSAGING_SERVICE
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
contentSid: {
|
|
124
|
+
label: 'Content Template SID',
|
|
125
|
+
description: 'The SID of the Content Template to use.',
|
|
126
|
+
type: 'string',
|
|
127
|
+
dynamic: true,
|
|
128
|
+
required: false,
|
|
129
|
+
allowNull: false,
|
|
130
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
|
|
131
|
+
depends_on: {
|
|
132
|
+
match: 'all',
|
|
133
|
+
conditions: [
|
|
134
|
+
{
|
|
135
|
+
fieldKey: 'contentTemplateType',
|
|
136
|
+
operator: 'is_not',
|
|
137
|
+
value: constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
mediaUrls: {
|
|
143
|
+
label: 'Media URLs',
|
|
144
|
+
description: 'The URLs of the media to include with the message. The URLs should be configured in the Content Template in Twilio.',
|
|
145
|
+
type: 'object',
|
|
146
|
+
multiple: true,
|
|
147
|
+
required: false,
|
|
148
|
+
properties: {
|
|
149
|
+
url: {
|
|
150
|
+
label: 'URL',
|
|
151
|
+
type: 'string',
|
|
152
|
+
description: 'The URL of the media to include with the message.',
|
|
153
|
+
required: true,
|
|
154
|
+
dynamic: true,
|
|
155
|
+
allowNull: false,
|
|
156
|
+
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment']
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
depends_on: {
|
|
160
|
+
match: 'all',
|
|
161
|
+
conditions: [
|
|
162
|
+
{
|
|
163
|
+
fieldKey: 'contentTemplateType',
|
|
164
|
+
operator: 'is',
|
|
165
|
+
value: constants_1.CONTENT_TYPE_FRIENDLY_NAMES_SUPPORTING_MEDIA
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
contentVariables: {
|
|
171
|
+
label: 'Content Variables',
|
|
172
|
+
description: 'Variables to be used in the Content Template. The Variables must be defined in the Content Template in Twilio.',
|
|
173
|
+
type: 'object',
|
|
174
|
+
dynamic: true,
|
|
175
|
+
required: false,
|
|
176
|
+
defaultObjectUI: 'keyvalue',
|
|
177
|
+
additionalProperties: true,
|
|
178
|
+
depends_on: {
|
|
179
|
+
match: 'all',
|
|
180
|
+
conditions: [
|
|
181
|
+
{
|
|
182
|
+
fieldKey: 'contentTemplateType',
|
|
183
|
+
operator: 'is_not',
|
|
184
|
+
value: constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
inlineBody: {
|
|
190
|
+
label: 'Inline Template',
|
|
191
|
+
description: 'Define an inline message body to be sent. Variables values can be referenced using {{variable}} format. e.g. Hello {{first_name}}!.',
|
|
192
|
+
type: 'text',
|
|
193
|
+
format: 'text',
|
|
194
|
+
required: false,
|
|
195
|
+
default: undefined,
|
|
196
|
+
depends_on: {
|
|
197
|
+
match: 'all',
|
|
198
|
+
conditions: [
|
|
199
|
+
{
|
|
200
|
+
fieldKey: 'contentTemplateType',
|
|
201
|
+
operator: 'is',
|
|
202
|
+
value: constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
inlineMediaUrls: {
|
|
208
|
+
label: 'Inline Media URLs',
|
|
209
|
+
description: 'The URLs of the media to sent with the inline message. The URLs must be publicaly accessible.',
|
|
210
|
+
type: 'string',
|
|
211
|
+
multiple: true,
|
|
212
|
+
required: false,
|
|
213
|
+
depends_on: {
|
|
214
|
+
match: 'all',
|
|
215
|
+
conditions: [
|
|
216
|
+
{
|
|
217
|
+
fieldKey: 'contentTemplateType',
|
|
218
|
+
operator: 'is',
|
|
219
|
+
value: constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
inlineVariables: {
|
|
225
|
+
label: 'Inline Variables',
|
|
226
|
+
description: "Variables to be send with the inline message. e.g. 'first_name' would match with {{first_name}} in the Inline Template message body.",
|
|
227
|
+
type: 'object',
|
|
228
|
+
required: false,
|
|
229
|
+
defaultObjectUI: 'keyvalue',
|
|
230
|
+
additionalProperties: true,
|
|
231
|
+
default: undefined,
|
|
232
|
+
depends_on: {
|
|
233
|
+
match: 'all',
|
|
234
|
+
conditions: [
|
|
235
|
+
{
|
|
236
|
+
fieldKey: 'contentTemplateType',
|
|
237
|
+
operator: 'is',
|
|
238
|
+
value: constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
validityPeriod: {
|
|
244
|
+
label: 'Validity Period',
|
|
245
|
+
description: 'The number of seconds between 1-14400 that the message is valid for. Default is 14400. If the message is not delivered within this time, it will not be delivered.',
|
|
246
|
+
type: 'number',
|
|
247
|
+
required: false,
|
|
248
|
+
minimum: 1,
|
|
249
|
+
maximum: 14400,
|
|
250
|
+
default: undefined
|
|
251
|
+
},
|
|
252
|
+
sendAt: {
|
|
253
|
+
label: 'Send At',
|
|
254
|
+
description: 'The time that Twilio will send the message. Must be in ISO 8601 format.',
|
|
255
|
+
type: 'string',
|
|
256
|
+
format: 'date-time',
|
|
257
|
+
required: false,
|
|
258
|
+
default: undefined
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/fields.ts"],"names":[],"mappings":";;;AACA,2CAAoH;AAEvG,QAAA,MAAM,GAA+B;IAChD,OAAO,EAAE;QACP,KAAK,EAAE,SAAS;QAChB,WAAW,EAAE,qCAAqC;QAClD,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAQ,CAAC,GAAG,EAAE;YACrC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAQ,CAAC,GAAG,EAAE;YACrC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,oBAAQ,CAAC,QAAQ,EAAE;YAC/C,EAAE,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAQ,CAAC,SAAS,EAAE;SAC3D;QACD,OAAO,EAAE,oBAAQ,CAAC,GAAG;QACrB,oBAAoB,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC;KACpF;IACD,UAAU,EAAE;QACV,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,oJAAoJ;QACjK,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd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emplateType: string;
|
|
5
|
+
toPhoneNumber?: string;
|
|
6
|
+
toMessengerPageUserId?: string;
|
|
7
|
+
fromPhoneNumber?: string;
|
|
8
|
+
fromMessengerSenderId?: string;
|
|
9
|
+
messagingServiceSid?: string;
|
|
10
|
+
contentSid?: string;
|
|
11
|
+
mediaUrls?: {
|
|
12
|
+
url: string;
|
|
13
|
+
}[];
|
|
14
|
+
contentVariables?: {
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
inlineBody?: string;
|
|
18
|
+
inlineMediaUrls?: string[];
|
|
19
|
+
inlineVariables?: {
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
validityPeriod?: number;
|
|
23
|
+
sendAt?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fields_1 = require("./fields");
|
|
4
|
+
const dynamic_fields_1 = require("./dynamic-fields");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Send message',
|
|
8
|
+
description: "Send messages with Twilio's REST API.",
|
|
9
|
+
fields: fields_1.fields,
|
|
10
|
+
dynamicFields: {
|
|
11
|
+
senderType: async (_, { payload }) => {
|
|
12
|
+
return await dynamic_fields_1.dynamicSenderType(payload);
|
|
13
|
+
},
|
|
14
|
+
fromPhoneNumber: async (request, { payload, settings }) => {
|
|
15
|
+
return await dynamic_fields_1.dynamicFromPhoneNumber(request, payload, settings);
|
|
16
|
+
},
|
|
17
|
+
messagingServiceSid: async (request, { settings }) => {
|
|
18
|
+
return await dynamic_fields_1.dynamicMessagingServiceSid(request, settings);
|
|
19
|
+
},
|
|
20
|
+
contentTemplateType: async (_, { payload }) => {
|
|
21
|
+
return await dynamic_fields_1.dynamicContentTemplateType(payload);
|
|
22
|
+
},
|
|
23
|
+
contentSid: async (request, { payload }) => {
|
|
24
|
+
return await dynamic_fields_1.dynamicContentSid(request, payload);
|
|
25
|
+
},
|
|
26
|
+
mediaUrls: {
|
|
27
|
+
url: async (request, { payload }) => {
|
|
28
|
+
return await dynamic_fields_1.dynamicMediaUrls(request, payload);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
contentVariables: {
|
|
32
|
+
__keys__: async (request, { payload }) => {
|
|
33
|
+
return await dynamic_fields_1.dynamicContentVariables(request, payload);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
perform: async (request, { payload, settings }) => {
|
|
38
|
+
return await utils_1.send(request, payload, settings);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
exports.default = action;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/index.ts"],"names":[],"mappings":";;AAGA,qCAAiC;AACjC,qDAQyB;AACzB,mCAA8B;AAE9B,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,uCAAuC;IACpD,MAAM,EAAN,eAAM;IACN,aAAa,EAAE;QACb,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YACnC,OAAO,MAAM,kCAAiB,CAAC,OAAO,CAAC,CAAA;QACzC,CAAC;QACD,eAAe,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;YACxD,OAAO,MAAM,uCAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACjE,CAAC;QACD,mBAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YACnD,OAAO,MAAM,2CAA0B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QAC5D,CAAC;QACD,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC5C,OAAO,MAAM,2CAA0B,CAAC,OAAO,CAAC,CAAA;QAClD,CAAC;QACD,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YACzC,OAAO,MAAM,kCAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAClD,CAAC;QACD,SAAS,EAAE;YACT,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBAClC,OAAO,MAAM,iCAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACjD,CAAC;SACF;QACD,gBAAgB,EAAE;YAChB,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBACvC,OAAO,MAAM,wCAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACxD,CAAC;SACF;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAChD,OAAO,MAAM,YAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;IAC/C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PREDEFINED_CONTENT_TYPES, CHANNELS } from './constants';
|
|
2
|
+
export declare type TwilioPayload = {
|
|
3
|
+
To: string;
|
|
4
|
+
SendAt?: string;
|
|
5
|
+
ValidityPeriod?: number;
|
|
6
|
+
MediaUrl?: string[];
|
|
7
|
+
} & Sender & Content;
|
|
8
|
+
export declare type Sender = FromPhone | FromMessagingService;
|
|
9
|
+
declare type FromMessagingService = {
|
|
10
|
+
MessagingServiceSid: string;
|
|
11
|
+
};
|
|
12
|
+
declare type FromPhone = {
|
|
13
|
+
From: string;
|
|
14
|
+
};
|
|
15
|
+
export declare type Content = ContentTemplateMessage | InlineMessage;
|
|
16
|
+
declare type ContentTemplateMessage = {
|
|
17
|
+
ContentSid: string;
|
|
18
|
+
ContentVariables?: string;
|
|
19
|
+
};
|
|
20
|
+
declare type InlineMessage = {
|
|
21
|
+
Body: string;
|
|
22
|
+
};
|
|
23
|
+
export declare type PredefinedContentTypes = {
|
|
24
|
+
[key: string]: PredefinedContentTypeItem;
|
|
25
|
+
};
|
|
26
|
+
export declare type Channel = typeof CHANNELS[keyof typeof CHANNELS];
|
|
27
|
+
export declare type PredefinedContentTypeItem = {
|
|
28
|
+
friendly_name: string;
|
|
29
|
+
name: string;
|
|
30
|
+
supports_media: boolean;
|
|
31
|
+
supported_channels: Array<Channel>;
|
|
32
|
+
};
|
|
33
|
+
export declare type ContentTypeName = typeof PREDEFINED_CONTENT_TYPES[keyof typeof PREDEFINED_CONTENT_TYPES]['name'];
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { Payload } from './generated-types';
|
|
3
|
+
import { Settings } from '../generated-types';
|
|
4
|
+
export declare function send(request: RequestClient, payload: Payload, settings: Settings): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
5
|
+
export declare function parseFieldValue(value: string | undefined | null): string | undefined;
|
|
6
|
+
export declare function validateContentSid(contentSid: string): boolean;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateContentSid = exports.parseFieldValue = exports.send = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
async function send(request, payload, settings) {
|
|
7
|
+
let { toPhoneNumber, fromPhoneNumber, fromMessengerSenderId, messagingServiceSid, contentSid } = payload;
|
|
8
|
+
const { channel, senderType, toMessengerPageUserId, contentTemplateType, contentVariables, inlineBody, inlineVariables, validityPeriod, sendAt, mediaUrls, inlineMediaUrls } = payload;
|
|
9
|
+
const getTo = () => {
|
|
10
|
+
switch (channel) {
|
|
11
|
+
case 'SMS':
|
|
12
|
+
case 'MMS': {
|
|
13
|
+
toPhoneNumber = toPhoneNumber?.trim() ?? '';
|
|
14
|
+
if (!(constants_1.E164_REGEX.test(toPhoneNumber) || constants_1.TWILIO_SHORT_CODE_REGEX.test(toPhoneNumber))) {
|
|
15
|
+
throw new actions_core_1.PayloadValidationError("'To' field should be a valid phone number in E.164 format or a Twilio Short Code");
|
|
16
|
+
}
|
|
17
|
+
return toPhoneNumber;
|
|
18
|
+
}
|
|
19
|
+
case 'Whatsapp': {
|
|
20
|
+
toPhoneNumber = toPhoneNumber?.trim() ?? '';
|
|
21
|
+
if (!constants_1.E164_REGEX.test(toPhoneNumber)) {
|
|
22
|
+
throw new actions_core_1.PayloadValidationError("'To' field should be a valid phone number in E.164 format");
|
|
23
|
+
}
|
|
24
|
+
return `whatsapp:${toPhoneNumber}`;
|
|
25
|
+
}
|
|
26
|
+
case 'Messenger': {
|
|
27
|
+
if (!toMessengerPageUserId) {
|
|
28
|
+
throw new actions_core_1.PayloadValidationError("'Messenger Page or User ID' field is required when Channel field set to 'Messenger'");
|
|
29
|
+
}
|
|
30
|
+
return `messenger:${toMessengerPageUserId.trim()}`;
|
|
31
|
+
}
|
|
32
|
+
default: {
|
|
33
|
+
throw new actions_core_1.PayloadValidationError('Unsupported Channel');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const getSendAt = () => (sendAt ? { SendAt: sendAt } : {});
|
|
38
|
+
const getValidityPeriod = () => (validityPeriod ? { ValidityPeriod: validityPeriod } : {});
|
|
39
|
+
const getSender = () => {
|
|
40
|
+
if (senderType === constants_1.SENDER_TYPE.PHONE_NUMBER) {
|
|
41
|
+
fromPhoneNumber = fromPhoneNumber?.trim();
|
|
42
|
+
if (!fromPhoneNumber) {
|
|
43
|
+
throw new actions_core_1.PayloadValidationError("'From Phone Number' field is required when sending from a phone number.");
|
|
44
|
+
}
|
|
45
|
+
if (!constants_1.E164_REGEX.test(fromPhoneNumber)) {
|
|
46
|
+
throw new actions_core_1.PayloadValidationError("'From' field should be a valid phone number in E.164 format");
|
|
47
|
+
}
|
|
48
|
+
return channel === constants_1.CHANNELS.WHATSAPP ? { From: `whatsapp:${fromPhoneNumber}` } : { From: fromPhoneNumber };
|
|
49
|
+
}
|
|
50
|
+
if (senderType === constants_1.SENDER_TYPE.MESSENGER_SENDER_ID) {
|
|
51
|
+
fromMessengerSenderId = fromMessengerSenderId?.trim();
|
|
52
|
+
if (!fromMessengerSenderId) {
|
|
53
|
+
throw new actions_core_1.PayloadValidationError("'From Messenger Sender ID' field is required when sending from a Messenger Sender ID.");
|
|
54
|
+
}
|
|
55
|
+
return { From: `messenger:${fromMessengerSenderId}` };
|
|
56
|
+
}
|
|
57
|
+
if (senderType === constants_1.SENDER_TYPE.MESSAGING_SERVICE) {
|
|
58
|
+
messagingServiceSid = parseFieldValue(messagingServiceSid);
|
|
59
|
+
if (!messagingServiceSid) {
|
|
60
|
+
throw new actions_core_1.PayloadValidationError("'Messaging Service SID' field is required when 'Choose Sender' field = Messaging Service SID");
|
|
61
|
+
}
|
|
62
|
+
if (!constants_1.MESSAGING_SERVICE_SID_REGEX.test(messagingServiceSid ?? '')) {
|
|
63
|
+
throw new actions_core_1.PayloadValidationError("'Messaging Service SID' field value should start with 'MG' followed by 32 hexadecimal characters, totaling 34 characters.");
|
|
64
|
+
}
|
|
65
|
+
return { MessagingServiceSid: messagingServiceSid };
|
|
66
|
+
}
|
|
67
|
+
throw new actions_core_1.PayloadValidationError('Unsupported Sender Type');
|
|
68
|
+
};
|
|
69
|
+
const getContent = () => {
|
|
70
|
+
contentSid = parseFieldValue(contentSid);
|
|
71
|
+
if (contentSid && !constants_1.CONTENT_SID_REGEX.test(contentSid)) {
|
|
72
|
+
throw new actions_core_1.PayloadValidationError("Content SID should start with 'HX' followed by 32 hexadecimal characters.");
|
|
73
|
+
}
|
|
74
|
+
if (contentTemplateType === constants_1.INLINE_CONTENT_TYPES.INLINE.friendly_name && inlineBody) {
|
|
75
|
+
return { Body: encodeURIComponent(replaceTokens(inlineBody, inlineVariables)) };
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return {
|
|
79
|
+
ContentSid: contentSid,
|
|
80
|
+
...(Object.keys(contentVariables ?? {}).length > 0 && { ContentVariables: JSON.stringify(contentVariables) })
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const getMediaUrl = () => {
|
|
85
|
+
const supportsMedia = Object.values(constants_1.ALL_CONTENT_TYPES).find((type) => type.supports_media);
|
|
86
|
+
if (supportsMedia) {
|
|
87
|
+
const urls = contentTemplateType === constants_1.ALL_CONTENT_TYPES.INLINE.friendly_name
|
|
88
|
+
? inlineMediaUrls
|
|
89
|
+
?.filter((item) => item.trim() !== '')
|
|
90
|
+
.map((item) => replaceTokens(item.trim(), inlineVariables)) ?? []
|
|
91
|
+
: mediaUrls?.map((item) => item.url.trim()) ?? [];
|
|
92
|
+
if (urls.length > 10) {
|
|
93
|
+
throw new actions_core_1.PayloadValidationError('Media URL cannot contain more than 10 URLs');
|
|
94
|
+
}
|
|
95
|
+
urls
|
|
96
|
+
.filter((url) => url.trim() !== '')
|
|
97
|
+
.some((url) => {
|
|
98
|
+
try {
|
|
99
|
+
new URL(url);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw new actions_core_1.PayloadValidationError(`Media URL ${url} is not a valid URL.`);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return urls.length > 0 ? { MediaUrl: urls } : {};
|
|
107
|
+
}
|
|
108
|
+
return {};
|
|
109
|
+
};
|
|
110
|
+
const twilioPayload = (() => ({
|
|
111
|
+
To: getTo(),
|
|
112
|
+
...getSendAt(),
|
|
113
|
+
...getValidityPeriod(),
|
|
114
|
+
...getSender(),
|
|
115
|
+
...getContent(),
|
|
116
|
+
...getMediaUrl()
|
|
117
|
+
}))();
|
|
118
|
+
const encodedBody = encode(twilioPayload);
|
|
119
|
+
return await request(constants_1.SEND_SMS_URL.replace(constants_1.ACCOUNT_SID_TOKEN, settings.accountSID), {
|
|
120
|
+
method: 'post',
|
|
121
|
+
body: encodedBody
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
exports.send = send;
|
|
125
|
+
function parseFieldValue(value) {
|
|
126
|
+
if (!value) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
const match = constants_1.FIELD_REGEX.exec(value);
|
|
130
|
+
return match ? match[1] : value;
|
|
131
|
+
}
|
|
132
|
+
exports.parseFieldValue = parseFieldValue;
|
|
133
|
+
function replaceTokens(str, tokens) {
|
|
134
|
+
return str.replace(constants_1.TOKEN_REGEX, (_, key) => String(tokens?.[key] ?? ''));
|
|
135
|
+
}
|
|
136
|
+
function encode(twilioPayload) {
|
|
137
|
+
const encodedSmsBody = new URLSearchParams();
|
|
138
|
+
Object.entries(twilioPayload).forEach(([key, value]) => {
|
|
139
|
+
if (key === 'MediaUrl' && Array.isArray(value)) {
|
|
140
|
+
value.forEach((url) => {
|
|
141
|
+
encodedSmsBody.append(`MediaUrl`, url);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
encodedSmsBody.append(key, String(value));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
return encodedSmsBody.toString();
|
|
149
|
+
}
|
|
150
|
+
function validateContentSid(contentSid) {
|
|
151
|
+
return /^HX[0-9a-fA-F]{32}$/.test(contentSid);
|
|
152
|
+
}
|
|
153
|
+
exports.validateContentSid = validateContentSid;
|
|
154
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/destinations/twilio-messaging/sendMessage/utils.ts"],"names":[],"mappings":";;;AAAA,wDAA6E;AAG7E,2CAaoB;AAGb,KAAK,UAAU,IAAI,CAAC,OAAsB,EAAE,OAAgB,EAAE,QAAkB;IACrF,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,UAAU,EAAE,GAAG,OAAO,CAAA;IAExG,MAAM,EACJ,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,cAAc,EACd,MAAM,EACN,SAAS,EACT,eAAe,EAChB,GAAG,OAAO,CAAA;IAEX,MAAM,KAAK,GAAG,GAAW,EAAE;QACzB,QAAQ,OAAO,EAAE;YACf,KAAK,KAAK,CAAC;YACX,KAAK,KAAK,CAAC,CAAC;gBACV,aAAa,GAAG,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;gBAC3C,IAAI,CAAC,CAAC,sBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,mCAAuB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE;oBACpF,MAAM,IAAI,qCAAsB,CAAC,kFAAkF,CAAC,CAAC;iBACtH;gBACD,OAAO,aAAa,CAAA;aACrB;YACD,KAAK,UAAU,CAAC,CAAC;gBACf,aAAa,GAAG,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;gBAC3C,IAAI,CAAC,sBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;oBACnC,MAAM,IAAI,qCAAsB,CAAC,2DAA2D,CAAC,CAAA;iBAC9F;gBACD,OAAO,YAAY,aAAa,EAAE,CAAA;aACnC;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AAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC9C,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACpB,cAAc,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;YACxC,CAAC,CAAC,CAAA;SACH;aAAM;YACL,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;SAC1C;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,cAAc,CAAC,QAAQ,EAAE,CAAA;AAClC,CAAC;AACD,SAAgB,kBAAkB,CAAC,UAAkB;IACnD,OAAO,qBAAqB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;AAC/C,CAAC;AAFD,gDAEC"}
|
|
@@ -18,20 +18,48 @@ const destination = {
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
refreshAccessToken: async (request, { settings, auth }) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
let res;
|
|
22
|
+
const { clientId, clientSecret } = auth;
|
|
23
|
+
const { oauth } = settings.dynamicAuthSettings;
|
|
24
|
+
if (oauth.type === 'authCode') {
|
|
25
|
+
res = await request(oauth.refreshTokenServerUrl, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
headers: {
|
|
28
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
29
|
+
Authorization: `Basic ${Buffer.from(clientId + ':' + clientSecret).toString('base64')}`
|
|
30
|
+
},
|
|
31
|
+
body: new URLSearchParams({
|
|
32
|
+
grant_type: 'refresh_token',
|
|
33
|
+
refresh_token: auth.refreshToken ?? oauth.access.refresh_token,
|
|
34
|
+
scope: oauth.scopes,
|
|
35
|
+
client_id: clientId,
|
|
36
|
+
client_secret: clientSecret
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
accessToken: res.data.access_token,
|
|
41
|
+
refreshToken: res.data.refresh_token
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
res = await request(oauth.refreshTokenServerUrl, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
49
|
+
Authorization: `Basic ${Buffer.from(clientId + ':' + clientSecret).toString('base64')}`
|
|
50
|
+
},
|
|
51
|
+
body: new URLSearchParams({
|
|
52
|
+
grant_type: 'client_credentials',
|
|
53
|
+
scope: oauth.scopes
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
return { accessToken: res.data.access_token };
|
|
57
|
+
}
|
|
30
58
|
}
|
|
31
59
|
},
|
|
32
|
-
extendRequest: ({ settings }) => {
|
|
60
|
+
extendRequest: ({ settings, auth }) => {
|
|
33
61
|
const { dynamicAuthSettings } = settings;
|
|
34
|
-
const accessToken = dynamicAuthSettings?.oauth?.access?.access_token;
|
|
62
|
+
const accessToken = auth?.accessToken ?? dynamicAuthSettings?.oauth?.access?.access_token;
|
|
35
63
|
return {
|
|
36
64
|
headers: {
|
|
37
65
|
authorization: `Bearer ${accessToken}`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/webhook-extensible/index.ts"],"names":[],"mappings":";;;;;AAIA,kDAAyB;AAKzB,MAAM,WAAW,GAAmD;IAClE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,OAAO;IACb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,YAAY,EAAE;gBACZ,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,eAAe;gBACtB,WAAW,EACT,mLAAmL;aACtL;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,E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