@webex/internal-plugin-calendar 3.0.0-beta.3 → 3.0.0-beta.300

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/calendar.js CHANGED
@@ -1,71 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = void 0;
12
-
13
9
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
14
-
15
- var _btoa = _interopRequireDefault(require("btoa"));
16
-
10
+ var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
11
+ var _common = require("@webex/common");
17
12
  var _webexCore = require("@webex/webex-core");
18
-
19
13
  var _collection = _interopRequireDefault(require("./collection"));
20
-
21
14
  var _constants = require("./constants");
22
-
23
- /*!
24
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
25
- */
26
-
27
- /**
28
- * Calendar Item Create Event
29
- * Emitted when a calendar item has been added
30
- * @event calendar:meeting:create
31
- * @instance
32
- * @memberof Calendar
33
- */
34
-
35
- /**
36
- * Calendar Item Update Event
37
- * Emitted when a calendar item has been updated
38
- * @event calendar:meeting:update
39
- * @instance
40
- * @memberof Calendar
41
- */
42
-
43
- /**
44
- * Calendar Item Update Event
45
- * Emitted when a calendar item has been deleted
46
- * @event calendar:meeting:delete
47
- * @instance
48
- * @memberof Calendar
49
- */
50
-
51
- /**
52
- * Calendar Registered Event
53
- * Emitted when the calendar instance has been registered and listening
54
- * @event calendar:registered
55
- * @instance
56
- * @memberof Calendar
57
- */
58
-
59
- /**
60
- * Calendar Registered Event
61
- * Emitted when the calendar instance has been registered and listening
62
- * @event calendar:unregistered
63
- * @instance
64
- * @memberof Calendar
65
- */
15
+ var _calendarEncrypt = _interopRequireDefault(require("./calendar.encrypt.helper"));
16
+ var _calendarDecrypt = _interopRequireDefault(require("./calendar.decrypt.helper"));
66
17
  var Calendar = _webexCore.WebexPlugin.extend({
67
18
  namespace: 'Calendar',
68
-
69
19
  /**
70
20
  * registered value indicating events registration is successful
71
21
  * @instance
@@ -73,7 +23,43 @@ var Calendar = _webexCore.WebexPlugin.extend({
73
23
  * @memberof Calendar
74
24
  */
75
25
  registered: false,
76
-
26
+ /**
27
+ * Cache all rpc event request locally
28
+ * */
29
+ rpcEventRequests: [],
30
+ /**
31
+ * Cache KMS encryptionKeyUrl
32
+ * */
33
+ encryptionKeyUrl: null,
34
+ /**
35
+ * WebexPlugin initialize method. This triggers once Webex has completed its
36
+ * initialization workflow.
37
+ *
38
+ * If the plugin is meant to perform startup actions, place them in this
39
+ * `initialize()` method instead of the `constructor()` method.
40
+ * @returns {void}
41
+ */
42
+ initialize: function initialize() {
43
+ var _this = this;
44
+ // Used to perform actions after webex is fully qualified and ready for
45
+ // operation.
46
+ this.listenToOnce(this.webex, 'ready', function () {
47
+ // Pre-fetch a KMS encryption key url to improve performance
48
+ _this.webex.internal.encryption.kms.createUnboundKeys({
49
+ count: 1
50
+ }).then(function (keys) {
51
+ var key = (0, _isArray2.default)(keys) ? keys[0] : keys;
52
+ _this.encryptionKeyUrl = key ? key.uri : null;
53
+ _this.logger.info('calendar->bind a KMS encryption key url');
54
+ _this.webex.internal.encryption.getKey(_this.encryptionKeyUrl, {
55
+ onBehalfOf: null
56
+ }).then(function (retrievedKey) {
57
+ _this.encryptionKeyUrl = retrievedKey ? retrievedKey.uri : null;
58
+ _this.logger.info('calendar->retrieve the KMS encryption key url and cache it');
59
+ });
60
+ });
61
+ });
62
+ },
77
63
  /**
78
64
  * Explicitly sets up the calendar plugin by registering
79
65
  * the device, connecting to mercury, and listening for calendar events.
@@ -82,33 +68,26 @@ var Calendar = _webexCore.WebexPlugin.extend({
82
68
  * @memberof Calendar
83
69
  */
84
70
  register: function register() {
85
- var _this = this;
86
-
71
+ var _this2 = this;
87
72
  if (!this.webex.canAuthorize) {
88
73
  this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');
89
74
  return _promise.default.reject(new Error('SDK cannot authorize'));
90
75
  }
91
-
92
76
  if (this.registered) {
93
77
  this.logger.info('calendar->register#INFO, Calendar plugin already registered');
94
78
  return _promise.default.resolve();
95
79
  }
96
-
97
80
  return this.webex.internal.device.register().then(function () {
98
- return _this.webex.internal.mercury.connect();
81
+ return _this2.webex.internal.mercury.connect();
99
82
  }).then(function () {
100
- _this.listenForEvents();
101
-
102
- _this.trigger(_constants.CALENDAR_REGISTERED);
103
-
104
- _this.registered = true;
83
+ _this2.listenForEvents();
84
+ _this2.trigger(_constants.CALENDAR_REGISTERED);
85
+ _this2.registered = true;
105
86
  }).catch(function (error) {
106
- _this.logger.error("calendar->register#ERROR, Unable to register, ".concat(error.message));
107
-
87
+ _this2.logger.error("calendar->register#ERROR, Unable to register, ".concat(error.message));
108
88
  return _promise.default.reject(error);
109
89
  });
110
90
  },
111
-
112
91
  /**
113
92
  * Explicitly tears down the calendar plugin by deregistering
114
93
  * the device, disconnecting from mercury, and stops listening to calendar events
@@ -118,49 +97,46 @@ var Calendar = _webexCore.WebexPlugin.extend({
118
97
  * @memberof Calendar
119
98
  */
120
99
  unregister: function unregister() {
121
- var _this2 = this;
122
-
100
+ var _this3 = this;
123
101
  if (!this.registered) {
124
102
  this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');
125
103
  return _promise.default.resolve();
126
104
  }
127
-
128
105
  this.stopListeningForEvents();
129
106
  return this.webex.internal.mercury.disconnect().then(function () {
130
- return _this2.webex.internal.device.unregister();
107
+ return _this3.webex.internal.device.unregister();
131
108
  }).then(function () {
132
- _this2.trigger(_constants.CALENDAR_UNREGISTERED);
133
-
134
- _this2.registered = false;
109
+ _this3.trigger(_constants.CALENDAR_UNREGISTERED);
110
+ _this3.registered = false;
135
111
  });
136
112
  },
137
-
138
113
  /**
139
114
  * registers for calendar events through mercury
140
115
  * @returns {undefined}
141
116
  * @private
142
117
  */
143
118
  listenForEvents: function listenForEvents() {
144
- var _this3 = this;
145
-
119
+ var _this4 = this;
146
120
  // Calendar mercury events listener
147
121
  this.webex.internal.mercury.on('event:calendar.meeting.create', function (envelope) {
148
- _this3._handleCreate(envelope.data);
122
+ _this4._handleCreate(envelope.data);
149
123
  });
150
124
  this.webex.internal.mercury.on('event:calendar.meeting.update', function (envelope) {
151
- _this3._handleUpdate(envelope.data);
125
+ _this4._handleUpdate(envelope.data);
152
126
  });
153
127
  this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', function (envelope) {
154
- _this3._handleCreate(envelope.data);
128
+ _this4._handleCreate(envelope.data);
155
129
  });
156
130
  this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', function (envelope) {
157
- _this3._handleUpdate(envelope.data);
131
+ _this4._handleUpdate(envelope.data);
158
132
  });
