@webex/internal-plugin-dss 3.0.0-beta.15 → 3.0.0-beta.151

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,31 @@
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
+ * Debounce wait (ms) before sending a dss request (gap between lookups that will trigger a request)
15
+ * @type {Number}
16
+ */
17
+ batcherWait: 50,
18
+ /**
19
+ * Maximum queue size before sending a dss request
20
+ * @type {Number}
21
+ */
22
+ batcherMaxCalls: 50,
23
+ /**
24
+ * Debounce max wait (ms) before sending a dss request (time from first lookup that will trigger a request)
25
+ * @type {Number}
26
+ */
27
+ batcherMaxWait: 150
28
+ }
29
+ };
30
+ exports.default = _default;
31
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["dss","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 * 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,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
@@ -1,12 +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
- 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;
10
8
  var DSS_REGISTERED = 'dss:registered';
11
9
  exports.DSS_REGISTERED = DSS_REGISTERED;
12
10
  var DSS_UNREGISTERED = 'dss:unregistered';
@@ -29,4 +27,14 @@ var SEARCH_TYPES = {
29
27
  ROBOT: 'ROBOT'
30
28
  };
31
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;
32
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,gBAAvB;;AACA,IAAMC,gBAAgB,GAAG,kBAAzB;;AACA,IAAMC,wBAAwB,GAAG,wBAAjC;;AACA,IAAMC,wBAAwB,GAAG,wBAAjC;;AACA,IAAMC,iBAAiB,GAAG,mBAA1B;;AACA,IAAMC,UAAU,GAAG,YAAnB;;AACA,IAAMC,gBAAgB,GAAG,iBAAzB;;AACA,IAAMC,YAAY,GAAG;EAC1BC,MAAM,EAAE,QADkB;EAE1BC,eAAe,EAAE,iBAFS;EAG1BC,gBAAgB,EAAE,kBAHQ;EAI1BC,IAAI,EAAE,MAJoB;EAK1BC,KAAK,EAAE;AALmB,CAArB"}
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) {\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,QAAQ,EAAE;MACRC,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,SAAS,EAAE;IACb,CAAC;IACDC,QAAQ,EAAE;MACRJ,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,SAAS,EAAE;IACb,CAAC;IACDE,iBAAiB,EAAE;MACjBL,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,SAAS,EAAE;IACb,CAAC;IACDG,oBAAoB,EAAE;MACpBN,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,SAAS,EAAE;IACb,CAAC;IACDI,UAAU,EAAE;MACVP,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAE,IAAI;MACdC,OAAO,EAAE,IAAI;MACbC,SAAS,EAAE;IACb;EACF,CAAC;EAED;AACF;AACA;AACA;AACA;EACEK,iBAAiB,6BAACC,OAAO,EAAE;IACzB,OAAO,IAAI,CAACC,MAAM,CAACC,QAAQ,CAAC;MAC1BP,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBQ,SAAS,EAAE,IAAI,CAACP,iBAAiB;MACjCQ,YAAY,EAAE,IAAI,CAACP,oBAAoB;MACvCP,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBe,MAAM,EAAE;QACNC,YAAY,EAAEN;MAChB;IACF,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;EACEO,iBAAiB,6BAACC,GAAG,EAAE;IAAA;IACrB,IAAMC,YAAY,GAAGD,GAAG,CAACE,UAAU,CAACC,GAAG,CAAC,UAACC,YAAY,EAAEC,KAAK;MAAA,OAAM;QAChED,YAAY,EAAZA,YAAY;QACZE,MAAM,EAAEN,GAAG,CAACO,WAAW,CAACF,KAAK;MAC/B,CAAC;IAAA,CAAC,CAAC;IACH,IAAMG,YAAY,GAAGR,GAAG,CAACS,aAAa,CAACN,GAAG,CAAC,UAACC,YAAY;MAAA,OAAM;QAACA,YAAY,EAAZA,YAAY;QAAEE,MAAM,EAAE;MAAI,CAAC;IAAA,CAAC,CAAC;IAE5F,OAAO,iBAAQI,GAAG,CAACT,YAAY,CAACU,MAAM,CAACH,YAAY,CAAC,CAACL,GAAG,CAAC,UAACS,IAAI;MAAA,OAAK,KAAI,CAACC,UAAU,CAACD,IAAI,CAAC;IAAA,EAAC,CAAC;EAC5F,CAAC;EAED;AACF;AACA;AACA;AACA;EACEE,WAAW,uBAACF,IAAI,EAAE;IAChB,OAAO,iBAAQG,OAAO,CAACH,IAAI,CAACN,MAAM,KAAK,IAAI,CAAC;EAC9C,CAAC;EAED;AACF;AACA;AACA;AACA;EACEU,iBAAiB,6BAACJ,IAAI,EAAE;IACtB,OAAO,IAAI,CAACK,sBAAsB,CAACL,IAAI,CAAC,CAACM,IAAI,CAAC,UAACC,KAAK,EAAK;MACvDA,KAAK,CAACJ,OAAO,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;EACEK,iBAAiB,6BAACR,IAAI,EAAE;IACtB,OAAO,IAAI,CAACK,sBAAsB,CAACL,IAAI,CAAC,CAACM,IAAI,CAAC,UAACC,KAAK,EAAK;MACvDA,KAAK,CAACJ,OAAO,CAACH,IAAI,CAACN,MAAM,CAAC;IAC5B,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;AACA;AACA;EACEe,kBAAkB,8BAACT,IAAI,EAAE;IACvB,OAAO,iBAAQG,OAAO,CAACH,IAAI,CAAC;EAC9B,CAAC;EAED;AACF;AACA;AACA;AACA;EACEU,mBAAmB,+BAACV,IAAI,EAAE;IACxB,OAAO,iBAAQG,OAAO,CAACH,IAAI,CAACR,YAAY,CAAC;EAC3C;AACF,CAAC,CAAC;AAAC,eAEY3B,UAAU;AAAA"}
package/dist/dss.js CHANGED
@@ -1,54 +1,33 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$keys2 = require("@babel/runtime-corejs2/core-js/object/keys");
4
-
5
4
  var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs2/core-js/object/get-own-property-symbols");
6
-
7
5
  var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptor");
8
-
9
6
  var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs2/core-js/object/get-own-property-descriptors");
10
-
11
7
  var _Object$defineProperties = require("@babel/runtime-corejs2/core-js/object/define-properties");
12
-
13
8
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
14
-
15
9
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
16
-
17
10
  _Object$defineProperty(exports, "__esModule", {
18
11
  value: true
19
12
  });
20
-
21
13
  exports.default = void 0;
22
-
14
+ var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
23
15
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
24
-
25
16
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/keys"));
26
-
27
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
28
-
29
18
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/toConsumableArray"));
30
-
31
19
  var _get2 = _interopRequireDefault(require("lodash/get"));
32
-
33
20
  var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
34
-
35
21
  var _range2 = _interopRequireDefault(require("lodash/range"));
36
-
37
22
  var _uuid = _interopRequireDefault(require("uuid"));
38
-
39
23
  var _webexCore = require("@webex/webex-core");
40
-
41
24
  require("@webex/internal-plugin-mercury");
42
-
43
25
  var _constants = require("./constants");
44
-
26
+ var _dssBatcher = _interopRequireDefault(require("./dss-batcher"));
45
27
  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; }
