@webex/internal-plugin-ediscovery 3.0.0-beta.9 → 3.0.0-bnr.2

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.
@@ -1,69 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys = require("@babel/runtime-corejs2/core-js/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
-
7
5
  var _Object$getOwnPropertyDescriptor2 = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
-
9
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
10
-
11
7
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
12
-
13
8
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
-
15
9
  var _Array$from = require("@babel/runtime-corejs2/core-js/array/from");
16
-
17
10
  var _Symbol = require("@babel/runtime-corejs2/core-js/symbol");
18
-
19
11
  var _Symbol$iterator = require("@babel/runtime-corejs2/core-js/symbol/iterator");
20
-
21
12
  var _Array$isArray2 = require("@babel/runtime-corejs2/core-js/array/is-array");
22
-
23
13
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
24
-
25
14
  _Object$defineProperty(exports, "__esModule", {
26
15
  value: true
27
16
  });
28
-
29
17
  exports.default = void 0;
30
-
31
18
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
32
-
33
19
  var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
34
-
35
20
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
36
-
37
21
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
38
-
39
22
  var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
40
-
41
23
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
42
-
43
24
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
44
-
45
25
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
46
-
47
26
  var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
48
-
49
27
  var _webexCore = require("@webex/webex-core");
50
-
51
28
  var _common = require("@webex/common");
52
-
53
29
  var _ediscoveryError = require("./ediscovery-error");
54
-
55
30
  var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _obj;
56
-
57
31
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && o[_Symbol$iterator] || o["@@iterator"]; if (!it) { if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
58
-
59
32
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
60
-
61
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
62
-
33
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
63
34
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor2(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
64
-
65
35
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor2(source, key)); }); } return target; }
66
-
67
36
  /**
68
37
  * Creates a unique oneflight key for a request from the reportId and options params
69
38
  * It is important that the offset params are included if present to ensure paged requests get back the correct data
@@ -73,29 +42,24 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
73
42
  */
74
43
  function createOneFlightKey(reportId, options) {
75
44
  var key = String(reportId);
76
-
77
45
  if (options) {
78
46
  if (options.offset) {
79
47
  key += String(options.offset);
80
48
  }
81
-
82
49
  if (options.size) {
83
50
  key += String(options.size);
84
51
  }
85
-
86
52
  if (options.types) {
87
53
  key += String(options.types);
88
54
  }
89
55
  }
90
-
91
56
  return key;
92
57
  }
58
+
93
59
  /**
94
60
  * @class EDiscovery is used by compliance officers to run compliance reports
95
61
  *
96
62
  */
97
-
98
-
99
63
  var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForValue)('@'), _dec2 = (0, _webexCore.waitForValue)('@'), _dec3 = (0, _webexCore.waitForValue)('@'), _dec4 = (0, _webexCore.waitForValue)('@'), _dec5 = (0, _webexCore.waitForValue)('@'), _dec6 = (0, _webexCore.waitForValue)('@'), _dec7 = (0, _common.oneFlight)({
100
64
  keyFactory: function keyFactory(reportId, options) {
101
65
  return createOneFlightKey(reportId, options);
@@ -118,7 +82,6 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
118
82
  }
119
83
  }
120
84
  },
121
-
122
85
  /**
123
86
  * Creates a compliance report with a specific set of search parameters
124
87
  * @param {Object} reportRequest - A set of criteria for determining the focus of the search
@@ -128,51 +91,42 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
128
91
  */
