@webex/internal-plugin-dss 3.0.0-beta.42 → 3.0.0-beta.420

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 ADDED
@@ -0,0 +1,36 @@
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 = {
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
+ exports.default = _default;
36
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["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,eAIe;EACbA,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;AAAA"}
package/dist/constants.js CHANGED
@@ -4,7 +4,7 @@ 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;
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
8
  var DSS_REGISTERED = 'dss:registered';
9
9
  exports.DSS_REGISTERED = DSS_REGISTERED;
10
10
  var DSS_UNREGISTERED = 'dss:unregistered';
@@ -27,4 +27,14 @@ var SEARCH_TYPES = {
27
27
  ROBOT: 'ROBOT'
28
28
  };
29
29
  exports.SEARCH_TYPES = SEARCH_TYPES;
30
+ var LOOKUP_DATA_PATH = 'lookupResult.entities';
31
+ exports.LOOKUP_DATA_PATH = LOOKUP_DATA_PATH;
32
+ var LOOKUP_FOUND_PATH = 'lookupResult.entitiesFound';
33
+ exports.LOOKUP_FOUND_PATH = LOOKUP_FOUND_PATH;
34
+ var LOOKUP_NOT_FOUND_PATH = 'lookupResult.entitiesNotFound';
35
+ exports.LOOKUP_NOT_FOUND_PATH = LOOKUP_NOT_FOUND_PATH;
36
+ var LOOKUP_REQUEST_KEY = 'lookupValues';
37
+ exports.LOOKUP_REQUEST_KEY = LOOKUP_REQUEST_KEY;
38
+ var SEARCH_DATA_PATH = 'directoryEntities';
39
+ exports.SEARCH_DATA_PATH = SEARCH_DATA_PATH;
30
40
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DSS_REGISTERED","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,GAAG,gBAAgB;AAAC;AACxC,IAAMC,gBAAgB,GAAG,kBAAkB;AAAC;AAC5C,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,iBAAiB,GAAG,mBAAmB;AAAC;AAC9C,IAAMC,UAAU,GAAG,YAAY;AAAC;AAChC,IAAMC,gBAAgB,GAAG,iBAAiB;AAAC;AAC3C,IAAMC,YAAY,GAAG;EAC1BC,MAAM,EAAE,QAAQ;EAChBC,eAAe,EAAE,iBAAiB;EAClCC,gBAAgB,EAAE,kBAAkB;EACpCC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAC;AAAC"}
1
+ {"version":3,"names":["DSS_REGISTERED","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,GAAG,gBAAgB;AAAC;AACxC,IAAMC,gBAAgB,GAAG,kBAAkB;AAAC;AAC5C,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,wBAAwB,GAAG,wBAAwB;AAAC;AAC1D,IAAMC,iBAAiB,GAAG,mBAAmB;AAAC;AAC9C,IAAMC,UAAU,GAAG,YAAY;AAAC;AAChC,IAAMC,gBAAgB,GAAG,iBAAiB;AAAC;AAC3C,IAAMC,YAAY,GAAG;EAC1BC,MAAM,EAAE,QAAQ;EAChBC,eAAe,EAAE,iBAAiB;EAClCC,gBAAgB,EAAE,kBAAkB;EACpCC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE;AACT,CAAC;AAAC;AACK,IAAMC,gBAAgB,GAAG,uBAAuB;AAAC;AACjD,IAAMC,iBAAiB,GAAG,4BAA4B;AAAC;AACvD,IAAMC,qBAAqB,GAAG,+BAA+B;AAAC;AAC9D,IAAMC,kBAAkB,GAAG,cAAc;AAAC;AAC1C,IAAMC,gBAAgB,GAAG,mBAAmB;AAAC"}
@@ -0,0 +1,139 @@
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 = DssBatcher;
138
+ exports.default = _default;
139
+ //# sourceMappingURL=dss-batcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DssBatcher","Batcher","extend","namespace","props","resource","type","required","setOnce","allowNull","dataPath","entitiesFoundPath","entitiesNotFoundPath","requestKey","submitHttpRequest","payload","parent","_request","foundPath","notFoundPath","params","lookupValues","handleHttpSuccess","res","successItems","foundArray","map","requestValue","index","entity","resultArray","failureItems","notFoundArray","all","concat","item","acceptItem","didItemFail","resolve","handleItemFailure","getDeferredForResponse","then","defer","handleItemSuccess","fingerprintRequest","fingerprintResponse"],"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":";;;;;;;;;AAKA;AALA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA,IAAMA,UAAU,GAAGC,kBAAO,CAACC,MAAM,CAAC;EAChCC,SAAS,EAAE,KAAK;EAEhBC,KAAK,EAAE;IACLC,QAA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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 = /*#__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
+ exports.DssTimeoutError = DssTimeoutError;
50
+ //# sourceMappingURL=dss-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DssTimeoutError","details","timeout","requestId","resource","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;AAAwC;AAAA;AAQxC;AACA;AACA;AAFA,IAGaA,eAAe;EAAA;EAAA;EAC1B;AACF;AACA;AACA;EACE;EACA,yBAAYC,OAA8B,EAAE;IAAA;IAAA,yBACpCA,OAAO;EACf;;EAEA;AACF;AACA;AACA;AACA;AACA;EALE;IAAA;IAAA,OAMA,eAAMA,OAA8B,EAAE;MACpC,OACE,yCAAkCA,OAAO,CAACC,OAAO,qCAC/BD,OAAO,CAACE,SAAS,CAAE,0BACrBF,OAAO,CAACG,QAAQ,CAAE,wBACpB,wBAAeH,OAAO,CAACI,MAAM,CAAC,CAAE;IAElD;EAAC;EAAA;AAAA,EAvBkCC,iBAAS;AAAA"}
package/dist/dss.js CHANGED
@@ -11,6 +11,7 @@ _Object$defineProperty(exports, "__esModule", {
11
11
  value: true
12
12
  });
13
13
  exports.default = void 0;
14
+ var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
14
15
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
15
16
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
16
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
@@ -21,7 +22,10 @@ var _range2 = _interopRequireDefault(require("lodash/range"));
21
22
  var _uuid = _interopRequireDefault(require("uuid"));
22
23
  var _webexCore = require("@webex/webex-core");
23
24
  require("@webex/internal-plugin-mercury");
25
+ var _commonTimers = require("@webex/common-timers");
24
26
  var _constants = require("./constants");
27
+ var _dssBatcher = _interopRequireDefault(require("./dss-batcher"));
28
+ var _dssErrors = require("./dss-errors");
25
29
  function ownKeys(object, enumerableOnly) { var keys = _Object$keys2(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
27
31
  var DSS = _webexCore.WebexPlugin.extend({
@@ -33,6 +37,20 @@ var DSS = _webexCore.WebexPlugin.extend({
33
37
  * @memberof DSS
34
38
  */
35
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
+ },
36
54
  /**
37
55
  * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.
38
56
  * @returns {Promise}
@@ -100,6 +118,7 @@ var DSS = _webexCore.WebexPlugin.extend({
100
118
  this.webex.internal.mercury.off(_constants.DSS_SEARCH_MERCURY_EVENT);
101
119
  },
102
120
  /**
121
+ * constructs the event name based on request id
103
122
  * @param {UUID} requestId the id of the request
104
123
  * @returns {string}
105
124
  */
@@ -107,6 +126,7 @@ var DSS = _webexCore.WebexPlugin.extend({
107
126
  return "".concat(_constants.DSS_RESULT).concat(requestId);
108
127
  },
109
128
  /**
129
+ * Takes incoming data and triggers correct events
110
130
  * @param {Object} data the event data
111
131
  * @returns {undefined}
112
132
  */
@@ -118,36 +138,82 @@ var DSS = _webexCore.WebexPlugin.extend({
118
138
  * Makes the request to the directory service
119
139
  * @param {Object} options
120
140
  * @param {string} options.resource the URL to query
121
- * @param {string} options.params additional params for the body of the request
122
- * @param {string} options.dataPath to path to get the data in the result object
123
- * @returns {Promise} Resolves with an array of entities found
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
124
150
  */
125
151
  _request: function _request(options) {
126
152
  var _this4 = this;
127
153
  var resource = options.resource,
128
154
  params = options.params,
129
- dataPath = options.dataPath;
155
+ dataPath = options.dataPath,
156
+ foundPath = options.foundPath,
157
+ notFoundPath = options.notFoundPath;
158
+ var timeout = this.config.requestTimeout;
130
159
  var requestId = _uuid.default.v4();
131
160
  var eventName = this._getResultEventName(requestId);
132
161
  var result = {};
133
162
  var expectedSeqNums;
134
- return new _promise.default(function (resolve) {
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);
135
174
  _this4.listenTo(_this4, eventName, function (data) {
136
- var resultData = (0, _get2.default)(data, dataPath);
137
- result[data.sequence] = resultData;
175
+ timer.reset();
176
+ var resultData = (0, _get2.default)(data, dataPath, []);
177
+ var found;
178
+ if (foundPath) {
179
+ found = (0, _get2.default)(data, foundPath, []);
180
+ }
181
+ result[data.sequence] = foundPath ? {
182
+ resultData: resultData,
183
+ found: found
184
+ } : {
185
+ resultData: resultData
186
+ };
138
187
  if (data.finished) {
139
188
  expectedSeqNums = (0, _range2.default)(data.sequence + 1).map(String);
189
+ if (notFoundPath) {
190
+ notFoundArray = (0, _get2.default)(data, notFoundPath, []);
191
+ }
140
192
  }
141
193
  var done = (0, _isEqual2.default)(expectedSeqNums, (0, _keys.default)(result));
142
194
  if (done) {
195
+ timer.cancel();
143
196
  var resultArray = [];
197
+ var foundArray = [];
144
198
  expectedSeqNums.forEach(function (index) {
145
199
  var seqResult = result[index];
146
200
  if (seqResult) {
147
- 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
+ }
148
205
  }
149
206
  });
150
- resolve(resultArray);
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);
151
217
  _this4.stopListening(_this4, eventName);
152
218
  }
153
219
  });
@@ -160,54 +226,115 @@ var DSS = _webexCore.WebexPlugin.extend({
160
226
  requestId: requestId
161
227
  }, params)
162
228
  });
229
+ timer.start();
163
230
  });
164
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
+ },
165
257
  /**
166
258
  * Retrieves detailed information about an entity
167
259
  * @param {Object} options
168
260
  * @param {UUID} options.id the id of the entity to lookup
169
- * @returns {Promise} Resolves with an array of entities found
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
170
263
  */
171
264
  lookupDetail: function lookupDetail(options) {
172
265
  var id = options.id;
266
+ var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail");
173
267
  return this._request({
174
- dataPath: 'lookupResult.entities',
175
- resource: "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail")
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;
176
279
  });
177
280
  },
178
281
  /**
179
- * Retrieves basic information about a list entities within an organization
282
+ * Retrieves basic information about an entity within an organization
180
283
  * @param {Object} options
181
- * @param {UUID} options.ids the id of the entity to lookup
182
- * @param {UUID} options.entityProviderType the provider to query (optional)
183
- * @returns {Promise} Resolves with an array of entities found
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
184
289
  */
185
290
  lookup: function lookup(options) {
186
- var ids = options.ids,
187
- 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;
188
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
+ }
189
302
  return this._request({
190
- dataPath: 'lookupResult.entities',
303
+ dataPath: _constants.LOOKUP_DATA_PATH,
304
+ foundPath: _constants.LOOKUP_FOUND_PATH,
191
305
  resource: resource,
192
- params: {
193
- lookupValues: ids
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];
194
312
  }
313
+ return null;
195
314
  });
196
315
  },
197
316
  /**
198
- * Retrieves basic information about a list entities within an organization
317
+ * Retrieves basic information about an enitity within an organization
199
318
  * @param {Object} options
200
- * @param {UUID} options.emails the emails of the entities to lookup
201
- * @returns {Promise} Resolves with an array of entities found
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
202
322
  */
203
323
  lookupByEmail: function lookupByEmail(options) {
204
- var emails = options.emails;
324
+ var email = options.email;
325
+ var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/emails");
205
326
  return this._request({
206
- dataPath: 'lookupResult.entities',
207
- resource: "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/emails"),
208
- params: {
209
- lookupValues: emails
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];
210
336
  }
337
+ return null;
211
338
  });
212
339
  },
