@memberjunction/communication-twilio 2.33.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.
- package/dist/TwilioProvider.js +268 -0
- package/dist/TwilioProvider.js.map +1 -0
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.LoadProvider = exports.TwilioProvider = void 0;
|
|
39
|
+
const communication_types_1 = require("@memberjunction/communication-types");
|
|
40
|
+
const global_1 = require("@memberjunction/global");
|
|
41
|
+
const core_1 = require("@memberjunction/core");
|
|
42
|
+
const twilio_1 = __importDefault(require("twilio"));
|
|
43
|
+
const Config = __importStar(require("./config"));
|
|
44
|
+
let TwilioProvider = class TwilioProvider extends communication_types_1.BaseCommunicationProvider {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.twilioClient = (0, twilio_1.default)(Config.TWILIO_ACCOUNT_SID, Config.TWILIO_AUTH_TOKEN);
|
|
48
|
+
}
|
|
49
|
+
getChannelType(to) {
|
|
50
|
+
if (to.startsWith('whatsapp:')) {
|
|
51
|
+
return 'whatsapp';
|
|
52
|
+
}
|
|
53
|
+
else if (to.startsWith('messenger:')) {
|
|
54
|
+
return 'messenger';
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return 'sms';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
formatFrom(channelType) {
|
|
61
|
+
switch (channelType) {
|
|
62
|
+
case 'whatsapp':
|
|
63
|
+
return Config.TWILIO_WHATSAPP_NUMBER ? `whatsapp:${Config.TWILIO_WHATSAPP_NUMBER}` : '';
|
|
64
|
+
case 'messenger':
|
|
65
|
+
return Config.TWILIO_FACEBOOK_PAGE_ID ? `messenger:${Config.TWILIO_FACEBOOK_PAGE_ID}` : '';
|
|
66
|
+
case 'sms':
|
|
67
|
+
default:
|
|
68
|
+
return Config.TWILIO_PHONE_NUMBER;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
formatTo(to, channelType) {
|
|
72
|
+
if (to.startsWith('whatsapp:') || to.startsWith('messenger:')) {
|
|
73
|
+
return to;
|
|
74
|
+
}
|
|
75
|
+
switch (channelType) {
|
|
76
|
+
case 'whatsapp':
|
|
77
|
+
return `whatsapp:${to}`;
|
|
78
|
+
case 'messenger':
|
|
79
|
+
return `messenger:${to}`;
|
|
80
|
+
case 'sms':
|
|
81
|
+
default:
|
|
82
|
+
return to;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async SendSingleMessage(message) {
|
|
86
|
+
try {
|
|
87
|
+
if (!message.To) {
|
|
88
|
+
return {
|
|
89
|
+
Message: message,
|
|
90
|
+
Success: false,
|
|
91
|
+
Error: 'Recipient not specified'
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const channelType = this.getChannelType(message.To);
|
|
95
|
+
const from = message.From || this.formatFrom(channelType);
|
|
96
|
+
const to = this.formatTo(message.To, channelType);
|
|
97
|
+
if (!from) {
|
|
98
|
+
return {
|
|
99
|
+
Message: message,
|
|
100
|
+
Success: false,
|
|
101
|
+
Error: `${channelType.toUpperCase()} sender not configured`
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const body = message.ProcessedBody || '';
|
|
105
|
+
const mediaUrls = message.ContextData?.mediaUrls || [];
|
|
106
|
+
const result = await this.twilioClient.messages.create({
|
|
107
|
+
body,
|
|
108
|
+
from,
|
|
109
|
+
to,
|
|
110
|
+
...(mediaUrls.length > 0 && { mediaUrl: mediaUrls })
|
|
111
|
+
});
|
|
112
|
+
(0, core_1.LogStatus)(`${channelType.toUpperCase()} message sent via Twilio (SID: ${result.sid})`);
|
|
113
|
+
return {
|
|
114
|
+
Message: message,
|
|
115
|
+
Success: true,
|
|
116
|
+
Error: ''
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
(0, core_1.LogError)('Error sending message via Twilio', undefined, error);
|
|
121
|
+
return {
|
|
122
|
+
Message: message,
|
|
123
|
+
Success: false,
|
|
124
|
+
Error: error.message || 'Error sending message'
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async GetMessages(params) {
|
|
129
|
+
try {
|
|
130
|
+
const queryParams = {
|
|
131
|
+
limit: params.NumMessages
|
|
132
|
+
};
|
|
133
|
+
if (params.ContextData) {
|
|
134
|
+
if (params.ContextData.dateSent) {
|
|
135
|
+
queryParams.dateSent = params.ContextData.dateSent;
|
|
136
|
+
}
|
|
137
|
+
if (params.ContextData.from) {
|
|
138
|
+
queryParams.from = params.ContextData.from;
|
|
139
|
+
}
|
|
140
|
+
if (params.ContextData.to) {
|
|
141
|
+
queryParams.to = params.ContextData.to;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const messages = await this.twilioClient.messages.list(queryParams);
|
|
145
|
+
const formattedMessages = messages.map((message) => {
|
|
146
|
+
return {
|
|
147
|
+
From: message.from || '',
|
|
148
|
+
To: message.to || '',
|
|
149
|
+
Body: message.body || '',
|
|
150
|
+
ExternalSystemRecordID: message.sid,
|
|
151
|
+
Subject: '',
|
|
152
|
+
ThreadID: message.sid
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
Success: true,
|
|
157
|
+
Messages: formattedMessages,
|
|
158
|
+
SourceData: messages
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
(0, core_1.LogError)('Error fetching messages from Twilio', undefined, error);
|
|
163
|
+
return {
|
|
164
|
+
Success: false,
|
|
165
|
+
Messages: [],
|
|
166
|
+
ErrorMessage: error.message || 'Error fetching messages'
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
async ReplyToMessage(params) {
|
|
171
|
+
try {
|
|
172
|
+
if (!params.MessageID) {
|
|
173
|
+
return {
|
|
174
|
+
Success: false,
|
|
175
|
+
ErrorMessage: 'Message ID not provided'
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const originalMessage = await this.twilioClient.messages(params.MessageID).fetch();
|
|
179
|
+
if (!originalMessage) {
|
|
180
|
+
return {
|
|
181
|
+
Success: false,
|
|
182
|
+
ErrorMessage: 'Original message not found'
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const to = originalMessage.from || '';
|
|
186
|
+
if (!to) {
|
|
187
|
+
return {
|
|
188
|
+
Success: false,
|
|
189
|
+
ErrorMessage: 'Could not determine recipient for reply'
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const channelType = this.getChannelType(to);
|
|
193
|
+
const from = params.Message.From || this.formatFrom(channelType);
|
|
194
|
+
const body = params.Message.ProcessedBody || '';
|
|
195
|
+
const mediaUrls = params.Message.ContextData?.mediaUrls || [];
|
|
196
|
+
const result = await this.twilioClient.messages.create({
|
|
197
|
+
body,
|
|
198
|
+
from,
|
|
199
|
+
to,
|
|
200
|
+
...(mediaUrls.length > 0 && { mediaUrl: mediaUrls })
|
|
201
|
+
});
|
|
202
|
+
return {
|
|
203
|
+
Success: true,
|
|
204
|
+
Result: result
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
(0, core_1.LogError)('Error replying to message via Twilio', undefined, error);
|
|
209
|
+
return {
|
|
210
|
+
Success: false,
|
|
211
|
+
ErrorMessage: error.message || 'Error replying to message'
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async ForwardMessage(params) {
|
|
216
|
+
try {
|
|
217
|
+
if (!params.MessageID || !params.ToRecipients || params.ToRecipients.length === 0) {
|
|
218
|
+
return {
|
|
219
|
+
Success: false,
|
|
220
|
+
ErrorMessage: 'Message ID or recipients not provided'
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const originalMessage = await this.twilioClient.messages(params.MessageID).fetch();
|
|
224
|
+
if (!originalMessage) {
|
|
225
|
+
return {
|
|
226
|
+
Success: false,
|
|
227
|
+
ErrorMessage: 'Original message not found'
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const forwardPrefix = 'Forwarded message:\n';
|
|
231
|
+
const originalSender = `From: ${originalMessage.from}\n`;
|
|
232
|
+
const originalContent = originalMessage.body || '';
|
|
233
|
+
const forwardComment = params.Message ? `${params.Message}\n\n` : '';
|
|
234
|
+
const body = `${forwardComment}${forwardPrefix}${originalSender}${originalContent}`;
|
|
235
|
+
const results = await Promise.all(params.ToRecipients.map(async (recipient) => {
|
|
236
|
+
const channelType = this.getChannelType(recipient);
|
|
237
|
+
const from = this.formatFrom(channelType);
|
|
238
|
+
const to = this.formatTo(recipient, channelType);
|
|
239
|
+
return this.twilioClient.messages.create({
|
|
240
|
+
body,
|
|
241
|
+
from,
|
|
242
|
+
to,
|
|
243
|
+
...(originalMessage.numMedia !== '0' && { mediaUrl: [originalMessage.uri] })
|
|
244
|
+
});
|
|
245
|
+
}));
|
|
246
|
+
return {
|
|
247
|
+
Success: true,
|
|
248
|
+
Result: results
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
(0, core_1.LogError)('Error forwarding message via Twilio', undefined, error);
|
|
253
|
+
return {
|
|
254
|
+
Success: false,
|
|
255
|
+
ErrorMessage: error.message || 'Error forwarding message'
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
exports.TwilioProvider = TwilioProvider;
|
|
261
|
+
exports.TwilioProvider = TwilioProvider = __decorate([
|
|
262
|
+
(0, global_1.RegisterClass)(communication_types_1.BaseCommunicationProvider, 'Twilio'),
|
|
263
|
+
__metadata("design:paramtypes", [])
|
|
264
|
+
], TwilioProvider);
|
|
265
|
+
function LoadProvider() {
|
|
266
|
+
}
|
|
267
|
+
exports.LoadProvider = LoadProvider;
|
|
268
|
+
//# sourceMappingURL=TwilioProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TwilioProvider.js","sourceRoot":"","sources":["../src/TwilioProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAA+O;AAC/O,mDAAuD;AACvD,+CAA2D;AAC3D,oDAA4B;AAC5B,iDAAmC;AAM5B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,+CAAyB;IAG3D;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,IAAA,gBAAM,EAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAClF,CAAC;IAKO,cAAc,CAAC,EAAU;QAC/B,IAAI,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,OAAO,UAAU,CAAC;QACpB,CAAC;aAAM,IAAI,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,OAAO,WAAW,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAKO,UAAU,CAAC,WAA6C;QAC9D,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,UAAU;gBACb,OAAO,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1F,KAAK,WAAW;gBACd,OAAO,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAAE,CAA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AC,MAAM,CAAC;oBACvC,IAAI;oBACJ,IAAI;oBACJ,EAAE;oBAEF,GAAG,CAAC,eAAe,CAAC,QAAQ,KAAK,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;iBAC7E,CAAC,CAAC;YACL,CAAC,CAAC,CAAC,CAAC;YAEJ,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,OAAO;aAChB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAA,eAAQ,EAAC,qCAAqC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAClE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,YAAY,EAAE,KAAK,CAAC,OAAO,IAAI,0BAA0B;aAC1D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA3SY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAa,EAAC,+CAAyB,EAAE,QAAQ,CAAC;;GACtC,cAAc,CA2S1B;AAED,SAAgB,YAAY;AAE5B,CAAC;AAFD,oCAEC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.TWILIO_FACEBOOK_PAGE_ID = exports.TWILIO_WHATSAPP_NUMBER = exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = void 0;
|
|
27
|
+
const env = __importStar(require("env-var"));
|
|
28
|
+
const dotenv = __importStar(require("dotenv"));
|
|
29
|
+
dotenv.config();
|
|
30
|
+
exports.TWILIO_ACCOUNT_SID = env.get('TWILIO_ACCOUNT_SID').required().asString();
|
|
31
|
+
exports.TWILIO_AUTH_TOKEN = env.get('TWILIO_AUTH_TOKEN').required().asString();
|
|
32
|
+
exports.TWILIO_PHONE_NUMBER = env.get('TWILIO_PHONE_NUMBER').required().asString();
|
|
33
|
+
exports.TWILIO_WHATSAPP_NUMBER = env.get('TWILIO_WHATSAPP_NUMBER').default('').asString();
|
|
34
|
+
exports.TWILIO_FACEBOOK_PAGE_ID = env.get('TWILIO_FACEBOOK_PAGE_ID').default('').asString();
|
|
35
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,+CAAiC;AAGjC,MAAM,CAAC,MAAM,EAAE,CAAC;AAGH,QAAA,kBAAkB,GAAG,GAAG,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACzE,QAAA,iBAAiB,GAAG,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AACvE,QAAA,mBAAmB,GAAG,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC;AAG3E,QAAA,sBAAsB,GAAG,GAAG,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAGlF,QAAA,uBAAuB,GAAG,GAAG,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./TwilioProvider"), exports);
|
|
18
|
+
__exportStar(require("./config"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,mDAAiC;AACjC,2CAAyB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/communication-twilio",
|
|
3
|
+
"version": "2.33.0",
|
|
4
|
+
"description": "Twilio provider for MemberJunction Communication framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"clean": "rimraf dist"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@memberjunction/communication-types": "2.33.0",
|
|
16
|
+
"@memberjunction/core": "2.33.0",
|
|
17
|
+
"@memberjunction/global": "2.33.0",
|
|
18
|
+
"dotenv": "^16.3.1",
|
|
19
|
+
"env-var": "^7.4.1",
|
|
20
|
+
"twilio": "^4.23.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.0.2",
|
|
24
|
+
"rimraf": "^5.0.5"
|
|
25
|
+
}
|
|
26
|
+
}
|