129
92
  createReport: function createReport(reportRequest, options) {
130
93
  var _this = this;
131
-
132
94
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
133
95
  var body;
134
96
  return _regenerator.default.wrap(function _callee$(_context) {
135
- while (1) {
136
- switch (_context.prev = _context.next) {
137
- case 0:
138
- if (reportRequest) {
139
- _context.next = 2;
140
- break;
141
- }
142
-
143
- throw Error('Undefined parameter');
144
-
145
- case 2:
146
- // use spread operator to set default options
147
- options = _objectSpread(_objectSpread({}, _this.config.defaultOptions), options);
148
- body = reportRequest;
149
- _context.prev = 4;
150
- _context.next = 7;
151
- return _this.request({
152
- method: 'POST',
153
- service: 'ediscovery',
154
- resource: 'reports',
155
- timeout: options.timeoutMs,
156
- body: body
157
- });
158
-
159
- case 7:
160
- return _context.abrupt("return", _context.sent);
161
-
162
- case 10:
163
- _context.prev = 10;
164
- _context.t0 = _context["catch"](4);
165
- return _context.abrupt("return", _this._handleReportRequestError(_context.t0));
166
-
167
- case 13:
168
- case "end":
169
- return _context.stop();
170
- }
97
+ while (1) switch (_context.prev = _context.next) {
98
+ case 0:
99
+ if (reportRequest) {
100
+ _context.next = 2;
101
+ break;
102
+ }
103
+ throw Error('Undefined parameter');
104
+ case 2:
105
+ // use spread operator to set default options
106
+ options = _objectSpread(_objectSpread({}, _this.config.defaultOptions), options);
107
+ body = reportRequest;
108
+ _context.prev = 4;
109
+ _context.next = 7;
110
+ return _this.request({
111
+ method: 'POST',
112
+ service: 'ediscovery',
113
+ resource: 'reports',
114
+ timeout: options.timeoutMs,
115
+ body: body
116
+ });
117
+ case 7:
118
+ return _context.abrupt("return", _context.sent);
119
+ case 10:
120
+ _context.prev = 10;
121
+ _context.t0 = _context["catch"](4);
122
+ return _context.abrupt("return", _this._handleReportRequestError(_context.t0));
123
+ case 13:
124
+ case "end":
125
+ return _context.stop();
171
126
  }
172
127
  }, _callee, null, [[4, 10]]);
173
128
  }))();
174
129
  },
175
-
176
130
  /**
177
131
  * Checks the error from createReport and ensures the appropriate error is sent to the client
178
132
  * @param {Error} reason - Error response thrown by the request to createReport
@@ -182,22 +136,18 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
182
136
  if (reason.body.errorCode === _ediscoveryError.InvalidEmailAddressError.getErrorCode()) {
183
137
  try {
184
138
  var invalidEmails = JSON.parse(reason.body.message);
185
-
186
139
  if ((0, _isArray.default)(invalidEmails) && invalidEmails.length) {
187
140
  var invalidEmailAddressError = new _ediscoveryError.InvalidEmailAddressError(invalidEmails);
188
141
  return _promise.default.reject(invalidEmailAddressError);
189
142
  }
190
-
191
143
  this.logger.warn('InvalidEmailAddress error received but the list could not be parsed to the correct format.');
192
144
  } catch (error) {
193
145
  // assume syntax error and continue
194
146
  this.logger.error('InvalidEmailAddress error received but an error occured while parsing the emails.');
195
147
  }
196
148
  }
197
-
198
149
  return _promise.default.reject(reason);
199
150
  },
200
-
201
151
  /**
202
152
  * Retrieves information relating to a specified report
203
153
  * @param {UUID} reportId - Id of the report being requested
@@ -207,38 +157,31 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
207
157
  */
208
158
  getReport: function getReport(reportId, options) {
209
159
  var _this2 = this;
210
-
211
160
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
212
161
  return _regenerator.default.wrap(function _callee2$(_context2) {
213
- while (1) {
214
- switch (_context2.prev = _context2.next) {
215
- case 0:
216
- if (reportId) {
217
- _context2.next = 2;
218
- break;
219
- }
220
-
221
- throw Error('Undefined parameter');
222
-
223
- case 2:
224
- // use spread operator to set default options
225
- options = _objectSpread(_objectSpread({}, _this2.config.defaultOptions), options);
226
- return _context2.abrupt("return", _this2.request({
227
- method: 'GET',
228
- service: 'ediscovery',
229
- resource: "reports/".concat(reportId),
230
- timeout: options.timeoutMs
231
- }));
232
-
233
- case 4:
234
- case "end":
235
- return _context2.stop();
236
- }
162
+ while (1) switch (_context2.prev = _context2.next) {
163
+ case 0:
164
+ if (reportId) {
165
+ _context2.next = 2;
166
+ break;
167
+ }
168
+ throw Error('Undefined parameter');
169
+ case 2:
170
+ // use spread operator to set default options
171
+ options = _objectSpread(_objectSpread({}, _this2.config.defaultOptions), options);
172
+ return _context2.abrupt("return", _this2.request({
173
+ method: 'GET',
174
+ service: 'ediscovery',
175
+ resource: "reports/".concat(reportId),
176
+ timeout: options.timeoutMs
177
+ }));
178
+ case 4:
179
+ case "end":
180
+ return _context2.stop();
237
181
  }
238
182
  }, _callee2);
239
183
  }))();
