@webex/internal-plugin-conversation 3.0.0-beta.8 → 3.0.0-bnr.0

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.
Files changed (57) hide show
  1. package/README.md +1 -3
  2. package/dist/activities.js +8 -69
  3. package/dist/activities.js.map +1 -1
  4. package/dist/activity-thread-ordering.js +19 -79
  5. package/dist/activity-thread-ordering.js.map +1 -1
  6. package/dist/config.js +1 -7
  7. package/dist/config.js.map +1 -1
  8. package/dist/constants.js +4 -5
  9. package/dist/constants.js.map +1 -1
  10. package/dist/conversation.js +790 -1199
  11. package/dist/conversation.js.map +1 -1
  12. package/dist/convo-error.js +0 -23
  13. package/dist/convo-error.js.map +1 -1
  14. package/dist/decryption-transforms.js +35 -98
  15. package/dist/decryption-transforms.js.map +1 -1
  16. package/dist/encryption-transforms.js +11 -48
  17. package/dist/encryption-transforms.js.map +1 -1
  18. package/dist/index.js +7 -50
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal-plugin-conversation.d.ts +21 -0
  21. package/dist/share-activity.js +40 -106
  22. package/dist/share-activity.js.map +1 -1
  23. package/dist/to-array.js +9 -11
  24. package/dist/to-array.js.map +1 -1
  25. package/dist/tsdoc-metadata.json +11 -0
  26. package/dist/types/activities.d.ts +32 -0
  27. package/dist/types/activity-thread-ordering.d.ts +18 -0
  28. package/dist/types/config.d.ts +19 -0
  29. package/dist/types/constants.d.ts +5 -0
  30. package/dist/types/conversation.d.ts +2 -0
  31. package/dist/types/convo-error.d.ts +10 -0
  32. package/dist/types/decryption-transforms.d.ts +1 -0
  33. package/dist/types/encryption-transforms.d.ts +1 -0
  34. package/dist/types/index.d.ts +3 -0
  35. package/dist/types/share-activity.d.ts +7 -0
  36. package/dist/types/to-array.d.ts +9 -0
  37. package/package.json +15 -15
  38. package/src/activities.js +10 -7
  39. package/src/activity-thread-ordering.js +27 -30
  40. package/src/activity-threading.md +68 -49
  41. package/src/config.js +5 -5
  42. package/src/conversation.js +621 -589
  43. package/src/decryption-transforms.js +103 -62
  44. package/src/encryption-transforms.js +103 -83
  45. package/src/index.js +82 -66
  46. package/src/share-activity.js +64 -55
  47. package/src/to-array.js +2 -2
  48. package/test/integration/spec/create.js +184 -118
  49. package/test/integration/spec/encryption.js +250 -186
  50. package/test/integration/spec/get.js +761 -513
  51. package/test/integration/spec/mercury.js +37 -27
  52. package/test/integration/spec/share.js +292 -229
  53. package/test/integration/spec/verbs.js +628 -441
  54. package/test/unit/spec/conversation.js +265 -163
  55. package/test/unit/spec/decrypt-transforms.js +112 -131
  56. package/test/unit/spec/encryption-transforms.js +24 -18
  57. package/test/unit/spec/share-activity.js +37 -40
@@ -26,21 +26,21 @@ describe('plugin-conversation', function () {
26
26
 
27
27
  webex = new WebexCore({
28
28
  credentials: {
29
- authorization: spock.token
30
- }
29
+ authorization: spock.token,
30
+ },
31
31
  });
32
32
 
33
33
  webex.config.conversation.allowedOutboundTags = {
34
- strong: []
34
+ strong: [],
35
35
  };
36
36
  webex.config.conversation.allowedInboundTags = {
37
- strong: []
37
+ strong: [],
38
38
  };
39
39
 
40
40
  mccoy.webex = new WebexCore({
41
41
  credentials: {
42
- authorization: mccoy.token
43
- }
42
+ authorization: mccoy.token,
43
+ },
44
44
  });
45
45
 
46
46
  // eslint-disable-next-line no-unused-expressions
