@webex/internal-plugin-dss 2.59.8-next.1 → 2.60.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/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.js +14 -17
- package/dist/constants.js.map +1 -1
- package/dist/dss-batcher.js +138 -0
- package/dist/dss-batcher.js.map +1 -0
- package/dist/dss-errors.js +49 -0
- package/dist/dss-errors.js.map +1 -0
- package/dist/dss.js +186 -38
- package/dist/dss.js.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/types.js +7 -8
- package/dist/types.js.map +1 -1
- package/package.json +11 -9
- package/src/config.ts +31 -0
- package/src/constants.ts +5 -0
- package/src/dss-batcher.ts +129 -0
- package/src/dss-errors.ts +36 -0
- package/src/dss.ts +186 -32
- package/src/index.ts +2 -1
- package/src/types.ts +23 -2
- package/test/unit/spec/dss-batcher.ts +139 -0
- package/test/unit/spec/dss.ts +954 -66
package/dist/config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
/*!
|
|
9
|
+
* Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
|
|
10
|
+
*/
|
|
11
|
+
var _default = exports.default = {
|
|
12
|
+
dss: {
|
|
13
|
+
/**
|
|
14
|
+
* Timeout before DSS request fails, in milliseconds.
|
|
15
|
+
* @type {Number}
|
|
16
|
+
*/
|
|
17
|
+
requestTimeout: 6000,
|
|
18
|
+
/**
|
|
19
|
+
* Debounce wait (ms) before sending a dss request (gap between lookups that will trigger a request)
|
|
20
|
+
* @type {Number}
|
|
21
|
+
*/
|
|
22
|
+
batcherWait: 50,
|
|
23
|
+
/**
|
|
24
|
+
* Maximum queue size before sending a dss request
|
|
25
|
+
* @type {Number}
|
|
26
|
+
*/
|
|
27
|
+
batcherMaxCalls: 50,
|
|
28
|
+
/**
|
|
29
|
+
* Debounce max wait (ms) before sending a dss request (time from first lookup that will trigger a request)
|
|
30
|
+
* @type {Number}
|
|
31
|
+
*/
|
|
32
|
+
batcherMaxWait: 150
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_default","exports","default","dss","requestTimeout","batcherWait","batcherMaxCalls","batcherMaxWait"],"sources":["config.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\n\nexport default {\n dss: {\n /**\n * Timeout before DSS request fails, in milliseconds.\n * @type {Number}\n */\n requestTimeout: 6000,\n\n /**\n * Debounce wait (ms) before sending a dss request (gap between lookups that will trigger a request)\n * @type {Number}\n */\n batcherWait: 50,\n\n /**\n * Maximum queue size before sending a dss request\n * @type {Number}\n */\n batcherMaxCalls: 50,\n\n /**\n * Debounce max wait (ms) before sending a dss request (time from first lookup that will trigger a request)\n * @type {Number}\n */\n batcherMaxWait: 150,\n },\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAFA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAIe;EACbC,GAAG,EAAE;IACH;AACJ;AACA;AACA;IACIC,cAAc,EAAE,IAAI;IAEpB;AACJ;AACA;AACA;IACIC,WAAW,EAAE,EAAE;IAEf;AACJ;AACA;AACA;IACIC,eAAe,EAAE,EAAE;IAEnB;AACJ;AACA;AACA;IACIC,cAAc,EAAE;EAClB;AACF,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -4,27 +4,24 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.SEARCH_TYPES = exports.DSS_UNREGISTERED = exports.DSS_SERVICE_NAME = exports.DSS_SEARCH_MERCURY_EVENT = exports.DSS_RESULT = exports.DSS_REGISTERED = exports.DSS_LOOKUP_RESULT = exports.DSS_LOOKUP_MERCURY_EVENT = void 0;
|
|
8
|
-
var DSS_REGISTERED = 'dss:registered';
|
|
9
|
-
exports.
|
|
10
|
-
var
|
|
11
|
-
exports.
|
|
12
|
-
var
|
|
13
|
-
exports.
|
|
14
|
-
var
|
|
15
|
-
exports.
|
|
16
|
-
var DSS_LOOKUP_RESULT = 'dss:lookup.result';
|
|
17
|
-
exports.DSS_LOOKUP_RESULT = DSS_LOOKUP_RESULT;
|
|
18
|
-
var DSS_RESULT = 'dss:result';
|
|
19
|
-
exports.DSS_RESULT = DSS_RESULT;
|
|
20
|
-
var DSS_SERVICE_NAME = 'directorySearch';
|
|
21
|
-
exports.DSS_SERVICE_NAME = DSS_SERVICE_NAME;
|
|
22
|
-
var SEARCH_TYPES = {
|
|
7
|
+
exports.SEARCH_TYPES = exports.SEARCH_DATA_PATH = exports.LOOKUP_REQUEST_KEY = exports.LOOKUP_NOT_FOUND_PATH = exports.LOOKUP_FOUND_PATH = exports.LOOKUP_DATA_PATH = exports.DSS_UNREGISTERED = exports.DSS_SERVICE_NAME = exports.DSS_SEARCH_MERCURY_EVENT = exports.DSS_RESULT = exports.DSS_REGISTERED = exports.DSS_LOOKUP_RESULT = exports.DSS_LOOKUP_MERCURY_EVENT = void 0;
|
|
8
|
+
var DSS_REGISTERED = exports.DSS_REGISTERED = 'dss:registered';
|
|
9
|
+
var DSS_UNREGISTERED = exports.DSS_UNREGISTERED = 'dss:unregistered';
|
|
10
|
+
var DSS_LOOKUP_MERCURY_EVENT = exports.DSS_LOOKUP_MERCURY_EVENT = 'event:directory.lookup';
|
|
11
|
+
var DSS_SEARCH_MERCURY_EVENT = exports.DSS_SEARCH_MERCURY_EVENT = 'event:directory.search';
|
|
12
|
+
var DSS_LOOKUP_RESULT = exports.DSS_LOOKUP_RESULT = 'dss:lookup.result';
|
|
13
|
+
var DSS_RESULT = exports.DSS_RESULT = 'dss:result';
|
|
14
|
+
var DSS_SERVICE_NAME = exports.DSS_SERVICE_NAME = 'directorySearch';
|
|
15
|
+
var SEARCH_TYPES = exports.SEARCH_TYPES = {
|
|
23
16
|
PERSON: 'PERSON',
|
|
24
17
|
CALLING_SERVICE: 'CALLING_SERVICE',
|
|
25
18
|
EXTERNAL_CALLING: 'EXTERNAL_CALLING',
|
|
26
19
|
ROOM: 'ROOM',
|
|
27
20
|
ROBOT: 'ROBOT'
|
|
28
21
|
};
|
|
29
|
-
exports.
|
|
22
|
+
var LOOKUP_DATA_PATH = exports.LOOKUP_DATA_PATH = 'lookupResult.entities';
|
|
23
|
+
var LOOKUP_FOUND_PATH = exports.LOOKUP_FOUND_PATH = 'lookupResult.entitiesFound';
|
|
24
|
+
var LOOKUP_NOT_FOUND_PATH = exports.LOOKUP_NOT_FOUND_PATH = 'lookupResult.entitiesNotFound';
|
|
25
|
+
var LOOKUP_REQUEST_KEY = exports.LOOKUP_REQUEST_KEY = 'lookupValues';
|
|
26
|
+
var SEARCH_DATA_PATH = exports.SEARCH_DATA_PATH = 'directoryEntities';
|
|
30
27
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DSS_REGISTERED","exports","DSS_UNREGISTERED","DSS_LOOKUP_MERCURY_EVENT","DSS_SEARCH_MERCURY_EVENT","DSS_LOOKUP_RESULT","DSS_RESULT","DSS_SERVICE_NAME","SEARCH_TYPES","PERSON","CALLING_SERVICE","EXTERNAL_CALLING","ROOM","ROBOT"],"sources":["constants.ts"],"sourcesContent":["export const DSS_REGISTERED = 'dss:registered';\nexport const DSS_UNREGISTERED = 'dss:unregistered';\nexport const DSS_LOOKUP_MERCURY_EVENT = 'event:directory.lookup';\nexport const DSS_SEARCH_MERCURY_EVENT = 'event:directory.search';\nexport const DSS_LOOKUP_RESULT = 'dss:lookup.result';\nexport const DSS_RESULT = 'dss:result';\nexport const DSS_SERVICE_NAME = 'directorySearch';\nexport const SEARCH_TYPES = {\n PERSON: 'PERSON',\n CALLING_SERVICE: 'CALLING_SERVICE',\n EXTERNAL_CALLING: 'EXTERNAL_CALLING',\n ROOM: 'ROOM',\n ROBOT: 'ROBOT',\n};\n"],"mappings":";;;;;;;AAAO,IAAMA,cAAc,
|
|
1
|
+
{"version":3,"names":["DSS_REGISTERED","exports","DSS_UNREGISTERED","DSS_LOOKUP_MERCURY_EVENT","DSS_SEARCH_MERCURY_EVENT","DSS_LOOKUP_RESULT","DSS_RESULT","DSS_SERVICE_NAME","SEARCH_TYPES","PERSON","CALLING_SERVICE","EXTERNAL_CALLING","ROOM","ROBOT","LOOKUP_DATA_PATH","LOOKUP_FOUND_PATH","LOOKUP_NOT_FOUND_PATH","LOOKUP_REQUEST_KEY","SEARCH_DATA_PATH"],"sources":["constants.ts"],"sourcesContent":["export const DSS_REGISTERED = 'dss:registered';\nexport const DSS_UNREGISTERED = 'dss:unregistered';\nexport const DSS_LOOKUP_MERCURY_EVENT = 'event:directory.lookup';\nexport const DSS_SEARCH_MERCURY_EVENT = 'event:directory.search';\nexport const DSS_LOOKUP_RESULT = 'dss:lookup.result';\nexport const DSS_RESULT = 'dss:result';\nexport const DSS_SERVICE_NAME = 'directorySearch';\nexport const SEARCH_TYPES = {\n PERSON: 'PERSON',\n CALLING_SERVICE: 'CALLING_SERVICE',\n EXTERNAL_CALLING: 'EXTERNAL_CALLING',\n ROOM: 'ROOM',\n ROBOT: 'ROBOT',\n};\nexport const LOOKUP_DATA_PATH = 'lookupResult.entities';\nexport const LOOKUP_FOUND_PATH = 'lookupResult.entitiesFound';\nexport const LOOKUP_NOT_FOUND_PATH = 'lookupResult.entitiesNotFound';\nexport const LOOKUP_REQUEST_KEY = 'lookupValues';\nexport const SEARCH_DATA_PATH = 'directoryEntities';\n"],"mappings":";;;;;;;AAAO,IAAMA,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,gBAAgB;AACvC,IAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,kBAAkB;AAC3C,IAAMC,wBAAwB,GAAAF,OAAA,CAAAE,wBAAA,GAAG,wBAAwB;AACzD,IAAMC,wBAAwB,GAAAH,OAAA,CAAAG,wBAAA,GAAG,wBAAwB;AACzD,IAAMC,iBAAiB,GAAAJ,OAAA,CAAAI,iBAAA,GAAG,mBAAmB;AAC7C,IAAMC,UAAU,GAAAL,OAAA,CAAAK,UAAA,GAAG,YAAY;AAC/B,IAAMC,gBAAgB,GAAAN,OAAA,CAAAM,gBAAA,GAAG,iBAAiB;AAC1C,IAAMC,YAAY,GAAAP,OAAA,CAAAO,YAAA,GAAG;EAC1BC,MAAM,EAAE,QAAQ;EAChBC,eAAe,EAAE,iBAAiB;EAClCC,gBAAgB,EAAE,kBAAkB;EACpCC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAC;AACM,IAAMC,gBAAgB,GAAAb,OAAA,CAAAa,gBAAA,GAAG,uBAAuB;AAChD,IAAMC,iBAAiB,GAAAd,OAAA,CAAAc,iBAAA,GAAG,4BAA4B;AACtD,IAAMC,qBAAqB,GAAAf,OAAA,CAAAe,qBAAA,GAAG,+BAA+B;AAC7D,IAAMC,kBAAkB,GAAAhB,OAAA,CAAAgB,kBAAA,GAAG,cAAc;AACzC,IAAMC,gBAAgB,GAAAjB,OAAA,CAAAiB,gBAAA,GAAG,mBAAmB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
10
|
+
var _webexCore = require("@webex/webex-core");
|
|
11
|
+
/*!
|
|
12
|
+
* Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
|
|
13
|
+
*/
|
|
14
|
+
/* eslint-disable no-underscore-dangle */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @class
|
|
18
|
+
*/
|
|
19
|
+
var DssBatcher = _webexCore.Batcher.extend({
|
|
20
|
+
namespace: 'DSS',
|
|
21
|
+
props: {
|
|
22
|
+
resource: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
required: true,
|
|
25
|
+
setOnce: true,
|
|
26
|
+
allowNull: false
|
|
27
|
+
},
|
|
28
|
+
dataPath: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true,
|
|
31
|
+
setOnce: true,
|
|
32
|
+
allowNull: false
|
|
33
|
+
},
|
|
34
|
+
entitiesFoundPath: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: true,
|
|
37
|
+
setOnce: true,
|
|
38
|
+
allowNull: false
|
|
39
|
+
},
|
|
40
|
+
entitiesNotFoundPath: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
required: true,
|
|
43
|
+
setOnce: true,
|
|
44
|
+
allowNull: false
|
|
45
|
+
},
|
|
46
|
+
requestKey: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: true,
|
|
49
|
+
setOnce: true,
|
|
50
|
+
allowNull: false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Submits the DSS request
|
|
55
|
+
* @param {Object} payload
|
|
56
|
+
* @returns {Promise<Array>}
|
|
57
|
+
*/
|
|
58
|
+
submitHttpRequest: function submitHttpRequest(payload) {
|
|
59
|
+
return this.parent._request({
|
|
60
|
+
dataPath: this.dataPath,
|
|
61
|
+
foundPath: this.entitiesFoundPath,
|
|
62
|
+
notFoundPath: this.entitiesNotFoundPath,
|
|
63
|
+
resource: this.resource,
|
|
64
|
+
params: {
|
|
65
|
+
lookupValues: payload
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Actions taken when the http request returns a success
|
|
71
|
+
* @param {Promise<Array>} res
|
|
72
|
+
* @returns {Promise<undefined>}
|
|
73
|
+
*/
|
|
74
|
+
handleHttpSuccess: function handleHttpSuccess(res) {
|
|
75
|
+
var _this = this;
|
|
76
|
+
var successItems = res.foundArray.map(function (requestValue, index) {
|
|
77
|
+
return {
|
|
78
|
+
requestValue: requestValue,
|
|
79
|
+
entity: res.resultArray[index]
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
var failureItems = res.notFoundArray.map(function (requestValue) {
|
|
83
|
+
return {
|
|
84
|
+
requestValue: requestValue,
|
|
85
|
+
entity: null
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
return _promise.default.all(successItems.concat(failureItems).map(function (item) {
|
|
89
|
+
return _this.acceptItem(item);
|
|
90
|
+
}));
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the item was found
|
|
94
|
+
* @param {Object} item
|
|
95
|
+
* @returns {Promise<Boolean>}
|
|
96
|
+
*/
|
|
97
|
+
didItemFail: function didItemFail(item) {
|
|
98
|
+
return _promise.default.resolve(item.entity === null);
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Finds the Defer for the specified item and resolves its promise with null
|
|
102
|
+
* @param {Object} item
|
|
103
|
+
* @returns {Promise<undefined>}
|
|
104
|
+
*/
|
|
105
|
+
handleItemFailure: function handleItemFailure(item) {
|
|
106
|
+
return this.getDeferredForResponse(item).then(function (defer) {
|
|
107
|
+
defer.resolve(null);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
/**
|
|
111
|
+
* Finds the Defer for the specified item and resolves its promise
|
|
112
|
+
* @param {Object} item
|
|
113
|
+
* @returns {Promise<undefined>}
|
|
114
|
+
*/
|
|
115
|
+
handleItemSuccess: function handleItemSuccess(item) {
|
|
116
|
+
return this.getDeferredForResponse(item).then(function (defer) {
|
|
117
|
+
defer.resolve(item.entity);
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Returns a promise with the unique key for the item
|
|
122
|
+
* @param {Object} item
|
|
123
|
+
* @returns {Promise}
|
|
124
|
+
*/
|
|
125
|
+
fingerprintRequest: function fingerprintRequest(item) {
|
|
126
|
+
return _promise.default.resolve(item);
|
|
127
|
+
},
|
|
128
|
+
/**
|
|
129
|
+
* Returns a promise with the unique key for the item
|
|
130
|
+
* @param {Object} item
|
|
131
|
+
* @returns {Promise}
|
|
132
|
+
*/
|
|
133
|
+
fingerprintResponse: function fingerprintResponse(item) {
|
|
134
|
+
return _promise.default.resolve(item.requestValue);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
var _default = exports.default = DssBatcher;
|
|
138
|
+
//# sourceMappingURL=dss-batcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_webexCore","require","DssBatcher","Batcher","extend","namespace","props","resource","type","required","setOnce","allowNull","dataPath","entitiesFoundPath","entitiesNotFoundPath","requestKey","submitHttpRequest","payload","parent","_request","foundPath","notFoundPath","params","lookupValues","handleHttpSuccess","res","_this","successItems","foundArray","map","requestValue","index","entity","resultArray","failureItems","notFoundArray","_promise","default","all","concat","item","acceptItem","didItemFail","resolve","handleItemFailure","getDeferredForResponse","then","defer","handleItemSuccess","fingerprintRequest","fingerprintResponse","_default","exports"],"sources":["dss-batcher.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.\n */\n/* eslint-disable no-underscore-dangle */\n\nimport {Batcher} from '@webex/webex-core';\n\n/**\n * @class\n */\nconst DssBatcher = Batcher.extend({\n namespace: 'DSS',\n\n props: {\n resource: {\n type: 'string',\n required: true,\n setOnce: true,\n allowNull: false,\n },\n dataPath: {\n type: 'string',\n required: true,\n setOnce: true,\n allowNull: false,\n },\n entitiesFoundPath: {\n type: 'string',\n required: true,\n setOnce: true,\n allowNull: false,\n },\n entitiesNotFoundPath: {\n type: 'string',\n required: true,\n setOnce: true,\n allowNull: false,\n },\n requestKey: {\n type: 'string',\n required: true,\n setOnce: true,\n allowNull: false,\n },\n },\n\n /**\n * Submits the DSS request\n * @param {Object} payload\n * @returns {Promise<Array>}\n */\n submitHttpRequest(payload: unknown) {\n return this.parent._request({\n dataPath: this.dataPath,\n foundPath: this.entitiesFoundPath,\n notFoundPath: this.entitiesNotFoundPath,\n resource: this.resource,\n params: {\n lookupValues: payload,\n },\n });\n },\n\n /**\n * Actions taken when the http request returns a success\n * @param {Promise<Array>} res\n * @returns {Promise<undefined>}\n */\n handleHttpSuccess(res) {\n const successItems = res.foundArray.map((requestValue, index) => ({\n requestValue,\n entity: res.resultArray[index],\n }));\n const failureItems = res.notFoundArray.map((requestValue) => ({requestValue, entity: null}));\n\n return Promise.all(successItems.concat(failureItems).map((item) => this.acceptItem(item)));\n },\n\n /**\n * Checks if the item was found\n * @param {Object} item\n * @returns {Promise<Boolean>}\n */\n didItemFail(item) {\n return Promise.resolve(item.entity === null);\n },\n\n /**\n * Finds the Defer for the specified item and resolves its promise with null\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemFailure(item) {\n return this.getDeferredForResponse(item).then((defer) => {\n defer.resolve(null);\n });\n },\n\n /**\n * Finds the Defer for the specified item and resolves its promise\n * @param {Object} item\n * @returns {Promise<undefined>}\n */\n handleItemSuccess(item) {\n return this.getDeferredForResponse(item).then((defer) => {\n defer.resolve(item.entity);\n });\n },\n\n /**\n * Returns a promise with the unique key for the item\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintRequest(item) {\n return Promise.resolve(item);\n },\n\n /**\n * Returns a promise with the unique key for the item\n * @param {Object} item\n * @returns {Promise}\n */\n fingerprintResponse(item) {\n return Promise.resolve(item.requestValue);\n },\n});\n\nexport default DssBatcher;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Reflect$construct = require("@babel/runtime-corejs2/core-js/reflect/construct");
|
|
4
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
6
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.DssTimeoutError = void 0;
|
|
10
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/createClass"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/inherits"));
|
|
14
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/possibleConstructorReturn"));
|
|
15
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/getPrototypeOf"));
|
|
16
|
+
var _common = require("@webex/common");
|
|
17
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
/**
|
|
20
|
+
* Thrown when an expected DSS respond is not received in a timely manner.
|
|
21
|
+
*/
|
|
22
|
+
var DssTimeoutError = exports.DssTimeoutError = /*#__PURE__*/function (_Exception) {
|
|
23
|
+
(0, _inherits2.default)(DssTimeoutError, _Exception);
|
|
24
|
+
var _super = _createSuper(DssTimeoutError);
|
|
25
|
+
/**
|
|
26
|
+
* Construct DssTimeoutError
|
|
27
|
+
* @param {DssTimeoutErrorParams} details
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line no-useless-constructor
|
|
30
|
+
function DssTimeoutError(details) {
|
|
31
|
+
(0, _classCallCheck2.default)(this, DssTimeoutError);
|
|
32
|
+
return _super.call(this, details);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Parse Error details
|
|
37
|
+
*
|
|
38
|
+
* @param {DssTimeoutErrorParams} details
|
|
39
|
+
* @returns {string}
|
|
40
|
+
*/
|
|
41
|
+
(0, _createClass2.default)(DssTimeoutError, [{
|
|
42
|
+
key: "parse",
|
|
43
|
+
value: function parse(details) {
|
|
44
|
+
return "The DSS did not respond within ".concat(details.timeout, " ms.") + "\n Request Id: ".concat(details.requestId) + "\n Resource: ".concat(details.resource) + "\n Params: ".concat((0, _stringify.default)(details.params));
|
|
45
|
+
}
|
|
46
|
+
}]);
|
|
47
|
+
return DssTimeoutError;
|
|
48
|
+
}(_common.Exception);
|
|
49
|
+
//# sourceMappingURL=dss-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_common","require","_createSuper","Derived","hasNativeReflectConstruct","_isNativeReflectConstruct","_createSuperInternal","Super","_getPrototypeOf2","default","result","NewTarget","constructor","_Reflect$construct","arguments","apply","_possibleConstructorReturn2","Reflect","sham","Proxy","Boolean","prototype","valueOf","call","e","DssTimeoutError","exports","_Exception","_inherits2","_super","details","_classCallCheck2","_createClass2","key","value","parse","concat","timeout","requestId","resource","_stringify","params","Exception"],"sources":["dss-errors.ts"],"sourcesContent":["import {Exception} from '@webex/common';\nimport {RequestOptions} from './types';\n\ninterface DssTimeoutErrorParams extends Required<Pick<RequestOptions, 'resource' | 'params'>> {\n requestId: string;\n timeout: number;\n}\n\n/**\n * Thrown when an expected DSS respond is not received in a timely manner.\n */\nexport class DssTimeoutError extends Exception {\n /**\n * Construct DssTimeoutError\n * @param {DssTimeoutErrorParams} details\n */\n // eslint-disable-next-line no-useless-constructor\n constructor(details: DssTimeoutErrorParams) {\n super(details);\n }\n\n /**\n * Parse Error details\n *\n * @param {DssTimeoutErrorParams} details\n * @returns {string}\n */\n parse(details: DssTimeoutErrorParams) {\n return (\n `The DSS did not respond within ${details.timeout} ms.` +\n `\\n Request Id: ${details.requestId}` +\n `\\n Resource: ${details.resource}` +\n `\\n Params: ${JSON.stringify(details.params)}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAwC,SAAAC,aAAAC,OAAA,QAAAC,yBAAA,GAAAC,yBAAA,oBAAAC,qBAAA,QAAAC,KAAA,OAAAC,gBAAA,CAAAC,OAAA,EAAAN,OAAA,GAAAO,MAAA,MAAAN,yBAAA,QAAAO,SAAA,OAAAH,gBAAA,CAAAC,OAAA,QAAAG,WAAA,EAAAF,MAAA,GAAAG,kBAAA,CAAAN,KAAA,EAAAO,SAAA,EAAAH,SAAA,YAAAD,MAAA,GAAAH,KAAA,CAAAQ,KAAA,OAAAD,SAAA,gBAAAE,2BAAA,CAAAP,OAAA,QAAAC,MAAA;AAAA,SAAAL,0BAAA,eAAAY,OAAA,qBAAAJ,kBAAA,oBAAAA,kBAAA,CAAAK,IAAA,2BAAAC,KAAA,oCAAAC,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAV,kBAAA,CAAAO,OAAA,8CAAAI,CAAA;AAQxC;AACA;AACA;AAFA,IAGaC,eAAe,GAAAC,OAAA,CAAAD,eAAA,0BAAAE,UAAA;EAAA,IAAAC,UAAA,CAAAnB,OAAA,EAAAgB,eAAA,EAAAE,UAAA;EAAA,IAAAE,MAAA,GAAA3B,YAAA,CAAAuB,eAAA;EAC1B;AACF;AACA;AACA;EACE;EACA,SAAAA,gBAAYK,OAA8B,EAAE;IAAA,IAAAC,gBAAA,CAAAtB,OAAA,QAAAgB,eAAA;IAAA,OAAAI,MAAA,CAAAN,IAAA,OACpCO,OAAO;EACf;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE,IAAAE,aAAA,CAAAvB,OAAA,EAAAgB,eAAA;IAAAQ,GAAA;IAAAC,KAAA,EAMA,SAAAC,MAAML,OAA8B,EAAE;MACpC,OACE,kCAAAM,MAAA,CAAkCN,OAAO,CAACO,OAAO,8BAAAD,MAAA,CAC/BN,OAAO,CAACQ,SAAS,CAAE,mBAAAF,MAAA,CACrBN,OAAO,CAACS,QAAQ,CAAE,iBAAAH,MAAA,CACpB,IAAAI,UAAA,CAAA/B,OAAA,EAAeqB,OAAO,CAACW,MAAM,CAAC,CAAE;IAElD;EAAC;EAAA,OAAAhB,eAAA;AAAA,EAvBkCiB,iBAAS"}
|
package/dist/dss.js
CHANGED
|
@@ -13,16 +13,22 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
13
13
|
exports.default = void 0;
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
15
15
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
|
|
16
|
+
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
16
17
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
17
18
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
|
|
18
19
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
19
20
|
var _webexCore = require("@webex/webex-core");
|
|
20
21
|
require("@webex/internal-plugin-mercury");
|
|
21
22
|
var _lodash = require("lodash");
|
|
23
|
+
var _commonTimers = require("@webex/common-timers");
|
|
22
24
|
var _constants = require("./constants");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
25
|
+
var _dssBatcher = _interopRequireDefault(require("./dss-batcher"));
|
|
26
|
+
var _dssErrors = require("./dss-errors");
|
|
27
|
+
function ownKeys(e, r) { var t = _Object$keys2(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable no-underscore-dangle */ /*!
|
|
29
|
+
* Copyright (c) 2015-2022 Cisco Systems, Inc. See LICENSE file.
|
|
30
|
+
*/ /* eslint-disable no-underscore-dangle */
|
|
31
|
+
var DSS = _webexCore.WebexPlugin.extend((0, _defineProperty2.default)((0, _defineProperty2.default)({
|
|
26
32
|
namespace: 'DSS',
|
|
27
33
|
/**
|
|
28
34
|
* registered value indicating events registration is successful
|
|
@@ -31,6 +37,20 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
31
37
|
* @memberof DSS
|
|
32
38
|
*/
|
|
33
39
|
registered: false,
|
|
40
|
+
/**
|
|
41
|
+
* Initializer
|
|
42
|
+
* @private
|
|
43
|
+
* @param {Object} attrs
|
|
44
|
+
* @param {Object} options
|
|
45
|
+
* @returns {undefined}
|
|
46
|
+
*/
|
|
47
|
+
initialize: function initialize() {
|
|
48
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
+
args[_key] = arguments[_key];
|
|
50
|
+
}
|
|
51
|
+
(0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
|
|
52
|
+
this.batchers = {};
|
|
53
|
+
},
|
|
34
54
|
/**
|
|
35
55
|
* Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.
|
|
36
56
|
* @returns {Promise}
|
|
@@ -98,6 +118,7 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
98
118
|
this.webex.internal.mercury.off(_constants.DSS_SEARCH_MERCURY_EVENT);
|
|
99
119
|
},
|
|
100
120
|
/**
|
|
121
|
+
* constructs the event name based on request id
|
|
101
122
|
* @param {UUID} requestId the id of the request
|
|
102
123
|
* @returns {string}
|
|
103
124
|
*/
|
|
@@ -105,6 +126,7 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
105
126
|
return "".concat(_constants.DSS_RESULT).concat(requestId);
|
|
106
127
|
},
|
|
107
128
|
/**
|
|
129
|
+
* Takes incoming data and triggers correct events
|
|
108
130
|
* @param {Object} data the event data
|
|
109
131
|
* @returns {undefined}
|
|
110
132
|
*/
|
|
@@ -116,36 +138,82 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
116
138
|
* Makes the request to the directory service
|
|
117
139
|
* @param {Object} options
|
|
118
140
|
* @param {string} options.resource the URL to query
|
|
119
|
-
* @param {
|
|
120
|
-
* @param {string} options.dataPath
|
|
121
|
-
* @
|
|
141
|
+
* @param {Mixed} options.params additional params for the body of the request
|
|
142
|
+
* @param {string} options.dataPath the path to get the data in the result object
|
|
143
|
+
* @param {string} [options.foundPath] the path to get the lookups of the found data
|
|
144
|
+
* @param {string} [options.notFoundPath] the path to get the lookups of the not found data
|
|
145
|
+
* @returns {Promise<Object>} result Resolves with an object
|
|
146
|
+
* @returns {Array} result.resultArray an array of entities found
|
|
147
|
+
* @returns {Array} result.foundArray an array of the lookups of the found entities (if foundPath provided)
|
|
148
|
+
* @returns {Array} result.notFoundArray an array of the lookups of the not found entities (if notFoundPath provided)
|
|
149
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
122
150
|
*/
|
|
123
151
|
_request: function _request(options) {
|
|
124
152
|
var _this4 = this;
|
|
125
153
|
var resource = options.resource,
|
|
126
154
|
params = options.params,
|
|
127
|
-
dataPath = options.dataPath
|
|
155
|
+
dataPath = options.dataPath,
|
|
156
|
+
foundPath = options.foundPath,
|
|
157
|
+
notFoundPath = options.notFoundPath;
|
|
158
|
+
var timeout = this.config.requestTimeout;
|
|
128
159
|
var requestId = _uuid.default.v4();
|
|
129
160
|
var eventName = this._getResultEventName(requestId);
|
|
130
161
|
var result = {};
|
|
131
162
|
var expectedSeqNums;
|
|
132
|
-
|
|
163
|
+
var notFoundArray;
|
|
164
|
+
return new _promise.default(function (resolve, reject) {
|
|
165
|
+
var timer = new _commonTimers.Timer(function () {
|
|
166
|
+
_this4.stopListening(_this4, eventName);
|
|
167
|
+
reject(new _dssErrors.DssTimeoutError({
|
|
168
|
+
requestId: requestId,
|
|
169
|
+
timeout: timeout,
|
|
170
|
+
resource: resource,
|
|
171
|
+
params: params
|
|
172
|
+
}));
|
|
173
|
+
}, timeout);
|
|
133
174
|
_this4.listenTo(_this4, eventName, function (data) {
|
|
134
|
-
|
|
135
|
-
|
|
175
|
+
timer.reset();
|
|
176
|
+
var resultData = (0, _lodash.get)(data, dataPath, []);
|
|
177
|
+
var found;
|
|
178
|
+
if (foundPath) {
|
|
179
|
+
found = (0, _lodash.get)(data, foundPath, []);
|
|
180
|
+
}
|
|
181
|
+
result[data.sequence] = foundPath ? {
|
|
182
|
+
resultData: resultData,
|
|
183
|
+
found: found
|
|
184
|
+
} : {
|
|
185
|
+
resultData: resultData
|
|
186
|
+
};
|
|
136
187
|
if (data.finished) {
|
|
137
188
|
expectedSeqNums = (0, _lodash.range)(data.sequence + 1).map(String);
|
|
189
|
+
if (notFoundPath) {
|
|
190
|
+
notFoundArray = (0, _lodash.get)(data, notFoundPath, []);
|
|
191
|
+
}
|
|
138
192
|
}
|
|
139
193
|
var done = (0, _lodash.isEqual)(expectedSeqNums, (0, _keys.default)(result));
|
|
140
194
|
if (done) {
|
|
195
|
+
timer.cancel();
|
|
141
196
|
var resultArray = [];
|
|
197
|
+
var foundArray = [];
|
|
142
198
|
expectedSeqNums.forEach(function (index) {
|
|
143
199
|
var seqResult = result[index];
|
|
144
200
|
if (seqResult) {
|
|
145
|
-
resultArray.push.apply(resultArray, (0, _toConsumableArray2.default)(seqResult));
|
|
201
|
+
resultArray.push.apply(resultArray, (0, _toConsumableArray2.default)(seqResult.resultData));
|
|
202
|
+
if (foundPath) {
|
|
203
|
+
foundArray.push.apply(foundArray, (0, _toConsumableArray2.default)(seqResult.found));
|
|
204
|
+
}
|
|
146
205
|
}
|
|
147
206
|
});
|
|
148
|
-
|
|
207
|
+
var resolveValue = {
|
|
208
|
+
resultArray: resultArray
|
|
209
|
+
};
|
|
210
|
+
if (foundPath) {
|
|
211
|
+
resolveValue.foundArray = foundArray;
|
|
212
|
+
}
|
|
213
|
+
if (notFoundPath) {
|
|
214
|
+
resolveValue.notFoundArray = notFoundArray;
|
|
215
|
+
}
|
|
216
|
+
resolve(resolveValue);
|
|
149
217
|
_this4.stopListening(_this4, eventName);
|
|
150
218
|
}
|
|
151
219
|
});
|
|
@@ -158,54 +226,115 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
158
226
|
requestId: requestId
|
|
159
227
|
}, params)
|
|
160
228
|
});
|
|
229
|
+
timer.start();
|
|
161
230
|
});
|
|
162
231
|
},
|
|
232
|
+
/**
|
|
233
|
+
* Uses a batcher to make the request to the directory service
|
|
234
|
+
* @param {Object} options
|
|
235
|
+
* @param {string} options.resource the URL to query
|
|
236
|
+
* @param {string} options.value the id or email to lookup
|
|
237
|
+
* @returns {Promise} Resolves with an array of entities found
|
|
238
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
239
|
+
*/
|
|
240
|
+
_batchedLookup: function _batchedLookup(options) {
|
|
241
|
+
var resource = options.resource,
|
|
242
|
+
lookupValue = options.lookupValue;
|
|
243
|
+
var dataPath = _constants.LOOKUP_DATA_PATH;
|
|
244
|
+
var entitiesFoundPath = _constants.LOOKUP_FOUND_PATH;
|
|
245
|
+
var entitiesNotFoundPath = _constants.LOOKUP_NOT_FOUND_PATH;
|
|
246
|
+
var requestKey = _constants.LOOKUP_REQUEST_KEY;
|
|
247
|
+
this.batchers[resource] = this.batchers[resource] || new _dssBatcher.default({
|
|
248
|
+
resource: resource,
|
|
249
|
+
dataPath: dataPath,
|
|
250
|
+
entitiesFoundPath: entitiesFoundPath,
|
|
251
|
+
entitiesNotFoundPath: entitiesNotFoundPath,
|
|
252
|
+
requestKey: requestKey,
|
|
253
|
+
parent: this
|
|
254
|
+
});
|
|
255
|
+
return this.batchers[resource].request(lookupValue);
|
|
256
|
+
},
|
|
163
257
|
/**
|
|
164
258
|
* Retrieves detailed information about an entity
|
|
165
259
|
* @param {Object} options
|
|
166
260
|
* @param {UUID} options.id the id of the entity to lookup
|
|
167
|
-
* @returns {Promise} Resolves with
|
|
261
|
+
* @returns {Promise} Resolves with the entity found or null if not found
|
|
262
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
168
263
|
*/
|
|
169
264
|
lookupDetail: function lookupDetail(options) {
|
|
170
265
|
var id = options.id;
|
|
266
|
+
var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail");
|
|
171
267
|
return this._request({
|
|
172
|
-
dataPath:
|
|
173
|
-
|
|
268
|
+
dataPath: _constants.LOOKUP_DATA_PATH,
|
|
269
|
+
foundPath: _constants.LOOKUP_FOUND_PATH,
|
|
270
|
+
resource: resource
|
|
271
|
+
}).then(function (_ref) {
|
|
272
|
+
var resultArray = _ref.resultArray,
|
|
273
|
+
foundArray = _ref.foundArray;
|
|
274
|
+
// TODO: find out what is actually returned!
|
|
275
|
+
if (foundArray[0] === id) {
|
|
276
|
+
return resultArray[0];
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
174
279
|
});
|
|
175
280
|
},
|
|
176
281
|
/**
|
|
177
|
-
* Retrieves basic information about
|
|
282
|
+
* Retrieves basic information about an entity within an organization
|
|
178
283
|
* @param {Object} options
|
|
179
|
-
* @param {UUID} options.
|
|
180
|
-
* @param {UUID} options.entityProviderType the provider to query
|
|
181
|
-
* @
|
|
284
|
+
* @param {UUID} options.id the id of the entity to lookup
|
|
285
|
+
* @param {UUID} [options.entityProviderType] the provider to query
|
|
286
|
+
* @param {Boolean} options.shouldBatch whether to batch the query, set to false for single immediate result (defaults to true)
|
|
287
|
+
* @returns {Promise} Resolves with the entity found or null if not found
|
|
288
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
182
289
|
*/
|
|
183
290
|
lookup: function lookup(options) {
|
|
184
|
-
var
|
|
185
|
-
entityProviderType = options.entityProviderType
|
|
291
|
+
var id = options.id,
|
|
292
|
+
entityProviderType = options.entityProviderType,
|
|
293
|
+
_options$shouldBatch = options.shouldBatch,
|
|
294
|
+
shouldBatch = _options$shouldBatch === void 0 ? true : _options$shouldBatch;
|
|
186
295
|
var resource = entityProviderType ? "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/entityprovidertype/").concat(entityProviderType) : "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identities");
|
|
296
|
+
if (shouldBatch) {
|
|
297
|
+
return this._batchedLookup({
|
|
298
|
+
resource: resource,
|
|
299
|
+
lookupValue: id
|
|
300
|
+
});
|
|
301
|
+
}
|
|
187
302
|
return this._request({
|
|
188
|
-
dataPath:
|
|
303
|
+
dataPath: _constants.LOOKUP_DATA_PATH,
|
|
304
|
+
foundPath: _constants.LOOKUP_FOUND_PATH,
|
|
189
305
|
resource: resource,
|
|
190
|
-
params: {
|
|
191
|
-
|
|
306
|
+
params: (0, _defineProperty2.default)({}, _constants.LOOKUP_REQUEST_KEY, [id])
|
|
307
|
+
}).then(function (_ref2) {
|
|
308
|
+
var resultArray = _ref2.resultArray,
|
|
309
|
+
foundArray = _ref2.foundArray;
|
|
310
|
+
if (foundArray[0] === id) {
|
|
311
|
+
return resultArray[0];
|
|
192
312
|
}
|
|
313
|
+
return null;
|
|
193
314
|
});
|
|
194
315
|
},
|
|
195
316
|
/**
|
|
196
|
-
* Retrieves basic information about
|
|
317
|
+
* Retrieves basic information about an enitity within an organization
|
|
197
318
|
* @param {Object} options
|
|
198
|
-
* @param {UUID} options.
|
|
199
|
-
* @returns {Promise} Resolves with
|
|
319
|
+
* @param {UUID} options.email the email of the entity to lookup
|
|
320
|
+
* @returns {Promise} Resolves with the entity found or rejects if not found
|
|
321
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
200
322
|
*/
|
|
201
323
|
lookupByEmail: function lookupByEmail(options) {
|
|
202
|
-
var
|
|
324
|
+
var email = options.email;
|
|
325
|
+
var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/emails");
|
|
203
326
|
return this._request({
|
|
204
|
-
dataPath:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
327
|
+
dataPath: _constants.LOOKUP_DATA_PATH,
|
|
328
|
+
foundPath: _constants.LOOKUP_FOUND_PATH,
|
|
329
|
+
resource: resource,
|
|
330
|
+
params: (0, _defineProperty2.default)({}, _constants.LOOKUP_REQUEST_KEY, [email])
|
|
331
|
+
}).then(function (_ref3) {
|
|
332
|
+
var resultArray = _ref3.resultArray,
|
|
333
|
+
foundArray = _ref3.foundArray;
|
|
334
|
+
if (foundArray[0] === email) {
|
|
335
|
+
return resultArray[0];
|
|
208
336
|
}
|
|
337
|
+
return null;
|
|
209
338
|
});
|
|
210
339
|
},
|
|
211
340
|
/**
|
|
@@ -215,19 +344,23 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
215
344
|
* @param {string[]} options.queryString A query string that will be transformed into a Directory search filter query. It is used to search the following fields: username, givenName, familyName, displayName and email
|
|
216
345
|
* @param {number} options.resultSize The maximum number of results returned from each provider
|
|
217
346
|
* @returns {Promise} Resolves with an array of entities found
|
|
347
|
+
* @throws {DssTimeoutError} when server does not respond in the specified timeframe
|
|
218
348
|
*/
|
|
219
349
|
search: function search(options) {
|
|
220
350
|
var requestedTypes = options.requestedTypes,
|
|
221
351
|
resultSize = options.resultSize,
|
|
222
352
|
queryString = options.queryString;
|
|
223
353
|
return this._request({
|
|
224
|
-
dataPath:
|
|
354
|
+
dataPath: _constants.SEARCH_DATA_PATH,
|
|
225
355
|
resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/entities"),
|
|
226
356
|
params: {
|
|
227
357
|
queryString: queryString,
|
|
228
358
|
resultSize: resultSize,
|
|
229
359
|
requestedTypes: requestedTypes
|
|
230
360
|
}
|
|
361
|
+
}).then(function (_ref4) {
|
|
362
|
+
var resultArray = _ref4.resultArray;
|
|
363
|
+
return resultArray;
|
|
231
364
|
});
|
|
232
365
|
},
|
|
233
366
|
/**
|
|
@@ -254,9 +387,24 @@ var DSS = _webexCore.WebexPlugin.extend({
|
|
|
254
387
|
_this5.logger.error("DSS->search place#ERROR, search place failure, ".concat(error.message));
|
|
255
388
|
return _promise.default.reject(error);
|
|
256
389
|
});
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
var
|
|
261
|
-
|
|
390
|
+
}
|
|
391
|
+
}, "searchPlaces", function searchPlaces(options) {
|
|
392
|
+
var _this6 = this;
|
|
393
|
+
var resultSize = options.resultSize,
|
|
394
|
+
queryString = options.queryString,
|
|
395
|
+
isOnlySchedulableRooms = options.isOnlySchedulableRooms;
|
|
396
|
+
return this._request({
|
|
397
|
+
dataPath: 'directoryEntities',
|
|
398
|
+
resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/places"),
|
|
399
|
+
params: {
|
|
400
|
+
queryString: queryString,
|
|
401
|
+
resultSize: resultSize,
|
|
402
|
+
isOnlySchedulableRooms: isOnlySchedulableRooms
|
|
403
|
+
}
|
|
404
|
+
}).catch(function (error) {
|
|
405
|
+
_this6.logger.error("DSS->search place#ERROR, search place failure, ".concat(error.message));
|
|
406
|
+
return _promise.default.reject(error);
|
|
407
|
+
});
|
|
408
|
+
}), "version", "2.60.0-next.1"));
|
|
409
|
+
var _default = exports.default = DSS;
|
|
262
410
|
//# sourceMappingURL=dss.js.map
|