240
184
  },
241
-
242
185
  /**
243
186
  * Retrieves all the compliance officers reports
244
187
  * @param {Object} options - optional parameters for this method
@@ -249,34 +192,29 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
249
192
  */
250
193
  getReports: function getReports(options) {
251
194
  var _this3 = this;
252
-
253
195
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
254
196
  return _regenerator.default.wrap(function _callee3$(_context3) {
255
- while (1) {
256
- switch (_context3.prev = _context3.next) {
257
- case 0:
258
- // use spread operator to set default options
259
- options = _objectSpread(_objectSpread({}, _this3.config.defaultOptions), options);
260
- return _context3.abrupt("return", _this3.request({
261
- method: 'GET',
262
- service: 'ediscovery',
263
- resource: 'reports',
264
- qs: {
265
- offset: options.offset,
266
- size: options.size
267
- },
268
- timeout: options.timeoutMs
269
- }));
270
-
271
- case 2:
272
- case "end":
273
- return _context3.stop();
274
- }
197
+ while (1) switch (_context3.prev = _context3.next) {
198
+ case 0:
199
+ // use spread operator to set default options
200
+ options = _objectSpread(_objectSpread({}, _this3.config.defaultOptions), options);
201
+ return _context3.abrupt("return", _this3.request({
202
+ method: 'GET',
203
+ service: 'ediscovery',
204
+ resource: 'reports',
205
+ qs: {
206
+ offset: options.offset,
207
+ size: options.size
208
+ },
209
+ timeout: options.timeoutMs
210
+ }));
211
+ case 2:
212
+ case "end":
213
+ return _context3.stop();
275
214
  }
276
215
  }, _callee3);
277
216
  }))();
278
217
  },
279
-
280
218
  /**
281
219
  * Deletes a specified report
282
220
  * @param {UUID} reportId - Id of the report being requested for deletion
@@ -286,38 +224,31 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
286
224
  */
287
225
  deleteReport: function deleteReport(reportId, options) {
288
226
  var _this4 = this;
289
-
290
227
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
291
228
  return _regenerator.default.wrap(function _callee4$(_context4) {
292
- while (1) {
293
- switch (_context4.prev = _context4.next) {
294
- case 0:
295
- if (reportId) {
296
- _context4.next = 2;
297
- break;
298
- }
299
-
300
- throw Error('Undefined parameter');
301
-
302
- case 2:
303
- // use spread operator to set default options
304
- options = _objectSpread(_objectSpread({}, _this4.config.defaultOptions), options);
305
- return _context4.abrupt("return", _this4.request({
306
- method: 'DELETE',
307
- service: 'ediscovery',
308
- resource: "reports/".concat(reportId),
309
- timeout: options.timeoutMs
310
- }));
311
-
312
- case 4:
313
- case "end":
314
- return _context4.stop();
315
- }
229
+ while (1) switch (_context4.prev = _context4.next) {
230
+ case 0:
231
+ if (reportId) {
232
+ _context4.next = 2;
233
+ break;
234
+ }
235
+ throw Error('Undefined parameter');
236
+ case 2:
237
+ // use spread operator to set default options
238
+ options = _objectSpread(_objectSpread({}, _this4.config.defaultOptions), options);
239
+ return _context4.abrupt("return", _this4.request({
240
+ method: 'DELETE',
241
+ service: 'ediscovery',
242
+ resource: "reports/".concat(reportId),
243
+ timeout: options.timeoutMs
244
+ }));
245
+ case 4:
246
+ case "end":
247
+ return _context4.stop();
316
248
  }
317
249
  }, _callee4);
318
250
  }))();
319
251
  },
320
-
321
252
  /**
322
253
  * Restarts a completed or cancelled report so that it begins again from scratch
323
254
  * @param {UUID} reportId - Id of the report being requested
@@ -327,38 +258,31 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
327
258
  */