46
-
47
28
  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; }
48
-
49
29
  var DSS = _webexCore.WebexPlugin.extend({
50
30
  namespace: 'DSS',
51
-
52
31
  /**
53
32
  * registered value indicating events registration is successful
54
33
  * @instance
@@ -56,7 +35,20 @@ var DSS = _webexCore.WebexPlugin.extend({
56
35
  * @memberof DSS
57
36
  */
58
37
  registered: false,
59
-
38
+ /**
39
+ * Initializer
40
+ * @private
41
+ * @param {Object} attrs
42
+ * @param {Object} options
43
+ * @returns {undefined}
44
+ */
45
+ initialize: function initialize() {
46
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
47
+ args[_key] = arguments[_key];
48
+ }
49
+ (0, _apply.default)(_webexCore.WebexPlugin.prototype.initialize, this, args);
50
+ this.batchers = {};
51
+ },
60
52
  /**
61
53
  * Explicitly sets up the DSS plugin by connecting to mercury, and listening for DSS events.
62
54
  * @returns {Promise}
@@ -65,30 +57,23 @@ var DSS = _webexCore.WebexPlugin.extend({
65
57
  */
66
58
  register: function register() {
67
59
  var _this = this;
68
-
69
60
  if (!this.webex.canAuthorize) {
70
61
  this.logger.error('DSS->register#ERROR, Unable to register, SDK cannot authorize');
71
62
  return _promise.default.reject(new Error('SDK cannot authorize'));
72
63
  }
73
-
74
64
  if (this.registered) {
75
65
  this.logger.info('dss->register#INFO, DSS plugin already registered');
76
66
  return _promise.default.resolve();
77
67
  }
78
-
79
68
  return this.webex.internal.mercury.connect().then(function () {
80
69
  _this.listenForEvents();
81
-
82
70
  _this.trigger(_constants.DSS_REGISTERED);
83
-
84
71
  _this.registered = true;
85
72
  }).catch(function (error) {
86
73
  _this.logger.error("DSS->register#ERROR, Unable to register, ".concat(error.message));
87
-
88
74
  return _promise.default.reject(error);
89
75
  });
90
76
  },
91
-
92
77
  /**
93
78
  * Explicitly tears down the DSS plugin by disconnecting from mercury, and stops listening to DSS events
94
79
  * @returns {Promise}
@@ -97,20 +82,16 @@ var DSS = _webexCore.WebexPlugin.extend({
97
82
  */
98
83
  unregister: function unregister() {
99
84
  var _this2 = this;
100
-
101
85
  if (!this.registered) {
102
86
  this.logger.info('DSS->unregister#INFO, DSS plugin already unregistered');
103
87
  return _promise.default.resolve();
104
88
  }
105
-
106
89
  this.stopListeningForEvents();
107
90
  return this.webex.internal.mercury.disconnect().then(function () {
108
91
  _this2.trigger(_constants.DSS_UNREGISTERED);
109
-
110
92
  _this2.registered = false;
111
93
  });
112
94
  },
113
-
114
95
  /**
115
96
  * registers for DSS events through mercury
116
97
  * @returns {undefined}
@@ -118,7 +99,6 @@ var DSS = _webexCore.WebexPlugin.extend({
118
99
  */
119
100
  listenForEvents: function listenForEvents() {
120
101
  var _this3 = this;
121
-
122
102
  this.webex.internal.mercury.on(_constants.DSS_LOOKUP_MERCURY_EVENT, function (envelope) {
123
103
  _this3._handleEvent(envelope.data);
124
104
  });
@@ -126,7 +106,6 @@ var DSS = _webexCore.WebexPlugin.extend({
126
106
  _this3._handleEvent(envelope.data);
127
107
  });
128
108
  },
129
-
130
109
  /**
131
110
  * unregisteres all the DSS events from mercury
132
111
  * @returns {undefined}
@@ -136,16 +115,16 @@ var DSS = _webexCore.WebexPlugin.extend({
136
115
  this.webex.internal.mercury.off(_constants.DSS_LOOKUP_MERCURY_EVENT);
137
116
  this.webex.internal.mercury.off(_constants.DSS_SEARCH_MERCURY_EVENT);
138
117
  },
139
-
140
118
  /**
119
+ * constructs the event name based on request id
141
120
  * @param {UUID} requestId the id of the request
142
121
  * @returns {string}
143
122
  */
144
123
  _getResultEventName: function _getResultEventName(requestId) {
145
124
  return "".concat(_constants.DSS_RESULT).concat(requestId);
146
125
  },
147
-
148
126
  /**
127
+ * Takes incoming data and triggers correct events
149
128
  * @param {Object} data the event data
150
129
  * @returns {undefined}
151
130
  */
@@ -153,54 +132,76 @@ var DSS = _webexCore.WebexPlugin.extend({
153
132
  this.trigger(this._getResultEventName(data.requestId), data);
154
133
  this.trigger(_constants.DSS_LOOKUP_RESULT, data);
155
134
  },
156
-
157
135
  /**
158
136
  * Makes the request to the directory service
159
137
  * @param {Object} options
160
138
  * @param {string} options.resource the URL to query
161
139
  * @param {string} options.params additional params for the body of the request
162
- * @param {string} options.dataPath to path to get the data in the result object
163
- * @returns {Promise} Resolves with an array of entities found
140
+ * @param {string} options.dataPath the path to get the data in the result object
141
+ * @param {string} options.foundPath the path to get the lookups of the found data (optional)
142
+ * @param {string} options.notFoundPath the path to get the lookups of the not found data (optional)
143
+ * @returns {Promise<Object>} result Resolves with an object
144
+ * @returns {Array} result.resultArray an array of entities found
145
+ * @returns {Array} result.foundArray an array of the lookups of the found entities (if foundPath provided)
146
+ * @returns {Array} result.notFoundArray an array of the lookups of the not found entities (if notFoundPath provided)
164
147
  */
165
148
  _request: function _request(options) {
166
149
  var _this4 = this;
167
-
168
150
  var resource = options.resource,
169
- params = options.params,
170
- dataPath = options.dataPath;
171
-
151
+ params = options.params,
152
+ dataPath = options.dataPath,
153
+ foundPath = options.foundPath,
154
+ notFoundPath = options.notFoundPath;
172
155
  var requestId = _uuid.default.v4();
173
-
174
156
  var eventName = this._getResultEventName(requestId);
175
-
176
157
  var result = {};
177
158
  var expectedSeqNums;
159
+ var notFoundArray;
178
160
  return new _promise.default(function (resolve) {
179
161
  _this4.listenTo(_this4, eventName, function (data) {
180
- var resultData = (0, _get2.default)(data, dataPath);
181
- result[data.sequence] = resultData;
182
-
162
+ var resultData = (0, _get2.default)(data, dataPath, []);
163
+ var found;
164
+ if (foundPath) {
165
+ found = (0, _get2.default)(data, foundPath, []);
166
+ }
167
+ result[data.sequence] = foundPath ? {
168
+ resultData: resultData,
169
+ found: found
170
+ } : {
171
+ resultData: resultData
172
+ };
183
173
  if (data.finished) {
184
174
  expectedSeqNums = (0, _range2.default)(data.sequence + 1).map(String);
175
+ if (notFoundPath) {
176
+ notFoundArray = (0, _get2.default)(data, notFoundPath, []);
177
+ }
185
178
  }
186
-
187
179
  var done = (0, _isEqual2.default)(expectedSeqNums, (0, _keys.default)(result));
188
-
189
180
  if (done) {
190
181
  var resultArray = [];
182
+ var foundArray = [];
191
183
  expectedSeqNums.forEach(function (index) {
192
184
  var seqResult = result[index];
193
-
194
185
  if (seqResult) {
195
- resultArray.push.apply(resultArray, (0, _toConsumableArray2.default)(seqResult));
186
+ resultArray.push.apply(resultArray, (0, _toConsumableArray2.default)(seqResult.resultData));
187
+ if (foundPath) {
188
+ foundArray.push.apply(foundArray, (0, _toConsumableArray2.default)(seqResult.found));
189
+ }
196
190
  }
197
191
  });
198
- resolve(resultArray);
199
-
192
+ var resolveValue = {
193
+ resultArray: resultArray
194
+ };
195
+ if (foundPath) {
196
+ resolveValue.foundArray = foundArray;
197
+ }
198
+ if (notFoundPath) {
199
+ resolveValue.notFoundArray = notFoundArray;
200
+ }
201
+ resolve(resolveValue);
200
202
  _this4.stopListening(_this4, eventName);
201
203
  }
202
204
  });
203
-
204
205
  _this4.webex.request({
205
206
  service: _constants.DSS_SERVICE_NAME,
206
207
  resource: resource,
@@ -212,58 +213,110 @@ var DSS = _webexCore.WebexPlugin.extend({
212
213
  });
213
214
  });
214
215
  },
215
-
216
+ /**
217
+ * Uses a batcher to make the request to the directory service
218
+ * @param {Object} options
219
+ * @param {string} options.resource the URL to query
220
+ * @param {string} options.value the id or email to lookup
221
+ * @returns {Promise} Resolves with an array of entities found
222
+ */
223
+ _batchedLookup: function _batchedLookup(options) {
224
+ var resource = options.resource,
225
+ lookupValue = options.lookupValue;
226
+ var dataPath = _constants.LOOKUP_DATA_PATH;
227
+ var entitiesFoundPath = _constants.LOOKUP_FOUND_PATH;
228
+ var entitiesNotFoundPath = _constants.LOOKUP_NOT_FOUND_PATH;
229
+ var requestKey = _constants.LOOKUP_REQUEST_KEY;
230
+ this.batchers[resource] = this.batchers[resource] || new _dssBatcher.default({
231
+ resource: resource,
232
+ dataPath: dataPath,
233
+ entitiesFoundPath: entitiesFoundPath,
234
+ entitiesNotFoundPath: entitiesNotFoundPath,
235
+ requestKey: requestKey,
236
+ parent: this
237
+ });
238
+ return this.batchers[resource].request(lookupValue);
239
+ },
216
240
  /**
217
241
  * Retrieves detailed information about an entity
218
242
  * @param {Object} options
219
243
  * @param {UUID} options.id the id of the entity to lookup
220
- * @returns {Promise} Resolves with an array of entities found
244
+ * @returns {Promise} Resolves with the entity found or null if not found
221
245
  */
222
246
  lookupDetail: function lookupDetail(options) {
223
247
  var id = options.id;
248
+ var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail");
224
249
  return this._request({
225
- dataPath: 'lookupResult.entities',
226
- resource: "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identity/").concat(id, "/detail")
250
+ dataPath: _constants.LOOKUP_DATA_PATH,
251
+ foundPath: _constants.LOOKUP_FOUND_PATH,
252
+ resource: resource
253
+ }).then(function (_ref) {
254
+ var resultArray = _ref.resultArray,
255
+ foundArray = _ref.foundArray;
256
+ // TODO: find out what is actually returned!
257
+ if (foundArray[0] === id) {
258
+ return resultArray[0];
259
+ }
260
+ return null;
227
261
  });
228
262
  },
229
-
230
263
  /**
231
- * Retrieves basic information about a list entities within an organization
264
+ * Retrieves basic information about an entity within an organization
232
265
  * @param {Object} options
233
- * @param {UUID} options.ids the id of the entity to lookup
266
+ * @param {UUID} options.id the id of the entity to lookup
234
267
  * @param {UUID} options.entityProviderType the provider to query (optional)
235
- * @returns {Promise} Resolves with an array of entities found
268
+ * @param {Boolean} options.shouldBatch whether to batch the query, set to false for single immediate result (defaults to true)
269
+ * @returns {Promise} Resolves with the entity found or null if not found
236
270
  */
237
271
  lookup: function lookup(options) {
238
- var ids = options.ids,
239
- entityProviderType = options.entityProviderType;
272
+ var id = options.id,
273
+ entityProviderType = options.entityProviderType,
274
+ _options$shouldBatch = options.shouldBatch,
275
+ shouldBatch = _options$shouldBatch === void 0 ? true : _options$shouldBatch;
240
276
  var resource = entityProviderType ? "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/entityprovidertype/").concat(entityProviderType) : "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/identities");
277
+ if (shouldBatch) {
278
+ return this._batchedLookup({
279
+ resource: resource,
280
+ lookupValue: id
281
+ });
282
+ }
241
283
  return this._request({
242
- dataPath: 'lookupResult.entities',
284
+ dataPath: _constants.LOOKUP_DATA_PATH,
285
+ foundPath: _constants.LOOKUP_FOUND_PATH,
243
286
  resource: resource,
244
- params: {
245
- lookupValues: ids
287
+ params: (0, _defineProperty2.default)({}, _constants.LOOKUP_REQUEST_KEY, [id])
288
+ }).then(function (_ref2) {
289
+ var resultArray = _ref2.resultArray,
290
+ foundArray = _ref2.foundArray;
291
+ if (foundArray[0] === id) {
292
+ return resultArray[0];
246
293
  }
294
+ return null;
247
295
  });
248
296
  },
249
-
250
297
  /**
251
- * Retrieves basic information about a list entities within an organization
298
+ * Retrieves basic information about an enitity within an organization
252
299
  * @param {Object} options
253
- * @param {UUID} options.emails the emails of the entities to lookup
254
- * @returns {Promise} Resolves with an array of entities found
300
+ * @param {UUID} options.email the email of the entity to lookup
301
+ * @returns {Promise} Resolves with the entity found or rejects if not found
255
302
  */
256
303
  lookupByEmail: function lookupByEmail(options) {
257
- var emails = options.emails;
304
+ var email = options.email;
305
+ var resource = "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/emails");
258
306
  return this._request({
259
- dataPath: 'lookupResult.entities',
260
- resource: "/lookup/orgid/".concat(this.webex.internal.device.orgId, "/emails"),
261
- params: {
262
- lookupValues: emails
307
+ dataPath: _constants.LOOKUP_DATA_PATH,
308
+ foundPath: _constants.LOOKUP_FOUND_PATH,
309
+ resource: resource,
310
+ params: (0, _defineProperty2.default)({}, _constants.LOOKUP_REQUEST_KEY, [email])
311
+ }).then(function (_ref3) {
312
+ var resultArray = _ref3.resultArray,
313
+ foundArray = _ref3.foundArray;
314
+ if (foundArray[0] === email) {
315
+ return resultArray[0];
263
316
  }
317
+ return null;
264
318
  });
265
319
  },
266
-
267
320
  /**
268
321
  * Search for information about entities
269
322
  * @param {Object} options
@@ -274,21 +327,23 @@ var DSS = _webexCore.WebexPlugin.extend({
274
327
  */
275
328
  search: function search(options) {
276
329
  var requestedTypes = options.requestedTypes,
277
- resultSize = options.resultSize,
278
- queryString = options.queryString;
330
+ resultSize = options.resultSize,
331
+ queryString = options.queryString;
279
332
  return this._request({
280
- dataPath: 'directoryEntities',
333
+ dataPath: _constants.SEARCH_DATA_PATH,
281
334
  resource: "/search/orgid/".concat(this.webex.internal.device.orgId, "/entities"),
282
335
  params: {
283
336
  queryString: queryString,
284
337
  resultSize: resultSize,
285
338
  requestedTypes: requestedTypes
286
339
  }
340
+ }).then(function (_ref4) {
341
+ var resultArray = _ref4.resultArray;
342
+ return resultArray;
287
343
  });
288
344
  },
289
- version: "3.0.0-beta.15"
345
+ version: "3.0.0-beta.151"
290
346
  });
291
-
292
347
  var _default = DSS;
293
348
  exports.default = _default;
294
349
  //# sourceMappingURL=dss.js.map