@webex/internal-plugin-conversation 3.0.0-bnr.4 → 3.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -0
- package/babel.config.js +3 -0
- package/dist/activities.js +26 -48
- package/dist/activities.js.map +1 -1
- package/dist/activity-thread-ordering.js +19 -34
- package/dist/activity-thread-ordering.js.map +1 -1
- package/dist/config.js +1 -2
- package/dist/config.js.map +1 -1
- package/dist/constants.js +4 -14
- package/dist/constants.js.map +1 -1
- package/dist/conversation.js +82 -111
- package/dist/conversation.js.map +1 -1
- package/dist/convo-error.js +5 -5
- package/dist/convo-error.js.map +1 -1
- package/dist/decryption-transforms.js +9 -8
- package/dist/decryption-transforms.js.map +1 -1
- package/dist/encryption-transforms.js +27 -23
- package/dist/encryption-transforms.js.map +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/dist/share-activity.js +20 -25
- package/dist/share-activity.js.map +1 -1
- package/dist/to-array.js +7 -5
- package/dist/to-array.js.map +1 -1
- package/jest.config.js +3 -0
- package/package.json +32 -17
- package/process +1 -0
- package/src/constants.js +0 -5
- package/src/conversation.js +8 -27
- package/src/encryption-transforms.js +8 -0
- package/test/integration/spec/create.js +2 -3
- package/test/integration/spec/encryption.js +0 -1
- package/test/integration/spec/get.js +4 -2
- package/test/unit/spec/conversation.js +51 -21
- package/test/unit/spec/encryption-transforms.js +23 -0
- package/dist/internal-plugin-conversation.d.ts +0 -21
- package/dist/tsdoc-metadata.json +0 -11
- package/dist/types/activities.d.ts +0 -32
- package/dist/types/activity-thread-ordering.d.ts +0 -18
- package/dist/types/config.d.ts +0 -19
- package/dist/types/constants.d.ts +0 -5
- package/dist/types/conversation.d.ts +0 -2
- package/dist/types/convo-error.d.ts +0 -10
- package/dist/types/decryption-transforms.d.ts +0 -1
- package/dist/types/encryption-transforms.d.ts +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/share-activity.d.ts +0 -7
- package/dist/types/to-array.d.ts +0 -9
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import {assert} from '@webex/test-helper-chai';
|
|
6
6
|
import MockWebex from '@webex/test-helper-mock-webex';
|
|
7
7
|
import sinon from 'sinon';
|
|
8
|
-
|
|
9
8
|
import Conversation from '@webex/internal-plugin-conversation';
|
|
10
9
|
|
|
11
10
|
import {
|
|
@@ -32,7 +31,48 @@ describe('plugin-conversation', () => {
|
|
|
32
31
|
|
|
33
32
|
webex.internal.services = {};
|
|
34
33
|
webex.internal.services.get = sinon.stub().returns(Promise.resolve(convoUrl));
|
|
35
|
-
webex.internal.services.
|
|
34
|
+
webex.internal.services.getServiceUrlFromClusterId = sinon.stub().returns(convoUrl);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('addReaction()', () => {
|
|
38
|
+
it('should add recipients to the payload if provided', () => {
|
|
39
|
+
const {conversation} = webex.internal;
|
|
40
|
+
const recipientId = 'example-recipient-id';
|
|
41
|
+
const expected = {items: [{id: recipientId, objectType: 'person'}]}
|
|
42
|
+
conversation.sendReaction = sinon.stub().returns(Promise.resolve())
|
|
43
|
+
conversation.createReactionHmac = sinon.stub().returns(Promise.resolve('hmac'))
|
|
44
|
+
|
|
45
|
+
return conversation.addReaction({}, 'example-display-name', {}, recipientId)
|
|
46
|
+
.then(() => {
|
|
47
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expected);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('deleteReaction()', () => {
|
|
53
|
+
it('should add recipients to the payload if provided', () => {
|
|
54
|
+
const {conversation} = webex.internal;
|
|
55
|
+
const recipientId = 'example-recipient-id';
|
|
56
|
+
const expected = {items: [{id: recipientId, objectType: 'person'}]}
|
|
57
|
+
conversation.sendReaction = sinon.stub().returns(Promise.resolve())
|
|
58
|
+
|
|
59
|
+
return conversation.deleteReaction({}, 'example-reaction-id', recipientId)
|
|
60
|
+
.then(() => {
|
|
61
|
+
assert.deepEqual(conversation.sendReaction.args[0][1].recipients, expected);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('prepare()', () => {
|
|
67
|
+
it('should ammend activity recipients to the returned object', () => {
|
|
68
|
+
const {conversation} = webex.internal;
|
|
69
|
+
const activity = { recipients: 'example-recipients' };
|
|
70
|
+
|
|
71
|
+
return conversation.prepare(activity)
|
|
72
|
+
.then((results) => {
|
|
73
|
+
assert.deepEqual(results.recipients, activity.recipients);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
36
76
|
});
|
|
37
77
|
|
|
38
78
|
describe('addReaction()', () => {
|
|
@@ -180,27 +220,21 @@ describe('plugin-conversation', () => {
|
|
|
180
220
|
it('should convert a "us" cluster to WEBEX_CONVERSATION_DEFAULT_CLUSTER cluster', async () => {
|
|
181
221
|
await webex.internal.conversation.getUrlFromClusterId({cluster: 'us'});
|
|
182
222
|
|
|
183
|
-
sinon.assert.calledWith(webex.internal.services.
|
|
184
|
-
clusterId: process.env.WEBEX_CONVERSATION_DEFAULT_CLUSTER,
|
|
185
|
-
});
|
|
223
|
+
sinon.assert.calledWith(webex.internal.services.getServiceUrlFromClusterId, {cluster: 'us'});
|
|
186
224
|
});
|
|
187
225
|
|
|
188
226
|
it('should add the cluster service when missing', async () => {
|
|
189
227
|
await webex.internal.conversation.getUrlFromClusterId({cluster: 'urn:TEAM:us-west-2_r'});
|
|
190
228
|
|
|
191
|
-
sinon.assert.calledWith(webex.internal.services.
|
|
192
|
-
clusterId: 'urn:TEAM:us-west-2_r:identityLookup',
|
|
193
|
-
});
|
|
229
|
+
sinon.assert.calledWith(webex.internal.services.getServiceUrlFromClusterId, {cluster: 'urn:TEAM:us-west-2_r'});
|
|
194
230
|
});
|
|
195
231
|
});
|
|
196
232
|
|
|
197
233
|
describe('paginate', () => {
|
|
198
234
|
it('should throw an error if a page is passed with no links', () => {
|
|
199
|
-
|
|
200
|
-
webex.internal.conversation.paginate({page: {}});
|
|
201
|
-
} catch (error) {
|
|
235
|
+
webex.internal.conversation.paginate({page: {}}).catch((error) => {
|
|
202
236
|
assert.equal(error.message, 'No link to follow for the provided page');
|
|
203
|
-
}
|
|
237
|
+
});
|
|
204
238
|
});
|
|
205
239
|
});
|
|
206
240
|
|
|
@@ -375,14 +409,12 @@ describe('plugin-conversation', () => {
|
|
|
375
409
|
conversationUrl: convoUrl,
|
|
376
410
|
});
|
|
377
411
|
|
|
378
|
-
|
|
379
|
-
jumpToActivity();
|
|
380
|
-
} catch (e) {
|
|
412
|
+
jumpToActivity().catch((e) => {
|
|
381
413
|
assert.equal(
|
|
382
414
|
e.message,
|
|
383
415
|
'Search must be an activity object from conversation service'
|
|
384
416
|
);
|
|
385
|
-
}
|
|
417
|
+
});
|
|
386
418
|
});
|
|
387
419
|
|
|
388
420
|
it('should throw an error if activity.target.url is missing', () => {
|
|
@@ -390,11 +422,9 @@ describe('plugin-conversation', () => {
|
|
|
390
422
|
conversationUrl: convoUrl,
|
|
391
423
|
});
|
|
392
424
|
|
|
393
|
-
|
|
394
|
-
assert.
|
|
395
|
-
}
|
|
396
|
-
//
|
|
397
|
-
}
|
|
425
|
+
jumpToActivity({target: null}).catch((e) => {
|
|
426
|
+
assert.equal(e.message, 'Search object must have a target url!');
|
|
427
|
+
});
|
|
398
428
|
});
|
|
399
429
|
|
|
400
430
|
it('should implement the iterator protocol', () => {
|
|
@@ -36,6 +36,29 @@ describe('plugin-conversation', () => {
|
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
it('does not transform when object type is "policies" for a "meetingContainer" activity', async () => {
|
|
40
|
+
const transform = transforms.find((t) => t.name === 'encryptActivity');
|
|
41
|
+
const transformStub = sinon.stub().resolves();
|
|
42
|
+
|
|
43
|
+
const ctx = {
|
|
44
|
+
transform: transformStub,
|
|
45
|
+
};
|
|
46
|
+
const key = null;
|
|
47
|
+
const activity = {
|
|
48
|
+
object: {
|
|
49
|
+
objectType: 'policies',
|
|
50
|
+
},
|
|
51
|
+
objectType: 'activity',
|
|
52
|
+
target: {
|
|
53
|
+
objectType: 'meetingContainer',
|
|
54
|
+
},
|
|
55
|
+
verb: 'update',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const results = await transform.fn(ctx, key, activity);
|
|
59
|
+
assert.equal(results, undefined);
|
|
60
|
+
});
|
|
61
|
+
|
|
39
62
|
it('does transfom when created is not True', async () => {
|
|
40
63
|
const transform = transforms.find((t) => t.name === 'encryptActivity');
|
|
41
64
|
const transformStub = sinon.stub().resolves();
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
declare const Conversation: any;
|
|
2
|
-
export default Conversation;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* General conversation error
|
|
6
|
-
*/
|
|
7
|
-
export declare class ConversationError {
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* InvalidUserCreation thrown when failed to create conversation with invalid user
|
|
12
|
-
*/
|
|
13
|
-
export declare class InvalidUserCreation extends ConversationError {
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @class
|
|
18
|
-
*/
|
|
19
|
-
export declare const ShareActivity: any;
|
|
20
|
-
|
|
21
|
-
export { }
|
package/dist/tsdoc-metadata.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.34.4"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export const OLDER: "older";
|
|
2
|
-
export const NEWER: "newer";
|
|
3
|
-
export const MID: "mid";
|
|
4
|
-
export const INITIAL: "initial";
|
|
5
|
-
export namespace ACTIVITY_TYPES {
|
|
6
|
-
const REPLY: string;
|
|
7
|
-
const EDIT: string;
|
|
8
|
-
const REACTION: string;
|
|
9
|
-
const REACTION_SELF: string;
|
|
10
|
-
const ROOT: string;
|
|
11
|
-
const CREATE: string;
|
|
12
|
-
const TOMBSTONE: string;
|
|
13
|
-
const DELETE: string;
|
|
14
|
-
const REPLY_EDIT: string;
|
|
15
|
-
}
|
|
16
|
-
export function getActivityType(activity: any): string;
|
|
17
|
-
export function getPublishedDate(activity?: {}): number;
|
|
18
|
-
export function isNewer(activity1: any, activity2: any): boolean;
|
|
19
|
-
export function sortActivitiesByPublishedDate(activities: any): any[];
|
|
20
|
-
export function getParentId(activity: any): any;
|
|
21
|
-
export function isRootActivity(act: any): boolean;
|
|
22
|
-
export function isReplyActivity(act: any): boolean;
|
|
23
|
-
export function isEditActivity(act: any): boolean;
|
|
24
|
-
export function isCreateActivity(act: any): boolean;
|
|
25
|
-
export function isDeleteActivity(act: any): boolean;
|
|
26
|
-
export function sanitizeActivity(activity: any): any;
|
|
27
|
-
export function getIsActivityOrphaned(activity: any, activities: any): boolean;
|
|
28
|
-
export function determineActivityType(activity: any, activities: any): string;
|
|
29
|
-
export function createRootActivity(activity: any): any;
|
|
30
|
-
export function createReplyActivity(activity: any): any;
|
|
31
|
-
export function createEditActivity(editActivity: any, activities: any): any;
|
|
32
|
-
export function createReplyEditActivity(editActivity: any, activities: any): any;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const defaultMinDisplayableActivities: 20;
|
|
2
|
-
export const minBatchSize: 10;
|
|
3
|
-
export const fetchLoopCountMax: 100;
|
|
4
|
-
export const batchSizeIncrementCount: 10;
|
|
5
|
-
export function setValue(destination: Map<any, any>, key: string, value: any): Map<any, any>;
|
|
6
|
-
export function getValue(source: Map<any, any>, key: string): Map<any, any>;
|
|
7
|
-
export function getActivityObjectsFromMap(hashMap: any): any[];
|
|
8
|
-
export function activityManager(): object;
|
|
9
|
-
export function bookendManager(): object;
|
|
10
|
-
export function noMoreActivitiesManager(): object;
|
|
11
|
-
export function rootActivityManager(): object;
|
|
12
|
-
export function getLoopCounterFailsafe(): () => void;
|
|
13
|
-
export function getQuery(type: string, queryOptions: {
|
|
14
|
-
newestPublishedDate?: string;
|
|
15
|
-
oldestPublishedDate?: string;
|
|
16
|
-
batchSize?: number;
|
|
17
|
-
activityToSearch?: object;
|
|
18
|
-
}): object;
|
package/dist/types/config.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
namespace conversation {
|
|
3
|
-
const allowedInboundTags: {
|
|
4
|
-
'webex-mention': string[];
|
|
5
|
-
};
|
|
6
|
-
const allowedOutboundTags: {
|
|
7
|
-
'webex-mention': string[];
|
|
8
|
-
};
|
|
9
|
-
function inboundProcessFunc(): void;
|
|
10
|
-
function outboundProcessFunc(): void;
|
|
11
|
-
const allowedInboundStyles: any[];
|
|
12
|
-
const allowedOutboundStyles: any[];
|
|
13
|
-
const thumbnailMaxHeight: number;
|
|
14
|
-
const thumbnailMaxWidth: number;
|
|
15
|
-
const keepEncryptedProperties: boolean;
|
|
16
|
-
const decryptionFailureMessage: string;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const transforms: any[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const transforms: any[];
|
package/dist/types/index.d.ts
DELETED
package/dist/types/to-array.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper to convert objects into arrays of transforms. probably belongs in
|
|
3
|
-
* webex-core
|
|
4
|
-
* @param {string} direction "inbound"|"outbound"
|
|
5
|
-
* @param {Object} obj
|
|
6
|
-
* @private
|
|
7
|
-
* @returns {Array}
|
|
8
|
-
*/
|
|
9
|
-
export default function toArray(direction: string, obj: any): any[];
|