328
259
  restartReport: function restartReport(reportId, options) {
329
260
  var _this5 = this;
330
-
331
261
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
332
262
  return _regenerator.default.wrap(function _callee5$(_context5) {
333
- while (1) {
334
- switch (_context5.prev = _context5.next) {
335
- case 0:
336
- if (reportId) {
337
- _context5.next = 2;
338
- break;
339
- }
340
-
341
- throw Error('Undefined parameter');
342
-
343
- case 2:
344
- // use spread operator to set default options
345
- options = _objectSpread(_objectSpread({}, _this5.config.defaultOptions), options);
346
- return _context5.abrupt("return", _this5.request({
347
- method: 'PUT',
348
- service: 'ediscovery',
349
- resource: "reports/".concat(reportId),
350
- timeout: options.timeoutMs
351
- }));
352
-
353
- case 4:
354
- case "end":
355
- return _context5.stop();
356
- }
263
+ while (1) switch (_context5.prev = _context5.next) {
264
+ case 0:
265
+ if (reportId) {
266
+ _context5.next = 2;
267
+ break;
268
+ }
269
+ throw Error('Undefined parameter');
270
+ case 2:
271
+ // use spread operator to set default options
272
+ options = _objectSpread(_objectSpread({}, _this5.config.defaultOptions), options);
273
+ return _context5.abrupt("return", _this5.request({
274
+ method: 'PUT',
275
+ service: 'ediscovery',
276
+ resource: "reports/".concat(reportId),
277
+ timeout: options.timeoutMs
278
+ }));
279
+ case 4:
280
+ case "end":
281
+ return _context5.stop();
357
282
  }
358
283
  }, _callee5);
359
284
  }))();
360
285
  },
361
-
362
286
  /**
363
287
  * Retrieves content associated with a report
364
288
  * @param {UUID|string} reportId - UUID or url of the report which contains the content
@@ -370,44 +294,36 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
370
294
  */
371
295
  getContent: function getContent(reportId, options) {
372
296
  var _this6 = this;
373
-
374
297
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
375
298
  var _this6$_createRequest, _this6$_createRequest2, requestOptions;
376
-
377
299
  return _regenerator.default.wrap(function _callee6$(_context6) {
378
- while (1) {
379
- switch (_context6.prev = _context6.next) {
380
- case 0:
381
- if (reportId) {
382
- _context6.next = 2;
383
- break;
384
- }
385
-
386
- throw Error('Undefined parameter');
387
-
388
- case 2:
389
- // use spread operator to set default options
390
- options = _objectSpread(_objectSpread({}, _this6.config.defaultOptions), options);
391
- _this6$_createRequest = _this6._createRequestOptions(reportId, '/contents'), _this6$_createRequest2 = (0, _slicedToArray2.default)(_this6$_createRequest, 1), requestOptions = _this6$_createRequest2[0];
392
- return _context6.abrupt("return", _this6.request(_objectSpread(_objectSpread({
393
- method: 'GET'
394
- }, requestOptions), {}, {
395
- qs: {
396
- offset: options.offset,
397
- size: options.size
398
- },
399
- timeout: options.timeoutMs
400
- })));
401
-
402
- case 5:
403
- case "end":
404
- return _context6.stop();
405
- }
300
+ while (1) switch (_context6.prev = _context6.next) {
301
+ case 0:
302
+ if (reportId) {
303
+ _context6.next = 2;
304
+ break;
305
+ }
306
+ throw Error('Undefined parameter');
307
+ case 2:
308
+ // use spread operator to set default options
309
+ options = _objectSpread(_objectSpread({}, _this6.config.defaultOptions), options);
310
+ _this6$_createRequest = _this6._createRequestOptions(reportId, '/contents'), _this6$_createRequest2 = (0, _slicedToArray2.default)(_this6$_createRequest, 1), requestOptions = _this6$_createRequest2[0];
311
+ return _context6.abrupt("return", _this6.request(_objectSpread(_objectSpread({
312
+ method: 'GET'
313
+ }, requestOptions), {}, {
314
+ qs: {
315
+ offset: options.offset,
316
+ size: options.size
317
+ },
318
+ timeout: options.timeoutMs
319
+ })));
320
+ case 5:
321
+ case "end":
322
+ return _context6.stop();
406
323
  }
407
324
  }, _callee6);
408
325
  }))();
