@webex/plugin-people 3.0.0-beta.9 → 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.
- package/README.md +3 -6
- package/dist/config.js +0 -4
- package/dist/config.js.map +1 -1
- package/dist/index.js +1 -7
- package/dist/index.js.map +1 -1
- package/dist/people-batcher.js +0 -15
- package/dist/people-batcher.js.map +1 -1
- package/dist/people.js +3 -23
- package/dist/people.js.map +1 -1
- package/dist/plugin-people.d.ts +7 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/config.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/people-batcher.d.ts +6 -0
- package/dist/types/people.d.ts +30 -0
- package/package.json +8 -8
- package/src/config.js +2 -2
- package/src/index.js +1 -1
- package/src/people-batcher.js +11 -13
- package/src/people.js +10 -11
- package/test/integration/spec/people.js +59 -49
- package/test/unit/spec/people-batcher.js +36 -26
- package/test/unit/spec/people.js +4 -3
package/README.md
CHANGED
|
@@ -29,15 +29,12 @@ npm install --save @webex/plugin-people
|
|
|
29
29
|
## Usage
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
|
-
|
|
33
32
|
const Webex = require('webex');
|
|
34
33
|
|
|
35
34
|
const webex = Webex.init();
|
|
36
|
-
webex.people.get(id)
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
})
|
|
40
|
-
|
|
35
|
+
webex.people.get(id).then((people) => {
|
|
36
|
+
console.log(people);
|
|
37
|
+
});
|
|
41
38
|
```
|
|
42
39
|
|
|
43
40
|
## Maintainers
|
package/dist/config.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
-
|
|
5
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
exports.default = void 0;
|
|
10
|
-
|
|
11
8
|
/*!
|
|
12
9
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
13
10
|
*/
|
|
@@ -16,7 +13,6 @@ var _default = {
|
|
|
16
13
|
batcherWait: 100,
|
|
17
14
|
batcherMaxCalls: 10,
|
|
18
15
|
batcherMaxWait: 1500,
|
|
19
|
-
|
|
20
16
|
/**
|
|
21
17
|
* optional flag that requires Hydra to send every type field,
|
|
22
18
|
* even if the type is not "person" (e.g.: SX10, webhook_integration, etc.)
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["people","batcherWait","batcherMaxCalls","batcherMaxWait","showAllTypes"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n people: {\n batcherWait: 100,\n batcherMaxCalls: 10,\n batcherMaxWait: 1500,\n /**\n * optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @private\n */\n showAllTypes: false
|
|
1
|
+
{"version":3,"names":["people","batcherWait","batcherMaxCalls","batcherMaxWait","showAllTypes"],"sources":["config.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n people: {\n batcherWait: 100,\n batcherMaxCalls: 10,\n batcherMaxWait: 1500,\n /**\n * optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @private\n */\n showAllTypes: false,\n },\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,eAIe;EACbA,MAAM,EAAE;IACNC,WAAW,EAAE,GAAG;IAChBC,eAAe,EAAE,EAAE;IACnBC,cAAc,EAAE,IAAI;IACpB;AACJ;AACA;AACA;AACA;IACIC,YAAY,EAAE;EAChB;AACF,CAAC;AAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
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
|
_Object$defineProperty(exports, "default", {
|
|
12
9
|
enumerable: true,
|
|
13
10
|
get: function get() {
|
|
14
11
|
return _people.default;
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
var _webexCore = require("@webex/webex-core");
|
|
19
|
-
|
|
20
15
|
var _people = _interopRequireDefault(require("./people"));
|
|
21
|
-
|
|
22
16
|
var _config = _interopRequireDefault(require("./config"));
|
|
23
|
-
|
|
24
17
|
/*!
|
|
25
18
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
26
19
|
*/
|
|
20
|
+
|
|
27
21
|
(0, _webexCore.registerPlugin)('people', _people.default, {
|
|
28
22
|
config: _config.default
|
|
29
23
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerPlugin","People","config"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport People from './people';\nimport config from './config';\n\nregisterPlugin('people', People, {\n config
|
|
1
|
+
{"version":3,"names":["registerPlugin","People","config"],"sources":["index.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {registerPlugin} from '@webex/webex-core';\n\nimport People from './people';\nimport config from './config';\n\nregisterPlugin('people', People, {\n config,\n});\n\nexport {default} from './people';\n"],"mappings":";;;;;;;;;;;;;AAIA;AAEA;AACA;AAPA;AACA;AACA;;AAOA,IAAAA,yBAAc,EAAC,QAAQ,EAAEC,eAAM,EAAE;EAC/BC,MAAM,EAANA;AACF,CAAC,CAAC"}
|
package/dist/people-batcher.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
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
10
|
var _webexCore = require("@webex/webex-core");
|
|
16
|
-
|
|
17
11
|
/*!
|
|
18
12
|
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
|
|
19
13
|
*/
|
|
@@ -24,7 +18,6 @@ var _webexCore = require("@webex/webex-core");
|
|
|
24
18
|
*/
|
|
25
19
|
var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
26
20
|
namespace: 'People',
|
|
27
|
-
|
|
28
21
|
/**
|
|
29
22
|
* @instance
|
|
30
23
|
* @memberof PersonUUIDRequestBatcher
|
|
@@ -33,17 +26,14 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
33
26
|
*/
|
|
34
27
|
handleHttpSuccess: function handleHttpSuccess(res) {
|
|
35
28
|
var _this = this;
|
|
36
|
-
|
|
37
29
|
var promises = res.body.items.map(function (personResponse) {
|
|
38
30
|
return _this.handleItemSuccess(personResponse.id, personResponse);
|
|
39
31
|
});
|
|
40
|
-
|
|
41
32
|
if (res.body.notFoundIds) {
|
|
42
33
|
promises.concat(res.body.notFoundIds.map(function (id) {
|
|
43
34
|
return _this.handleItemFailure(id);
|
|
44
35
|
}));
|
|
45
36
|
}
|
|
46
|
-
|
|
47
37
|
return _promise.default.all(promises);
|
|
48
38
|
},
|
|
49
39
|
handleItemFailure: function handleItemFailure(id) {
|
|
@@ -51,7 +41,6 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
51
41
|
defer.reject(id);
|
|
52
42
|
});
|
|
53
43
|
},
|
|
54
|
-
|
|
55
44
|
/**
|
|
56
45
|
* @instance
|
|
57
46
|
* @memberof PersonUUIDRequestBatcher
|
|
@@ -64,7 +53,6 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
64
53
|
defer.resolve(response);
|
|
65
54
|
});
|
|
66
55
|
},
|
|
67
|
-
|
|
68
56
|
/**
|
|
69
57
|
* @instance
|
|
70
58
|
* @memberof PersonUUIDRequestBatcher
|
|
@@ -75,7 +63,6 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
75
63
|
var hydraId = this.webex.people.inferPersonIdFromUuid(uuidOrHydraId);
|
|
76
64
|
return _promise.default.resolve(hydraId);
|
|
77
65
|
},
|
|
78
|
-
|
|
79
66
|
/**
|
|
80
67
|
* @instance
|
|
81
68
|
* @memberof PersonUUIDRequestBatcher
|
|
@@ -88,7 +75,6 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
88
75
|
prepareRequest: function prepareRequest(ids) {
|
|
89
76
|
return _promise.default.resolve(ids.join());
|
|
90
77
|
},
|
|
91
|
-
|
|
92
78
|
/**
|
|
93
79
|
* @instance
|
|
94
80
|
* @memberof PersonUUIDRequestBatcher
|
|
@@ -102,7 +88,6 @@ var PersonUUIDRequestBatcher = _webexCore.Batcher.extend({
|
|
|
102
88
|
});
|
|
103
89
|
}
|
|
104
90
|
});
|
|
105
|
-
|
|
106
91
|
var _default = PersonUUIDRequestBatcher;
|
|
107
92
|
exports.default = _default;
|
|
108
93
|
//# sourceMappingURL=people-batcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PersonUUIDRequestBatcher","Batcher","extend","namespace","handleHttpSuccess","res","promises","body","items","map","personResponse","handleItemSuccess","id","notFoundIds","concat","handleItemFailure","all","getDeferredForResponse","then","defer","reject","email","response","resolve","fingerprintRequest","uuidOrHydraId","hydraId","webex","people","inferPersonIdFromUuid","fingerprintResponse","prepareRequest","ids","join","submitHttpRequest","request","service","resource","config","showAllTypes"],"sources":["people-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Batcher} from '@webex/webex-core';\n\n/**\n * @class\n * @ignore\n */\nconst PersonUUIDRequestBatcher = Batcher.extend({\n namespace: 'People',\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {HttpResponseObject} res\n * @returns {Promise}\n */\n handleHttpSuccess(res) {\n const promises = res.body.items.map((personResponse) =>\n this.handleItemSuccess(personResponse.id, personResponse));\n\n if (res.body.notFoundIds) {\n promises.concat(res.body.notFoundIds.map((id)
|
|
1
|
+
{"version":3,"names":["PersonUUIDRequestBatcher","Batcher","extend","namespace","handleHttpSuccess","res","promises","body","items","map","personResponse","handleItemSuccess","id","notFoundIds","concat","handleItemFailure","all","getDeferredForResponse","then","defer","reject","email","response","resolve","fingerprintRequest","uuidOrHydraId","hydraId","webex","people","inferPersonIdFromUuid","fingerprintResponse","prepareRequest","ids","join","submitHttpRequest","request","service","resource","config","showAllTypes"],"sources":["people-batcher.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {Batcher} from '@webex/webex-core';\n\n/**\n * @class\n * @ignore\n */\nconst PersonUUIDRequestBatcher = Batcher.extend({\n namespace: 'People',\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {HttpResponseObject} res\n * @returns {Promise}\n */\n handleHttpSuccess(res) {\n const promises = res.body.items.map((personResponse) =>\n this.handleItemSuccess(personResponse.id, personResponse)\n );\n\n if (res.body.notFoundIds) {\n promises.concat(res.body.notFoundIds.map((id) => this.handleItemFailure(id)));\n }\n\n return Promise.all(promises);\n },\n\n handleItemFailure(id) {\n return this.getDeferredForResponse(id).then((defer) => {\n defer.reject(id);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} email\n * @param {Object} response\n * @returns {Promise}\n */\n handleItemSuccess(email, response) {\n return this.getDeferredForResponse(email).then((defer) => {\n defer.resolve(response);\n });\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} uuidOrHydraId\n * @returns {Promise<string>}\n */\n fingerprintRequest(uuidOrHydraId) {\n const hydraId = this.webex.people.inferPersonIdFromUuid(uuidOrHydraId);\n\n return Promise.resolve(hydraId);\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {string} hydraId\n * @returns {Promise<string>}\n */\n fingerprintResponse(hydraId) {\n return Promise.resolve(hydraId);\n },\n\n prepareRequest(ids) {\n return Promise.resolve(ids.join());\n },\n\n /**\n * @instance\n * @memberof PersonUUIDRequestBatcher\n * @param {Object} ids\n * @returns {Promise<HttpResponseObject>}\n */\n submitHttpRequest(ids) {\n return this.webex.request({\n service: 'hydra',\n resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`,\n });\n },\n});\n\nexport default PersonUUIDRequestBatcher;\n"],"mappings":";;;;;;;;;AAIA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,wBAAwB,GAAGC,kBAAO,CAACC,MAAM,CAAC;EAC9CC,SAAS,EAAE,QAAQ;EAEnB;AACF;AACA;AACA;AACA;AACA;EACEC,iBAAiB,6BAACC,GAAG,EAAE;IAAA;IACrB,IAAMC,QAAQ,GAAGD,GAAG,CAACE,IAAI,CAACC,KAAK,CAACC,GAAG,CAAC,UAACC,cAAc;MAAA,OACjD,KAAI,CAACC,iBAAiB,CAACD,cAAc,CAACE,EAAE,EAAEF,cAAc,CAAC;IAAA,EAC1D;IAED,IAAIL,GAAG,CAACE,IAAI,CAACM,WAAW,EAAE;MACxBP,QAAQ,CAACQ,MAAM,CAACT,GAAG,CAACE,IAAI,CAACM,WAAW,CAACJ,GAAG,CAAC,UAACG,EAAE;QAAA,OAAK,KAAI,CAACG,iBAAiB,CAACH,EAAE,CAAC;MAAA,EAAC,CAAC;IAC/E;IAEA,OAAO,iBAAQI,GAAG,CAACV,QAAQ,CAAC;EAC9B,CAAC;EAEDS,iBAAiB,6BAACH,EAAE,EAAE;IACpB,OAAO,IAAI,CAACK,sBAAsB,CAACL,EAAE,CAAC,CAACM,IAAI,CAAC,UAACC,KAAK,EAAK;MACrDA,KAAK,CAACC,MAAM,CAACR,EAAE,CAAC;IAClB,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;EACED,iBAAiB,6BAACU,KAAK,EAAEC,QAAQ,EAAE;IACjC,OAAO,IAAI,CAACL,sBAAsB,CAACI,KAAK,CAAC,CAACH,IAAI,CAAC,UAACC,KAAK,EAAK;MACxDA,KAAK,CAACI,OAAO,CAACD,QAAQ,CAAC;IACzB,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEE,kBAAkB,8BAACC,aAAa,EAAE;IAChC,IAAMC,OAAO,GAAG,IAAI,CAACC,KAAK,CAACC,MAAM,CAACC,qBAAqB,CAACJ,aAAa,CAAC;IAEtE,OAAO,iBAAQF,OAAO,CAACG,OAAO,CAAC;EACjC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEI,mBAAmB,+BAACJ,OAAO,EAAE;IAC3B,OAAO,iBAAQH,OAAO,CAACG,OAAO,CAAC;EACjC,CAAC;EAEDK,cAAc,0BAACC,GAAG,EAAE;IAClB,OAAO,iBAAQT,OAAO,CAACS,GAAG,CAACC,IAAI,EAAE,CAAC;EACpC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,iBAAiB,6BAACF,GAAG,EAAE;IACrB,OAAO,IAAI,CAACL,KAAK,CAACQ,OAAO,CAAC;MACxBC,OAAO,EAAE,OAAO;MAChBC,QAAQ,uBAAgBL,GAAG,2BAAiB,IAAI,CAACM,MAAM,CAACC,YAAY;IACtE,CAAC,CAAC;EACJ;AACF,CAAC,CAAC;AAAC,eAEYvC,wBAAwB;AAAA"}
|
package/dist/people.js
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
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
10
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/array/is-array"));
|
|
16
|
-
|
|
17
11
|
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor"));
|
|
18
|
-
|
|
19
12
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
20
|
-
|
|
21
13
|
var _webexCore = require("@webex/webex-core");
|
|
22
|
-
|
|
23
14
|
var _common = require("@webex/common");
|
|
24
|
-
|
|
25
15
|
var _peopleBatcher = _interopRequireDefault(require("./people-batcher"));
|
|
26
|
-
|
|
27
16
|
var _obj;
|
|
28
|
-
|
|
29
17
|
/**
|
|
30
18
|
* @typedef {Object} PersonObject
|
|
31
19
|
* @property {string} id - (server generated) Unique identifier for the person
|
|
@@ -42,7 +30,6 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
42
30
|
children: {
|
|
43
31
|
batcher: _peopleBatcher.default
|
|
44
32
|
},
|
|
45
|
-
|
|
46
33
|
/**
|
|
47
34
|
* Returns a single person by ID
|
|
48
35
|
* @instance
|
|
@@ -77,15 +64,12 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
77
64
|
if (!person) {
|
|
78
65
|
return _promise.default.reject(new Error('A person with an id is required'));
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
if (person === 'me') {
|
|
82
68
|
return this._getMe();
|
|
83
69
|
}
|
|
84
|
-
|
|
85
70
|
var id = person.personId || person.id || person;
|
|
86
71
|
return this.batcher.request(id);
|
|
87
72
|
},
|
|
88
|
-
|
|
89
73
|
/**
|
|
90
74
|
* Returns a list of people
|
|
91
75
|
* @instance
|
|
@@ -167,14 +151,12 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
167
151
|
*/
|
|
168
152
|
list: function list(options) {
|
|
169
153
|
var _this = this;
|
|
170
|
-
|
|
171
154
|
if ((0, _isArray.default)(options)) {
|
|
172
155
|
var peopleIds = options;
|
|
173
156
|
return _promise.default.all(peopleIds.map(function (personId) {
|
|
174
157
|
return _this.batcher.request(personId);
|
|
175
158
|
}));
|
|
176
159
|
}
|
|
177
|
-
|
|
178
160
|
return this.request({
|
|
179
161
|
service: 'hydra',
|
|
180
162
|
resource: 'people',
|
|
@@ -183,7 +165,6 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
183
165
|
return new _webexCore.Page(res, _this.webex);
|
|
184
166
|
});
|
|
185
167
|
},
|
|
186
|
-
|
|
187
168
|
/**
|
|
188
169
|
* Converts a uuid to a hydra id without a network dip.
|
|
189
170
|
* @param {string} id
|
|
@@ -197,9 +178,9 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
197
178
|
if (_common.base64.decode(id).includes('ciscospark://')) {
|
|
198
179
|
return id;
|
|
199
180
|
}
|
|
200
|
-
} catch (err) {
|
|
181
|
+
} catch (err) {
|
|
182
|
+
// ignore
|
|
201
183
|
}
|
|
202
|
-
|
|
203
184
|
return _common.base64.encode("ciscospark://us/PEOPLE/".concat(id));
|
|
204
185
|
},
|
|
205
186
|
_getMe: function _getMe() {
|
|
@@ -210,9 +191,8 @@ var People = _webexCore.WebexPlugin.extend((_obj = {
|
|
|
210
191
|
return res.body;
|
|
211
192
|
});
|
|
212
193
|
},
|
|
213
|
-
version: "3.0.0-
|
|
194
|
+
version: "3.0.0-bnr.0"
|
|
214
195
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "_getMe", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "_getMe"), _obj)), _obj));
|
|
215
|
-
|
|
216
196
|
var _default = People;
|
|
217
197
|
exports.default = _default;
|
|
218
198
|
//# sourceMappingURL=people.js.map
|
package/dist/people.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["People","WebexPlugin","extend","namespace","children","batcher","PeopleBatcher","get","person","reject","Error","_getMe","id","personId","request","list","options","peopleIds","all","map","service","resource","qs","then","res","Page","webex","inferPersonIdFromUuid","base64","decode","includes","err","encode","body","oneFlight"],"sources":["people.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {base64, oneFlight} from '@webex/common';\n\nimport PeopleBatcher from './people-batcher';\n\n/**\n * @typedef {Object} PersonObject\n * @property {string} id - (server generated) Unique identifier for the person\n * @property {Array<email>} emails - Email addresses of the person\n * @property {string} displayName - Display name of the person\n * @property {isoDate} created - (server generated) The date and time that the person was created\n */\n\n/**\n * @class\n */\nconst People = WebexPlugin.extend({\n namespace: 'People',\n\n children: {\n batcher: PeopleBatcher
|
|
1
|
+
{"version":3,"names":["People","WebexPlugin","extend","namespace","children","batcher","PeopleBatcher","get","person","reject","Error","_getMe","id","personId","request","list","options","peopleIds","all","map","service","resource","qs","then","res","Page","webex","inferPersonIdFromUuid","base64","decode","includes","err","encode","body","oneFlight"],"sources":["people.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport {WebexPlugin, Page} from '@webex/webex-core';\nimport {base64, oneFlight} from '@webex/common';\n\nimport PeopleBatcher from './people-batcher';\n\n/**\n * @typedef {Object} PersonObject\n * @property {string} id - (server generated) Unique identifier for the person\n * @property {Array<email>} emails - Email addresses of the person\n * @property {string} displayName - Display name of the person\n * @property {isoDate} created - (server generated) The date and time that the person was created\n */\n\n/**\n * @class\n */\nconst People = WebexPlugin.extend({\n namespace: 'People',\n\n children: {\n batcher: PeopleBatcher,\n },\n /**\n * Returns a single person by ID\n * @instance\n * @memberof People\n * @param {PersonObject|uuid|string} person\n * @returns {Promise<PersonObject>}\n * @example\n * webex.rooms.create({title: 'Get Person Example'})\n * .then(function(room) {\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * return webex.people.get(membership.personId);\n * })\n * .then(function(alice) {\n * var assert = require('assert');\n * assert(alice.id);\n * assert(Array.isArray(alice.emails));\n * assert.equal(alice.emails.filter(function(email) {\n * return email === 'alice@example.com';\n * }).length, 1);\n * assert(alice.displayName);\n * assert(alice.created);\n * return 'success';\n * });\n * // => success\n */\n get(person) {\n if (!person) {\n return Promise.reject(new Error('A person with an id is required'));\n }\n if (person === 'me') {\n return this._getMe();\n }\n const id = person.personId || person.id || person;\n\n return this.batcher.request(id);\n },\n\n /**\n * Returns a list of people\n * @instance\n * @memberof People\n * @param {Object | uuid[]} options or array of uuids\n * @param {email} options.email - Returns people with an email that contains this string\n * @param {string} options.displayName - Returns people with a name that contains this string\n * @param {bool} showAllTypes optional flag that requires Hydra to send every type field,\n * even if the type is not \"person\" (e.g.: SX10, webhook_integration, etc.)\n * @returns {Promise<Page<PersonObject>>}\n * @example\n * var room;\n * webex.rooms.create({title: 'List People Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function() {\n * return webex.people.list({email: 'alice@example.com'});\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 1);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n * @example <caption>Example usage of array method</caption>\n * var room;\n * var aliceId;\n * var bobId;\n * webex.rooms.create({title: 'List People Array Example'})\n * .then(function(r) {\n * room = r;\n * return webex.memberships.create({\n * personEmail: 'alice@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * aliceId = membership.personId;\n * })\n * .then(function() {\n * return webex.memberships.create({\n * personEmail: 'bob@example.com',\n * roomId: room.id\n * });\n * })\n * .then(function(membership) {\n * bobId = membership.personId;\n * })\n * .then(function() {\n * return webex.people.list([aliceId, bobId]);\n * })\n * .then(function(people) {\n * var assert = require('assert');\n * assert.equal(people.length, 2);\n * var person = people.items[0];\n * assert(person.id);\n * assert(Array.isArray(person.emails));\n * assert(person.displayName);\n * assert(person.created);\n * return 'success';\n * });\n * // => success\n */\n list(options) {\n if (Array.isArray(options)) {\n const peopleIds = options;\n\n return Promise.all(peopleIds.map((personId) => this.batcher.request(personId)));\n }\n\n return this.request({\n service: 'hydra',\n resource: 'people',\n qs: options,\n }).then((res) => new Page(res, this.webex));\n },\n\n /**\n * Converts a uuid to a hydra id without a network dip.\n * @param {string} id\n * @private\n * @returns {string}\n */\n inferPersonIdFromUuid(id) {\n // base64.validate seems to return true for uuids, so we need a different\n // check\n try {\n if (base64.decode(id).includes('ciscospark://')) {\n return id;\n }\n } catch (err) {\n // ignore\n }\n\n return base64.encode(`ciscospark://us/PEOPLE/${id}`);\n },\n\n /**\n * Fetches the current user from the /people/me endpoint\n * @instance\n * @memberof People\n * @private\n * @returns {Promise<PersonObject>}\n */\n @oneFlight\n _getMe() {\n return this.webex\n .request({\n service: 'hydra',\n resource: 'people/me',\n })\n .then((res) => res.body);\n },\n});\n\nexport default People;\n"],"mappings":";;;;;;;;;;;;AAIA;AACA;AAEA;AAA6C;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,IAAMA,MAAM,GAAGC,sBAAW,CAACC,MAAM,SAAC;EAChCC,SAAS,EAAE,QAAQ;EAEnBC,QAAQ,EAAE;IACRC,OAAO,EAAEC;EACX,CAAC;EACD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,GAAG,eAACC,MAAM,EAAE;IACV,IAAI,CAACA,MAAM,EAAE;MACX,OAAO,iBAAQC,MAAM,CAAC,IAAIC,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrE;IACA,IAAIF,MAAM,KAAK,IAAI,EAAE;MACnB,OAAO,IAAI,CAACG,MAAM,EAAE;IACtB;IACA,IAAMC,EAAE,GAAGJ,MAAM,CAACK,QAAQ,IAAIL,MAAM,CAACI,EAAE,IAAIJ,MAAM;IAEjD,OAAO,IAAI,CAACH,OAAO,CAACS,OAAO,CAACF,EAAE,CAAC;EACjC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEG,IAAI,gBAACC,OAAO,EAAE;IAAA;IACZ,IAAI,sBAAcA,OAAO,CAAC,EAAE;MAC1B,IAAMC,SAAS,GAAGD,OAAO;MAEzB,OAAO,iBAAQE,GAAG,CAACD,SAAS,CAACE,GAAG,CAAC,UAACN,QAAQ;QAAA,OAAK,KAAI,CAACR,OAAO,CAACS,OAAO,CAACD,QAAQ,CAAC;MAAA,EAAC,CAAC;IACjF;IAEA,OAAO,IAAI,CAACC,OAAO,CAAC;MAClBM,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE,QAAQ;MAClBC,EAAE,EAAEN;IACN,CAAC,CAAC,CAACO,IAAI,CAAC,UAACC,GAAG;MAAA,OAAK,IAAIC,eAAI,CAACD,GAAG,EAAE,KAAI,CAACE,KAAK,CAAC;IAAA,EAAC;EAC7C,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,qBAAqB,iCAACf,EAAE,EAAE;IACxB;IACA;IACA,IAAI;MACF,IAAIgB,cAAM,CAACC,MAAM,CAACjB,EAAE,CAAC,CAACkB,QAAQ,CAAC,eAAe,CAAC,EAAE;QAC/C,OAAOlB,EAAE;MACX;IACF,CAAC,CAAC,OAAOmB,GAAG,EAAE;MACZ;IAAA;IAGF,OAAOH,cAAM,CAACI,MAAM,kCAA2BpB,EAAE,EAAG;EACtD,CAAC;EAUDD,MAAM,oBAAG;IACP,OAAO,IAAI,CAACe,KAAK,CACdZ,OAAO,CAAC;MACPM,OAAO,EAAE,OAAO;MAChBC,QAAQ,EAAE;IACZ,CAAC,CAAC,CACDE,IAAI,CAAC,UAACC,GAAG;MAAA,OAAKA,GAAG,CAACS,IAAI;IAAA,EAAC;EAC5B,CAAC;EAAA;AACH,CAAC,4DATEC,iBAAS,yEASV;AAAC,eAEYlC,MAAM;AAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./people";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default People;
|
|
2
|
+
export type PersonObject = {
|
|
3
|
+
/**
|
|
4
|
+
* - (server generated) Unique identifier for the person
|
|
5
|
+
*/
|
|
6
|
+
id: string;
|
|
7
|
+
/**
|
|
8
|
+
* - Email addresses of the person
|
|
9
|
+
*/
|
|
10
|
+
emails: Array<email>;
|
|
11
|
+
/**
|
|
12
|
+
* - Display name of the person
|
|
13
|
+
*/
|
|
14
|
+
displayName: string;
|
|
15
|
+
/**
|
|
16
|
+
* - (server generated) The date and time that the person was created
|
|
17
|
+
*/
|
|
18
|
+
created: isoDate;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} PersonObject
|
|
22
|
+
* @property {string} id - (server generated) Unique identifier for the person
|
|
23
|
+
* @property {Array<email>} emails - Email addresses of the person
|
|
24
|
+
* @property {string} displayName - Display name of the person
|
|
25
|
+
* @property {isoDate} created - (server generated) The date and time that the person was created
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* @class
|
|
29
|
+
*/
|
|
30
|
+
declare const People: any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/plugin-people",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-bnr.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@webex/test-helper-chai": "3.0.0-
|
|
24
|
-
"@webex/test-helper-mock-webex": "3.0.0-
|
|
25
|
-
"@webex/test-helper-test-users": "3.0.0-
|
|
23
|
+
"@webex/test-helper-chai": "3.0.0-bnr.0",
|
|
24
|
+
"@webex/test-helper-mock-webex": "3.0.0-bnr.0",
|
|
25
|
+
"@webex/test-helper-test-users": "3.0.0-bnr.0",
|
|
26
26
|
"sinon": "^9.2.4"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@webex/common": "3.0.0-
|
|
30
|
-
"@webex/internal-plugin-mercury": "3.0.0-
|
|
31
|
-
"@webex/plugin-people": "3.0.0-
|
|
32
|
-
"@webex/webex-core": "3.0.0-
|
|
29
|
+
"@webex/common": "3.0.0-bnr.0",
|
|
30
|
+
"@webex/internal-plugin-mercury": "3.0.0-bnr.0",
|
|
31
|
+
"@webex/plugin-people": "3.0.0-bnr.0",
|
|
32
|
+
"@webex/webex-core": "3.0.0-bnr.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/config.js
CHANGED
package/src/index.js
CHANGED
package/src/people-batcher.js
CHANGED
|
@@ -19,21 +19,20 @@ const PersonUUIDRequestBatcher = Batcher.extend({
|
|
|
19
19
|
*/
|
|
20
20
|
handleHttpSuccess(res) {
|
|
21
21
|
const promises = res.body.items.map((personResponse) =>
|
|
22
|
-
this.handleItemSuccess(personResponse.id, personResponse)
|
|
22
|
+
this.handleItemSuccess(personResponse.id, personResponse)
|
|
23
|
+
);
|
|
23
24
|
|
|
24
25
|
if (res.body.notFoundIds) {
|
|
25
|
-
promises.concat(res.body.notFoundIds.map((id) =>
|
|
26
|
-
this.handleItemFailure(id)));
|
|
26
|
+
promises.concat(res.body.notFoundIds.map((id) => this.handleItemFailure(id)));
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return Promise.all(promises);
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
handleItemFailure(id) {
|
|
33
|
-
return this.getDeferredForResponse(id)
|
|
34
|
-
.
|
|
35
|
-
|
|
36
|
-
});
|
|
33
|
+
return this.getDeferredForResponse(id).then((defer) => {
|
|
34
|
+
defer.reject(id);
|
|
35
|
+
});
|
|
37
36
|
},
|
|
38
37
|
|
|
39
38
|
/**
|
|
@@ -44,10 +43,9 @@ const PersonUUIDRequestBatcher = Batcher.extend({
|
|
|
44
43
|
* @returns {Promise}
|
|
45
44
|
*/
|
|
46
45
|
handleItemSuccess(email, response) {
|
|
47
|
-
return this.getDeferredForResponse(email)
|
|
48
|
-
.
|
|
49
|
-
|
|
50
|
-
});
|
|
46
|
+
return this.getDeferredForResponse(email).then((defer) => {
|
|
47
|
+
defer.resolve(response);
|
|
48
|
+
});
|
|
51
49
|
},
|
|
52
50
|
|
|
53
51
|
/**
|
|
@@ -85,9 +83,9 @@ const PersonUUIDRequestBatcher = Batcher.extend({
|
|
|
85
83
|
submitHttpRequest(ids) {
|
|
86
84
|
return this.webex.request({
|
|
87
85
|
service: 'hydra',
|
|
88
|
-
resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}
|
|
86
|
+
resource: `people/?id=${ids}&showAllTypes=${this.config.showAllTypes}`,
|
|
89
87
|
});
|
|
90
|
-
}
|
|
88
|
+
},
|
|
91
89
|
});
|
|
92
90
|
|
|
93
91
|
export default PersonUUIDRequestBatcher;
|
package/src/people.js
CHANGED
|
@@ -22,7 +22,7 @@ const People = WebexPlugin.extend({
|
|
|
22
22
|
namespace: 'People',
|
|
23
23
|
|
|
24
24
|
children: {
|
|
25
|
-
batcher: PeopleBatcher
|
|
25
|
+
batcher: PeopleBatcher,
|
|
26
26
|
},
|
|
27
27
|
/**
|
|
28
28
|
* Returns a single person by ID
|
|
@@ -155,9 +155,8 @@ const People = WebexPlugin.extend({
|
|
|
155
155
|
return this.request({
|
|
156
156
|
service: 'hydra',
|
|
157
157
|
resource: 'people',
|
|
158
|
-
qs: options
|
|
159
|
-
})
|
|
160
|
-
.then((res) => new Page(res, this.webex));
|
|
158
|
+
qs: options,
|
|
159
|
+
}).then((res) => new Page(res, this.webex));
|
|
161
160
|
},
|
|
162
161
|
|
|
163
162
|
/**
|
|
@@ -173,8 +172,7 @@ const People = WebexPlugin.extend({
|
|
|
173
172
|
if (base64.decode(id).includes('ciscospark://')) {
|
|
174
173
|
return id;
|
|
175
174
|
}
|
|
176
|
-
}
|
|
177
|
-
catch (err) {
|
|
175
|
+
} catch (err) {
|
|
178
176
|
// ignore
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -190,12 +188,13 @@ const People = WebexPlugin.extend({
|
|
|
190
188
|
*/
|
|
191
189
|
@oneFlight
|
|
192
190
|
_getMe() {
|
|
193
|
-
return this.webex
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
return this.webex
|
|
192
|
+
.request({
|
|
193
|
+
service: 'hydra',
|
|
194
|
+
resource: 'people/me',
|
|
195
|
+
})
|
|
197
196
|
.then((res) => res.body);
|
|
198
|
-
}
|
|
197
|
+
},
|
|
199
198
|
});
|
|
200
199
|
|
|
201
200
|
export default People;
|
|
@@ -15,56 +15,58 @@ describe('plugin-people', function () {
|
|
|
15
15
|
describe('People', () => {
|
|
16
16
|
let bones, mccoy, spock;
|
|
17
17
|
|
|
18
|
-
beforeEach('create users', () =>
|
|
19
|
-
.then((users) => {
|
|
18
|
+
beforeEach('create users', () =>
|
|
19
|
+
testUsers.create({count: 3}).then((users) => {
|
|
20
20
|
[spock, mccoy, bones] = users;
|
|
21
21
|
spock.webex = new WebexCore({
|
|
22
22
|
credentials: {
|
|
23
|
-
authorization: users[0].token
|
|
24
|
-
}
|
|
23
|
+
authorization: users[0].token,
|
|
24
|
+
},
|
|
25
25
|
});
|
|
26
26
|
mccoy.webex = new WebexCore({
|
|
27
27
|
credentials: {
|
|
28
|
-
authorization: users[1].token
|
|
29
|
-
}
|
|
28
|
+
authorization: users[1].token,
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
|
-
})
|
|
31
|
+
})
|
|
32
|
+
);
|
|
32
33
|
|
|
33
34
|
describe('#get()', () => {
|
|
34
|
-
it('gets a person by id', () =>
|
|
35
|
-
.then((peopleResponse) => {
|
|
35
|
+
it('gets a person by id', () =>
|
|
36
|
+
spock.webex.people.get(mccoy.id).then((peopleResponse) => {
|
|
36
37
|
assert.isPerson(peopleResponse);
|
|
37
38
|
assert.equal(peopleResponse.emails[0], mccoy.email);
|
|
38
39
|
}));
|
|
39
40
|
|
|
40
|
-
it('gets the current user with "get(\'me\')"', () =>
|
|
41
|
-
.then((peopleResponse) => {
|
|
41
|
+
it('gets the current user with "get(\'me\')"', () =>
|
|
42
|
+
spock.webex.people.get('me').then((peopleResponse) => {
|
|
42
43
|
assert.isPerson(peopleResponse);
|
|
43
44
|
assert.equal(peopleResponse.emails[0], spock.email);
|
|
44
45
|
}));
|
|
45
46
|
|
|
46
|
-
it('gets a user by hydra id', () =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
it('gets a user by hydra id', () =>
|
|
48
|
+
spock.webex.people
|
|
49
|
+
.get('me')
|
|
50
|
+
.then((person) => spock.webex.people.get(person.id))
|
|
51
|
+
.then((person) => {
|
|
52
|
+
assert.isPerson(person);
|
|
53
|
+
assert.equal(person.emails[0], spock.email);
|
|
54
|
+
}));
|
|
52
55
|
|
|
53
|
-
it('gets multiple users at a time', () =>
|
|
54
|
-
spock.webex.people.get(mccoy.id),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}));
|
|
56
|
+
it('gets multiple users at a time', () =>
|
|
57
|
+
Promise.all([spock.webex.people.get(mccoy.id), spock.webex.people.get('me')]).then(
|
|
58
|
+
(peopleResponse) => {
|
|
59
|
+
assert.isPerson(peopleResponse[0]);
|
|
60
|
+
assert.isPerson(peopleResponse[1]);
|
|
61
|
+
assert.equal(peopleResponse[0].emails[0], mccoy.email);
|
|
62
|
+
assert.equal(peopleResponse[1].emails[0], spock.email);
|
|
63
|
+
}
|
|
64
|
+
));
|
|
63
65
|
});
|
|
64
66
|
|
|
65
67
|
describe('#list()', () => {
|
|
66
|
-
it('gets a group of people by ids', () =>
|
|
67
|
-
.then((peopleResponse) => {
|
|
68
|
+
it('gets a group of people by ids', () =>
|
|
69
|
+
spock.webex.people.list([mccoy.id, spock.id, bones.id]).then((peopleResponse) => {
|
|
68
70
|
assert.equal(peopleResponse.length, 3);
|
|
69
71
|
assert.isPerson(peopleResponse[0]);
|
|
70
72
|
assert.isPerson(peopleResponse[1]);
|
|
@@ -73,18 +75,21 @@ describe('plugin-people', function () {
|
|
|
73
75
|
assert.equal(peopleResponse[1].emails[0], spock.email);
|
|
74
76
|
}));
|
|
75
77
|
|
|
76
|
-
it('defaults to false showAllTypes', () =>
|
|
77
|
-
|
|
78
|
+
it('defaults to false showAllTypes', () =>
|
|
79
|
+
spock.webex.people
|
|
80
|
+
.list([mccoy.id, spock.id, bones.id])
|
|
81
|
+
.then(assert.isFalse(spock.webex.people.batcher.config.showAllTypes)));
|
|
78
82
|
|
|
79
83
|
it('sets showAllTypes to true', () => {
|
|
80
84
|
spock.webex.people.batcher.config.showAllTypes = true;
|
|
81
85
|
|
|
82
|
-
return spock.webex.people
|
|
86
|
+
return spock.webex.people
|
|
87
|
+
.list([mccoy.id, spock.id, bones.id])
|
|
83
88
|
.then(assert.isTrue(spock.webex.people.batcher.config.showAllTypes));
|
|
84
89
|
});
|
|
85
90
|
|
|
86
|
-
it('returns a list of people matching email address', () =>
|
|
87
|
-
.then((peopleResponse) => {
|
|
91
|
+
it('returns a list of people matching email address', () =>
|
|
92
|
+
spock.webex.people.list({email: mccoy.email}).then((peopleResponse) => {
|
|
88
93
|
assert.isAbove(peopleResponse.items.length, 0);
|
|
89
94
|
const person = peopleResponse.items[0];
|
|
90
95
|
|
|
@@ -92,8 +97,8 @@ describe('plugin-people', function () {
|
|
|
92
97
|
assert.equal(person.emails[0], mccoy.email);
|
|
93
98
|
}));
|
|
94
99
|
|
|
95
|
-
it('returns a list of people matching name', () =>
|
|
96
|
-
.then((peopleResponse) => {
|
|
100
|
+
it('returns a list of people matching name', () =>
|
|
101
|
+
spock.webex.people.list({displayName: mccoy.name}).then((peopleResponse) => {
|
|
97
102
|
assert.isAbove(peopleResponse.items.length, 0);
|
|
98
103
|
let isMccoyFound = false;
|
|
99
104
|
|
|
@@ -109,40 +114,43 @@ describe('plugin-people', function () {
|
|
|
109
114
|
describe('batching of people requests', () => {
|
|
110
115
|
let batchTestUsers;
|
|
111
116
|
|
|
112
|
-
beforeEach('create more users', () =>
|
|
113
|
-
.then((users) => {
|
|
117
|
+
beforeEach('create more users', () =>
|
|
118
|
+
testUsers.create({count: 6}).then((users) => {
|
|
114
119
|
batchTestUsers = users;
|
|
115
|
-
})
|
|
120
|
+
})
|
|
121
|
+
);
|
|
116
122
|
|
|
117
123
|
it('batches uuid get requests into one', () => {
|
|
118
124
|
sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
|
|
119
125
|
|
|
120
|
-
return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user.id)))
|
|
121
|
-
|
|
126
|
+
return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user.id))).then(
|
|
127
|
+
(peopleResponse) => {
|
|
122
128
|
assert.equal(peopleResponse.length, 6);
|
|
123
129
|
assert.calledOnce(spock.webex.people.batcher.submitHttpRequest);
|
|
124
130
|
spock.webex.people.batcher.submitHttpRequest.restore();
|
|
125
|
-
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
126
133
|
});
|
|
127
134
|
|
|
128
135
|
it('batches people get requests into one', () => {
|
|
129
136
|
sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
|
|
130
137
|
|
|
131
|
-
return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user)))
|
|
132
|
-
|
|
138
|
+
return Promise.all(batchTestUsers.map((user) => spock.webex.people.get(user))).then(
|
|
139
|
+
(peopleResponse) => {
|
|
133
140
|
assert.equal(peopleResponse.length, 6);
|
|
134
141
|
peopleResponse.map((personResponse) => assert.isPerson(personResponse));
|
|
135
142
|
assert.calledOnce(spock.webex.people.batcher.submitHttpRequest);
|
|
136
143
|
spock.webex.people.batcher.submitHttpRequest.restore();
|
|
137
|
-
}
|
|
144
|
+
}
|
|
145
|
+
);
|
|
138
146
|
});
|
|
139
147
|
|
|
140
|
-
|
|
141
148
|
it('executes network requests for max limit', () => {
|
|
142
149
|
spock.webex.people.config.batcherMaxCalls = 2;
|
|
143
150
|
sinon.spy(spock.webex.people.batcher, 'submitHttpRequest');
|
|
144
151
|
|
|
145
|
-
return spock.webex.people
|
|
152
|
+
return spock.webex.people
|
|
153
|
+
.list(batchTestUsers.map((user) => user.id))
|
|
146
154
|
.then((peopleResponse) => {
|
|
147
155
|
assert.equal(peopleResponse.length, 6);
|
|
148
156
|
assert.calledThrice(spock.webex.people.batcher.submitHttpRequest);
|
|
@@ -153,8 +161,10 @@ describe('plugin-people', function () {
|
|
|
153
161
|
});
|
|
154
162
|
|
|
155
163
|
describe('#inferPersonId', () => {
|
|
156
|
-
it('infers a person id without a network dip', () =>
|
|
157
|
-
|
|
164
|
+
it('infers a person id without a network dip', () =>
|
|
165
|
+
spock.webex.people
|
|
166
|
+
.get(spock.id)
|
|
167
|
+
.then((me) => assert.equal(spock.webex.people.inferPersonIdFromUuid(spock.id), me.id)));
|
|
158
168
|
});
|
|
159
169
|
});
|
|
160
170
|
});
|
|
@@ -15,25 +15,29 @@ describe('people-batcher', () => {
|
|
|
15
15
|
beforeEach(() => {
|
|
16
16
|
webex = new MockWebex({
|
|
17
17
|
children: {
|
|
18
|
-
people: People
|
|
18
|
+
people: People,
|
|
19
19
|
},
|
|
20
20
|
config: {
|
|
21
|
-
people: {showAllTypes: false}
|
|
22
|
-
}
|
|
21
|
+
people: {showAllTypes: false},
|
|
22
|
+
},
|
|
23
23
|
});
|
|
24
24
|
batcher = webex.people.batcher;
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
describe('#fingerprints', () => {
|
|
28
|
-
it(
|
|
29
|
-
|
|
28
|
+
it("fingerprintRequest returns encrypted 'hydraId'", () =>
|
|
29
|
+
batcher
|
|
30
|
+
.fingerprintRequest('hydraId')
|
|
31
|
+
.then((result) =>
|
|
32
|
+
assert.deepEqual(result, webex.people.inferPersonIdFromUuid('hydraId'))
|
|
33
|
+
));
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
describe('#submitHttpRequest()', () => {
|
|
33
37
|
const ids = ['id1'];
|
|
34
38
|
const mockRequest = {
|
|
35
39
|
service: 'hydra',
|
|
36
|
-
resource: `people/?id=${ids}&showAllTypes=false
|
|
40
|
+
resource: `people/?id=${ids}&showAllTypes=false`,
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
it('calls webex.request with expected params', () => {
|
|
@@ -41,8 +45,7 @@ describe('people-batcher', () => {
|
|
|
41
45
|
return Promise.resolve(options);
|
|
42
46
|
};
|
|
43
47
|
|
|
44
|
-
return batcher.submitHttpRequest(ids)
|
|
45
|
-
.then((req) => assert.deepEqual(req, mockRequest));
|
|
48
|
+
return batcher.submitHttpRequest(ids).then((req) => assert.deepEqual(req, mockRequest));
|
|
46
49
|
});
|
|
47
50
|
});
|
|
48
51
|
|
|
@@ -56,15 +59,18 @@ describe('people-batcher', () => {
|
|
|
56
59
|
|
|
57
60
|
it('handles item success', () => {
|
|
58
61
|
const mockResponse = {
|
|
59
|
-
items: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
items: [
|
|
63
|
+
{
|
|
64
|
+
id: 'hydra1',
|
|
65
|
+
displayName: 'name1',
|
|
66
|
+
},
|
|
67
|
+
],
|
|
63
68
|
};
|
|
64
69
|
|
|
65
|
-
return batcher
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
return batcher
|
|
71
|
+
.handleHttpSuccess({
|
|
72
|
+
body: mockResponse,
|
|
73
|
+
})
|
|
68
74
|
.then(() => {
|
|
69
75
|
assert.calledWith(successSpy, 'hydra1', mockResponse.items[0]);
|
|
70
76
|
assert.notCalled(failureSpy);
|
|
@@ -73,19 +79,23 @@ describe('people-batcher', () => {
|
|
|
73
79
|
|
|
74
80
|
it('handles item failure', () => {
|
|
75
81
|
const mockResponse = {
|
|
76
|
-
items: [
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
items: [
|
|
83
|
+
{
|
|
84
|
+
id: 'hydra1',
|
|
85
|
+
displayName: 'name1',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'hydra2',
|
|
89
|
+
displayName: 'name2',
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
notFoundIds: ['hydra3'],
|
|
84
93
|
};
|
|
85
94
|
|
|
86
|
-
return batcher
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
return batcher
|
|
96
|
+
.handleHttpSuccess({
|
|
97
|
+
body: mockResponse,
|
|
98
|
+
})
|
|
89
99
|
.then(() => {
|
|
90
100
|
assert.calledTwice(successSpy);
|
|
91
101
|
assert.calledWith(failureSpy, 'hydra3');
|
package/test/unit/spec/people.js
CHANGED
|
@@ -13,13 +13,14 @@ describe('plugin-people', () => {
|
|
|
13
13
|
beforeEach(() => {
|
|
14
14
|
webex = new MockWebex({
|
|
15
15
|
children: {
|
|
16
|
-
people: People
|
|
17
|
-
}
|
|
16
|
+
people: People,
|
|
17
|
+
},
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
describe('#get()', () => {
|
|
22
|
-
it('requires a person parameter', () =>
|
|
22
|
+
it('requires a person parameter', () =>
|
|
23
|
+
assert.isRejected(webex.people.get(), /A person with an id is required/));
|
|
23
24
|
});
|
|
24
25
|
});
|
|
25
26
|
});
|