213
340
  /**
@@ -217,22 +344,51 @@ var DSS = _webexCore.WebexPlugin.extend({
217
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
218
345
  * @param {number} options.resultSize The maximum number of results returned from each provider
219
346
  * @returns {Promise} Resolves with an array of entities found
347
+ * @throws {DssTimeoutError} when server does not respond in the specified timeframe
220
348
  */
221
349
  search: function search(options) {
222
350
  var requestedTypes = options.requestedTypes,
223
351
  resultSize = options.resultSize,
224
352
  queryString = options.queryString;
225
353
  return this._request({
226
- dataPath: 'directoryEntities',
354
+ dataPath: _constants.SEARCH_DATA_PATH,
227
355
  resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/entities"),
228
356
  params: {
229
357
  queryString: queryString,
230
358
  resultSize: resultSize,
231
359
  requestedTypes: requestedTypes
232
360
  }
361
+ }).then(function (_ref4) {
362
+ var resultArray = _ref4.resultArray;
363
+ return resultArray;
364
+ });
365
+ },
366
+ /**
367
+ * Search for information about places
368
+ * @param {Object} options
369
+ * @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: placeName, displayName.
370
+ * @param {number} options.resultSize The maximum number of results returned from each provider
371
+ * @returns {Promise} Resolves with an array of entities found
372
+ */
373
+ searchPlaces: function searchPlaces(options) {
374
+ var _this5 = this;
375
+ var resultSize = options.resultSize,
376
+ queryString = options.queryString,
377
+ isOnlySchedulableRooms = options.isOnlySchedulableRooms;
378
+ return this._request({
379
+ dataPath: 'directoryEntities',
380
+ resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/places"),
381
+ params: {
382
+ queryString: queryString,
383
+ resultSize: resultSize,
384
+ isOnlySchedulableRooms: isOnlySchedulableRooms
385
+ }
386
+ }).catch(function (error) {
387
+ _this5.logger.error("DSS->search place#ERROR, search place failure, ".concat(error.message));
388
+ return _promise.default.reject(error);
233
389
  });
234
390
  },
235
- version: "3.0.0-beta.42"
391
+ version: "3.0.0-beta.420"
236
392
  });
237
393
  var _default = DSS;
238
394
  exports.default = _default;