409
326
  },
410
-
411
327
  /**
412
328
  * Retrieves a list of content containers relevant to a specified report
413
329
  * @param {UUID|string} reportId - UUID or url of the report being requested
@@ -420,54 +336,44 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
420
336
  */
421
337
  getContentContainer: function getContentContainer(reportId, options) {
422
338
  var _this7 = this;
423
-
424
339
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
425
340
  var _this7$_createRequest, _this7$_createRequest2, requestOptions, reportUUID, res;
426
-
427
341
  return _regenerator.default.wrap(function _callee7$(_context7) {
428
- while (1) {
429
- switch (_context7.prev = _context7.next) {
430
- case 0:
431
- if (reportId) {
432
- _context7.next = 2;
433
- break;
434
- }
435
-
436
- throw Error('Undefined parameter');
437
-
438
- case 2:
439
- // use spread operator to set default options
440
- options = _objectSpread(_objectSpread({}, _this7.config.defaultOptions), options);
441
- _this7$_createRequest = _this7._createRequestOptions(reportId, '/contents/container'), _this7$_createRequest2 = (0, _slicedToArray2.default)(_this7$_createRequest, 2), requestOptions = _this7$_createRequest2[0], reportUUID = _this7$_createRequest2[1];
442
- _context7.next = 6;
443
- return _this7.request(_objectSpread(_objectSpread({
444
- method: 'GET'
445
- }, requestOptions), {}, {
446
- qs: {
447
- offset: options.offset,
448
- size: options.size
449
- },
450
- timeout: options.timeoutMs,
451
- types: options.types
452
- }));
453
-
454
- case 6:
455
- res = _context7.sent;
456
- _context7.next = 9;
457
- return _this7._writeToContentContainerCache(reportUUID, res.body);
458
-
459
- case 9:
460
- return _context7.abrupt("return", res);
461
-
462
- case 10:
463
- case "end":
464
- return _context7.stop();
465
- }
342
+ while (1) switch (_context7.prev = _context7.next) {
343
+ case 0:
344
+ if (reportId) {
345
+ _context7.next = 2;
346
+ break;
347
+ }
348
+ throw Error('Undefined parameter');
349
+ case 2:
350
+ // use spread operator to set default options
351
+ options = _objectSpread(_objectSpread({}, _this7.config.defaultOptions), options);
352
+ _this7$_createRequest = _this7._createRequestOptions(reportId, '/contents/container'), _this7$_createRequest2 = (0, _slicedToArray2.default)(_this7$_createRequest, 2), requestOptions = _this7$_createRequest2[0], reportUUID = _this7$_createRequest2[1];
353
+ _context7.next = 6;
354
+ return _this7.request(_objectSpread(_objectSpread({
355
+ method: 'GET'
356
+ }, requestOptions), {}, {
357
+ qs: {
358
+ offset: options.offset,
359
+ size: options.size
360
+ },
361
+ timeout: options.timeoutMs,
362
+ types: options.types
363
+ }));
364
+ case 6:
365
+ res = _context7.sent;
366
+ _context7.next = 9;
367
+ return _this7._writeToContentContainerCache(reportUUID, res.body);
368
+ case 9:
369
+ return _context7.abrupt("return", res);
370
+ case 10:
371
+ case "end":
372
+ return _context7.stop();
466
373
  }
467
374
  }, _callee7);
468
375
  }))();
469
376
  },
470
-
471
377
  /**
472
378
  * Retrieves information for a specific content container relevant to a specified report
473
379
  * @param {UUID|string} reportId - UUID or url of the report being requested
@@ -478,67 +384,53 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
478
384
  */