@@ -52,9 +52,9 @@ describe('plugin-conversation', function () {
52
52
 
53
53
  after(async () => {
54
54
  // eslint-disable-next-line no-unused-expressions
55
- webex && await webex.internal.mercury.disconnect();
55
+ webex && (await webex.internal.mercury.disconnect());
56
56
  // eslint-disable-next-line no-unused-expressions
57
- mccoy && await mccoy.webex.internal.mercury.disconnect();
57
+ mccoy && (await mccoy.webex.internal.mercury.disconnect());
58
58
  });
59
59
 
60
60
  function makeEmailAddress() {
@@ -62,8 +62,8 @@ describe('plugin-conversation', function () {
62
62
  }
63
63
 
64
64
  describe('when there is only one other participant', () => {
65
- it('creates a 1:1 conversation', () => webex.internal.conversation.create({participants: [mccoy]})
66
- .then((conversation) => {
65
+ it('creates a 1:1 conversation', () =>
66
+ webex.internal.conversation.create({participants: [mccoy]}).then((conversation) => {
67
67
  assert.isConversation(conversation);
68
68
  assert.isOneOnOneConversation(conversation);
69
69
  assert.isNewEncryptedConversation(conversation);
@@ -73,13 +73,15 @@ describe('plugin-conversation', function () {
73
73
  }));
74
74
 
75
75
  // TODO: Issues with side boarding users too soon. Skipping until it's fixed
76
- describe.skip('when the other user doesn\'t exist', () => {
76
+ describe.skip("when the other user doesn't exist", () => {
77
77
  let email;
78
78
 
79
- beforeEach(() => { email = makeEmailAddress(); });
79
+ beforeEach(() => {
80
+ email = makeEmailAddress();
81
+ });
80
82
 
81
- it('invites the other user', () => webex.internal.conversation.create({participants: [email]})
82
- .then((conversation) => {
83
+ it('invites the other user', () =>
84
+ webex.internal.conversation.create({participants: [email]}).then((conversation) => {
83
85
  assert.isConversation(conversation);
84
86
  assert.isOneOnOneConversation(conversation);
85
87
  assert.isNewEncryptedConversation(conversation);
@@ -93,132 +95,196 @@ describe('plugin-conversation', function () {
93
95
 
94
96
  describe('when the conversation already exists', () => {
95
97
  describe('with skipOneOnOneFetch=true', () => {
96
- it('fails to create a 1:1 conversation that already exists', () => assert.isRejected(webex.internal.conversation.create({participants: [mccoy]}, {skipOneOnOneFetch: true}))
97
- .then((reason) => assert.instanceOf(reason, WebexHttpError.Conflict)));
98
+ it('fails to create a 1:1 conversation that already exists', () =>
99
+ assert
100
+ .isRejected(
101
+ webex.internal.conversation.create(
102
+ {participants: [mccoy]},
103
+ {skipOneOnOneFetch: true}
104
+ )
105
+ )
106
+ .then((reason) => assert.instanceOf(reason, WebexHttpError.Conflict)));
98
107
  });
99
108
 
100
- it('returns the preexisting conversation', () => webex.internal.conversation.create({participants: [checkov]})
101
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
102
- .then((conversation2) => {
109
+ it('returns the preexisting conversation', () =>
110
+ webex.internal.conversation.create({participants: [checkov]}).then((conversation) =>
111
+ webex.internal.conversation.create({participants: [checkov]}).then((conversation2) => {
103
112
  assert.equal(conversation2.url, conversation.url);
104
113
  assert.lengthOf(conversation.activities.items, 1);
105
114
  assert.equal(conversation.activities.items[0].verb, 'create');
106
- })));
107
-
108
- it('returns the preexisting conversation and posts a comment', () => webex.internal.conversation.create({participants: [checkov], comment: 'hi'})
109
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
110
- .then((conversation2) => {
111
- assert.equal(conversation2.id, conversation.id);
112
- // the first activity is "create"; get the "post"
113
- const activity = conversation.activities.items.pop();
114
-
115
- assert.equal(activity.verb, 'post');
116
- assert.equal(activity.object.displayName, 'hi');
117
- })));
118
-
119
- it('returns the preexisting conversation and posts a comment with html', () => webex.internal.conversation.create({participants: [checkov], comment: '**hi**', html: '<strong>hi</strong>'})
120
- .then((conversation) => webex.internal.conversation.create({participants: [checkov]})
121
- .then((conversation2) => {
122
- assert.equal(conversation2.id, conversation.id);
123
- // the first activity is "create"; get the "post"
124
- const activity = conversation.activities.items.pop();
125
-
126
- assert.equal(activity.verb, 'post');
127
- assert.equal(activity.object.displayName, '**hi**');
128
- assert.equal(activity.object.content, '<strong>hi</strong>');
129
- })));
115
+ })
116
+ ));
117
+
118
+ it('returns the preexisting conversation and posts a comment', () =>
119
+ webex.internal.conversation
120
+ .create({participants: [checkov], comment: 'hi'})
121
+ .then((conversation) =>
122
+ webex.internal.conversation
123
+ .create({participants: [checkov]})
124
+ .then((conversation2) => {
125
+ assert.equal(conversation2.id, conversation.id);
126
+ // the first activity is "create"; get the "post"
127
+ const activity = conversation.activities.items.pop();
128
+
129
+ assert.equal(activity.verb, 'post');
130
+ assert.equal(activity.object.displayName, 'hi');
131
+ })
132
+ ));
133
+
134
+ it('returns the preexisting conversation and posts a comment with html', () =>
135
+ webex.internal.conversation
136
+ .create({participants: [checkov], comment: '**hi**', html: '<strong>hi</strong>'})
137
+ .then((conversation) =>
138
+ webex.internal.conversation
139
+ .create({participants: [checkov]})
140
+ .then((conversation2) => {
141
+ assert.equal(conversation2.id, conversation.id);
142
+ // the first activity is "create"; get the "post"
143
+ const activity = conversation.activities.items.pop();
144
+
145
+ assert.equal(activity.verb, 'post');
146
+ assert.equal(activity.object.displayName, '**hi**');
147
+ assert.equal(activity.object.content, '<strong>hi</strong>');
148
+ })
149
+ ));
130
150
  });
131
151
 
132
152
  describe('when {forceGrouped: true} is specified', () => {
133
- it('creates a grouped conversation @canary', () => webex.internal.conversation.create({participants: [mccoy]}, {forceGrouped: true})
134
- .then((conversation) => {
135
- assert.isConversation(conversation);
136
- assert.isGroupConversation(conversation);
137
- assert.isNewEncryptedConversation(conversation);
138
-
139
- assert.lengthOf(conversation.participants.items, 2);
140
- assert.lengthOf(conversation.activities.items, 1);
141
- }));
153
+ it('creates a grouped conversation @canary', () =>
154
+ webex.internal.conversation
155
+ .create({participants: [mccoy]}, {forceGrouped: true})
156
+ .then((conversation) => {
157
+ assert.isConversation(conversation);
158
+ assert.isGroupConversation(conversation);
159
+ assert.isNewEncryptedConversation(conversation);
160
+
161
+ assert.lengthOf(conversation.participants.items, 2);
162
+ assert.lengthOf(conversation.activities.items, 1);
163
+ }));
142
164
  });
143
165
  });
144
166
 
145
167
  describe('when there is an invalid user in the participants list', () => {
146
168
  describe('with allowPartialCreation', () => {
147
- it('creates a group conversation', () => webex.internal.conversation.create({participants: [mccoy, 'invalidUser']}, {allowPartialCreation: true})
148
- .then((conversation) => {
149
- assert.isConversation(conversation);
150
- assert.isGroupConversation(conversation);
151
- assert.isNewEncryptedConversation(conversation);
152
-
153
- assert.lengthOf(conversation.participants.items, 2);
154
- assert.lengthOf(conversation.activities.items, 1);
155
- }));
156
-
157
- it('creates a group conversation with invalid uuid', () => testUsers.remove([kirk])
158
- .then(() => webex.internal.conversation.create({participants: [mccoy.id, kirk.id]}, {allowPartialCreation: true}))
159
- .then((conversation) => {
160
- assert.isConversation(conversation);
161
- assert.isGroupConversation(conversation);
162
- assert.isNewEncryptedConversation(conversation);
163
-
164
- assert.lengthOf(conversation.participants.items, 2);
165
- assert.lengthOf(conversation.activities.items, 1);
166
- }));
167
-
168
- it('fails to create a 1:1 conversation', () => assert.isRejected(webex.internal.conversation.create({participants: ['invalidUser']}, {allowPartialCreation: true}))
169
- .then((reason) => assert.instanceOf(reason, InvalidUserCreation)));
169
+ it('creates a group conversation', () =>
170
+ webex.internal.conversation
171
+ .create({participants: [mccoy, 'invalidUser']}, {allowPartialCreation: true})
172
+ .then((conversation) => {
173
+ assert.isConversation(conversation);
174
+ assert.isGroupConversation(conversation);
175
+ assert.isNewEncryptedConversation(conversation);
176
+
177
+ assert.lengthOf(conversation.participants.items, 2);
178
+ assert.lengthOf(conversation.activities.items, 1);
179
+ }));
180
+
181
+ it('creates a group conversation with invalid uuid', () =>
182
+ testUsers
183
+ .remove([kirk])
184
+ .then(() =>
185
+ webex.internal.conversation.create(
186
+ {participants: [mccoy.id, kirk.id]},
187
+ {allowPartialCreation: true}
188
+ )
189
+ )
190
+ .then((conversation) => {
191
+ assert.isConversation(conversation);
192
+ assert.isGroupConversation(conversation);
193
+ assert.isNewEncryptedConversation(conversation);
194
+
195
+ assert.lengthOf(conversation.participants.items, 2);
196
+ assert.lengthOf(conversation.activities.items, 1);
197
+ }));
198
+
199
+ it('fails to create a 1:1 conversation', () =>
200
+ assert
201
+ .isRejected(
202
+ webex.internal.conversation.create(
203
+ {participants: ['invalidUser']},
204
+ {allowPartialCreation: true}
205
+ )
206
+ )
207
+ .then((reason) => assert.instanceOf(reason, InvalidUserCreation)));
170
208
  });
171
209
 
172
210
  describe('without allowPartialCreation', () => {
173
- it('fails to create a group conversation without allowPartialCreation param', () => assert.isRejected(webex.internal.conversation.create({participants: [mccoy, 'invalidUser']})));
211
+ it('fails to create a group conversation without allowPartialCreation param', () =>
212
+ assert.isRejected(
213
+ webex.internal.conversation.create({participants: [mccoy, 'invalidUser']})
214
+ ));
174
215
  });
175
216
  });
176
217
 
177
218
  describe('when {compact: ?} is not specified', () => {
178
- it('creates a compact conversation', () => webex.internal.conversation.create({participants})
179
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 5}))
180
- .then((c) => assert.lengthOf(c.activities.items, 1)));
219
+ it('creates a compact conversation', () =>
220
+ webex.internal.conversation
221
+ .create({participants})
222
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 5}))
223
+ .then((c) => assert.lengthOf(c.activities.items, 1)));
181
224
  });
182
225
 
183
- it('creates a conversation with a name', () => webex.internal.conversation.create({displayName: 'displayName', participants})
184
- .then((c) => webex.internal.conversation.get(c))
185
- .then((c) => assert.equal(c.displayName, 'displayName')));
186
-
187
- it('creates a conversation with a comment', () => webex.internal.conversation.create({comment: 'comment', participants})
188
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
189
- .then((c) => assert.equal(c.activities.items[1].object.displayName, 'comment')));
190
-
191
- it('creates a conversation with a tag', () => webex.internal.conversation.create({tags: ['WELCOME'], participants})
192
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
193
- .then((c) => assert.equal(c.tags[0], 'WELCOME')));
194
-
195
- it('creates a favorite conversation', () => webex.internal.conversation.create({favorite: true, participants})
196
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
197
- .then((c) => assert.equal(c.tags[0], 'FAVORITE')));
198
-
199
- it('creates a conversation with a comment with html', () => webex.internal.conversation.create({comment: '**comment**', html: '<strong>comment</strong>', participants})
200
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
201
- .then((c) => {
202
- assert.equal(c.activities.items[1].object.displayName, '**comment**');
203
- assert.equal(c.activities.items[1].object.content, '<strong>comment</strong>');
204
- }));
205
-
206
- it('creates a conversation with a share', () => webex.internal.conversation.create({participants, files: [sampleTextOne]})
207
- .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 10}))
208
- .then((c) => {
209
- assert.equal(last(c.activities.items).verb, 'share');
210
-
211
- return webex.internal.conversation.download(last(c.activities.items).object.files.items[0]);
212
- })
213
- .then((file) => fh.isMatchingFile(file, sampleTextOne)));
214
-
215
- it('ensures the current user is in the participants list', () => webex.internal.conversation.create({comment: 'comment', participants: [mccoy, checkov]})
216
- .then((c) => webex.internal.conversation.get(c, {includeParticipants: true}))
217
- .then((c) => assert.include(map(c.participants.items, 'id'), spock.id)));
218
-
219
- it('does not allow me to create a conversation with zero participants', () => assert.isRejected(webex.internal.conversation.create({participants: []}, /`params.participants` is required/)));
226
+ it('creates a conversation with a name', () =>
227
+ webex.internal.conversation
228
+ .create({displayName: 'displayName', participants})
229
+ .then((c) => webex.internal.conversation.get(c))
230
+ .then((c) => assert.equal(c.displayName, 'displayName')));
231
+
232
+ it('creates a conversation with a comment', () =>
233
+ webex.internal.conversation
234
+ .create({comment: 'comment', participants})
235
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
236
+ .then((c) => assert.equal(c.activities.items[1].object.displayName, 'comment')));
237
+
238
+ it('creates a conversation with a tag', () =>
239
+ webex.internal.conversation
240
+ .create({tags: ['WELCOME'], participants})
241
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
242
+ .then((c) => assert.equal(c.tags[0], 'WELCOME')));
243
+
244
+ it('creates a favorite conversation', () =>
245
+ webex.internal.conversation
246
+ .create({favorite: true, participants})
247
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 1}))
248
+ .then((c) => assert.equal(c.tags[0], 'FAVORITE')));
249
+
250
+ it('creates a conversation with a comment with html', () =>
251
+ webex.internal.conversation
252
+ .create({comment: '**comment**', html: '<strong>comment</strong>', participants})
253
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 2}))
254
+ .then((c) => {
255
+ assert.equal(c.activities.items[1].object.displayName, '**comment**');
256
+ assert.equal(c.activities.items[1].object.content, '<strong>comment</strong>');
257
+ }));
220
258
 
221
- it('does not allow me to create a classified space when feature toggle is disabled for the org', () => webex.internal.conversation.create({participants: [mccoy, checkov], classificationId: 'abcde-12345-Some-UUID'})
222
- .catch((err) => assert.match(err.toString(), /Org not entitled for space classifications/)));
259
+ it('creates a conversation with a share', () =>
260
+ webex.internal.conversation
261
+ .create({participants, files: [sampleTextOne]})
262
+ .then((c) => webex.internal.conversation.get(c, {activitiesLimit: 10}))
263
+ .then((c) => {
264
+ assert.equal(last(c.activities.items).verb, 'share');
265
+
266
+ return webex.internal.conversation.download(
267
+ last(c.activities.items).object.files.items[0]
268
+ );
269
+ })
270
+ .then((file) => fh.isMatchingFile(file, sampleTextOne)));
271
+
272
+ it('ensures the current user is in the participants list', () =>
273
+ webex.internal.conversation
274
+ .create({comment: 'comment', participants: [mccoy, checkov]})
275
+ .then((c) => webex.internal.conversation.get(c, {includeParticipants: true}))
276
+ .then((c) => assert.include(map(c.participants.items, 'id'), spock.id)));
277
+
278
+ it('does not allow me to create a conversation with zero participants', () =>
279
+ assert.isRejected(
280
+ webex.internal.conversation.create({participants: []}, /`params.participants` is required/)
281
+ ));
282
+
283
+ it('does not allow me to create a classified space when feature toggle is disabled for the org', () =>
284
+ webex.internal.conversation
285
+ .create({participants: [mccoy, checkov], classificationId: 'abcde-12345-Some-UUID'})
286
+ .catch((err) =>
287
+ assert.match(err.toString(), /Org not entitled for space classifications/)
288
+ ));
223
289
  });
224
290
  });