@webex/plugin-messages 2.59.1 → 2.59.3-next.1

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/messages.js CHANGED
@@ -27,36 +27,36 @@ var getRoomType = function getRoomType(roomTags) {
27
27
  return roomTags.includes(_common.SDK_EVENT.INTERNAL.ACTIVITY_TAG.ONE_ON_ONE) ? _common.SDK_EVENT.EXTERNAL.SPACE_TYPE.DIRECT : _common.SDK_EVENT.EXTERNAL.SPACE_TYPE.GROUP;
28
28
  };
29
29
 
30
- /**
31
- * @typedef {Object} MessageObject
32
- * @property {string} id - (server generated) Unique identifier for the message
33
- * @property {string} personId - The ID for the author of the message
34
- * @property {email} personEmail - The email for the author of the message
35
- * @property {string} roomId - The ID for the room of the message
36
- * @property {string} text - The message posted to the room in plain text
37
- * @property {string} markdown - The message posted to the room in markdown
38
- * @property {Array<string>} files - The source URL(s) for the message attachment(s).
39
- * See the {@link https://developer.webex.com/docs/api/basics#message-attachments|Message Attachments}
40
- * Guide for a list of supported media types.
41
- * @property {isoDate} created - (server generated) The date and time that the message was created
30
+ /**
31
+ * @typedef {Object} MessageObject
32
+ * @property {string} id - (server generated) Unique identifier for the message
33
+ * @property {string} personId - The ID for the author of the message
34
+ * @property {email} personEmail - The email for the author of the message
35
+ * @property {string} roomId - The ID for the room of the message
36
+ * @property {string} text - The message posted to the room in plain text
37
+ * @property {string} markdown - The message posted to the room in markdown
38
+ * @property {Array<string>} files - The source URL(s) for the message attachment(s).
39
+ * See the {@link https://developer.webex.com/docs/api/basics#message-attachments|Message Attachments}
40
+ * Guide for a list of supported media types.
41
+ * @property {isoDate} created - (server generated) The date and time that the message was created
42
42
  */
43
43
 
44
- /**
45
- * Messages are how people communicate in rooms. Each message timestamped and
46
- * represented in Webex as a distinct block of content. Messages can contain
47
- * plain text and a single file attachment. See the
48
- * {@link https://developer.webex.com/docs/api/basics#message-attachments|Message Attachments} Guide
49
- * for a list of supported media types.
50
- * @class
44
+ /**
45
+ * Messages are how people communicate in rooms. Each message timestamped and
46
+ * represented in Webex as a distinct block of content. Messages can contain
47
+ * plain text and a single file attachment. See the
48
+ * {@link https://developer.webex.com/docs/api/basics#message-attachments|Message Attachments} Guide
49
+ * for a list of supported media types.
50
+ * @class
51
51
  */