479
385
  getContentContainerByContainerId: function getContentContainerByContainerId(reportId, containerId, options) {
480
386
  var _this8 = this;
481
-
482
387
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
483
388
  var _this8$_createRequest, _this8$_createRequest2, requestOptions, reportUUID, res;
484
-
485
389
  return _regenerator.default.wrap(function _callee8$(_context8) {
486
- while (1) {
487
- switch (_context8.prev = _context8.next) {
488
- case 0:
489
- if (!(!reportId || !containerId)) {
490
- _context8.next = 2;
491
- break;
492
- }
493
-
494
- throw Error('Undefined parameter');
495
-
496
- case 2:
497
- // use spread operator to set default options
498
- options = _objectSpread(_objectSpread({}, _this8.config.defaultOptions), options);
499
- _this8$_createRequest = _this8._createRequestOptions(reportId, "/contents/container/".concat(containerId)), _this8$_createRequest2 = (0, _slicedToArray2.default)(_this8$_createRequest, 2), requestOptions = _this8$_createRequest2[0], reportUUID = _this8$_createRequest2[1]; // If this content container has already been cached then it can be retrieved from there instead of making a network call to ediscovery
500
-
501
- if (!(_this8.contentContainerCache.has(reportUUID) && _this8.contentContainerCache.get(reportUUID).has(containerId))) {
502
- _context8.next = 6;
503
- break;
504
- }
505
-
506
- return _context8.abrupt("return", {
507
- body: _this8.contentContainerCache.get(reportUUID).get(containerId),
508
- statusCode: 200
509
- });
510
-
511
- case 6:
512
- _this8.logger.warn("Cache miss for container ".concat(containerId, " in contentContainerCache"));
513
-
514
- _context8.next = 9;
515
- return _this8.request(_objectSpread(_objectSpread({
516
- method: 'GET'
517
- }, requestOptions), {}, {
518
- qs: {
519
- offset: options.offset,
520
- size: options.size
521
- },
522
- timeout: options.timeoutMs
523
- }));
524
-
525
- case 9:
526
- res = _context8.sent;
527
- _context8.next = 12;
528
- return _this8._writeToContentContainerCache(reportUUID, [res.body]);
529
-
530
- case 12:
531
- return _context8.abrupt("return", res);
532
-
533
- case 13:
534
- case "end":
535
- return _context8.stop();
536
- }
390
+ while (1) switch (_context8.prev = _context8.next) {
391
+ case 0:
392
+ if (!(!reportId || !containerId)) {
393
+ _context8.next = 2;
394
+ break;
395
+ }
396
+ throw Error('Undefined parameter');
397
+ case 2:
398
+ // use spread operator to set default options
399
+ options = _objectSpread(_objectSpread({}, _this8.config.defaultOptions), options);
400
+ _this8$_createRequest = _this8._createRequestOptions(reportId, "/contents/container/".concat(containerId)), _this8$_createRequest2 = (0, _slicedToArray2.default)(_this8$_createRequest, 2), requestOptions = _this8$_createRequest2[0], reportUUID = _this8$_createRequest2[1]; // If this content container has already been cached then it can be retrieved from there instead of making a network call to ediscovery
401
+ if (!(_this8.contentContainerCache.has(reportUUID) && _this8.contentContainerCache.get(reportUUID).has(containerId))) {
402
+ _context8.next = 6;
403
+ break;
404
+ }
405
+ return _context8.abrupt("return", {
406
+ body: _this8.contentContainerCache.get(reportUUID).get(containerId),
407
+ statusCode: 200
408
+ });
409
+ case 6:
410
+ _this8.logger.warn("Cache miss for container ".concat(containerId, " in contentContainerCache"));
411
+ _context8.next = 9;
412
+ return _this8.request(_objectSpread(_objectSpread({
413
+ method: 'GET'
414
+ }, requestOptions), {}, {
415
+ qs: {
416
+ offset: options.offset,
417
+ size: options.size
418
+ },
419
+ timeout: options.timeoutMs
420
+ }));
421
+ case 9:
422
+ res = _context8.sent;
423
+ _context8.next = 12;
424
+ return _this8._writeToContentContainerCache(reportUUID, [res.body]);
425
+ case 12:
426
+ return _context8.abrupt("return", res);
427
+ case 13:
428
+ case "end":
429
+ return _context8.stop();
537
430
  }
538
431
  }, _callee8);
539
432
  }))();
540
433
  },