159
133
  this.webex.internal.mercury.on('event:calendar.meeting.delete', function (envelope) {
160
- _this3._handleDelete(envelope.data);
134
+ _this4._handleDelete(envelope.data);
135
+ });
136
+ this.webex.internal.mercury.on('event:calendar.free_busy', function (envelope) {
137
+ _this4._handleFreeBusy(envelope.data);
161
138
  });
162
139
  },
163
-
164
140
  /**
165
141
  * unregisteres all the calendar events from mercury
166
142
  * @returns {undefined}
@@ -172,8 +148,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
172
148
  this.webex.internal.mercury.off('event:calendar.meeting.update');
173
149
  this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');
174
150
  this.webex.internal.mercury.off('event:calendar.meeting.delete');
151
+ this.webex.internal.mercury.off('event:calendar.free_busy');
175
152
  },
176
-
177
153
  /**
178
154
  * handles update events, triggers after collection updates
179
155
  * @param {Object} data
@@ -182,10 +158,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
182
158
  */
183
159
  _handleUpdate: function _handleUpdate(data) {
184
160
  var id = _collection.default.set(data.calendarMeetingExternal);
185
-
186
161
  this.trigger(_constants.CALENDAR_UPDATED, _collection.default.get(id));
187
162
  },
188
-
189
163
  /**
190
164
  * handles create events, triggers after collection updates
191
165
  * @param {Object} data
@@ -194,10 +168,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
194
168
  */
195
169
  _handleCreate: function _handleCreate(data) {
196
170
  var id = _collection.default.set(data.calendarMeetingExternal);
197
-
198
171
  this.trigger(_constants.CALENDAR_CREATE, _collection.default.get(id));
199
172
  },
200
-
201
173
  /**
202
174
  * handles delete events, triggers after collection updates
203
175
  * @param {Object} data
@@ -206,10 +178,32 @@ var Calendar = _webexCore.WebexPlugin.extend({
206
178
  */
207
179
  _handleDelete: function _handleDelete(data) {
208
180
  var item = _collection.default.remove(data.calendarMeetingExternal.id);
209
-
210
181
  this.trigger(_constants.CALENDAR_DELETE, item);
211
182
  },