52
52
  var Messages = _webexCore.WebexPlugin.extend({
53
- /**
54
- * Initializer used to generate Messages
55
- * as a plugin wrapped around the provided arguments.
56
- * @private
57
- * @see WebexPlugin.initialize
58
- * @param {...any} args
59
- * @returns {undefined}
53
+ /**
54
+ * Initializer used to generate Messages
55
+ * as a plugin wrapped around the provided arguments.
56
+ * @private
57
+ * @see WebexPlugin.initialize
58
+ * @param {...any} args
59
+ * @returns {undefined}
60
60
  */
61
61
  initialize: function initialize() {
62
62
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -64,38 +64,38 @@ var Messages = _webexCore.WebexPlugin.extend({
64
64
  }
65
65
  (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
66
66
  },
67
- /**
68
- * Register to listen for incoming messages events
69
- * This is an alternate approach to registering for messages webhooks.
70
- * The events passed to any registered handlers will be similar to the webhook JSON,
71
- * but will omit webhook specific fields such as name, secret, url, etc.
72
- * The messages.listen() event objects can also include additional fields not
73
- * available in the webhook's JSON payload: `text`, `markdown`, and `files`.
74
- * These fields are available when their details are included in the web socket's
75
- * `activity` object. Retrieving other fields, such as the `html` field,
76
- * will require a manual request to get the corresponding message object.
77
- * To utilize the `listen()` method, the authorization token used
78
- * will need to have `spark:all` and `spark:kms` scopes enabled.
79
- * Note that by configuring your application to enable or disable `spark:all`
80
- * via its configuration page will also enable or disable `spark:kms`.
81
- * See the <a href="https://webex.github.io/webex-js-sdk/samples/browser-socket/">Sample App</a>
82
- * for more details.
83
- * @instance
84
- * @memberof Messages
85
- * @returns {Promise}
86
- * @example
87
- * webex.messages.listen()
88
- * .then(() => {
89
- * console.log('listening to message events');
90
- * webex.messages.on('created', (event) => console.log(`Got a message:created event:\n${event}`));
91
- * webex.messages.on('deleted', (event) => console.log(`Got a message:deleted event:\n${event}`));
92
- * })
93
- * .catch((e) => console.error(`Unable to register for message events: ${e}`));
94
- * // Some app logic...
95
- * // When it is time to cleanup
96
- * webex.messages.stopListening();
97
- * webex.messages.off('created');
98
- * webex.messages.off('deleted');
67
+ /**
68
+ * Register to listen for incoming messages events
69
+ * This is an alternate approach to registering for messages webhooks.
70
+ * The events passed to any registered handlers will be similar to the webhook JSON,
71
+ * but will omit webhook specific fields such as name, secret, url, etc.
72
+ * The messages.listen() event objects can also include additional fields not
73
+ * available in the webhook's JSON payload: `text`, `markdown`, and `files`.
74
+ * These fields are available when their details are included in the web socket's
75
+ * `activity` object. Retrieving other fields, such as the `html` field,
76
+ * will require a manual request to get the corresponding message object.
77
+ * To utilize the `listen()` method, the authorization token used
78
+ * will need to have `spark:all` and `spark:kms` scopes enabled.
79
+ * Note that by configuring your application to enable or disable `spark:all`
80
+ * via its configuration page will also enable or disable `spark:kms`.
81
+ * See the <a href="https://webex.github.io/webex-js-sdk/samples/browser-socket/">Sample App</a>
82
+ * for more details.
83
+ * @instance
84
+ * @memberof Messages
85
+ * @returns {Promise}
86
+ * @example
87
+ * webex.messages.listen()
88
+ * .then(() => {
89
+ * console.log('listening to message events');
90
+ * webex.messages.on('created', (event) => console.log(`Got a message:created event:\n${event}`));
91
+ * webex.messages.on('deleted', (event) => console.log(`Got a message:deleted event:\n${event}`));
92
+ * })
93
+ * .catch((e) => console.error(`Unable to register for message events: ${e}`));
94
+ * // Some app logic...
95
+ * // When it is time to cleanup
96
+ * webex.messages.stopListening();
97
+ * webex.messages.off('created');
98
+ * webex.messages.off('deleted');
99
99
  */
100
100
  listen: function listen() {
101
101
  var _this = this;
@@ -111,30 +111,30 @@ var Messages = _webexCore.WebexPlugin.extend({
111
111
  });
112
112
  });
113
113
  },
114
- /**
115
- * Post a new message and/or media content into a room.
116
- * @instance
117
- * @memberof Messages
118
- * @param {MessageObject} message
119
- * @returns {Promise<MessageObject>}
120
- * @example
121
- * webex.rooms.create({title: 'Create Message Example'})
122
- * .then(function(room) {
123
- * return webex.messages.create({
124
- * text: 'Howdy!',
125
- * roomId: room.id
126
- * });
127
- * })
128
- * .then(function(message) {
129
- * var assert = require('assert');
130
- * assert(message.id);
131
- * assert(message.personId);
132
- * assert(message.personEmail);
133
- * assert(message.roomId);
134
- * assert(message.created);
135
- * return 'success';
136
- * });
137
- * // => success
114
+ /**
115
+ * Post a new message and/or media content into a room.
116
+ * @instance
117
+ * @memberof Messages
118
+ * @param {MessageObject} message
119
+ * @returns {Promise<MessageObject>}
120
+ * @example
121
+ * webex.rooms.create({title: 'Create Message Example'})
122
+ * .then(function(room) {
123
+ * return webex.messages.create({
124
+ * text: 'Howdy!',
125
+ * roomId: room.id
126
+ * });
127
+ * })
128
+ * .then(function(message) {
129
+ * var assert = require('assert');
130
+ * assert(message.id);
131
+ * assert(message.personId);
132
+ * assert(message.personEmail);
133
+ * assert(message.roomId);
134
+ * assert(message.created);
135
+ * return 'success';
136
+ * });
137
+ * // => success
138
138
  */
139
139
  create: function create(message) {
140
140
  var key = 'body';
@@ -157,39 +157,39 @@ var Messages = _webexCore.WebexPlugin.extend({
157
157
  return res.body;
158
158
  });
159
159
  },
160
- /**
161
- * Put an updated message and/or media content into a room instead of existing message.
162
- * @instance
163
- * @memberof Messages
164
- * @param {MessageObject} message
165
- * @param {MessageObject} altMessage
166
- * @returns {Promise<MessageObject>}
167
- * @example
168
- * webex.rooms.create({title: 'Create Message Example'})
169
- * .then(function(room) {
170
- * return webex.messages.create({
171
- * text: 'Howdy!',
172
- * roomId: room.id
173
- * });
174
- * })
175
- * .then(function(m) {
176
- * message = m;
177
- * return webex.messages.update(message,{markdown:`**What up**`});
178
- * })
179
- * .then(function(m) {
180
- * message = m;
181
- * return webex.messages.update(message.id,{roomId:message.roomId,text:'Howdy!'});
182
- * })
183
- * .then(function(message) {
184
- * var assert = require('assert');
185
- * assert(message.id);
186
- * assert(message.personId);
187
- * assert(message.personEmail);
188
- * assert(message.roomId);
189
- * assert(message.created);
190
- * return 'success';
191
- * });
192
- * // => success
160
+ /**
161
+ * Put an updated message and/or media content into a room instead of existing message.
162
+ * @instance
163
+ * @memberof Messages
164
+ * @param {MessageObject} message
165
+ * @param {MessageObject} altMessage
166
+ * @returns {Promise<MessageObject>}
167
+ * @example
168
+ * webex.rooms.create({title: 'Create Message Example'})
169
+ * .then(function(room) {
170
+ * return webex.messages.create({
171
+ * text: 'Howdy!',
172
+ * roomId: room.id
173
+ * });
174
+ * })
175
+ * .then(function(m) {
176
+ * message = m;
177
+ * return webex.messages.update(message,{markdown:`**What up**`});
178
+ * })
179
+ * .then(function(m) {
180
+ * message = m;
181
+ * return webex.messages.update(message.id,{roomId:message.roomId,text:'Howdy!'});
182
+ * })
183
+ * .then(function(message) {
184
+ * var assert = require('assert');
185
+ * assert(message.id);
186
+ * assert(message.personId);
187
+ * assert(message.personEmail);
188
+ * assert(message.roomId);
189
+ * assert(message.created);
190
+ * return 'success';
191
+ * });
192
+ * // => success
193
193
  */
194
194
  update: function update(message, altMessage) {
195
195
  var id = message.id || message;
@@ -207,9 +207,9 @@ var Messages = _webexCore.WebexPlugin.extend({
207
207
  if (!altMessage.roomId && !message.roomId) {
208
208
  this.logger.error('Error: RoomID is mandatory for message update call in one of the parameter, message or altMessage');
209
209
  } else {
210
- /* if altMessage doesnt contain RoomId use roomId from message object.
211
- I dont understand why RESTAPI call has RoomId Mandatory in body something webex Developers to clarity.
212
- In my opinion messageId provided in REST URL call should be enough to get roomID at serverside
210
+ /* if altMessage doesnt contain RoomId use roomId from message object.
211
+ I dont understand why RESTAPI call has RoomId Mandatory in body something webex Developers to clarity.
212
+ In my opinion messageId provided in REST URL call should be enough to get roomID at serverside
213
213
  */
214
214
  altMessage.roomId = altMessage.roomId ? altMessage.roomId : message.roomId;
215
215
  var options = (0, _defineProperty2.default)({
@@ -223,31 +223,31 @@ var Messages = _webexCore.WebexPlugin.extend({
223
223
  }
224
224
  return null;
225
225
  },
226
- /**
227
- * Returns a single message.
228
- * @instance
229
- * @memberof Messages
230
- * @param {RoomObject|string} message
231
- * @returns {Promise<MessageObject>}
232
- * @example
233
- * var message;
234
- * webex.rooms.create({title: 'Get Message Example'})
235
- * .then(function(room) {
236
- * return webex.messages.create({
237
- * text: 'Howdy!',
238
- * roomId: room.id
239
- * });
240
- * })
241
- * .then(function(m) {
242
- * message = m;
243
- * return webex.messages.get(message.id);
244
- * })
245
- * .then(function(message2) {
246
- * var assert = require('assert');
247
- * assert.deepEqual(message2, message);
248
- * return 'success';
249
- * });
250
- * // => success
226
+ /**
227
+ * Returns a single message.
228
+ * @instance
229
+ * @memberof Messages
230
+ * @param {RoomObject|string} message
231
+ * @returns {Promise<MessageObject>}
232
+ * @example
233
+ * var message;
234
+ * webex.rooms.create({title: 'Get Message Example'})
235
+ * .then(function(room) {
236
+ * return webex.messages.create({
237
+ * text: 'Howdy!',
238
+ * roomId: room.id
239
+ * });
240
+ * })
241
+ * .then(function(m) {
242
+ * message = m;
243
+ * return webex.messages.get(message.id);
244
+ * })
245
+ * .then(function(message2) {
246
+ * var assert = require('assert');
247
+ * assert.deepEqual(message2, message);
248
+ * return 'success';
249
+ * });
250
+ * // => success
251
251
  */
252
252
  get: function get(message) {
253
253
  var id = message.id || message;
@@ -258,44 +258,44 @@ var Messages = _webexCore.WebexPlugin.extend({
258
258
  return res.body.items || res.body;
259
259
  });
260
260
  },
261
- /**
262
- * Returns a list of messages. In most cases the results will only contain
263
- * messages posted in rooms that the authenticated user is a member of.
264
- * @instance
265
- * @memberof Messages
266
- * @param {Object} options
267
- * @param {string} options.roomId
268
- * @param {number} options.max
269
- * @returns {Promise<Page<MessageObject>>}
270
- * @example
271
- * var message1, message2, room;
272
- * webex.rooms.create({title: 'List Messages Example'})
273
- * .then(function(r) {
274
- * room = r;
275
- * return webex.messages.create({
276
- * text: 'Howdy!',
277
- * roomId: room.id
278
- * });
279
- * })
280
- * .then(function(m) {
281
- * message1 = m;
282
- * return webex.messages.create({
283
- * text: 'How are you?',
284
- * roomId: room.id
285
- * });
286
- * })
287
- * .then(function(m) {
288
- * message2 = m;
289
- * return webex.messages.list({roomId: room.id});
290
- * })
291
- * .then(function(messages) {
292
- * var assert = require('assert');
293
- * assert.equal(messages.length, 2);
294
- * assert.equal(messages.items[0].id, message2.id);
295
- * assert.equal(messages.items[1].id, message1.id);
296
- * return 'success';
297
- * });
298
- * // => success
261
+ /**
262
+ * Returns a list of messages. In most cases the results will only contain
263
+ * messages posted in rooms that the authenticated user is a member of.
264
+ * @instance
265
+ * @memberof Messages
266
+ * @param {Object} options
267
+ * @param {string} options.roomId
268
+ * @param {number} options.max
269
+ * @returns {Promise<Page<MessageObject>>}
270
+ * @example
271
+ * var message1, message2, room;
272
+ * webex.rooms.create({title: 'List Messages Example'})
273
+ * .then(function(r) {
274
+ * room = r;
275
+ * return webex.messages.create({
276
+ * text: 'Howdy!',
277
+ * roomId: room.id
278
+ * });
279
+ * })
280
+ * .then(function(m) {
281
+ * message1 = m;
282
+ * return webex.messages.create({
283
+ * text: 'How are you?',
284
+ * roomId: room.id
285
+ * });
286
+ * })
287
+ * .then(function(m) {
288
+ * message2 = m;
289
+ * return webex.messages.list({roomId: room.id});
290
+ * })
291
+ * .then(function(messages) {
292
+ * var assert = require('assert');
293
+ * assert.equal(messages.length, 2);
294
+ * assert.equal(messages.items[0].id, message2.id);
295
+ * assert.equal(messages.items[1].id, message1.id);
296
+ * return 'success';
297
+ * });
298
+ * // => success
299
299
  */
300
300
  list: function list(options) {
301
301
  var _this2 = this;
@@ -307,45 +307,45 @@ var Messages = _webexCore.WebexPlugin.extend({
307
307
  return new _webexCore.Page(res, _this2.webex);
308
308
  });
309
309
  },
310
- /**
311
- * Deletes a single message. Deleting a message will notify all members of the
312
- * room that the authenticated user deleted the message. Generally, users can
313
- * only delete their own messages except for the case of Moderated Rooms and
314
- * Org Administrators.
315
- * @instance
316
- * @memberof Messages
317
- * @param {MessageObject|uuid} message
318
- * @returns {Promise}}
319
- * @example
320
- * var message1, room;
321
- * webex.rooms.create({title: 'Messages Example'})
322
- * .then(function(r) {
323
- * room = r;
324
- * return webex.messages.create({
325
- * text: 'Howdy!',
326
- * roomId: room.id
327
- * });
328
- * })
329
- * .then(function(m) {
330
- * message1 = m;
331
- * return webex.messages.create({
332
- * text: 'How are you?',
333
- * roomId: room.id
334
- * });
335
- * })
336
- * .then(function() {
337
- * return webex.messages.remove(message1);
338
- * })
339
- * .then(function() {
340
- * return webex.messages.list({roomId: room.id});
341
- * })
342
- * .then(function(messages) {
343
- * var assert = require('assert');
344
- * assert.equal(messages.items.length, 1);
345
- * assert(messages.items[0].id !== message1.id);
346
- * return 'success';
347
- * });
348
- * // => success
310
+ /**
311
+ * Deletes a single message. Deleting a message will notify all members of the
312
+ * room that the authenticated user deleted the message. Generally, users can
313
+ * only delete their own messages except for the case of Moderated Rooms and
314
+ * Org Administrators.
315
+ * @instance
316
+ * @memberof Messages
317
+ * @param {MessageObject|uuid} message
318
+ * @returns {Promise}}
319
+ * @example
320
+ * var message1, room;
321
+ * webex.rooms.create({title: 'Messages Example'})
322
+ * .then(function(r) {
323
+ * room = r;
324
+ * return webex.messages.create({
325
+ * text: 'Howdy!',
326
+ * roomId: room.id
327
+ * });
328
+ * })
329
+ * .then(function(m) {
330
+ * message1 = m;
331
+ * return webex.messages.create({
332
+ * text: 'How are you?',
333
+ * roomId: room.id
334
+ * });
335
+ * })
336
+ * .then(function() {
337
+ * return webex.messages.remove(message1);
338
+ * })
339
+ * .then(function() {
340
+ * return webex.messages.list({roomId: room.id});
341
+ * })
342
+ * .then(function(messages) {
343
+ * var assert = require('assert');
344
+ * assert.equal(messages.items.length, 1);
345
+ * assert(messages.items[0].id !== message1.id);
346
+ * return 'success';
347
+ * });
348
+ * // => success
349
349
  */
350
350
  remove: function remove(message) {
351
351
  var id = message.id || message;
@@ -362,12 +362,12 @@ var Messages = _webexCore.WebexPlugin.extend({
362
362
  return res.body;
363
363
  });
364
364
  },
365
- /**
366
- * Curry the 'trigger' method
367
- * @private
368
- * @memberof Messages
369
- * @param {string} type the type of event to fire
370
- * @returns {function} takes event and triggers it
365
+ /**
366
+ * Curry the 'trigger' method
367
+ * @private
368
+ * @memberof Messages
369
+ * @param {string} type the type of event to fire
370
+ * @returns {function} takes event and triggers it
371
371
  */
372
372
  fire: function fire(type) {
373
373
  var _this3 = this;
@@ -375,16 +375,16 @@ var Messages = _webexCore.WebexPlugin.extend({
375
375
  return _this3.trigger(type, event);
376
376
  };
377
377
  },
378
- /**
379
- * This function is called when an internal membership events fires,
380
- * if the user registered for these events with the listen() function.
381
- * External users of the SDK should not call this function
382
- * @private
383
- * @memberof Messages
384
- * @param {Object} event
385
- * @param {Object} event.data contains the data of the event
386
- * @param {Object} event.data.activity the activity that triggered the event
387
- * @returns {void}
378
+ /**
379
+ * This function is called when an internal membership events fires,
380
+ * if the user registered for these events with the listen() function.
381
+ * External users of the SDK should not call this function
382
+ * @private
383
+ * @memberof Messages
384
+ * @param {Object} event
385
+ * @param {Object} event.data contains the data of the event
386
+ * @param {Object} event.data.activity the activity that triggered the event
387
+ * @returns {void}
388
388
  */
389
389
  onWebexApiEvent: function onWebexApiEvent(_ref) {
390
390
  var activity = _ref.data.activity;
@@ -394,15 +394,15 @@ var Messages = _webexCore.WebexPlugin.extend({
394
394
  }
395
395
  this.getMessageEvent(activity, type).then(this.fire(type));
396
396
  },
397
- /**
398
- * Constructs the data object for an event on the messages resource,
399
- * adhering to Hydra's Webhook data structure messages.
400
- * External users of the SDK should not call this function
401
- * @private
402
- * @memberof Messages
403
- * @param {Object} activity from mercury
404
- * @param {String} type the type of event
405
- * @returns {Object} constructed event
397
+ /**
398
+ * Constructs the data object for an event on the messages resource,
399
+ * adhering to Hydra's Webhook data structure messages.
400
+ * External users of the SDK should not call this function
401
+ * @private
402
+ * @memberof Messages
403
+ * @param {Object} activity from mercury
404
+ * @param {String} type the type of event
405
+ * @returns {Object} constructed event
406
406
  */
407
407
  getMessageEvent: function getMessageEvent(activity, type) {
408
408
  var id = activity.id,
@@ -439,7 +439,7 @@ var Messages = _webexCore.WebexPlugin.extend({
439
439
  });
440
440
  });
441
441
  },
442
- version: "2.59.1"
442
+ version: "2.59.0"
443
443
  });
444
444
  var _default = Messages;
445
445
  exports.default = _default;