@webex/plugin-attachment-actions 2.59.2 → 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/.eslintrc.js CHANGED
@@ -1,6 +1,6 @@
1
- const config = {
2
- root: true,
3
- extends: ['@webex/eslint-config-legacy'],
4
- };
5
-
6
- module.exports = config;
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
package/README.md CHANGED
@@ -1,41 +1,41 @@
1
- # @webex/plugin-messages
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- > Attachment Actions plugin for the Cisco Webex JS SDK.
6
-
7
- - [Install](#install)
8
- - [Usage](#usage)
9
- - [Contribute](#contribute)
10
- - [Maintainers](#maintainers)
11
- - [License](#license)
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install --save @webex/plugin-attachment-actions
17
- ```
18
-
19
- ## Usage
20
-
21
- This is a plugin for the Cisco Webex JS SDK . Please see our [developer portal](https://developer.webex.com/) and the [API docs](https://webex.github.io/webex-js-sdk/api/) for full details.
22
-
23
- ## Install
24
-
25
- ```bash
26
- npm install --save @webex/plugin-attachment-actions
27
- ```
28
-
29
- ## Usage
30
-
31
- ## Maintainers
32
-
33
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
34
-
35
- ## Contribute
36
-
37
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
38
-
39
- ## License
40
-
41
- © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/plugin-messages
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ > Attachment Actions plugin for the Cisco Webex JS SDK.
6
+
7
+ - [Install](#install)
8
+ - [Usage](#usage)
9
+ - [Contribute](#contribute)
10
+ - [Maintainers](#maintainers)
11
+ - [License](#license)
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install --save @webex/plugin-attachment-actions
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ This is a plugin for the Cisco Webex JS SDK . Please see our [developer portal](https://developer.webex.com/) and the [API docs](https://webex.github.io/webex-js-sdk/api/) for full details.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ npm install --save @webex/plugin-attachment-actions
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ## Maintainers
32
+
33
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
34
+
35
+ ## Contribute
36
+
37
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
38
+
39
+ ## License
40
+
41
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const babelConfigLegacy = require('@webex/babel-config-legacy');
2
-
3
- module.exports = babelConfigLegacy;
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
@@ -11,40 +11,40 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/
11
11
  var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
12
12
  var _webexCore = require("@webex/webex-core");
13
13
  var _common = require("@webex/common");
14
- /*!
15
- * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
14
+ /*!
15
+ * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
16
16
  */
17
17
 
18
18
  var debug = require('debug')('attachmentActions');
19
19
 
20
- /**
21
- * @typedef {Object} AttachmentActionObject
22
- * @property {string} id - (server generated) Unique identifier for the attachment action
23
- * @property {string} messageId - The ID of the message in which attachment action is to be performed
24
- * @property {string} type - The type of attachment action eg., submit
25
- * @property {Object} inputs - The inputs for form fields in attachment message
26
- * @property {string} personId - (server generated) The ID for the author of the attachment action
27
- * @property {string} roomId - (server generated) The ID for the room of the message
28
- * @property {isoDate} created - (server generated) The date and time that the message was created
20
+ /**
21
+ * @typedef {Object} AttachmentActionObject
22
+ * @property {string} id - (server generated) Unique identifier for the attachment action
23
+ * @property {string} messageId - The ID of the message in which attachment action is to be performed
24
+ * @property {string} type - The type of attachment action eg., submit
25
+ * @property {Object} inputs - The inputs for form fields in attachment message
26
+ * @property {string} personId - (server generated) The ID for the author of the attachment action
27
+ * @property {string} roomId - (server generated) The ID for the room of the message
28
+ * @property {isoDate} created - (server generated) The date and time that the message was created
29
29
  */
30
30
 
31
- /**
32
- * AttachmentActions are events that communicate information when a user clicks on an
33
- * Action.Submit button in a card displayed in Webex
34
- * Information conveyed in an AttachmentAction includes details about the user that
35
- * clicked the button along with any card specific inputs. See the
36
- * {@link https://developer.webex.com/docs/api/v1/attachment-actions|Attachments Actions API Documentation}
37
- * for more details
38
- * @class
31
+ /**
32
+ * AttachmentActions are events that communicate information when a user clicks on an
33
+ * Action.Submit button in a card displayed in Webex
34
+ * Information conveyed in an AttachmentAction includes details about the user that
35
+ * clicked the button along with any card specific inputs. See the
36
+ * {@link https://developer.webex.com/docs/api/v1/attachment-actions|Attachments Actions API Documentation}
37
+ * for more details
38
+ * @class
39
39
  */
40
40
  var AttachmentActions = _webexCore.WebexPlugin.extend({
41
- /**
42
- * Initializer used to generate AttachmentActions
43
- * as a plugin wrapped around the provided arguments.
44
- * @private
45
- * @see WebexPlugin.initialize
46
- * @param {...any} args
47
- * @returns {undefined}
41
+ /**
42
+ * Initializer used to generate AttachmentActions
43
+ * as a plugin wrapped around the provided arguments.
44
+ * @private
45
+ * @see WebexPlugin.initialize
46
+ * @param {...any} args
47
+ * @returns {undefined}
48
48
  */
49
49
  initialize: function initialize() {
50
50
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -52,33 +52,33 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
52
52
  }
53
53
  (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
54
54
  },
55
- /**
56
- * Register to listen for incoming attachmentAction events
57
- * This is an alternate approach to registering for attachmentAction webhooks.
58
- * The events passed to any registered handlers will be similar to the webhook JSON,
59
- * but will omit webhook specific fields such as name, secret, url, etc.
60
- * The attachmentActions.listen() event objects can also include additional fields not
61
- * available in the webhook's JSON payload, specifically: `inputs`.
62
- * To utilize the `listen()` method, the authorization token used
63
- * will need to have `spark:all` and `spark:kms` scopes enabled.
64
- * Note that by configuring your application to enable or disable `spark:all`
65
- * via its configuration page will also enable or disable `spark:kms`.
66
- * See the <a href="https://webex.github.io/webex-js-sdk/samples/browser-socket/">Sample App</a>
67
- * for more details.
68
- * @instance
69
- * @memberof Messages
70
- * @returns {Promise}
71
- * @example
72
- * webex.attachmentActions.listen()
73
- * .then(() => {
74
- * console.log('listening to attachmentActions events');
75
- * webex.attachmentActions.on('created', (event) => console.log(`Got an attachmentActions:created event:\n${event}`));
76
- * })
77
- * .catch((e) => console.error(`Unable to register for attachmentAction events: ${e}`));
78
- * // Some app logic...
79
- * // WHen it is time to cleanup
80
- * webex.attachmentActions.stopListening();
81
- * webex.attachmentActions.off('created');
55
+ /**
56
+ * Register to listen for incoming attachmentAction events
57
+ * This is an alternate approach to registering for attachmentAction webhooks.
58
+ * The events passed to any registered handlers will be similar to the webhook JSON,
59
+ * but will omit webhook specific fields such as name, secret, url, etc.
60
+ * The attachmentActions.listen() event objects can also include additional fields not
61
+ * available in the webhook's JSON payload, specifically: `inputs`.
62
+ * To utilize the `listen()` method, the authorization token used
63
+ * will need to have `spark:all` and `spark:kms` scopes enabled.
64
+ * Note that by configuring your application to enable or disable `spark:all`
65
+ * via its configuration page will also enable or disable `spark:kms`.
66
+ * See the <a href="https://webex.github.io/webex-js-sdk/samples/browser-socket/">Sample App</a>
67
+ * for more details.
68
+ * @instance
69
+ * @memberof Messages
70
+ * @returns {Promise}
71
+ * @example
72
+ * webex.attachmentActions.listen()
73
+ * .then(() => {
74
+ * console.log('listening to attachmentActions events');
75
+ * webex.attachmentActions.on('created', (event) => console.log(`Got an attachmentActions:created event:\n${event}`));
76
+ * })
77
+ * .catch((e) => console.error(`Unable to register for attachmentAction events: ${e}`));
78
+ * // Some app logic...
79
+ * // WHen it is time to cleanup
80
+ * webex.attachmentActions.stopListening();
81
+ * webex.attachmentActions.off('created');
82
82
  */
83
83
  listen: function listen() {
84
84
  var _this = this;
@@ -94,70 +94,70 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
94
94
  });
95
95
  });
96
96
  },
97
- /**
98
- * Post a new attachment action for a message with attachment.
99
- * @instance
100
- * @memberof AttachmentActions
101
- * @param {AttachmentActionObject} attachmentAction
102
- * @returns {Promise<AttachmentActionObject>}
103
- * @example
104
- * webex.rooms.create({title: 'Create Message with card Example'})
105
- * .then(function(room) {
106
- * return webex.messages.create({
107
- * text: 'Howdy!',
108
- * roomId: room.id,
109
- * attachments:[ {
110
- * contentType: 'application/vnd.microsoft.card.adaptive',
111
- * content: {
112
- * type: 'AdaptiveCard',
113
- * version: '1.0',
114
- * body: [
115
- * {
116
- * type: 'TextBlock',
117
- * text: '',
118
- * size: 'large'
119
- * },
120
- * {
121
- * type: 'TextBlock',
122
- * text: 'Adaptive Cards',
123
- * separation: 'none'
124
- * }
125
- * {
126
- * type: 'Input.Date',
127
- * id: 'dueDate'
128
- * }
129
- * ],
130
- * actions: [
131
- * {
132
- * type: 'Action.Submit',
133
- * title: 'Due Date'
134
- * }
135
- * ]
136
- * }
137
- * }]
138
- * });
139
- * })
140
- * .then(function(message) {
141
- * return webex.attachmentActions.create({
142
- * type: 'submit',
143
- * messageId: message.id,
144
- * inputs:{
145
- * dueDate: '26/06/1995'
146
- * }
147
- * })
148
- * .then(function(attachmentAction)){
149
- * var assert = require('assert');
150
- * assert(attachmentAction.id);
151
- * assert(attachmentAction.type);
152
- * assert(attachmentAction.personId);
153
- * assert(attachmentAction.inputs);
154
- * assert(attachmentAction.messageId);
155
- * assert(attachmentAction.roomId);
156
- * assert(attachmentAction.created);
157
- * return 'success';
158
- * }
159
- * });
160
- * // => success
97
+ /**
98
+ * Post a new attachment action for a message with attachment.
99
+ * @instance
100
+ * @memberof AttachmentActions
101
+ * @param {AttachmentActionObject} attachmentAction
102
+ * @returns {Promise<AttachmentActionObject>}
103
+ * @example
104
+ * webex.rooms.create({title: 'Create Message with card Example'})
105
+ * .then(function(room) {
106
+ * return webex.messages.create({
107
+ * text: 'Howdy!',
108
+ * roomId: room.id,
109
+ * attachments:[ {
110
+ * contentType: 'application/vnd.microsoft.card.adaptive',
111
+ * content: {
112
+ * type: 'AdaptiveCard',
113
+ * version: '1.0',
114
+ * body: [
115
+ * {
116
+ * type: 'TextBlock',
117
+ * text: '',
118
+ * size: 'large'
119
+ * },
120
+ * {
121
+ * type: 'TextBlock',
122
+ * text: 'Adaptive Cards',
123
+ * separation: 'none'
124
+ * }
125
+ * {
126
+ * type: 'Input.Date',
127
+ * id: 'dueDate'
128
+ * }
129
+ * ],
130
+ * actions: [
131
+ * {
132
+ * type: 'Action.Submit',
133
+ * title: 'Due Date'
134
+ * }
135
+ * ]
136
+ * }
137
+ * }]
138
+ * });
139
+ * })
140
+ * .then(function(message) {
141
+ * return webex.attachmentActions.create({
142
+ * type: 'submit',
143
+ * messageId: message.id,
144
+ * inputs:{
145
+ * dueDate: '26/06/1995'
146
+ * }
147
+ * })
148
+ * .then(function(attachmentAction)){
149
+ * var assert = require('assert');
150
+ * assert(attachmentAction.id);
151
+ * assert(attachmentAction.type);
152
+ * assert(attachmentAction.personId);
153
+ * assert(attachmentAction.inputs);
154
+ * assert(attachmentAction.messageId);
155
+ * assert(attachmentAction.roomId);
156
+ * assert(attachmentAction.created);
157
+ * return 'success';
158
+ * }
159
+ * });
160
+ * // => success
161
161
  */
162
162
  create: function create(attachmentAction) {
163
163
  return this.request({
@@ -169,67 +169,67 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
169
169
  return res.body;
170
170
  });
171
171
  },
172
- /**
173
- * Returns a single attachment action.
174
- * @instance
175
- * @memberof AttachmentActions
176
- * @param {string} attachmentAction
177
- * @returns {Promise<AttachmentActionObject>}
178
- * @example
179
- * var attachmentAction;
180
- * webex.rooms.create({title: 'Get Message Example'})
181
- * .then(function(room) {
182
- * return webex.messages.create({
183
- * text: 'Howdy!',
184
- * roomId: room.id,
185
- * attachments:[ {
186
- * contentType: 'application/vnd.microsoft.card.adaptive',
187
- * content: {
188
- * type: 'AdaptiveCard',
189
- * version: '1.0',
190
- * body: [
191
- * {
192
- * type: 'TextBlock',
193
- * text: '',
194
- * size: 'large'
195
- * },
196
- * {
197
- * type: 'TextBlock',
198
- * text: 'Adaptive Cards',
199
- * separation: 'none'
200
- * },
201
- * {
202
- * type: 'Input.Date',
203
- * id: 'dueDate'
204
- * }
205
- * ],
206
- * actions: [
207
- * {
208
- * type: 'Action.Submit',
209
- * title: 'Due Date'
210
- * }
211
- * ]
212
- * }
213
- * }]
214
- * });
215
- * })
216
- * .then(function(message) {
217
- * return webex.attachmentActions.create({
218
- * type: 'submit',
219
- * messageId: message.id,
220
- * inputs:{
221
- * dueDate: '26/06/1995'
222
- * });
223
- * })
224
- * .then(function(attachmentAction) {
225
- * return webex.attachmentActions.get(attachmentAction.id)
226
- * })
227
- * .then(function(attachmentAction){
228
- * var assert = require('assert');
229
- * assert.deepEqual(attachmentAction, attachmentAction);
230
- * return 'success';
231
- * })
232
- * // => success
172
+ /**
173
+ * Returns a single attachment action.
174
+ * @instance
175
+ * @memberof AttachmentActions
176
+ * @param {string} attachmentAction
177
+ * @returns {Promise<AttachmentActionObject>}
178
+ * @example
179
+ * var attachmentAction;
180
+ * webex.rooms.create({title: 'Get Message Example'})
181
+ * .then(function(room) {
182
+ * return webex.messages.create({
183
+ * text: 'Howdy!',
184
+ * roomId: room.id,
185
+ * attachments:[ {
186
+ * contentType: 'application/vnd.microsoft.card.adaptive',
187
+ * content: {
188
+ * type: 'AdaptiveCard',
189
+ * version: '1.0',
190
+ * body: [
191
+ * {
192
+ * type: 'TextBlock',
193
+ * text: '',
194
+ * size: 'large'
195
+ * },
196
+ * {
197
+ * type: 'TextBlock',
198
+ * text: 'Adaptive Cards',
199
+ * separation: 'none'
200
+ * },
201
+ * {
202
+ * type: 'Input.Date',
203
+ * id: 'dueDate'
204
+ * }
205
+ * ],
206
+ * actions: [
207
+ * {
208
+ * type: 'Action.Submit',
209
+ * title: 'Due Date'
210
+ * }
211
+ * ]
212
+ * }
213
+ * }]
214
+ * });
215
+ * })
216
+ * .then(function(message) {
217
+ * return webex.attachmentActions.create({
218
+ * type: 'submit',
219
+ * messageId: message.id,
220
+ * inputs:{
221
+ * dueDate: '26/06/1995'
222
+ * });
223
+ * })
224
+ * .then(function(attachmentAction) {
225
+ * return webex.attachmentActions.get(attachmentAction.id)
226
+ * })
227
+ * .then(function(attachmentAction){
228
+ * var assert = require('assert');
229
+ * assert.deepEqual(attachmentAction, attachmentAction);
230
+ * return 'success';
231
+ * })
232
+ * // => success
233
233
  */
234
234
  get: function get(attachmentAction) {
235
235
  var id = attachmentAction.id || attachmentAction;
@@ -240,14 +240,14 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
240
240
  return res.body.items || res.body;
241
241
  });
242
242
  },
243
- /**
244
- * This function is called when an internal mercury events fires,
245
- * if the user registered for these events with the listen() function.
246
- * External users of the SDK should not call this function
247
- * @private
248
- * @memberof AttachmentAction
249
- * @param {Object} event
250
- * @returns {void}
243
+ /**
244
+ * This function is called when an internal mercury events fires,
245
+ * if the user registered for these events with the listen() function.
246
+ * External users of the SDK should not call this function
247
+ * @private
248
+ * @memberof AttachmentAction
249
+ * @param {Object} event
250
+ * @returns {void}
251
251
  */
252
252
  onWebexApiEvent: function onWebexApiEvent(event) {
253
253
  var activity = event.data.activity;
@@ -267,15 +267,15 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
267
267
  }
268
268
  }
269
269
  },
270
- /**
271
- * Constructs the data object for an event on the attachmentAction resource,
272
- * adhering to Hydra's Webhook data structure messages.
273
- * External users of the SDK should not call this function
274
- * @private
275
- * @memberof AttachmentAction
276
- * @param {Object} activity from mercury
277
- * @param {Object} event type of "webhook" event
278
- * @returns {Object} constructed event
270
+ /**
271
+ * Constructs the data object for an event on the attachmentAction resource,
272
+ * adhering to Hydra's Webhook data structure messages.
273
+ * External users of the SDK should not call this function
274
+ * @private
275
+ * @memberof AttachmentAction
276
+ * @param {Object} activity from mercury
277
+ * @param {Object} event type of "webhook" event
278
+ * @returns {Object} constructed event
279
279
  */
280
280
  getattachmentActionEvent: function getattachmentActionEvent(activity, event) {
281
281
  try {
@@ -302,7 +302,7 @@ var AttachmentActions = _webexCore.WebexPlugin.extend({
302
302
  return null;
303
303
  }
304
304
  },
305
- version: "2.59.2"
305
+ version: "2.59.0"
306
306
  });
307
307
  var _default = AttachmentActions;
308
308
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"names":["_webexCore","require","_common","debug","AttachmentActions","WebexPlugin","extend","initialize","_len","arguments","length","args","Array","_key","_apply","default","prototype","listen","_this","createEventEnvelope","webex","SDK_EVENT","EXTERNAL","RESOURCE","ATTACHMENT_ACTIONS","then","envelope","eventEnvelope","internal","mercury","connect","listenTo","INTERNAL","WEBEX_ACTIVITY","event","onWebexApiEvent","create","attachmentAction","request","method","service","resource","body","res","get","id","concat","items","activity","data","verb","ACTIVITY_VERB","CARD_ACTION","createdEvent","getattachmentActionEvent","EVENT_TYPE","CREATED","_stringify","trigger","sdkEvent","_cloneDeep2","cluster","getHydraClusterString","target","url","created","published","actorId","constructHydraId","hydraTypes","PEOPLE","actor","entryUUID","roomId","ROOM","messageId","MESSAGE","parent","personId","ATTACHMENT_ACTION","object","inputs","type","objectType","e","logger","error","message","version","_default","exports"],"sources":["attachmentActions.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin} from '@webex/webex-core';\nimport {\n SDK_EVENT,\n createEventEnvelope,\n constructHydraId,\n getHydraClusterString,\n hydraTypes,\n} from '@webex/common';\nimport {cloneDeep} from 'lodash';\n\nconst debug = require('debug')('attachmentActions');\n\n/**\n * @typedef {Object} AttachmentActionObject\n * @property {string} id - (server generated) Unique identifier for the attachment action\n * @property {string} messageId - The ID of the message in which attachment action is to be performed\n * @property {string} type - The type of attachment action eg., submit\n * @property {Object} inputs - The inputs for form fields in attachment message\n * @property {string} personId - (server generated) The ID for the author of the attachment action\n * @property {string} roomId - (server generated) The ID for the room of the message\n * @property {isoDate} created - (server generated) The date and time that the message was created\n */\n\n/**\n * AttachmentActions are events that communicate information when a user clicks on an\n * Action.Submit button in a card displayed in Webex\n * Information conveyed in an AttachmentAction includes details about the user that\n * clicked the button along with any card specific inputs. See the\n * {@link https://developer.webex.com/docs/api/v1/attachment-actions|Attachments Actions API Documentation}\n * for more details\n * @class\n */\nconst AttachmentActions = WebexPlugin.extend({\n /**\n * Initializer used to generate AttachmentActions\n * as a plugin wrapped around the provided arguments.\n * @private\n * @see WebexPlugin.initialize\n * @param {...any} args\n * @returns {undefined}\n */\n initialize(...args) {\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\n },\n\n /**\n * Register to listen for incoming attachmentAction events\n * This is an alternate approach to registering for attachmentAction webhooks.\n * The events passed to any registered handlers will be similar to the webhook JSON,\n * but will omit webhook specific fields such as name, secret, url, etc.\n * The attachmentActions.listen() event objects can also include additional fields not\n * available in the webhook's JSON payload, specifically: `inputs`.\n * To utilize the `listen()` method, the authorization token used\n * will need to have `spark:all` and `spark:kms` scopes enabled.\n * Note that by configuring your application to enable or disable `spark:all`\n * via its configuration page will also enable or disable `spark:kms`.\n * See the <a href=\"https://webex.github.io/webex-js-sdk/samples/browser-socket/\">Sample App</a>\n * for more details.\n * @instance\n * @memberof Messages\n * @returns {Promise}\n * @example\n * webex.attachmentActions.listen()\n * .then(() => {\n * console.log('listening to attachmentActions events');\n * webex.attachmentActions.on('created', (event) => console.log(`Got an attachmentActions:created event:\\n${event}`));\n * })\n * .catch((e) => console.error(`Unable to register for attachmentAction events: ${e}`));\n * // Some app logic...\n * // WHen it is time to cleanup\n * webex.attachmentActions.stopListening();\n * webex.attachmentActions.off('created');\n */\n listen() {\n // Create a common envelope that we will wrap all events in\n return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ATTACHMENT_ACTIONS).then(\n (envelope) => {\n this.eventEnvelope = envelope;\n\n // Register to listen to events\n return this.webex.internal.mercury.connect().then(() => {\n this.listenTo(this.webex.internal.mercury, SDK_EVENT.INTERNAL.WEBEX_ACTIVITY, (event) =>\n this.onWebexApiEvent(event)\n );\n });\n }\n );\n },\n\n /**\n * Post a new attachment action for a message with attachment.\n * @instance\n * @memberof AttachmentActions\n * @param {AttachmentActionObject} attachmentAction\n * @returns {Promise<AttachmentActionObject>}\n * @example\n * webex.rooms.create({title: 'Create Message with card Example'})\n * .then(function(room) {\n * return webex.messages.create({\n * text: 'Howdy!',\n * roomId: room.id,\n * attachments:[ {\n * contentType: 'application/vnd.microsoft.card.adaptive',\n * content: {\n * type: 'AdaptiveCard',\n * version: '1.0',\n * body: [\n * {\n * type: 'TextBlock',\n * text: '',\n * size: 'large'\n * },\n * {\n * type: 'TextBlock',\n * text: 'Adaptive Cards',\n * separation: 'none'\n * }\n * {\n * type: 'Input.Date',\n * id: 'dueDate'\n * }\n * ],\n * actions: [\n * {\n * type: 'Action.Submit',\n * title: 'Due Date'\n * }\n * ]\n * }\n * }]\n * });\n * })\n * .then(function(message) {\n * return webex.attachmentActions.create({\n * type: 'submit',\n * messageId: message.id,\n * inputs:{\n * dueDate: '26/06/1995'\n * }\n * })\n * .then(function(attachmentAction)){\n * var assert = require('assert');\n * assert(attachmentAction.id);\n * assert(attachmentAction.type);\n * assert(attachmentAction.personId);\n * assert(attachmentAction.inputs);\n * assert(attachmentAction.messageId);\n * assert(attachmentAction.roomId);\n * assert(attachmentAction.created);\n * return 'success';\n * }\n * });\n * // => success\n */\n create(attachmentAction) {\n return this.request({\n method: 'POST',\n service: 'hydra',\n resource: 'attachment/actions',\n body: attachmentAction,\n }).then((res) => res.body);\n },\n\n /**\n * Returns a single attachment action.\n * @instance\n * @memberof AttachmentActions\n * @param {string} attachmentAction\n * @returns {Promise<AttachmentActionObject>}\n * @example\n * var attachmentAction;\n * webex.rooms.create({title: 'Get Message Example'})\n * .then(function(room) {\n * return webex.messages.create({\n * text: 'Howdy!',\n * roomId: room.id,\n * attachments:[ {\n * contentType: 'application/vnd.microsoft.card.adaptive',\n * content: {\n * type: 'AdaptiveCard',\n * version: '1.0',\n * body: [\n * {\n * type: 'TextBlock',\n * text: '',\n * size: 'large'\n * },\n * {\n * type: 'TextBlock',\n * text: 'Adaptive Cards',\n * separation: 'none'\n * },\n * {\n * type: 'Input.Date',\n * id: 'dueDate'\n * }\n * ],\n * actions: [\n * {\n * type: 'Action.Submit',\n * title: 'Due Date'\n * }\n * ]\n * }\n * }]\n * });\n * })\n * .then(function(message) {\n * return webex.attachmentActions.create({\n * type: 'submit',\n * messageId: message.id,\n * inputs:{\n * dueDate: '26/06/1995'\n * });\n * })\n * .then(function(attachmentAction) {\n * return webex.attachmentActions.get(attachmentAction.id)\n * })\n * .then(function(attachmentAction){\n * var assert = require('assert');\n * assert.deepEqual(attachmentAction, attachmentAction);\n * return 'success';\n * })\n * // => success\n */\n get(attachmentAction) {\n const id = attachmentAction.id || attachmentAction;\n\n return this.request({\n service: 'hydra',\n resource: `attachment/actions/${id}`,\n }).then((res) => res.body.items || res.body);\n },\n\n /**\n * This function is called when an internal mercury events fires,\n * if the user registered for these events with the listen() function.\n * External users of the SDK should not call this function\n * @private\n * @memberof AttachmentAction\n * @param {Object} event\n * @returns {void}\n */\n onWebexApiEvent(event) {\n const {activity} = event.data;\n\n /* eslint-disable no-case-declarations */\n switch (activity.verb) {\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.CARD_ACTION:\n const createdEvent = this.getattachmentActionEvent(\n activity,\n SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED\n );\n\n if (createdEvent) {\n debug(`attachmentAction \"created\" payload: \\\n ${JSON.stringify(createdEvent)}`);\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED, createdEvent);\n }\n break;\n\n default: {\n break;\n }\n }\n },\n\n /**\n * Constructs the data object for an event on the attachmentAction resource,\n * adhering to Hydra's Webhook data structure messages.\n * External users of the SDK should not call this function\n * @private\n * @memberof AttachmentAction\n * @param {Object} activity from mercury\n * @param {Object} event type of \"webhook\" event\n * @returns {Object} constructed event\n */\n getattachmentActionEvent(activity, event) {\n try {\n const sdkEvent = cloneDeep(this.eventEnvelope);\n const cluster = getHydraClusterString(this.webex, activity.target.url);\n\n sdkEvent.event = event;\n sdkEvent.data.created = activity.published;\n sdkEvent.actorId = constructHydraId(hydraTypes.PEOPLE, activity.actor.entryUUID, cluster);\n sdkEvent.data.roomId = constructHydraId(hydraTypes.ROOM, activity.target.id, cluster);\n sdkEvent.data.messageId = constructHydraId(hydraTypes.MESSAGE, activity.parent.id, cluster);\n sdkEvent.data.personId = constructHydraId(\n hydraTypes.PEOPLE,\n activity.actor.entryUUID,\n cluster\n );\n // Seems like it would be nice to have this, but its not in the hydra webhook\n // sdkEvent.data.personEmail =\n // activity.actor.emailAddress || activity.actor.entryEmail;\n\n sdkEvent.data.id = constructHydraId(hydraTypes.ATTACHMENT_ACTION, activity.id, cluster);\n if (activity.object.inputs) {\n sdkEvent.data.inputs = activity.object.inputs;\n }\n sdkEvent.data.type = activity.object.objectType;\n\n return sdkEvent;\n } catch (e) {\n this.webex.logger.error(`Unable to generate SDK event from mercury \\\n'socket activity for attachmentAction:${event} event: ${e.message}`);\n\n return null;\n }\n },\n});\n\nexport default AttachmentActions;\n"],"mappings":";;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAYA,IAAME,KAAK,GA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eAAe,CAACD,KAAK,CAAC;QAAA,EAC5B;MACH,CAAC,CAAC;IACJ,CAAC,CACF;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,MAAM,WAAAA,OAACC,gBAAgB,EAAE;IACvB,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBC,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE,oBAAoB;MAC9BC,IAAI,EAAEL;IACR,CAAC,CAAC,CAACZ,IAAI,CAAC,UAACkB,GAAG;MAAA,OAAKA,GAAG,CAACD,IAAI;IAAA,EAAC;EAC5B,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,GAAG,WAAAA,IAACP,gBAAgB,EAAE;IACpB,IAAMQ,EAAE,GAAGR,gBAAgB,CAACQ,EAAE,IAAIR,gBAAgB;IAElD,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBE,OAAO,EAAE,OAAO;MAChBC,QAAQ,wBAAAK,MAAA,CAAwBD,EAAE;IACpC,CAAC,CAAC,CAACpB,IAAI,CAAC,UAACkB,GAA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_common","debug","AttachmentActions","WebexPlugin","extend","initialize","_len","arguments","length","args","Array","_key","_apply","default","prototype","listen","_this","createEventEnvelope","webex","SDK_EVENT","EXTERNAL","RESOURCE","ATTACHMENT_ACTIONS","then","envelope","eventEnvelope","internal","mercury","connect","listenTo","INTERNAL","WEBEX_ACTIVITY","event","onWebexApiEvent","create","attachmentAction","request","method","service","resource","body","res","get","id","concat","items","activity","data","verb","ACTIVITY_VERB","CARD_ACTION","createdEvent","getattachmentActionEvent","EVENT_TYPE","CREATED","_stringify","trigger","sdkEvent","_cloneDeep2","cluster","getHydraClusterString","target","url","created","published","actorId","constructHydraId","hydraTypes","PEOPLE","actor","entryUUID","roomId","ROOM","messageId","MESSAGE","parent","personId","ATTACHMENT_ACTION","object","inputs","type","objectType","e","logger","error","message","version","_default","exports"],"sources":["attachmentActions.js"],"sourcesContent":["/*!\r\n * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.\r\n */\r\n\r\nimport {WebexPlugin} from '@webex/webex-core';\r\nimport {\r\n SDK_EVENT,\r\n createEventEnvelope,\r\n constructHydraId,\r\n getHydraClusterString,\r\n hydraTypes,\r\n} from '@webex/common';\r\nimport {cloneDeep} from 'lodash';\r\n\r\nconst debug = require('debug')('attachmentActions');\r\n\r\n/**\r\n * @typedef {Object} AttachmentActionObject\r\n * @property {string} id - (server generated) Unique identifier for the attachment action\r\n * @property {string} messageId - The ID of the message in which attachment action is to be performed\r\n * @property {string} type - The type of attachment action eg., submit\r\n * @property {Object} inputs - The inputs for form fields in attachment message\r\n * @property {string} personId - (server generated) The ID for the author of the attachment action\r\n * @property {string} roomId - (server generated) The ID for the room of the message\r\n * @property {isoDate} created - (server generated) The date and time that the message was created\r\n */\r\n\r\n/**\r\n * AttachmentActions are events that communicate information when a user clicks on an\r\n * Action.Submit button in a card displayed in Webex\r\n * Information conveyed in an AttachmentAction includes details about the user that\r\n * clicked the button along with any card specific inputs. See the\r\n * {@link https://developer.webex.com/docs/api/v1/attachment-actions|Attachments Actions API Documentation}\r\n * for more details\r\n * @class\r\n */\r\nconst AttachmentActions = WebexPlugin.extend({\r\n /**\r\n * Initializer used to generate AttachmentActions\r\n * as a plugin wrapped around the provided arguments.\r\n * @private\r\n * @see WebexPlugin.initialize\r\n * @param {...any} args\r\n * @returns {undefined}\r\n */\r\n initialize(...args) {\r\n Reflect.apply(WebexPlugin.prototype.initialize, this, args);\r\n },\r\n\r\n /**\r\n * Register to listen for incoming attachmentAction events\r\n * This is an alternate approach to registering for attachmentAction webhooks.\r\n * The events passed to any registered handlers will be similar to the webhook JSON,\r\n * but will omit webhook specific fields such as name, secret, url, etc.\r\n * The attachmentActions.listen() event objects can also include additional fields not\r\n * available in the webhook's JSON payload, specifically: `inputs`.\r\n * To utilize the `listen()` method, the authorization token used\r\n * will need to have `spark:all` and `spark:kms` scopes enabled.\r\n * Note that by configuring your application to enable or disable `spark:all`\r\n * via its configuration page will also enable or disable `spark:kms`.\r\n * See the <a href=\"https://webex.github.io/webex-js-sdk/samples/browser-socket/\">Sample App</a>\r\n * for more details.\r\n * @instance\r\n * @memberof Messages\r\n * @returns {Promise}\r\n * @example\r\n * webex.attachmentActions.listen()\r\n * .then(() => {\r\n * console.log('listening to attachmentActions events');\r\n * webex.attachmentActions.on('created', (event) => console.log(`Got an attachmentActions:created event:\\n${event}`));\r\n * })\r\n * .catch((e) => console.error(`Unable to register for attachmentAction events: ${e}`));\r\n * // Some app logic...\r\n * // WHen it is time to cleanup\r\n * webex.attachmentActions.stopListening();\r\n * webex.attachmentActions.off('created');\r\n */\r\n listen() {\r\n // Create a common envelope that we will wrap all events in\r\n return createEventEnvelope(this.webex, SDK_EVENT.EXTERNAL.RESOURCE.ATTACHMENT_ACTIONS).then(\r\n (envelope) => {\r\n this.eventEnvelope = envelope;\r\n\r\n // Register to listen to events\r\n return this.webex.internal.mercury.connect().then(() => {\r\n this.listenTo(this.webex.internal.mercury, SDK_EVENT.INTERNAL.WEBEX_ACTIVITY, (event) =>\r\n this.onWebexApiEvent(event)\r\n );\r\n });\r\n }\r\n );\r\n },\r\n\r\n /**\r\n * Post a new attachment action for a message with attachment.\r\n * @instance\r\n * @memberof AttachmentActions\r\n * @param {AttachmentActionObject} attachmentAction\r\n * @returns {Promise<AttachmentActionObject>}\r\n * @example\r\n * webex.rooms.create({title: 'Create Message with card Example'})\r\n * .then(function(room) {\r\n * return webex.messages.create({\r\n * text: 'Howdy!',\r\n * roomId: room.id,\r\n * attachments:[ {\r\n * contentType: 'application/vnd.microsoft.card.adaptive',\r\n * content: {\r\n * type: 'AdaptiveCard',\r\n * version: '1.0',\r\n * body: [\r\n * {\r\n * type: 'TextBlock',\r\n * text: '',\r\n * size: 'large'\r\n * },\r\n * {\r\n * type: 'TextBlock',\r\n * text: 'Adaptive Cards',\r\n * separation: 'none'\r\n * }\r\n * {\r\n * type: 'Input.Date',\r\n * id: 'dueDate'\r\n * }\r\n * ],\r\n * actions: [\r\n * {\r\n * type: 'Action.Submit',\r\n * title: 'Due Date'\r\n * }\r\n * ]\r\n * }\r\n * }]\r\n * });\r\n * })\r\n * .then(function(message) {\r\n * return webex.attachmentActions.create({\r\n * type: 'submit',\r\n * messageId: message.id,\r\n * inputs:{\r\n * dueDate: '26/06/1995'\r\n * }\r\n * })\r\n * .then(function(attachmentAction)){\r\n * var assert = require('assert');\r\n * assert(attachmentAction.id);\r\n * assert(attachmentAction.type);\r\n * assert(attachmentAction.personId);\r\n * assert(attachmentAction.inputs);\r\n * assert(attachmentAction.messageId);\r\n * assert(attachmentAction.roomId);\r\n * assert(attachmentAction.created);\r\n * return 'success';\r\n * }\r\n * });\r\n * // => success\r\n */\r\n create(attachmentAction) {\r\n return this.request({\r\n method: 'POST',\r\n service: 'hydra',\r\n resource: 'attachment/actions',\r\n body: attachmentAction,\r\n }).then((res) => res.body);\r\n },\r\n\r\n /**\r\n * Returns a single attachment action.\r\n * @instance\r\n * @memberof AttachmentActions\r\n * @param {string} attachmentAction\r\n * @returns {Promise<AttachmentActionObject>}\r\n * @example\r\n * var attachmentAction;\r\n * webex.rooms.create({title: 'Get Message Example'})\r\n * .then(function(room) {\r\n * return webex.messages.create({\r\n * text: 'Howdy!',\r\n * roomId: room.id,\r\n * attachments:[ {\r\n * contentType: 'application/vnd.microsoft.card.adaptive',\r\n * content: {\r\n * type: 'AdaptiveCard',\r\n * version: '1.0',\r\n * body: [\r\n * {\r\n * type: 'TextBlock',\r\n * text: '',\r\n * size: 'large'\r\n * },\r\n * {\r\n * type: 'TextBlock',\r\n * text: 'Adaptive Cards',\r\n * separation: 'none'\r\n * },\r\n * {\r\n * type: 'Input.Date',\r\n * id: 'dueDate'\r\n * }\r\n * ],\r\n * actions: [\r\n * {\r\n * type: 'Action.Submit',\r\n * title: 'Due Date'\r\n * }\r\n * ]\r\n * }\r\n * }]\r\n * });\r\n * })\r\n * .then(function(message) {\r\n * return webex.attachmentActions.create({\r\n * type: 'submit',\r\n * messageId: message.id,\r\n * inputs:{\r\n * dueDate: '26/06/1995'\r\n * });\r\n * })\r\n * .then(function(attachmentAction) {\r\n * return webex.attachmentActions.get(attachmentAction.id)\r\n * })\r\n * .then(function(attachmentAction){\r\n * var assert = require('assert');\r\n * assert.deepEqual(attachmentAction, attachmentAction);\r\n * return 'success';\r\n * })\r\n * // => success\r\n */\r\n get(attachmentAction) {\r\n const id = attachmentAction.id || attachmentAction;\r\n\r\n return this.request({\r\n service: 'hydra',\r\n resource: `attachment/actions/${id}`,\r\n }).then((res) => res.body.items || res.body);\r\n },\r\n\r\n /**\r\n * This function is called when an internal mercury events fires,\r\n * if the user registered for these events with the listen() function.\r\n * External users of the SDK should not call this function\r\n * @private\r\n * @memberof AttachmentAction\r\n * @param {Object} event\r\n * @returns {void}\r\n */\r\n onWebexApiEvent(event) {\r\n const {activity} = event.data;\r\n\r\n /* eslint-disable no-case-declarations */\r\n switch (activity.verb) {\r\n case SDK_EVENT.INTERNAL.ACTIVITY_VERB.CARD_ACTION:\r\n const createdEvent = this.getattachmentActionEvent(\r\n activity,\r\n SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED\r\n );\r\n\r\n if (createdEvent) {\r\n debug(`attachmentAction \"created\" payload: \\\r\n ${JSON.stringify(createdEvent)}`);\r\n this.trigger(SDK_EVENT.EXTERNAL.EVENT_TYPE.CREATED, createdEvent);\r\n }\r\n break;\r\n\r\n default: {\r\n break;\r\n }\r\n }\r\n },\r\n\r\n /**\r\n * Constructs the data object for an event on the attachmentAction resource,\r\n * adhering to Hydra's Webhook data structure messages.\r\n * External users of the SDK should not call this function\r\n * @private\r\n * @memberof AttachmentAction\r\n * @param {Object} activity from mercury\r\n * @param {Object} event type of \"webhook\" event\r\n * @returns {Object} constructed event\r\n */\r\n getattachmentActionEvent(activity, event) {\r\n try {\r\n const sdkEvent = cloneDeep(this.eventEnvelope);\r\n const cluster = getHydraClusterString(this.webex, activity.target.url);\r\n\r\n sdkEvent.event = event;\r\n sdkEvent.data.created = activity.published;\r\n sdkEvent.actorId = constructHydraId(hydraTypes.PEOPLE, activity.actor.entryUUID, cluster);\r\n sdkEvent.data.roomId = constructHydraId(hydraTypes.ROOM, activity.target.id, cluster);\r\n sdkEvent.data.messageId = constructHydraId(hydraTypes.MESSAGE, activity.parent.id, cluster);\r\n sdkEvent.data.personId = constructHydraId(\r\n hydraTypes.PEOPLE,\r\n activity.actor.entryUUID,\r\n cluster\r\n );\r\n // Seems like it would be nice to have this, but its not in the hydra webhook\r\n // sdkEvent.data.personEmail =\r\n // activity.actor.emailAddress || activity.actor.entryEmail;\r\n\r\n sdkEvent.data.id = constructHydraId(hydraTypes.ATTACHMENT_ACTION, activity.id, cluster);\r\n if (activity.object.inputs) {\r\n sdkEvent.data.inputs = activity.object.inputs;\r\n }\r\n sdkEvent.data.type = activity.object.objectType;\r\n\r\n return sdkEvent;\r\n } catch (e) {\r\n this.webex.logger.error(`Unable to generate SDK event from mercury \\\r\n'socket activity for attachmentAction:${event} event: ${e.message}`);\r\n\r\n return null;\r\n }\r\n },\r\n});\r\n\r\nexport default AttachmentActions;\r\n"],"mappings":";;;;;;;;;;;AAIA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AALA;AACA;AACA;;AAYA,IAAME,KAAK,GAAGF,OAAO,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMG,iBAAiB,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAC3C;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAU,WAAAA,WAAA,EAAU;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAANC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;IAAA;IAChB,IAAAC,MAAA,CAAAC,OAAA,EAAcV,sBAAW,CAACW,SAAS,CAACT,UAAU,EAAE,IAAI,EAAEI,IAAI,CAAC;EAC7D,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEM,MAAM,WAAAA,OAAA,EAAG;IAAA,IAAAC,KAAA;IACP;IACA,OAAO,IAAAC,2BAAmB,EAAC,IAAI,CAACC,KAAK,EAAEC,iBAAS,CAACC,QAAQ,CAACC,QAAQ,CAACC,kBAAkB,CAAC,CAACC,IAAI,CACzF,UAACC,QAAQ,EAAK;MACZR,KAAI,CAACS,aAAa,GAAGD,QAAQ;;MAE7B;MACA,OAAOR,KAAI,CAACE,KAAK,CAACQ,QAAQ,CAACC,OAAO,CAACC,OAAO,EAAE,CAACL,IAAI,CAAC,YAAM;QACtDP,KAAI,CAACa,QAAQ,CAACb,KAAI,CAACE,KAAK,CAACQ,QAAQ,CAACC,OAAO,EAAER,iBAAS,CAACW,QAAQ,CAACC,cAAc,EAAE,UAACC,KAAK;UAAA,OAClFhB,KAAI,CAACiB,eAAe,CAACD,KAAK,CAAC;QAAA,EAC5B;MACH,CAAC,CAAC;IACJ,CAAC,CACF;EACH,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,MAAM,WAAAA,OAACC,gBAAgB,EAAE;IACvB,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBC,MAAM,EAAE,MAAM;MACdC,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE,oBAAoB;MAC9BC,IAAI,EAAEL;IACR,CAAC,CAAC,CAACZ,IAAI,CAAC,UAACkB,GAAG;MAAA,OAAKA,GAAG,CAACD,IAAI;IAAA,EAAC;EAC5B,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,GAAG,WAAAA,IAACP,gBAAgB,EAAE;IACpB,IAAMQ,EAAE,GAAGR,gBAAgB,CAACQ,EAAE,IAAIR,gBAAgB;IAElD,OAAO,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C;EAAAC,OAAA;AACH,CAAC,CAAC;AAAC,IAAAC,QAAA,GAEYrF,iBAAiB;AAAAsF,OAAA,CAAA3E,OAAA,GAAA0E,QAAA"}
package/dist/index.js CHANGED
@@ -10,8 +10,8 @@ require("@webex/internal-plugin-conversation");
10
10
  require("@webex/internal-plugin-mercury");
11
11
  var _webexCore = require("@webex/webex-core");
12
12
  var _attachmentActions = _interopRequireDefault(require("./attachmentActions"));
13
- /*!
14
- * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
13
+ /*!
14
+ * Copyright (c) 2015-2017 Cisco Systems, Inc. See LICENSE file.
15
15
  */
16
16
 
17
17
  // decrypt mercury activities