212
-
183
+ /**
184
+ * handles free_busy events
185
+ * @param {Object} data
186
+ * @returns {undefined}
187
+ * @private
188
+ */
189
+ _handleFreeBusy: function _handleFreeBusy(data) {
190
+ var _this5 = this;
191
+ _calendarDecrypt.default.decryptFreeBusyResponse(this, data).then(function () {
192
+ var response = {};
193
+ if (data && data.calendarFreeBusyScheduleResponse) {
194
+ response = data.calendarFreeBusyScheduleResponse;
195
+ }
196
+ if (response && response.requestId && response.requestId in _this5.rpcEventRequests) {
197
+ _this5.logger.log("webex.internal.calendar - receive requests, requestId: ".concat(response.requestId));
198
+ delete response.encryptionKeyUrl;
199
+ var resolve = _this5.rpcEventRequests[response.requestId].resolve;
200
+ resolve(response);
201
+ delete _this5.rpcEventRequests[response.requestId];
202
+ } else {
203
+ _this5.logger.log('webex.internal.calendar - receive other requests.');
204
+ }
205
+ });
206
+ },
213
207
  /**
214
208
  * Retrieves a collection of calendars based on the request parameters
215
209
  * Defaults to 1 day before and 7 days ahead
@@ -228,11 +222,9 @@ var Calendar = _webexCore.WebexPlugin.extend({
228
222
  toDate: options.toDate
229
223
  }).then(function (res) {
230
224
  _collection.default.setAll(res);
231
-
232
225
  return _collection.default.getAll();
233
226
  });
234
227
  },
235
-
236
228
  /**
237
229
  * get the calendar item that has a matching value
238
230
  * @param {String} key meeting property
@@ -243,10 +235,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
243
235
  if (['spaceURI', 'spaceMeetURL', 'conversationId'].includes(key)) {
244
236
  return _collection.default.getBy(key, value);
245
237
  }
246
-
247
238
  throw new Error('key must be one of, spaceURI, spaceMeetURL, or conversationId');
248
239
  },
249
-
250
240
  /**
251
241
  * gets all the calendar items that have been populated
252
242
  * @returns {Object}
@@ -254,7 +244,6 @@ var Calendar = _webexCore.WebexPlugin.extend({
254
244
  getAll: function getAll() {
255
245
  return _collection.default.getAll();
256
246
  },
257
-
258
247
  /**
259
248
  * Decrypts an encrypted incoming calendar event
260
249
  * @param {Object} event
@@ -265,20 +254,28 @@ var Calendar = _webexCore.WebexPlugin.extend({
265
254
  return event;
266
255
  });
267
256
  },
268
-
269
257
  /**
270
- * Retrieves an array of meeting participants for the meeting id
271
- * @param {String} id
258
+ * Retrieves an array of meeting participants for the meeting participantsUrl
259
+ * @param {String} participantsUrl
272
260
  * @returns {Promise} Resolves with an object of meeting participants
273
261
  */
