@webex/internal-plugin-ediscovery 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/src/index.js CHANGED
@@ -1,175 +1,175 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
- /* eslint-disable */
5
-
6
- import '@webex/internal-plugin-encryption';
7
- import '@webex/internal-plugin-conversation';
8
-
9
- import {registerInternalPlugin} from '@webex/webex-core';
10
- import {has} from 'lodash';
11
-
12
- import EDiscovery from './ediscovery';
13
- import Transforms from './transforms';
14
- import config from './config';
15
-
16
- registerInternalPlugin('ediscovery', EDiscovery, {
17
- config,
18
- payloadTransformer: {
19
- predicates: [
20
- {
21
- name: 'decryptReportRequest',
22
- direction: 'inbound',
23
- test(ctx, object) {
24
- return Promise.resolve(has(object, 'body.reportRequest'));
25
- },
26
- extract(object) {
27
- return Promise.resolve(object);
28
- },
29
- },
30
- {
31
- name: 'decryptReportRequestArray',
32
- direction: 'inbound',
33
- test(ctx, object) {
34
- return Promise.resolve(has(object, 'body[0].reportRequest'));
35
- },
36
- extract(object) {
37
- return Promise.resolve(object);
38
- },
39
- },
40
- {
41
- name: 'encryptReportRequest',
42
- direction: 'outbound',
43
- test(ctx, object) {
44
- return Promise.resolve(
45
- has(object, 'body.keywords') ||
46
- has(object, 'body.spaceNames') ||
47
- has(object, 'body.emails')
48
- );
49
- },
50
- extract(object) {
51
- return Promise.resolve(object);
52
- },
53
- },
54
- {
55
- name: 'decryptReportContent',
56
- direction: 'inbound',
57
- test(ctx, object) {
58
- return Promise.resolve(has(object, 'body.activityId'));
59
- },
60
- extract(object) {
61
- return Promise.resolve(object);
62
- },
63
- },
64
- {
65
- name: 'decryptReportContentArray',
66
- direction: 'inbound',
67
- test(ctx, object) {
68
- return Promise.resolve(has(object, 'body[0].activityId'));
69
- },
70
- extract(object) {
71
- return Promise.resolve(object);
72
- },
73
- },
74
- {
75
- name: 'decryptReportContentContainer',
76
- direction: 'inbound',
77
- test(ctx, object) {
78
- return Promise.resolve(has(object, 'body.containerId'));
79
- },
80
- extract(object) {
81
- return Promise.resolve(object);
82
- },
83
- },
84
- {
85
- name: 'decryptReportContentContainerArray',
86
- direction: 'inbound',
87
- test(ctx, object) {
88
- return Promise.resolve(has(object, 'body[0].containerId'));
89
- },
90
- extract(object) {
91
- return Promise.resolve(object);
92
- },
93
- },
94
- ],
95
- transforms: [
96
- {
97
- name: 'decryptReportRequest',
98
- direction: 'inbound',
99
- fn(ctx, object) {
100
- return Transforms.decryptReportRequest(ctx, object);
101
- },
102
- },
103
- {
104
- name: 'decryptReportRequestArray',
105
- direction: 'inbound',
106
- fn(ctx, object) {
107
- if (!object || !object.body) {
108
- return Promise.resolve();
109
- }
110
-
111
- return Promise.all(
112
- object.body.map((item) => ctx.transform('decryptReportRequest', {body: item}))
113
- );
114
- },
115
- },
116
- {
117
- name: 'encryptReportRequest',
118
- direction: 'outbound',
119
- fn(ctx, object) {
120
- return Transforms.encryptReportRequest(ctx, object);
121
- },
122
- },
123
- {
124
- name: 'decryptReportContent',
125
- direction: 'inbound',
126
- fn(ctx, object, reportId) {
127
- return Transforms.decryptReportContent(ctx, object, reportId);
128
- },
129
- },
130
- {
131
- name: 'decryptReportContentArray',
132
- direction: 'inbound',
133
- fn(ctx, object) {
134
- if (!object || !object.body) {
135
- return Promise.resolve();
136
- }
137
-
138
- // Always use the report url as this'll resolve correctly for remote reports
139
- return Promise.all(
140
- object.body.map((item) =>
141
- ctx.transform('decryptReportContent', {body: item}, object.options.uri)
142
- )
143
- );
144
- },
145
- },
146
- {
147
- name: 'decryptReportContentContainer',
148
- direction: 'inbound',
149
- fn(ctx, object) {
150
- return Transforms.decryptReportContentContainer(ctx, object);
151
- },
152
- },
153
- {
154
- name: 'decryptReportContentContainerArray',
155
- direction: 'inbound',
156
- fn(ctx, object) {
157
- if (!object || !object.body) {
158
- return Promise.resolve();
159
- }
160
-
161
- return Promise.all(
162
- object.body.map((item) => ctx.transform('decryptReportContentContainer', {body: item}))
163
- );
164
- },
165
- },
166
- ],
167
- },
168
- });
169
-
170
- export default EDiscovery;
171
-
172
- // eslint-disable-next-line import/named
173
- export {config} from './config';
174
- export {default as ReportRequest} from './report-request';
175
- export {EdiscoveryError, InvalidEmailAddressError} from './ediscovery-error';
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+ /* eslint-disable */
5
+
6
+ import '@webex/internal-plugin-encryption';
7
+ import '@webex/internal-plugin-conversation';
8
+
9
+ import {registerInternalPlugin} from '@webex/webex-core';
10
+ import {has} from 'lodash';
11
+
12
+ import EDiscovery from './ediscovery';
13
+ import Transforms from './transforms';
14
+ import config from './config';
15
+
16
+ registerInternalPlugin('ediscovery', EDiscovery, {
17
+ config,
18
+ payloadTransformer: {
19
+ predicates: [
20
+ {
21
+ name: 'decryptReportRequest',
22
+ direction: 'inbound',
23
+ test(ctx, object) {
24
+ return Promise.resolve(has(object, 'body.reportRequest'));
25
+ },
26
+ extract(object) {
27
+ return Promise.resolve(object);
28
+ },
29
+ },
30
+ {
31
+ name: 'decryptReportRequestArray',
32
+ direction: 'inbound',
33
+ test(ctx, object) {
34
+ return Promise.resolve(has(object, 'body[0].reportRequest'));
35
+ },
36
+ extract(object) {
37
+ return Promise.resolve(object);
38
+ },
39
+ },
40
+ {
41
+ name: 'encryptReportRequest',
42
+ direction: 'outbound',
43
+ test(ctx, object) {
44
+ return Promise.resolve(
45
+ has(object, 'body.keywords') ||
46
+ has(object, 'body.spaceNames') ||
47
+ has(object, 'body.emails')
48
+ );
49
+ },
50
+ extract(object) {
51
+ return Promise.resolve(object);
52
+ },
53
+ },
54
+ {
55
+ name: 'decryptReportContent',
56
+ direction: 'inbound',
57
+ test(ctx, object) {
58
+ return Promise.resolve(has(object, 'body.activityId'));
59
+ },
60
+ extract(object) {
61
+ return Promise.resolve(object);
62
+ },
63
+ },
64
+ {
65
+ name: 'decryptReportContentArray',
66
+ direction: 'inbound',
67
+ test(ctx, object) {
68
+ return Promise.resolve(has(object, 'body[0].activityId'));
69
+ },
70
+ extract(object) {
71
+ return Promise.resolve(object);
72
+ },
73
+ },
74
+ {
75
+ name: 'decryptReportContentContainer',
76
+ direction: 'inbound',
77
+ test(ctx, object) {
78
+ return Promise.resolve(has(object, 'body.containerId'));
79
+ },
80
+ extract(object) {
81
+ return Promise.resolve(object);
82
+ },
83
+ },
84
+ {
85
+ name: 'decryptReportContentContainerArray',
86
+ direction: 'inbound',
87
+ test(ctx, object) {
88
+ return Promise.resolve(has(object, 'body[0].containerId'));
89
+ },
90
+ extract(object) {
91
+ return Promise.resolve(object);
92
+ },
93
+ },
94
+ ],
95
+ transforms: [
96
+ {
97
+ name: 'decryptReportRequest',
98
+ direction: 'inbound',
99
+ fn(ctx, object) {
100
+ return Transforms.decryptReportRequest(ctx, object);
101
+ },
102
+ },
103
+ {
104
+ name: 'decryptReportRequestArray',
105
+ direction: 'inbound',
106
+ fn(ctx, object) {
107
+ if (!object || !object.body) {
108
+ return Promise.resolve();
109
+ }
110
+
111
+ return Promise.all(
112
+ object.body.map((item) => ctx.transform('decryptReportRequest', {body: item}))
113
+ );
114
+ },
115
+ },
116
+ {
117
+ name: 'encryptReportRequest',
118
+ direction: 'outbound',
119
+ fn(ctx, object) {
120
+ return Transforms.encryptReportRequest(ctx, object);
121
+ },
122
+ },
123
+ {
124
+ name: 'decryptReportContent',
125
+ direction: 'inbound',
126
+ fn(ctx, object, reportId) {
127
+ return Transforms.decryptReportContent(ctx, object, reportId);
128
+ },
129
+ },
130
+ {
131
+ name: 'decryptReportContentArray',
132
+ direction: 'inbound',
133
+ fn(ctx, object) {
134
+ if (!object || !object.body) {
135
+ return Promise.resolve();
136
+ }
137
+
138
+ // Always use the report url as this'll resolve correctly for remote reports
139
+ return Promise.all(
140
+ object.body.map((item) =>
141
+ ctx.transform('decryptReportContent', {body: item}, object.options.uri)
142
+ )
143
+ );
144
+ },
145
+ },
146
+ {
147
+ name: 'decryptReportContentContainer',
148
+ direction: 'inbound',
149
+ fn(ctx, object) {
150
+ return Transforms.decryptReportContentContainer(ctx, object);
151
+ },
152
+ },
153
+ {
154
+ name: 'decryptReportContentContainerArray',
155
+ direction: 'inbound',
156
+ fn(ctx, object) {
157
+ if (!object || !object.body) {
158
+ return Promise.resolve();
159
+ }
160
+
161
+ return Promise.all(
162
+ object.body.map((item) => ctx.transform('decryptReportContentContainer', {body: item}))
163
+ );
164
+ },
165
+ },
166
+ ],
167
+ },
168
+ });
169
+
170
+ export default EDiscovery;
171
+
172
+ // eslint-disable-next-line import/named
173
+ export {config} from './config';
174
+ export {default as ReportRequest} from './report-request';
175
+ export {EdiscoveryError, InvalidEmailAddressError} from './ediscovery-error';
@@ -1,34 +1,34 @@
1
- /**
2
- * Creates a report request object with a specific set of search parameters
3
- * @param {String} name - A label to identify the report
4
- * @param {String} description - A textual summary of the reports purpose
5
- * @param {Array<String>} emails - A list of user emails relevant to the report
6
- * @param {Array<String>} userIds - A list of UUIDs relevant to the report
7
- * @param {Array<String>} keywords - A list of search terms relevant to the report
8
- * @param {Array<String>} spaceNames - A list of space names relevant to the report
9
- * @param {Object} range - Contains the start time and end time defining the search period
10
- * @returns {Object} ReportRequest - Contains all search parameters
11
- */
12
- class ReportRequest {
13
- constructor(
14
- name = '',
15
- description = '',
16
- emails = [],
17
- userIds = [],
18
- keywords = [],
19
- encryptionKeyUrl = '',
20
- spaceNames = [],
21
- range = {startTime: '2020-01-01T00:00:00', endTime: '2020-01-01T23:59:59'}
22
- ) {
23
- this.name = name;
24
- this.description = description;
25
- this.emails = emails;
26
- this.userIds = userIds;
27
- this.keywords = keywords;
28
- this.encryptionKeyUrl = encryptionKeyUrl;
29
- this.spaceNames = spaceNames;
30
- this.range = range;
31
- }
32
- }
33
-
34
- export default ReportRequest;
1
+ /**
2
+ * Creates a report request object with a specific set of search parameters
3
+ * @param {String} name - A label to identify the report
4
+ * @param {String} description - A textual summary of the reports purpose
5
+ * @param {Array<String>} emails - A list of user emails relevant to the report
6
+ * @param {Array<String>} userIds - A list of UUIDs relevant to the report
7
+ * @param {Array<String>} keywords - A list of search terms relevant to the report
8
+ * @param {Array<String>} spaceNames - A list of space names relevant to the report
9
+ * @param {Object} range - Contains the start time and end time defining the search period
10
+ * @returns {Object} ReportRequest - Contains all search parameters
11
+ */
12
+ class ReportRequest {
13
+ constructor(
14
+ name = '',
15
+ description = '',
16
+ emails = [],
17
+ userIds = [],
18
+ keywords = [],
19
+ encryptionKeyUrl = '',
20
+ spaceNames = [],
21
+ range = {startTime: '2020-01-01T00:00:00', endTime: '2020-01-01T23:59:59'}
22
+ ) {
23
+ this.name = name;
24
+ this.description = description;
25
+ this.emails = emails;
26
+ this.userIds = userIds;
27
+ this.keywords = keywords;
28
+ this.encryptionKeyUrl = encryptionKeyUrl;
29
+ this.spaceNames = spaceNames;
30
+ this.range = range;
31
+ }
32
+ }
33
+
34
+ export default ReportRequest;
package/src/retry.js CHANGED
@@ -1,43 +1,43 @@
1
- const retryErrors = [429, 502, 503, 504];
2
-
3
- async function requestWithRetries(
4
- ctx,
5
- func,
6
- args,
7
- retryCount = 0,
8
- retryIntervalInSeconds = 0,
9
- maxRetries = 3
10
- ) {
11
- await timeout(retryIntervalInSeconds);
12
-
13
- return func.apply(ctx, args).catch((reason) => {
14
- if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {
15
- retryCount += 1;
16
- // eslint-disable-next-line no-shadow
17
- let retryIntervalInSeconds = (retryCount + 1) ** 2; // 4, 9 and 16 second delays as default
18
-
19
- if (reason.headers && reason.headers['retry-after']) {
20
- retryIntervalInSeconds = reason.headers['retry-after'];
21
- }
22
- console.error(
23
- `Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`
24
- );
25
-
26
- return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);
27
- }
28
-
29
- return Promise.reject(reason);
30
- });
31
- }
32
-
33
- function timeout(sec) {
34
- // return immediately if timeout is zero or undefined
35
- if (!sec) {
36
- return Promise.resolve();
37
- }
38
-
39
- return new Promise((resolve) => setTimeout(resolve, sec * 1000));
40
- }
41
-
42
- module.exports.requestWithRetries = requestWithRetries;
43
- module.exports.timeout = timeout;
1
+ const retryErrors = [429, 502, 503, 504];
2
+
3
+ async function requestWithRetries(
4
+ ctx,
5
+ func,
6
+ args,
7
+ retryCount = 0,
8
+ retryIntervalInSeconds = 0,
9
+ maxRetries = 3
10
+ ) {
11
+ await timeout(retryIntervalInSeconds);
12
+
13
+ return func.apply(ctx, args).catch((reason) => {
14
+ if (retryErrors.includes(reason.statusCode) && retryCount < maxRetries) {
15
+ retryCount += 1;
16
+ // eslint-disable-next-line no-shadow
17
+ let retryIntervalInSeconds = (retryCount + 1) ** 2; // 4, 9 and 16 second delays as default
18
+
19
+ if (reason.headers && reason.headers['retry-after']) {
20
+ retryIntervalInSeconds = reason.headers['retry-after'];
21
+ }
22
+ console.error(
23
+ `Request #${retryCount} error: ${reason.statusCode}. Attempting retry #${retryCount} in ${retryIntervalInSeconds} seconds`
24
+ );
25
+
26
+ return requestWithRetries(ctx, func, args, retryCount, retryIntervalInSeconds, maxRetries);
27
+ }
28
+
29
+ return Promise.reject(reason);
30
+ });
31
+ }
32
+
33
+ function timeout(sec) {
34
+ // return immediately if timeout is zero or undefined
35
+ if (!sec) {
36
+ return Promise.resolve();
37
+ }
38
+
39
+ return new Promise((resolve) => setTimeout(resolve, sec * 1000));
40
+ }
41
+
42
+ module.exports.requestWithRetries = requestWithRetries;
43
+ module.exports.timeout = timeout;