@twilio/conversations 2.0.1-rc.9 → 2.1.0-rc.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/CHANGELOG.md +31 -0
- package/builds/browser.js +248 -64
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +86 -9
- package/builds/lib.js +248 -64
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +246 -63
- package/builds/twilio-conversations.min.js +3 -3
- package/dist/conversation.js +24 -10
- package/dist/conversation.js.map +1 -1
- package/dist/data/messages.js +1 -1
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +7 -3
- package/dist/data/participants.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/attributes.js +147 -0
- package/dist/interfaces/attributes.js.map +1 -0
- package/dist/message-builder.js +52 -0
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +35 -4
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +20 -3
- package/dist/participant.js.map +1 -1
- package/dist/user.js +2 -1
- package/dist/user.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +15 -0
- package/docs/classes/Client.html +15 -0
- package/docs/classes/Conversation.html +24 -2
- package/docs/classes/DetailedDeliveryReceipt.html +15 -0
- package/docs/classes/Media.html +15 -0
- package/docs/classes/Message.html +83 -2
- package/docs/classes/MessageBuilder.html +91 -0
- package/docs/classes/Participant.html +45 -1
- package/docs/classes/PushNotification.html +15 -0
- package/docs/classes/RestPaginator.html +15 -0
- package/docs/classes/UnsentMessage.html +15 -0
- package/docs/classes/User.html +15 -0
- package/docs/index.html +37 -3
- package/docs/interfaces/ClientOptions.html +15 -0
- package/docs/interfaces/ConversationBindings.html +3118 -0
- package/docs/interfaces/ConversationEmailBinding.html +3118 -0
- package/docs/interfaces/ConversationState.html +15 -0
- package/docs/interfaces/CreateConversationOptions.html +15 -0
- package/docs/interfaces/LastMessage.html +15 -0
- package/docs/interfaces/Paginator.html +15 -0
- package/docs/interfaces/ParticipantBindings.html +3118 -0
- package/docs/interfaces/ParticipantEmailBinding.html +3118 -0
- package/docs/interfaces/PushNotificationData.html +15 -0
- package/docs/interfaces/SendEmailOptions.html +15 -0
- package/docs/interfaces/SendMediaOptions.html +15 -0
- package/docs/modules.html +37 -3
- package/package.json +2 -2
@@ -6591,6 +6591,13 @@ this.Twilio.Conversations = (function (exports) {
|
|
6591
6591
|
var validateTypes_1 = browser$6.validateTypes = validateTypes;
|
6592
6592
|
var validateTypesAsync_1 = browser$6.validateTypesAsync = validateTypesAsync;
|
6593
6593
|
|
6594
|
+
var attributesValidator = custom_1(function (value) {
|
6595
|
+
return [['string', 'number', 'boolean', 'object'].includes(_typeof$4(value)), 'a JSON type'];
|
6596
|
+
});
|
6597
|
+
var optionalAttributesValidator = custom_1(function (value) {
|
6598
|
+
return [['undefined', 'string', 'number', 'boolean', 'object'].includes(_typeof$4(value)), 'an optional JSON type'];
|
6599
|
+
});
|
6600
|
+
|
6594
6601
|
var browser$5 = {};
|
6595
6602
|
|
6596
6603
|
/*
|
@@ -9758,7 +9765,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
9758
9765
|
return User;
|
9759
9766
|
}(ReplayEventEmitter_1);
|
9760
9767
|
|
9761
|
-
__decorate$1([validateTypesAsync_1(
|
9768
|
+
__decorate$1([validateTypesAsync_1(attributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Object]), __metadata$1("design:returntype", Promise)], User.prototype, "updateAttributes", null);
|
9762
9769
|
|
9763
9770
|
__decorate$1([validateTypesAsync_1(['string']), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], User.prototype, "updateFriendlyName", null);
|
9764
9771
|
|
@@ -34809,6 +34816,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
34809
34816
|
* @internal
|
34810
34817
|
*/
|
34811
34818
|
function Participant(data, sid, conversation, links, services) {
|
34819
|
+
var _data$bindings;
|
34820
|
+
|
34812
34821
|
var _this;
|
34813
34822
|
|
34814
34823
|
_classCallCheck$4(this, Participant);
|
@@ -34829,7 +34838,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
34829
34838
|
lastReadMessageIndex: Number.isInteger(data.lastConsumedMessageIndex) ? data.lastConsumedMessageIndex : null,
|
34830
34839
|
lastReadTimestamp: data.lastConsumptionTimestamp ? parseTime$1(data.lastConsumptionTimestamp) : null,
|
34831
34840
|
type: data.type || 'chat',
|
34832
|
-
userInfo: data.userInfo
|
34841
|
+
userInfo: data.userInfo,
|
34842
|
+
bindings: (_data$bindings = data.bindings) !== null && _data$bindings !== void 0 ? _data$bindings : {}
|
34833
34843
|
};
|
34834
34844
|
|
34835
34845
|
if (!data.identity && !data.type) {
|
@@ -34932,7 +34942,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
34932
34942
|
return this.state.roleSid;
|
34933
34943
|
}
|
34934
34944
|
/**
|
34935
|
-
*
|
34945
|
+
* Type of the participant.
|
34936
34946
|
*/
|
34937
34947
|
|
34938
34948
|
}, {
|
@@ -34940,6 +34950,21 @@ this.Twilio.Conversations = (function (exports) {
|
|
34940
34950
|
get: function get() {
|
34941
34951
|
return this.state.type;
|
34942
34952
|
}
|
34953
|
+
/**
|
34954
|
+
* Get the bindings mapping for the current participant.
|
34955
|
+
* Available binding depends on the participant type.
|
34956
|
+
* You could access it as `participant.bindings.sms?.address` or
|
34957
|
+
* using the type dynamically `participant.bindings[participant.type]`
|
34958
|
+
* just be aware that the binding information has different structure for
|
34959
|
+
* each participant type.
|
34960
|
+
* See also {ParticipantEmailBinding}, the only available currently binding descriptor.
|
34961
|
+
*/
|
34962
|
+
|
34963
|
+
}, {
|
34964
|
+
key: "bindings",
|
34965
|
+
get: function get() {
|
34966
|
+
return this.state.bindings;
|
34967
|
+
}
|
34943
34968
|
}, {
|
34944
34969
|
key: "_startTyping",
|
34945
34970
|
value:
|
@@ -35026,6 +35051,11 @@ this.Twilio.Conversations = (function (exports) {
|
|
35026
35051
|
}
|
35027
35052
|
}
|
35028
35053
|
|
35054
|
+
if (data.bindings && !isEqual(this.state.bindings, data.bindings)) {
|
35055
|
+
this.state.bindings = data.bindings;
|
35056
|
+
updateReasons.push('bindings');
|
35057
|
+
}
|
35058
|
+
|
35029
35059
|
if (updateReasons.length > 0) {
|
35030
35060
|
this.emit('updated', {
|
35031
35061
|
participant: this,
|
@@ -35145,7 +35175,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
35145
35175
|
|
35146
35176
|
_defineProperty$3(Participant, "updated", 'updated');
|
35147
35177
|
|
35148
|
-
__decorate$1([validateTypesAsync_1(
|
35178
|
+
__decorate$1([validateTypesAsync_1(attributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Object]), __metadata$1("design:returntype", Promise)], Participant.prototype, "updateAttributes", null);
|
35149
35179
|
|
35150
35180
|
function _createSuper$6(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$6(); return function _createSuperInternal() { var Super = _getPrototypeOf$4(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$4(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$4(this, result); }; }
|
35151
35181
|
|
@@ -35325,19 +35355,38 @@ this.Twilio.Conversations = (function (exports) {
|
|
35325
35355
|
|
35326
35356
|
}, {
|
35327
35357
|
key: "getParticipants",
|
35328
|
-
value: function
|
35329
|
-
var
|
35358
|
+
value: function () {
|
35359
|
+
var _getParticipants = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee3() {
|
35360
|
+
var _this4 = this;
|
35330
35361
|
|
35331
|
-
|
35332
|
-
|
35362
|
+
return _regeneratorRuntime$1.wrap(function _callee3$(_context3) {
|
35363
|
+
while (1) {
|
35364
|
+
switch (_context3.prev = _context3.next) {
|
35365
|
+
case 0:
|
35366
|
+
return _context3.abrupt("return", this.rosterEntityPromise.then(function () {
|
35367
|
+
var participants = [];
|
35333
35368
|
|
35334
|
-
|
35335
|
-
|
35336
|
-
|
35369
|
+
_this4.participants.forEach(function (participant) {
|
35370
|
+
return participants.push(participant);
|
35371
|
+
});
|
35337
35372
|
|
35338
|
-
|
35339
|
-
|
35340
|
-
|
35373
|
+
return participants;
|
35374
|
+
}));
|
35375
|
+
|
35376
|
+
case 1:
|
35377
|
+
case "end":
|
35378
|
+
return _context3.stop();
|
35379
|
+
}
|
35380
|
+
}
|
35381
|
+
}, _callee3, this);
|
35382
|
+
}));
|
35383
|
+
|
35384
|
+
function getParticipants() {
|
35385
|
+
return _getParticipants.apply(this, arguments);
|
35386
|
+
}
|
35387
|
+
|
35388
|
+
return getParticipants;
|
35389
|
+
}()
|
35341
35390
|
/**
|
35342
35391
|
* Get participant by SID from conversation
|
35343
35392
|
* @returns {Promise<Participant>}
|
@@ -35346,14 +35395,14 @@ this.Twilio.Conversations = (function (exports) {
|
|
35346
35395
|
}, {
|
35347
35396
|
key: "getParticipantBySid",
|
35348
35397
|
value: function () {
|
35349
|
-
var _getParticipantBySid = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function
|
35398
|
+
var _getParticipantBySid = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee4(participantSid) {
|
35350
35399
|
var _this5 = this;
|
35351
35400
|
|
35352
|
-
return _regeneratorRuntime$1.wrap(function
|
35401
|
+
return _regeneratorRuntime$1.wrap(function _callee4$(_context4) {
|
35353
35402
|
while (1) {
|
35354
|
-
switch (
|
35403
|
+
switch (_context4.prev = _context4.next) {
|
35355
35404
|
case 0:
|
35356
|
-
return
|
35405
|
+
return _context4.abrupt("return", this.rosterEntityPromise.then(function () {
|
35357
35406
|
var participant = _this5.participants.get(participantSid);
|
35358
35407
|
|
35359
35408
|
if (!participant) {
|
@@ -35365,10 +35414,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
35365
35414
|
|
35366
35415
|
case 1:
|
35367
35416
|
case "end":
|
35368
|
-
return
|
35417
|
+
return _context4.stop();
|
35369
35418
|
}
|
35370
35419
|
}
|
35371
|
-
},
|
35420
|
+
}, _callee4, this);
|
35372
35421
|
}));
|
35373
35422
|
|
35374
35423
|
function getParticipantBySid(_x3) {
|
@@ -35385,16 +35434,16 @@ this.Twilio.Conversations = (function (exports) {
|
|
35385
35434
|
}, {
|
35386
35435
|
key: "getParticipantByIdentity",
|
35387
35436
|
value: function () {
|
35388
|
-
var _getParticipantByIdentity = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function
|
35437
|
+
var _getParticipantByIdentity = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(identity) {
|
35389
35438
|
var _this6 = this;
|
35390
35439
|
|
35391
35440
|
var foundParticipant;
|
35392
|
-
return _regeneratorRuntime$1.wrap(function
|
35441
|
+
return _regeneratorRuntime$1.wrap(function _callee5$(_context5) {
|
35393
35442
|
while (1) {
|
35394
|
-
switch (
|
35443
|
+
switch (_context5.prev = _context5.next) {
|
35395
35444
|
case 0:
|
35396
35445
|
foundParticipant = null;
|
35397
|
-
return
|
35446
|
+
return _context5.abrupt("return", this.rosterEntityPromise.then(function () {
|
35398
35447
|
_this6.participants.forEach(function (participant) {
|
35399
35448
|
if (participant.identity === identity) {
|
35400
35449
|
foundParticipant = participant;
|
@@ -35410,10 +35459,10 @@ this.Twilio.Conversations = (function (exports) {
|
|
35410
35459
|
|
35411
35460
|
case 2:
|
35412
35461
|
case "end":
|
35413
|
-
return
|
35462
|
+
return _context5.stop();
|
35414
35463
|
}
|
35415
35464
|
}
|
35416
|
-
},
|
35465
|
+
}, _callee5, this);
|
35417
35466
|
}));
|
35418
35467
|
|
35419
35468
|
function getParticipantByIdentity(_x4) {
|
@@ -35430,26 +35479,26 @@ this.Twilio.Conversations = (function (exports) {
|
|
35430
35479
|
}, {
|
35431
35480
|
key: "add",
|
35432
35481
|
value: function () {
|
35433
|
-
var _add = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function
|
35434
|
-
return _regeneratorRuntime$1.wrap(function
|
35482
|
+
var _add = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee6(identity, attributes) {
|
35483
|
+
return _regeneratorRuntime$1.wrap(function _callee6$(_context6) {
|
35435
35484
|
while (1) {
|
35436
|
-
switch (
|
35485
|
+
switch (_context6.prev = _context6.next) {
|
35437
35486
|
case 0:
|
35438
|
-
|
35487
|
+
_context6.next = 2;
|
35439
35488
|
return this.services.commandExecutor.mutateResource('post', this.links.participants, {
|
35440
35489
|
identity: identity,
|
35441
35490
|
attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined
|
35442
35491
|
});
|
35443
35492
|
|
35444
35493
|
case 2:
|
35445
|
-
return
|
35494
|
+
return _context6.abrupt("return", _context6.sent);
|
35446
35495
|
|
35447
35496
|
case 3:
|
35448
35497
|
case "end":
|
35449
|
-
return
|
35498
|
+
return _context6.stop();
|
35450
35499
|
}
|
35451
35500
|
}
|
35452
|
-
},
|
35501
|
+
}, _callee6, this);
|
35453
35502
|
}));
|
35454
35503
|
|
35455
35504
|
function add(_x5, _x6) {
|
@@ -35464,17 +35513,24 @@ this.Twilio.Conversations = (function (exports) {
|
|
35464
35513
|
* @param proxyAddress
|
35465
35514
|
* @param address
|
35466
35515
|
* @param attributes
|
35516
|
+
* @param bindingOptions
|
35467
35517
|
* @returns {Promise<any>}
|
35468
35518
|
*/
|
35469
35519
|
|
35470
35520
|
}, {
|
35471
35521
|
key: "addNonChatParticipant",
|
35472
|
-
value: function addNonChatParticipant(proxyAddress, address
|
35522
|
+
value: function addNonChatParticipant(proxyAddress, address) {
|
35523
|
+
var _bindingOptions$email, _bindingOptions$email2;
|
35524
|
+
|
35525
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
35526
|
+
var bindingOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
35473
35527
|
return this.services.commandExecutor.mutateResource('post', this.links.participants, {
|
35474
35528
|
attributes: typeof attributes !== 'undefined' ? JSON.stringify(attributes) : undefined,
|
35475
35529
|
messaging_binding: {
|
35476
35530
|
address: address,
|
35477
|
-
proxy_address: proxyAddress
|
35531
|
+
proxy_address: proxyAddress,
|
35532
|
+
name: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email = bindingOptions.email) === null || _bindingOptions$email === void 0 ? void 0 : _bindingOptions$email.name,
|
35533
|
+
level: bindingOptions === null || bindingOptions === void 0 ? void 0 : (_bindingOptions$email2 = bindingOptions.email) === null || _bindingOptions$email2 === void 0 ? void 0 : _bindingOptions$email2.level
|
35478
35534
|
}
|
35479
35535
|
});
|
35480
35536
|
}
|
@@ -36222,7 +36278,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36222
36278
|
return this.state.attributes;
|
36223
36279
|
}
|
36224
36280
|
/**
|
36225
|
-
*
|
36281
|
+
* Type of the message.
|
36226
36282
|
*/
|
36227
36283
|
|
36228
36284
|
}, {
|
@@ -36231,7 +36287,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36231
36287
|
return this.state.type;
|
36232
36288
|
}
|
36233
36289
|
/**
|
36234
|
-
* One of the attached media.
|
36290
|
+
* One of the attached media (if present).
|
36235
36291
|
* @deprecated Use attachedMedia instead. Note that the latter is now an array.
|
36236
36292
|
*/
|
36237
36293
|
|
@@ -36283,6 +36339,38 @@ this.Twilio.Conversations = (function (exports) {
|
|
36283
36339
|
return categories.includes(m.category);
|
36284
36340
|
});
|
36285
36341
|
}
|
36342
|
+
/**
|
36343
|
+
* Get a media descriptor for an email body attachment of a provided type.
|
36344
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.
|
36345
|
+
* @param type Type of email body to request, defaults to `text/plain`.
|
36346
|
+
*/
|
36347
|
+
|
36348
|
+
}, {
|
36349
|
+
key: "getEmailBody",
|
36350
|
+
value: function getEmailBody() {
|
36351
|
+
var _this$getMediaByCateg, _this$getMediaByCateg2;
|
36352
|
+
|
36353
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
|
36354
|
+
return (_this$getMediaByCateg = (_this$getMediaByCateg2 = this.getMediaByCategory(['body'])) === null || _this$getMediaByCateg2 === void 0 ? void 0 : _this$getMediaByCateg2.filter(function (m) {
|
36355
|
+
return m.contentType == type;
|
36356
|
+
}).shift()) !== null && _this$getMediaByCateg !== void 0 ? _this$getMediaByCateg : null;
|
36357
|
+
}
|
36358
|
+
/**
|
36359
|
+
* Get a media descriptor for an email history attachment of a provided type.
|
36360
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.
|
36361
|
+
* @param type Type of email history to request, defaults to `text/plain`.
|
36362
|
+
*/
|
36363
|
+
|
36364
|
+
}, {
|
36365
|
+
key: "getEmailHistory",
|
36366
|
+
value: function getEmailHistory() {
|
36367
|
+
var _this$getMediaByCateg3, _this$getMediaByCateg4;
|
36368
|
+
|
36369
|
+
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'text/plain';
|
36370
|
+
return (_this$getMediaByCateg3 = (_this$getMediaByCateg4 = this.getMediaByCategory(['history'])) === null || _this$getMediaByCateg4 === void 0 ? void 0 : _this$getMediaByCateg4.filter(function (m) {
|
36371
|
+
return m.contentType == type;
|
36372
|
+
}).shift()) !== null && _this$getMediaByCateg3 !== void 0 ? _this$getMediaByCateg3 : null;
|
36373
|
+
}
|
36286
36374
|
}, {
|
36287
36375
|
key: "_update",
|
36288
36376
|
value: function _update(data) {
|
@@ -36696,14 +36784,18 @@ this.Twilio.Conversations = (function (exports) {
|
|
36696
36784
|
|
36697
36785
|
_defineProperty$3(Message, "updated", 'updated');
|
36698
36786
|
|
36787
|
+
__decorate$1([validateTypes_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Media)], Message.prototype, "getEmailBody", null);
|
36788
|
+
|
36789
|
+
__decorate$1([validateTypes_1(nonEmptyString_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Media)], Message.prototype, "getEmailHistory", null);
|
36790
|
+
|
36699
36791
|
__decorate$1([validateTypesAsync_1('string'), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], Message.prototype, "updateBody", null);
|
36700
36792
|
|
36701
|
-
__decorate$1([validateTypesAsync_1(
|
36793
|
+
__decorate$1([validateTypesAsync_1(attributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Object]), __metadata$1("design:returntype", Promise)], Message.prototype, "updateAttributes", null);
|
36702
36794
|
|
36703
36795
|
__decorate$1([validateTypesAsync_1(custom_1(function (value) {
|
36704
36796
|
return [value instanceof Array && value.length > 0 && value.reduce(function (a, c) {
|
36705
36797
|
return a && c instanceof Media;
|
36706
|
-
}), 'a non-empty array of Media'];
|
36798
|
+
}, true), 'a non-empty array of Media'];
|
36707
36799
|
})), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Array]), __metadata$1("design:returntype", Promise)], Message.prototype, "attachTemporaryUrlsFor", null);
|
36708
36800
|
|
36709
36801
|
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
@@ -36888,7 +36980,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
36888
36980
|
/**
|
36889
36981
|
* Send Message to the conversation, message could include both text and multiple media attachments.
|
36890
36982
|
* @param message Message to post
|
36891
|
-
* @returns Returns promise which can fail
|
36983
|
+
* @returns Returns a promise which can fail
|
36892
36984
|
*/
|
36893
36985
|
|
36894
36986
|
}, {
|
@@ -37361,6 +37453,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
37361
37453
|
|
37362
37454
|
this.limits = limits;
|
37363
37455
|
this.message = new UnsentMessage(messagesEntity);
|
37456
|
+
this.emailBodies = new Map();
|
37457
|
+
this.emailHistories = new Map();
|
37364
37458
|
}
|
37365
37459
|
/**
|
37366
37460
|
* Sets the message body.
|
@@ -37396,6 +37490,30 @@ this.Twilio.Conversations = (function (exports) {
|
|
37396
37490
|
this.message.attributes = attributes;
|
37397
37491
|
return this;
|
37398
37492
|
}
|
37493
|
+
/**
|
37494
|
+
* Set email body with given MIME-type.
|
37495
|
+
* @param mimeType Format of the body to set (text/plain or text/html).
|
37496
|
+
* @param body Body payload in selected format.
|
37497
|
+
*/
|
37498
|
+
|
37499
|
+
}, {
|
37500
|
+
key: "setEmailBody",
|
37501
|
+
value: function setEmailBody(mimeType, body) {
|
37502
|
+
this.emailBodies.set(mimeType, body);
|
37503
|
+
return this;
|
37504
|
+
}
|
37505
|
+
/**
|
37506
|
+
* Set email history with given MIME-type.
|
37507
|
+
* @param mimeType Format of the history to set (text/plain or text/html).
|
37508
|
+
* @param history History payload in selected format.
|
37509
|
+
*/
|
37510
|
+
|
37511
|
+
}, {
|
37512
|
+
key: "setEmailHistory",
|
37513
|
+
value: function setEmailHistory(mimeType, history) {
|
37514
|
+
this.emailHistories.set(mimeType, history);
|
37515
|
+
return this;
|
37516
|
+
}
|
37399
37517
|
/**
|
37400
37518
|
* Adds media to the message.
|
37401
37519
|
* @param payload Media to add.
|
@@ -37404,6 +37522,18 @@ this.Twilio.Conversations = (function (exports) {
|
|
37404
37522
|
}, {
|
37405
37523
|
key: "addMedia",
|
37406
37524
|
value: function addMedia(payload) {
|
37525
|
+
if (typeof FormData === 'undefined' && payload instanceof FormData) {
|
37526
|
+
throw new Error('Could not add FormData content whilst not in a browser');
|
37527
|
+
}
|
37528
|
+
|
37529
|
+
if (!(payload instanceof FormData)) {
|
37530
|
+
var mediaOptions = payload;
|
37531
|
+
|
37532
|
+
if (!mediaOptions.contentType || !mediaOptions.media) {
|
37533
|
+
throw new Error('Media content in SendMediaOptions must contain non-empty contentType and media');
|
37534
|
+
}
|
37535
|
+
}
|
37536
|
+
|
37407
37537
|
this.message.mediaContent.push(['media', payload]);
|
37408
37538
|
return this;
|
37409
37539
|
}
|
@@ -37414,11 +37544,39 @@ this.Twilio.Conversations = (function (exports) {
|
|
37414
37544
|
}, {
|
37415
37545
|
key: "build",
|
37416
37546
|
value: function build() {
|
37547
|
+
var _this = this;
|
37548
|
+
|
37549
|
+
this.emailBodies.forEach(function (_, key) {
|
37550
|
+
if (!_this.limits.emailBodiesAllowedMimeTypes.includes(key)) {
|
37551
|
+
throw new Error("Unsupported email body MIME type ".concat(key));
|
37552
|
+
}
|
37553
|
+
});
|
37554
|
+
this.emailHistories.forEach(function (_, key) {
|
37555
|
+
if (!_this.limits.emailHistoriesAllowedMimeTypes.includes(key)) {
|
37556
|
+
throw new Error("Unsupported email history MIME type ".concat(key));
|
37557
|
+
}
|
37558
|
+
});
|
37559
|
+
|
37560
|
+
if (this.emailBodies.size > this.limits.emailBodiesAllowedMimeTypes.length) {
|
37561
|
+
throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size, " > ").concat(this.limits.emailBodiesAllowedMimeTypes.length, ")"));
|
37562
|
+
}
|
37563
|
+
|
37564
|
+
if (this.emailHistories.size > this.limits.emailHistoriesAllowedMimeTypes.length) {
|
37565
|
+
throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size, " > ").concat(this.limits.emailHistoriesAllowedMimeTypes.length, ")"));
|
37566
|
+
}
|
37567
|
+
|
37417
37568
|
if (this.message.mediaContent.length > this.limits.mediaAttachmentsCountLimit) {
|
37418
37569
|
throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length, " > ").concat(this.limits.mediaAttachmentsCountLimit, ")"));
|
37419
37570
|
} // @todo we don't know the sizes of the attachments in FormData
|
37571
|
+
// @todo insertion below makes build() method non-repeatable - probably move to UnsentMessage.send() or even sendV2()?
|
37420
37572
|
|
37421
37573
|
|
37574
|
+
this.emailBodies.forEach(function (body) {
|
37575
|
+
_this.message.mediaContent.push(['body', body]);
|
37576
|
+
});
|
37577
|
+
this.emailHistories.forEach(function (history) {
|
37578
|
+
_this.message.mediaContent.push(['history', history]);
|
37579
|
+
});
|
37422
37580
|
return this.message;
|
37423
37581
|
}
|
37424
37582
|
}, {
|
@@ -37457,7 +37615,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
37457
37615
|
sid: 'sid',
|
37458
37616
|
status: 'status',
|
37459
37617
|
uniqueName: 'uniqueName',
|
37460
|
-
state: 'state'
|
37618
|
+
state: 'state',
|
37619
|
+
bindings: 'bindings'
|
37461
37620
|
};
|
37462
37621
|
|
37463
37622
|
function parseTime(timeString) {
|
@@ -37485,6 +37644,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
37485
37644
|
* @internal
|
37486
37645
|
*/
|
37487
37646
|
function Conversation(descriptor, sid, links, configuration, services) {
|
37647
|
+
var _descriptor$bindings;
|
37648
|
+
|
37488
37649
|
var _this;
|
37489
37650
|
|
37490
37651
|
_classCallCheck$4(this, Conversation);
|
@@ -37517,7 +37678,8 @@ this.Twilio.Conversations = (function (exports) {
|
|
37517
37678
|
dateCreated: dateCreated,
|
37518
37679
|
dateUpdated: dateUpdated,
|
37519
37680
|
friendlyName: friendlyName,
|
37520
|
-
lastReadMessageIndex: lastReadMessageIndex
|
37681
|
+
lastReadMessageIndex: lastReadMessageIndex,
|
37682
|
+
bindings: (_descriptor$bindings = descriptor.bindings) !== null && _descriptor$bindings !== void 0 ? _descriptor$bindings : {}
|
37521
37683
|
};
|
37522
37684
|
|
37523
37685
|
if (descriptor.notificationLevel) {
|
@@ -37651,6 +37813,11 @@ this.Twilio.Conversations = (function (exports) {
|
|
37651
37813
|
get: function get() {
|
37652
37814
|
return this.channelState.notificationLevel;
|
37653
37815
|
}
|
37816
|
+
}, {
|
37817
|
+
key: "bindings",
|
37818
|
+
get: function get() {
|
37819
|
+
return this.channelState.bindings;
|
37820
|
+
}
|
37654
37821
|
}, {
|
37655
37822
|
key: "limits",
|
37656
37823
|
get: function get() {
|
@@ -37940,6 +38107,15 @@ this.Twilio.Conversations = (function (exports) {
|
|
37940
38107
|
updateReasons.add(localKey);
|
37941
38108
|
break;
|
37942
38109
|
|
38110
|
+
case fieldMappings.bindings:
|
38111
|
+
if (isEqual(this.channelState.bindings, update.bindings)) {
|
38112
|
+
break;
|
38113
|
+
}
|
38114
|
+
|
38115
|
+
this.channelState.bindings = update.bindings;
|
38116
|
+
updateReasons.add(localKey);
|
38117
|
+
break;
|
38118
|
+
|
37943
38119
|
default:
|
37944
38120
|
var isDate = update[key] instanceof Date;
|
37945
38121
|
var keysMatchAsDates = isDate && ((_this$channelState$lo = this.channelState[localKey]) === null || _this$channelState$lo === void 0 ? void 0 : _this$channelState$lo.getTime()) === update[key].getTime();
|
@@ -38035,7 +38211,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38035
38211
|
while (1) {
|
38036
38212
|
switch (_context4.prev = _context4.next) {
|
38037
38213
|
case 0:
|
38038
|
-
return _context4.abrupt("return", this.participantsEntity.add(identity, attributes));
|
38214
|
+
return _context4.abrupt("return", this.participantsEntity.add(identity, attributes !== null && attributes !== void 0 ? attributes : {}));
|
38039
38215
|
|
38040
38216
|
case 1:
|
38041
38217
|
case "end":
|
@@ -38056,19 +38232,25 @@ this.Twilio.Conversations = (function (exports) {
|
|
38056
38232
|
* @param proxyAddress Proxy (Twilio) address of the participant.
|
38057
38233
|
* @param address User address of the participant.
|
38058
38234
|
* @param attributes Attributes to be attached to the participant.
|
38235
|
+
* @param bindingOptions Options for adding email participants - name and CC/To level.
|
38059
38236
|
*/
|
38060
38237
|
|
38061
38238
|
}, {
|
38062
38239
|
key: "addNonChatParticipant",
|
38063
38240
|
value: function () {
|
38064
|
-
var _addNonChatParticipant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(proxyAddress, address
|
38241
|
+
var _addNonChatParticipant = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1.mark(function _callee5(proxyAddress, address) {
|
38242
|
+
var attributes,
|
38243
|
+
bindingOptions,
|
38244
|
+
_args5 = arguments;
|
38065
38245
|
return _regeneratorRuntime$1.wrap(function _callee5$(_context5) {
|
38066
38246
|
while (1) {
|
38067
38247
|
switch (_context5.prev = _context5.next) {
|
38068
38248
|
case 0:
|
38069
|
-
|
38249
|
+
attributes = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
|
38250
|
+
bindingOptions = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : {};
|
38251
|
+
return _context5.abrupt("return", this.participantsEntity.addNonChatParticipant(proxyAddress, address, attributes !== null && attributes !== void 0 ? attributes : {}, bindingOptions !== null && bindingOptions !== void 0 ? bindingOptions : {}));
|
38070
38252
|
|
38071
|
-
case
|
38253
|
+
case 3:
|
38072
38254
|
case "end":
|
38073
38255
|
return _context5.stop();
|
38074
38256
|
}
|
@@ -38076,7 +38258,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38076
38258
|
}, _callee5, this);
|
38077
38259
|
}));
|
38078
38260
|
|
38079
|
-
function addNonChatParticipant(_x4, _x5
|
38261
|
+
function addNonChatParticipant(_x4, _x5) {
|
38080
38262
|
return _addNonChatParticipant.apply(this, arguments);
|
38081
38263
|
}
|
38082
38264
|
|
@@ -38128,7 +38310,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38128
38310
|
}, _callee6, this);
|
38129
38311
|
}));
|
38130
38312
|
|
38131
|
-
function advanceLastReadMessageIndex(
|
38313
|
+
function advanceLastReadMessageIndex(_x6) {
|
38132
38314
|
return _advanceLastReadMessageIndex.apply(this, arguments);
|
38133
38315
|
}
|
38134
38316
|
|
@@ -38229,7 +38411,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38229
38411
|
}, _callee9, this);
|
38230
38412
|
}));
|
38231
38413
|
|
38232
|
-
function getMessages(_x8, _x9
|
38414
|
+
function getMessages(_x7, _x8, _x9) {
|
38233
38415
|
return _getMessages.apply(this, arguments);
|
38234
38416
|
}
|
38235
38417
|
|
@@ -38332,7 +38514,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38332
38514
|
}, _callee12, this);
|
38333
38515
|
}));
|
38334
38516
|
|
38335
|
-
function getParticipantBySid(
|
38517
|
+
function getParticipantBySid(_x10) {
|
38336
38518
|
return _getParticipantBySid.apply(this, arguments);
|
38337
38519
|
}
|
38338
38520
|
|
@@ -38361,7 +38543,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38361
38543
|
}, _callee13, this);
|
38362
38544
|
}));
|
38363
38545
|
|
38364
|
-
function getParticipantByIdentity(
|
38546
|
+
function getParticipantByIdentity(_x11) {
|
38365
38547
|
return _getParticipantByIdentity.apply(this, arguments);
|
38366
38548
|
}
|
38367
38549
|
|
@@ -38571,7 +38753,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38571
38753
|
}, _callee18, this);
|
38572
38754
|
}));
|
38573
38755
|
|
38574
|
-
function removeParticipant(
|
38756
|
+
function removeParticipant(_x12) {
|
38575
38757
|
return _removeParticipant.apply(this, arguments);
|
38576
38758
|
}
|
38577
38759
|
|
@@ -38624,7 +38806,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38624
38806
|
}, _callee19, this);
|
38625
38807
|
}));
|
38626
38808
|
|
38627
|
-
function sendMessage(_x14, _x15
|
38809
|
+
function sendMessage(_x13, _x14, _x15) {
|
38628
38810
|
return _sendMessage.apply(this, arguments);
|
38629
38811
|
}
|
38630
38812
|
|
@@ -38633,6 +38815,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38633
38815
|
/**
|
38634
38816
|
* New interface to prepare for sending a message.
|
38635
38817
|
* Use instead of `sendMessage`.
|
38818
|
+
* @return A MessageBuilder to help set all message sending options.
|
38636
38819
|
*/
|
38637
38820
|
|
38638
38821
|
}, {
|
@@ -38751,7 +38934,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38751
38934
|
}, _callee22, this);
|
38752
38935
|
}));
|
38753
38936
|
|
38754
|
-
function setUserNotificationLevel(
|
38937
|
+
function setUserNotificationLevel(_x16) {
|
38755
38938
|
return _setUserNotificationLevel.apply(this, arguments);
|
38756
38939
|
}
|
38757
38940
|
|
@@ -38796,7 +38979,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38796
38979
|
}, _callee23, this);
|
38797
38980
|
}));
|
38798
38981
|
|
38799
|
-
function updateAttributes(
|
38982
|
+
function updateAttributes(_x17) {
|
38800
38983
|
return _updateAttributes.apply(this, arguments);
|
38801
38984
|
}
|
38802
38985
|
|
@@ -38836,7 +39019,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38836
39019
|
}, _callee24, this);
|
38837
39020
|
}));
|
38838
39021
|
|
38839
|
-
function updateFriendlyName(
|
39022
|
+
function updateFriendlyName(_x18) {
|
38840
39023
|
return _updateFriendlyName.apply(this, arguments);
|
38841
39024
|
}
|
38842
39025
|
|
@@ -38871,7 +39054,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38871
39054
|
}, _callee25, this);
|
38872
39055
|
}));
|
38873
39056
|
|
38874
|
-
function updateLastReadMessageIndex(
|
39057
|
+
function updateLastReadMessageIndex(_x19) {
|
38875
39058
|
return _updateLastReadMessageIndex.apply(this, arguments);
|
38876
39059
|
}
|
38877
39060
|
|
@@ -38915,7 +39098,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
38915
39098
|
}, _callee26, this);
|
38916
39099
|
}));
|
38917
39100
|
|
38918
|
-
function updateUniqueName(
|
39101
|
+
function updateUniqueName(_x20) {
|
38919
39102
|
return _updateUniqueName.apply(this, arguments);
|
38920
39103
|
}
|
38921
39104
|
|
@@ -38987,9 +39170,9 @@ this.Twilio.Conversations = (function (exports) {
|
|
38987
39170
|
|
38988
39171
|
_defineProperty$3(Conversation, "removed", 'removed');
|
38989
39172
|
|
38990
|
-
__decorate$1([validateTypesAsync_1(nonEmptyString_1,
|
39173
|
+
__decorate$1([validateTypesAsync_1(nonEmptyString_1, optionalAttributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String, Object]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "add", null);
|
38991
39174
|
|
38992
|
-
__decorate$1([validateTypesAsync_1(nonEmptyString_1, nonEmptyString_1,
|
39175
|
+
__decorate$1([validateTypesAsync_1(nonEmptyString_1, nonEmptyString_1, optionalAttributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String, String, Object, Object]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "addNonChatParticipant", null);
|
38993
39176
|
|
38994
39177
|
__decorate$1([validateTypesAsync_1(nonNegativeInteger_1), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Number]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "advanceLastReadMessageIndex", null);
|
38995
39178
|
|
@@ -39015,13 +39198,13 @@ this.Twilio.Conversations = (function (exports) {
|
|
39015
39198
|
|
39016
39199
|
return [isValid, 'a non-empty string, an instance of Buffer or an instance of Blob'];
|
39017
39200
|
})
|
39018
|
-
})],
|
39201
|
+
})], optionalAttributesValidator, ['undefined', literal_1(null), objectSchema_1('email attributes', {
|
39019
39202
|
subject: [nonEmptyString_1, 'undefined']
|
39020
39203
|
})]), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Object, Object, Object]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "sendMessage", null);
|
39021
39204
|
|
39022
39205
|
__decorate$1([validateTypesAsync_1(literal_1('default', 'muted')), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "setUserNotificationLevel", null);
|
39023
39206
|
|
39024
|
-
__decorate$1([validateTypesAsync_1(
|
39207
|
+
__decorate$1([validateTypesAsync_1(attributesValidator), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [Object]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "updateAttributes", null);
|
39025
39208
|
|
39026
39209
|
__decorate$1([validateTypesAsync_1(['string']), __metadata$1("design:type", Function), __metadata$1("design:paramtypes", [String]), __metadata$1("design:returntype", Promise)], Conversation.prototype, "updateFriendlyName", null);
|
39027
39210
|
|
@@ -40302,7 +40485,7 @@ this.Twilio.Conversations = (function (exports) {
|
|
40302
40485
|
this.data = data.data || {};
|
40303
40486
|
};
|
40304
40487
|
|
40305
|
-
var version = "2.0
|
40488
|
+
var version = "2.1.0-rc.0";
|
40306
40489
|
|
40307
40490
|
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
40308
40491
|
|