541
-
542
434
  /**
543
435
  * The results of a getContentContainer or getContentContainerByContainerId request are written to the contentContainerCache
544
436
  * since information for a container is likely to be accessed very frequently when decrypting activities
@@ -550,18 +442,14 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
550
442
  if (!reportId || !containers || !containers.length) {
551
443
  return;
552
444
  }
553
-
554
445
  if (!this.contentContainerCache.has(reportId)) {
555
446
  this.contentContainerCache.set(reportId, new _map.default());
556
447
  }
557
-
558
448
  var _iterator = _createForOfIteratorHelper(containers),
559
- _step;
560
-
449
+ _step;
561
450
  try {
562
451
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
563
452
  var container = _step.value;
564
-
565
453
  if (container && container.containerId) {
566
454
  try {
567
455
  this.contentContainerCache.get(reportId).set(container.containerId, container);
@@ -578,7 +466,6 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
578
466
  _iterator.f();
579
467
  }
580
468
  },
581
-
582
469
  /**
583
470
  * Wipe the cache used by eDiscovery to store the space summaries and content containers.
584
471
  * Good practice to clear it down when finished with a report to save RAM.
@@ -587,7 +474,6 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
587
474
  clearCache: function clearCache() {
588
475
  this.contentContainerCache.clear();
589
476
  },
590
-
591
477
  /**
592
478
  * Retrieves a uuid string from a report url
593
479
  * @param {String} reportUrl - full destination address (including report id parameter) for the http request being sent
@@ -597,19 +483,16 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
597
483
  _getReportIdFromUrl: function _getReportIdFromUrl(reportUrl) {
598
484
  if (reportUrl) {
599
485
  var uuids = reportUrl.match(/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}/);
600
-
601
486
  if (uuids && uuids.length > 0) {
602
487
  return uuids[0];
603
488
  }
604
489
  }
605
-
606
490
  return '';
607
491
  },
608
492
  _isUrl: function _isUrl(string) {
609
493
  // Regex found from `https://ihateregex.io/expr/url`
610
494
  return /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)/g.test(string);
611
495
  },
612
-
613
496
  /**
614
497
  * Create the appropriate request options based on whether the reportId is a url or a uuid.
615
498
  * @param {UUID|string} reportId - May be either a url for the report or a uuid.
@@ -620,20 +503,17 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
620
503
  _createRequestOptions: function _createRequestOptions(reportId, resource) {
621
504
  var requestOptions;
622
505
  var reportUUID;
623
-
624
506
  var isUrl = this._isUrl(reportId);
625
-
626
507
  if (isUrl) {
627
508
  reportUUID = this._getReportIdFromUrl(reportId);
628
-
629
509
  if (!reportUUID) {
630
510
  throw Error('Report url does not contain a report id');
631
- } // Ensure the url is formatted to
511
+ }
512
+
513
+ // Ensure the url is formatted to
632
514
  // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9
633
515
  // index.js for example passes the url in as
634
516
  // https://ediscovery.intb1.ciscospark.com/ediscovery/api/v1/reports/16bf0d01-b1f7-483b-89a2-915144158fb9/contents
635
-
636
-
637
517
  var reportUrl = reportId.substring(0, reportId.lastIndexOf(reportUUID) + reportUUID.length);
638
518
  requestOptions = {
639
519
  url: reportUrl + resource
@@ -645,10 +525,8 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
645
525
  };
646
526
  reportUUID = reportId;
647
527
  }
648
-
649
528
  return [requestOptions, reportUUID];
650
529
  },
651
-
652
530
  /**
653
531
  * Retrieves a config object from the service which can be used by the client for optimal performance, e.g. content page size
654
532
  * @param {Object} options - optional parameters for this method
@@ -657,30 +535,25 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
657
535
  */