274
- getParticipants: function getParticipants(id) {
262
+ getParticipants: function getParticipants(participantsUrl) {
275
263
  return this.request({
276
264
  method: 'GET',
277
- service: 'calendar',
278
- resource: "calendarEvents/".concat((0, _btoa.default)(id), "/participants")
265
+ uri: participantsUrl
266
+ });
267
+ },
268
+ /**
269
+ * get meeting notes using notesUrl from meeting object.
270
+ * @param {String} notesUrl
271
+ * @returns {Promise} Resolves with an object of meeting notes
272
+ */
273
+ getNotesByUrl: function getNotesByUrl(notesUrl) {
274
+ return this.request({
275
+ method: 'GET',
276
+ uri: notesUrl
279
277
  });
280
278
  },
281
-
282
279
  /**
283
280
  * Retrieves a collection of meetings based on the request parameters
284
281
  * @param {String} id
@@ -288,10 +285,9 @@ var Calendar = _webexCore.WebexPlugin.extend({
288
285
  return this.request({
289
286
  method: 'GET',
290
287
  service: 'calendar',
291
- resource: "calendarEvents/".concat((0, _btoa.default)(id), "/notes")
288
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/notes")
292
289
  });
293
290
  },
294
-
295
291
  /**
296
292
  * Retrieves a collection of meetings based on the request parameters
297
293
  * @param {Object} options
@@ -300,8 +296,7 @@ var Calendar = _webexCore.WebexPlugin.extend({
300
296
  * @returns {Promise} Resolves with an array of meetings
301
297
  */
302
298
  list: function list(options) {
303
- var _this4 = this;
304
-
299
+ var _this6 = this;
305
300
  options = options || {};
306
301
  return this.webex.request({
307
302
  method: 'GET',
@@ -312,14 +307,8 @@ var Calendar = _webexCore.WebexPlugin.extend({
312
307
  var meetingObjects = res.body.items;
313
308
  var promises = [];
314
309
  meetingObjects.forEach(function (meeting) {
315
- if (!meeting.encryptedNotes) {
316
- promises.push(_this4.getNotes(meeting.id).then(function (notesResponse) {
317
- meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;
318
- }));
319
- }
320
-
321
310
  if (!meeting.encryptedParticipants) {
322
- promises.push(_this4.getParticipants(meeting.id).then(function (notesResponse) {
311
+ promises.push(_this6.getParticipants(meeting.participantsUrl).then(function (notesResponse) {
323
312
  meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;
324
313
  }));
325
314
  }
@@ -329,9 +318,120 @@ var Calendar = _webexCore.WebexPlugin.extend({
329
318
  });
330
319
  });
331
320
  },
332
- version: "3.0.0-beta.3"
321
+ /**
322
+ * Create calendar event
323
+ * @param {object} [data] meeting payload data
324
+ * @param {object} [query] the query parameters for specific usage
325
+ * @returns {Promise} Resolves with creating calendar event response
326
+ * */
327
+ createCalendarEvent: function createCalendarEvent(data, query) {
328
+ var _this7 = this;
329
+ return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
330
+ return _this7.request({
331
+ method: 'POST',
332
+ service: 'calendar',
333
+ body: data,
334
+ resource: 'calendarEvents/sync',
335
+ qs: query || {}
336
+ });
337
+ });
338
+ },
339
+ /**
340
+ * Update calendar event
341
+ * @param {string} [id] calendar event id
342
+ * @param {object} [data] meeting payload data
343
+ * @param {object} [query] the query parameters for specific usage
344
+ * @returns {Promise} Resolves with updating calendar event response
345
+ * */
346
+ updateCalendarEvent: function updateCalendarEvent(id, data, query) {
347
+ var _this8 = this;
348
+ return _calendarEncrypt.default.encryptCalendarEventRequest(this, data).then(function () {
349
+ return _this8.request({
350
+ method: 'PATCH',
351
+ service: 'calendar',
352
+ body: data,
353
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
354
+ qs: query || {}
355
+ });
356
+ });
357
+ },
358
+ /**
359
+ * Delete calendar event
360
+ * @param {string} [id] calendar event id
361
+ * @param {object} [query] the query parameters for specific usage
362
+ * @returns {Promise} Resolves with deleting calendar event response
363
+ * */
364
+ deleteCalendarEvent: function deleteCalendarEvent(id, query) {
365
+ return this.request({
366
+ method: 'DELETE',
367
+ service: 'calendar',
368
+ resource: "calendarEvents/".concat(_common.base64.encode(id), "/sync"),
369
+ qs: query || {}
370
+ });
371
+ },
372
+ /**
373
+ * @typedef QuerySchedulerDataOptions
374
+ * @param {string} [siteName] it is site full url, must have. Example: ccctest.dmz.webex.com
375
+ * @param {string} [id] it is seriesOrOccurrenceId. If present, the series/occurrence meeting ID to fetch data for.
376
+ * Example: 040000008200E00074C5B7101A82E008000000004A99F11A0841D9010000000000000000100000009EE499D4A71C1A46B51494C70EC7BFE5
377
+ * @param {string} [clientMeetingId] If present, the client meeting UUID to fetch data for.
378
+ * Example: 7f318aa9-887c-6e94-802a-8dc8e6eb1a0a
379
+ * @param {string} [scheduleTemplateId] it template id.
380
+ * @param {string} [sessionTypeId] it session type id.
381
+ * @param {string} [organizerCIUserId] required in schedule-on-behalf case. It is the organizer's CI UUID.
382
+ * @param {boolean} [usmPreference]
383
+ * @param {string} [webexMeetingId] webex side meeting UUID
384
+ * @param {string} [eventId] event ID.
385
+ * @param {string} [icalUid] icalendar UUID.
386
+ * @param {string} [thirdPartyType] third part type, such as: Microsoft
387
+ */
388
+ /**
389
+ * Get scheduler data from calendar service
390
+ * @param {QuerySchedulerDataOptions} [query] the command parameters for fetching scheduler data.
391
+ * @returns {Promise} Resolves with a decrypted scheduler data
392
+ * */
393
+ getSchedulerData: function getSchedulerData(query) {
394
+ var _this9 = this;
395
+ return this.request({
396
+ method: 'GET',
397
+ service: 'calendar',
398
+ resource: 'schedulerData',
399
+ qs: query || {}
400
+ }).then(function (response) {
401
+ return _calendarDecrypt.default.decryptSchedulerDataResponse(_this9, response.body).then(function () {
402
+ return response;
403
+ });
404
+ });
405
+ },
406
+ /**
407
+ * Get free busy status from calendar service
408
+ * @param {Object} [data] the command parameters for fetching free busy status.
409
+ * @param {object} [query] the query parameters for specific usage
410
+ * @returns {Promise} Resolves with a decrypted response
411
+ * */
412
+ getFreeBusy: function getFreeBusy(data, query) {
413
+ var _this10 = this;
414
+ return _calendarEncrypt.default.encryptFreeBusyRequest(this, data).then(function () {
415
+ return _this10.request({
416
+ method: 'POST',
417
+ service: 'calendar',
418
+ body: data,
419
+ resource: 'freebusy',
420
+ qs: query || {}
421
+ });
422
+ }).then(function () {
423
+ return new _promise.default(function (resolve, reject) {
424
+ _this10.rpcEventRequests[data.requestId] = {
425
+ resolve: resolve,
426
+ reject: reject
427
+ };
428
+ });
429
+ }).catch(function (error) {
430
+ throw error;
431
+ });
432
+ },
433
+ version: "3.0.0-beta.300"
333
434
  });
334
-
335
435
  var _default = Calendar;
336
436
  exports.default = _default;
337
437
  //# sourceMappingURL=calendar.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Calendar","WebexPlugin","extend","namespace","registered","register","webex","canAuthorize","logger","error","reject","Error","info","resolve","internal","device","then","mercury","connect","listenForEvents","trigger","CALENDAR_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","CALENDAR_UNREGISTERED","on","envelope","_handleCreate","data","_handleUpdate","_handleDelete","off","id","CalendarCollection","set","calendarMeetingExternal","CALENDAR_UPDATED","get","CALENDAR_CREATE","item","remove","CALENDAR_DELETE","syncCalendar","options","fromDate","config","toDate","list","res","setAll","getAll","getByType","key","value","includes","getBy","processMeetingEvent","event","transform","getParticipants","request","method","service","resource","btoa","getNotes","qs","meetingObjects","body","items","promises","forEach","meeting","encryptedNotes","push","notesResponse","encryptedParticipants","all"],"sources":["calendar.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Calendar Item Create Event\n * Emitted when a calendar item has been added\n * @event calendar:meeting:create\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been updated\n * @event calendar:meeting:update\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been deleted\n * @event calendar:meeting:delete\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:registered\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:unregistered\n * @instance\n * @memberof Calendar\n */\n\nimport btoa from 'btoa';\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CalendarCollection from './collection';\nimport {CALENDAR_REGISTERED, CALENDAR_UNREGISTERED, CALENDAR_DELETE, CALENDAR_CREATE, CALENDAR_UPDATED} from './constants';\n\nconst Calendar = WebexPlugin.extend({\n namespace: 'Calendar',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof Calendar\n */\n registered: false,\n\n /**\n * Explicitly sets up the calendar plugin by registering\n * the device, connecting to mercury, and listening for calendar events.\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('calendar->register#INFO, Calendar plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.device.register()\n .then(() => this.webex.internal.mercury.connect())\n .then(() => {\n this.listenForEvents();\n this.trigger(CALENDAR_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`calendar->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the calendar plugin by deregistering\n * the device, disconnecting from mercury, and stops listening to calendar events\n *\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury.disconnect()\n .then(() => this.webex.internal.device.unregister())\n .then(() => {\n this.trigger(CALENDAR_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for calendar events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n // Calendar mercury events listener\n this.webex.internal.mercury.on('event:calendar.meeting.create', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.delete', (envelope) => {\n this._handleDelete(envelope.data);\n });\n },\n\n /**\n * unregisteres all the calendar events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off('event:calendar.meeting.create');\n this.webex.internal.mercury.off('event:calendar.meeting.create.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.update');\n this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.delete');\n },\n\n /**\n * handles update events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleUpdate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_UPDATED, CalendarCollection.get(id));\n },\n\n /**\n * handles create events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleCreate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_CREATE, CalendarCollection.get(id));\n },\n\n /**\n * handles delete events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleDelete(data) {\n const item = CalendarCollection.remove(data.calendarMeetingExternal.id);\n\n this.trigger(CALENDAR_DELETE, item);\n },\n\n /**\n * Retrieves a collection of calendars based on the request parameters\n * Defaults to 1 day before and 7 days ahead\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of calendars\n */\n syncCalendar(options = {fromDate: this.config.fromDate, toDate: this.config.toDate}) {\n return this.list({fromDate: options.fromDate, toDate: options.toDate}).then((res) => {\n CalendarCollection.setAll(res);\n\n return CalendarCollection.getAll();\n });\n },\n /**\n * get the calendar item that has a matching value\n * @param {String} key meeting property\n * @param {Any} value the meeting property to match\n * @returns {Object}\n */\n getByType(key, value) {\n if (['spaceURI', 'spaceMeetURL', 'conversationId'].includes(key)) {\n return CalendarCollection.getBy(key, value);\n }\n throw new Error('key must be one of, spaceURI, spaceMeetURL, or conversationId');\n },\n\n /**\n * gets all the calendar items that have been populated\n * @returns {Object}\n */\n getAll() {\n return CalendarCollection.getAll();\n },\n\n /**\n * Decrypts an encrypted incoming calendar event\n * @param {Object} event\n * @returns {Promise} Resolves with a decrypted calendar event\n */\n processMeetingEvent(event) {\n return this.webex.transform('inbound', event)\n .then(() => event);\n },\n\n /**\n * Retrieves an array of meeting participants for the meeting id\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting participants\n */\n getParticipants(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${btoa(id)}/participants`\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotes(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${btoa(id)}/notes`\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of meetings\n */\n list(options) {\n options = options || {};\n\n return this.webex.request({\n method: 'GET',\n service: 'calendar',\n resource: 'calendarEvents',\n qs: options\n })\n .then((res) => {\n const meetingObjects = res.body.items;\n const promises = [];\n\n meetingObjects.forEach((meeting) => {\n if (!meeting.encryptedNotes) {\n promises.push(\n this.getNotes(meeting.id)\n .then((notesResponse) => {\n meeting.encryptedNotes = notesResponse.body && notesResponse.body.encryptedNotes;\n })\n );\n }\n\n if (!meeting.encryptedParticipants) {\n promises.push(\n this.getParticipants(meeting.id)\n .then((notesResponse) => {\n meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;\n })\n );\n }\n });\n\n return Promise.all(promises)\n .then(() => meetingObjects);\n });\n }\n});\n\nexport default Calendar;\n"],"mappings":";;;;;;;;;;;;;;AA4CA;;AACA;;AAEA;;AACA;;AAhDA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAQA,IAAMA,QAAQ,GAAGC,sBAAA,CAAYC,MAAZ,CAAmB;EAClCC,SAAS,EAAE,UADuB;;EAGlC;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KATsB;;EAWlC;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,QAlBkC,sBAkBvB;IAAA;;IACT,IAAI,CAAC,KAA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AAMsD,cAAN;MAAA,CADD,CAAP;IAED,CAhCI,CAAP;EAiCD,CAlQiC;EAAA;AAAA,CAAnB,CAAjB;;eAqQetE,Q"}
1
+ {"version":3,"names":["Calendar","WebexPlugin","extend","namespace","registered","rpcEventRequests","encryptionKeyUrl","initialize","listenToOnce","webex","internal","encryption","kms","createUnboundKeys","count","then","keys","key","uri","logger","info","getKey","onBehalfOf","retrievedKey","register","canAuthorize","error","reject","Error","resolve","device","mercury","connect","listenForEvents","trigger","CALENDAR_REGISTERED","catch","message","unregister","stopListeningForEvents","disconnect","CALENDAR_UNREGISTERED","on","envelope","_handleCreate","data","_handleUpdate","_handleDelete","_handleFreeBusy","off","id","CalendarCollection","set","calendarMeetingExternal","CALENDAR_UPDATED","get","CALENDAR_CREATE","item","remove","CALENDAR_DELETE","DecryptHelper","decryptFreeBusyResponse","response","calendarFreeBusyScheduleResponse","requestId","log","syncCalendar","options","fromDate","config","toDate","list","res","setAll","getAll","getByType","value","includes","getBy","processMeetingEvent","event","transform","getParticipants","participantsUrl","request","method","getNotesByUrl","notesUrl","getNotes","service","resource","base64","encode","qs","meetingObjects","body","items","promises","forEach","meeting","encryptedParticipants","push","notesResponse","all","createCalendarEvent","query","EncryptHelper","encryptCalendarEventRequest","updateCalendarEvent","deleteCalendarEvent","getSchedulerData","decryptSchedulerDataResponse","getFreeBusy","encryptFreeBusyRequest"],"sources":["calendar.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Calendar Item Create Event\n * Emitted when a calendar item has been added\n * @event calendar:meeting:create\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been updated\n * @event calendar:meeting:update\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Item Update Event\n * Emitted when a calendar item has been deleted\n * @event calendar:meeting:delete\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:registered\n * @instance\n * @memberof Calendar\n */\n\n/**\n * Calendar Registered Event\n * Emitted when the calendar instance has been registered and listening\n * @event calendar:unregistered\n * @instance\n * @memberof Calendar\n */\nimport {isArray} from 'lodash';\nimport {base64} from '@webex/common';\nimport {WebexPlugin} from '@webex/webex-core';\n\nimport CalendarCollection from './collection';\nimport {\n CALENDAR_REGISTERED,\n CALENDAR_UNREGISTERED,\n CALENDAR_DELETE,\n CALENDAR_CREATE,\n CALENDAR_UPDATED,\n} from './constants';\n\nimport EncryptHelper from './calendar.encrypt.helper';\nimport DecryptHelper from './calendar.decrypt.helper';\n\nconst Calendar = WebexPlugin.extend({\n namespace: 'Calendar',\n\n /**\n * registered value indicating events registration is successful\n * @instance\n * @type {Boolean}\n * @memberof Calendar\n */\n registered: false,\n\n /**\n * Cache all rpc event request locally\n * */\n rpcEventRequests: [],\n\n /**\n * Cache KMS encryptionKeyUrl\n * */\n encryptionKeyUrl: null,\n\n /**\n * WebexPlugin initialize method. This triggers once Webex has completed its\n * initialization workflow.\n *\n * If the plugin is meant to perform startup actions, place them in this\n * `initialize()` method instead of the `constructor()` method.\n * @returns {void}\n */\n initialize() {\n // Used to perform actions after webex is fully qualified and ready for\n // operation.\n this.listenToOnce(this.webex, 'ready', () => {\n // Pre-fetch a KMS encryption key url to improve performance\n this.webex.internal.encryption.kms.createUnboundKeys({count: 1}).then((keys) => {\n const key = isArray(keys) ? keys[0] : keys;\n this.encryptionKeyUrl = key ? key.uri : null;\n this.logger.info('calendar->bind a KMS encryption key url');\n this.webex.internal.encryption\n .getKey(this.encryptionKeyUrl, {onBehalfOf: null})\n .then((retrievedKey) => {\n this.encryptionKeyUrl = retrievedKey ? retrievedKey.uri : null;\n this.logger.info('calendar->retrieve the KMS encryption key url and cache it');\n });\n });\n });\n },\n\n /**\n * Explicitly sets up the calendar plugin by registering\n * the device, connecting to mercury, and listening for calendar events.\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n register() {\n if (!this.webex.canAuthorize) {\n this.logger.error('calendar->register#ERROR, Unable to register, SDK cannot authorize');\n\n return Promise.reject(new Error('SDK cannot authorize'));\n }\n\n if (this.registered) {\n this.logger.info('calendar->register#INFO, Calendar plugin already registered');\n\n return Promise.resolve();\n }\n\n return this.webex.internal.device\n .register()\n .then(() => this.webex.internal.mercury.connect())\n .then(() => {\n this.listenForEvents();\n this.trigger(CALENDAR_REGISTERED);\n this.registered = true;\n })\n .catch((error) => {\n this.logger.error(`calendar->register#ERROR, Unable to register, ${error.message}`);\n\n return Promise.reject(error);\n });\n },\n\n /**\n * Explicitly tears down the calendar plugin by deregistering\n * the device, disconnecting from mercury, and stops listening to calendar events\n *\n * @returns {Promise}\n * @public\n * @memberof Calendar\n */\n unregister() {\n if (!this.registered) {\n this.logger.info('calendar->unregister#INFO, Calendar plugin already unregistered');\n\n return Promise.resolve();\n }\n\n this.stopListeningForEvents();\n\n return this.webex.internal.mercury\n .disconnect()\n .then(() => this.webex.internal.device.unregister())\n .then(() => {\n this.trigger(CALENDAR_UNREGISTERED);\n this.registered = false;\n });\n },\n\n /**\n * registers for calendar events through mercury\n * @returns {undefined}\n * @private\n */\n listenForEvents() {\n // Calendar mercury events listener\n this.webex.internal.mercury.on('event:calendar.meeting.create', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.create.minimal', (envelope) => {\n this._handleCreate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.update.minimal', (envelope) => {\n this._handleUpdate(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.meeting.delete', (envelope) => {\n this._handleDelete(envelope.data);\n });\n this.webex.internal.mercury.on('event:calendar.free_busy', (envelope) => {\n this._handleFreeBusy(envelope.data);\n });\n },\n\n /**\n * unregisteres all the calendar events from mercury\n * @returns {undefined}\n * @private\n */\n stopListeningForEvents() {\n this.webex.internal.mercury.off('event:calendar.meeting.create');\n this.webex.internal.mercury.off('event:calendar.meeting.create.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.update');\n this.webex.internal.mercury.off('event:calendar.meeting.update.minimal');\n this.webex.internal.mercury.off('event:calendar.meeting.delete');\n this.webex.internal.mercury.off('event:calendar.free_busy');\n },\n\n /**\n * handles update events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleUpdate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_UPDATED, CalendarCollection.get(id));\n },\n\n /**\n * handles create events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleCreate(data) {\n const id = CalendarCollection.set(data.calendarMeetingExternal);\n\n this.trigger(CALENDAR_CREATE, CalendarCollection.get(id));\n },\n\n /**\n * handles delete events, triggers after collection updates\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleDelete(data) {\n const item = CalendarCollection.remove(data.calendarMeetingExternal.id);\n\n this.trigger(CALENDAR_DELETE, item);\n },\n\n /**\n * handles free_busy events\n * @param {Object} data\n * @returns {undefined}\n * @private\n */\n _handleFreeBusy(data) {\n DecryptHelper.decryptFreeBusyResponse(this, data).then(() => {\n let response = {};\n if (data && data.calendarFreeBusyScheduleResponse) {\n response = data.calendarFreeBusyScheduleResponse;\n }\n if (response && response.requestId && response.requestId in this.rpcEventRequests) {\n this.logger.log(\n `webex.internal.calendar - receive requests, requestId: ${response.requestId}`\n );\n delete response.encryptionKeyUrl;\n const {resolve} = this.rpcEventRequests[response.requestId];\n resolve(response);\n delete this.rpcEventRequests[response.requestId];\n } else {\n this.logger.log('webex.internal.calendar - receive other requests.');\n }\n });\n },\n\n /**\n * Retrieves a collection of calendars based on the request parameters\n * Defaults to 1 day before and 7 days ahead\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of calendars\n */\n syncCalendar(options = {fromDate: this.config.fromDate, toDate: this.config.toDate}) {\n return this.list({fromDate: options.fromDate, toDate: options.toDate}).then((res) => {\n CalendarCollection.setAll(res);\n\n return CalendarCollection.getAll();\n });\n },\n /**\n * get the calendar item that has a matching value\n * @param {String} key meeting property\n * @param {Any} value the meeting property to match\n * @returns {Object}\n */\n getByType(key, value) {\n if (['spaceURI', 'spaceMeetURL', 'conversationId'].includes(key)) {\n return CalendarCollection.getBy(key, value);\n }\n throw new Error('key must be one of, spaceURI, spaceMeetURL, or conversationId');\n },\n\n /**\n * gets all the calendar items that have been populated\n * @returns {Object}\n */\n getAll() {\n return CalendarCollection.getAll();\n },\n\n /**\n * Decrypts an encrypted incoming calendar event\n * @param {Object} event\n * @returns {Promise} Resolves with a decrypted calendar event\n */\n processMeetingEvent(event) {\n return this.webex.transform('inbound', event).then(() => event);\n },\n\n /**\n * Retrieves an array of meeting participants for the meeting participantsUrl\n * @param {String} participantsUrl\n * @returns {Promise} Resolves with an object of meeting participants\n */\n getParticipants(participantsUrl) {\n return this.request({\n method: 'GET',\n uri: participantsUrl,\n });\n },\n\n /**\n * get meeting notes using notesUrl from meeting object.\n * @param {String} notesUrl\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotesByUrl(notesUrl) {\n return this.request({\n method: 'GET',\n uri: notesUrl,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {String} id\n * @returns {Promise} Resolves with an object of meeting notes\n */\n getNotes(id) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: `calendarEvents/${base64.encode(id)}/notes`,\n });\n },\n\n /**\n * Retrieves a collection of meetings based on the request parameters\n * @param {Object} options\n * @param {Date} options.fromDate the start of the time range\n * @param {Date} options.toDate the end of the time range\n * @returns {Promise} Resolves with an array of meetings\n */\n list(options) {\n options = options || {};\n\n return this.webex\n .request({\n method: 'GET',\n service: 'calendar',\n resource: 'calendarEvents',\n qs: options,\n })\n .then((res) => {\n const meetingObjects = res.body.items;\n const promises = [];\n\n meetingObjects.forEach((meeting) => {\n if (!meeting.encryptedParticipants) {\n promises.push(\n this.getParticipants(meeting.participantsUrl).then((notesResponse) => {\n meeting.encryptedParticipants = notesResponse.body.encryptedParticipants;\n })\n );\n }\n });\n\n return Promise.all(promises).then(() => meetingObjects);\n });\n },\n\n /**\n * Create calendar event\n * @param {object} [data] meeting payload data\n * @param {object} [query] the query parameters for specific usage\n * @returns {Promise} Resolves with creating calendar event response\n * */\n createCalendarEvent(data, query) {\n return EncryptHelper.encryptCalendarEventRequest(this, data).then(() =>\n this.request({\n method: 'POST',\n service: 'calendar',\n body: data,\n resource: 'calendarEvents/sync',\n qs: query || {},\n })\n );\n },\n\n /**\n * Update calendar event\n * @param {string} [id] calendar event id\n * @param {object} [data] meeting payload data\n * @param {object} [query] the query parameters for specific usage\n * @returns {Promise} Resolves with updating calendar event response\n * */\n updateCalendarEvent(id, data, query) {\n return EncryptHelper.encryptCalendarEventRequest(this, data).then(() =>\n this.request({\n method: 'PATCH',\n service: 'calendar',\n body: data,\n resource: `calendarEvents/${base64.encode(id)}/sync`,\n qs: query || {},\n })\n );\n },\n\n /**\n * Delete calendar event\n * @param {string} [id] calendar event id\n * @param {object} [query] the query parameters for specific usage\n * @returns {Promise} Resolves with deleting calendar event response\n * */\n deleteCalendarEvent(id, query) {\n return this.request({\n method: 'DELETE',\n service: 'calendar',\n resource: `calendarEvents/${base64.encode(id)}/sync`,\n qs: query || {},\n });\n },\n\n /**\n * @typedef QuerySchedulerDataOptions\n * @param {string} [siteName] it is site full url, must have. Example: ccctest.dmz.webex.com\n * @param {string} [id] it is seriesOrOccurrenceId. If present, the series/occurrence meeting ID to fetch data for.\n * Example: 040000008200E00074C5B7101A82E008000000004A99F11A0841D9010000000000000000100000009EE499D4A71C1A46B51494C70EC7BFE5\n * @param {string} [clientMeetingId] If present, the client meeting UUID to fetch data for.\n * Example: 7f318aa9-887c-6e94-802a-8dc8e6eb1a0a\n * @param {string} [scheduleTemplateId] it template id.\n * @param {string} [sessionTypeId] it session type id.\n * @param {string} [organizerCIUserId] required in schedule-on-behalf case. It is the organizer's CI UUID.\n * @param {boolean} [usmPreference]\n * @param {string} [webexMeetingId] webex side meeting UUID\n * @param {string} [eventId] event ID.\n * @param {string} [icalUid] icalendar UUID.\n * @param {string} [thirdPartyType] third part type, such as: Microsoft\n */\n /**\n * Get scheduler data from calendar service\n * @param {QuerySchedulerDataOptions} [query] the command parameters for fetching scheduler data.\n * @returns {Promise} Resolves with a decrypted scheduler data\n * */\n getSchedulerData(query) {\n return this.request({\n method: 'GET',\n service: 'calendar',\n resource: 'schedulerData',\n qs: query || {},\n }).then((response) => {\n return DecryptHelper.decryptSchedulerDataResponse(this, response.body).then(() => response);\n });\n },\n\n /**\n * Get free busy status from calendar service\n * @param {Object} [data] the command parameters for fetching free busy status.\n * @param {object} [query] the query parameters for specific usage\n * @returns {Promise} Resolves with a decrypted response\n * */\n getFreeBusy(data, query) {\n return EncryptHelper.encryptFreeBusyRequest(this, data)\n .then(() => {\n return this.request({\n method: 'POST',\n service: 'calendar',\n body: data,\n resource: 'freebusy',\n qs: query || {},\n });\n })\n .then(() => {\n return new Promise((resolve, reject) => {\n this.rpcEventRequests[data.requestId] = {resolve, reject};\n });\n })\n .catch((error) => {\n throw error;\n });\n },\n});\n\nexport default Calendar;\n"],"mappings":";;;;;;;;;;AA4CA;AACA;AAEA;AACA;AAQA;AACA;AAEA,IAAMA,QAAQ,GAAGC,sBAAW,CAACC,MAAM,CAAC;EAClCC,SAAS,EAAE,UAAU;EAErB;AACF;AACA;AACA;AACA;AACA;EACEC,UAAU,EAAE,KAAK;EAEjB;AACF;AACA;EACEC,gBAAgB,EAAE,EAAE;EAEpB;AACF;AACA;EACEC,gBAAgB,EAAE,IAAI;EAEtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAU,wBAAG;IAAA;IACX;IACA;IACA,IAAI,CAACC,YAAY,CAAC,IAAI,CAACC,KAAK,EAAE,OAAO,EAAE,YAAM;MA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