658
536
  getClientConfig: function getClientConfig(options) {
659
537
  var _this9 = this;
660
-
661
538
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
662
539
  return _regenerator.default.wrap(function _callee9$(_context9) {
663
- while (1) {
664
- switch (_context9.prev = _context9.next) {
665
- case 0:
666
- // use spread operator to set default options
667
- options = _objectSpread(_objectSpread({}, _this9.config.defaultOptions), options);
668
- return _context9.abrupt("return", _this9.request({
669
- method: 'GET',
670
- service: 'ediscovery',
671
- resource: 'reports/clientconfig',
672
- timeout: options.timeoutMs
673
- }));
674
-
675
- case 2:
676
- case "end":
677
- return _context9.stop();
678
- }
540
+ while (1) switch (_context9.prev = _context9.next) {
541
+ case 0:
542
+ // use spread operator to set default options
543
+ options = _objectSpread(_objectSpread({}, _this9.config.defaultOptions), options);
544
+ return _context9.abrupt("return", _this9.request({
545
+ method: 'GET',
546
+ service: 'ediscovery',
547
+ resource: 'reports/clientconfig',
548
+ timeout: options.timeoutMs
549
+ }));
550
+ case 2:
551
+ case "end":
552
+ return _context9.stop();
679
553
  }
680
554
  }, _callee9);
681
555
  }))();
682
556
  },
683
-
684
557
  /**
685
558
  * Submits an audit event to the eDiscovery service for admin use. Only expected to be used for
686
559
  * the getContentContainer API
@@ -691,40 +564,33 @@ var EDiscovery = _webexCore.WebexPlugin.extend((_dec = (0, _webexCore.waitForVal
691
564
  */
692
565
  postAuditLog: function postAuditLog(reportId, options) {
693
566
  var _this10 = this;
694
-
695
567
  return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
696
568
  return _regenerator.default.wrap(function _callee10$(_context10) {
697
- while (1) {
698
- switch (_context10.prev = _context10.next) {
699
- case 0:
700
- if (reportId) {
701
- _context10.next = 2;
702
- break;
703
- }
704
-
705
- throw Error('No report ID specified');
706
-
707
- case 2:
708
- // use spread operator to set default options
709
- options = _objectSpread(_objectSpread({}, _this10.config.defaultOptions), options);
710
- return _context10.abrupt("return", _this10.request({
711
- method: 'POST',
712
- service: 'ediscovery',
713
- resource: "reports/".concat(reportId, "/audit/summary-download"),
714
- timeout: options.timeoutMs
715
- }));
716
-
717
- case 4:
718
- case "end":
719
- return _context10.stop();
720
- }
569
+ while (1) switch (_context10.prev = _context10.next) {
570
+ case 0:
571
+ if (reportId) {
572
+ _context10.next = 2;
573
+ break;
574
+ }
575
+ throw Error('No report ID specified');
576
+ case 2:
577
+ // use spread operator to set default options
578
+ options = _objectSpread(_objectSpread({}, _this10.config.defaultOptions), options);
579
+ return _context10.abrupt("return", _this10.request({
580
+ method: 'POST',
581
+ service: 'ediscovery',
582
+ resource: "reports/".concat(reportId, "/audit/summary-download"),
583
+ timeout: options.timeoutMs
584
+ }));
585
+ case 4:
586
+ case "end":
587
+ return _context10.stop();
721
588
  }
722
589
  }, _callee10);
723
590
  }))();
724
591
  },
725
- version: "3.0.0-beta.9"
592
+ version: "3.0.0-bnr.2"
726
593
  }, ((0, _applyDecoratedDescriptor2.default)(_obj, "createReport", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "createReport"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getReport", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "getReport"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getReports", [_dec3], (0, _getOwnPropertyDescriptor.default)(_obj, "getReports"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "deleteReport", [_dec4], (0, _getOwnPropertyDescriptor.default)(_obj, "deleteReport"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "restartReport", [_dec5], (0, _getOwnPropertyDescriptor.default)(_obj, "restartReport"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getContent", [_dec6, _dec7], (0, _getOwnPropertyDescriptor.default)(_obj, "getContent"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getContentContainer", [_dec8, _dec9], (0, _getOwnPropertyDescriptor.default)(_obj, "getContentContainer"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getContentContainerByContainerId", [_dec10, _dec11], (0, _getOwnPropertyDescriptor.default)(_obj, "getContentContainerByContainerId"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "getClientConfig", [_dec12], (0, _getOwnPropertyDescriptor.default)(_obj, "getClientConfig"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "postAuditLog", [_dec13], (0, _getOwnPropertyDescriptor.default)(_obj, "postAuditLog"), _obj)), _obj)));
727
-
728
594
  var _default2 = EDiscovery;
729
595
  exports.default = _default2;
730
596
  //# sourceMappingURL=ediscovery.js.map