@webex/webex-core 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.3
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 +9 -0
- package/dist/config.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/services.js +74 -44
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +74 -44
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +2 -2
- package/package.json +11 -11
- package/src/config.js +10 -0
- package/src/lib/services/services.js +65 -30
- package/src/lib/services-v2/services-v2.ts +65 -29
- package/test/integration/spec/services/services.js +148 -113
- package/test/integration/spec/services-v2/services-v2.js +134 -99
- package/test/unit/spec/services/services.js +135 -2
- package/test/unit/spec/services-v2/services-v2.ts +138 -2
|
@@ -1218,9 +1218,11 @@ var Services = _webexPlugin.default.extend({
|
|
|
1218
1218
|
authorization: token
|
|
1219
1219
|
};
|
|
1220
1220
|
}
|
|
1221
|
-
|
|
1221
|
+
var sendRequest = function sendRequest() {
|
|
1222
1222
|
return _this1.request(requestObject);
|
|
1223
|
-
}
|
|
1223
|
+
};
|
|
1224
|
+
var responsePromise = this.webex.internal.newMetrics ? this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(sendRequest, 'internal.get.u2c.time') : sendRequest();
|
|
1225
|
+
return responsePromise.then(function (_ref12) {
|
|
1224
1226
|
var body = _ref12.body;
|
|
1225
1227
|
return _this1._formatReceivedHostmap(body || {});
|
|
1226
1228
|
});
|
|
@@ -1375,6 +1377,26 @@ var Services = _webexPlugin.default.extend({
|
|
|
1375
1377
|
}, _callee3);
|
|
1376
1378
|
}))();
|
|
1377
1379
|
},
|
|
1380
|
+
/**
|
|
1381
|
+
* Build a promise that rejects once the catalog init timeout elapses. Race
|
|
1382
|
+
* this against catalog collection so a hung request never leaves
|
|
1383
|
+
* `services.ready` false forever - that would stall `webex.ready` and leave
|
|
1384
|
+
* consumers waiting on it indefinitely. Timeout is configurable via
|
|
1385
|
+
* `config.services.catalogInitTimeout` (defaults to 15s in config). Created
|
|
1386
|
+
* lazily so paths that skip catalog collection never schedule a stray timer.
|
|
1387
|
+
*
|
|
1388
|
+
* @private
|
|
1389
|
+
* @returns {Promise<never>}
|
|
1390
|
+
*/
|
|
1391
|
+
_makeInitTimeout: function _makeInitTimeout() {
|
|
1392
|
+
var _this$webex$config4, _this$webex$config4$s;
|
|
1393
|
+
var initTimeoutMs = (_this$webex$config4 = this.webex.config) === null || _this$webex$config4 === void 0 ? void 0 : (_this$webex$config4$s = _this$webex$config4.services) === null || _this$webex$config4$s === void 0 ? void 0 : _this$webex$config4$s.catalogInitTimeout;
|
|
1394
|
+
return new _promise.default(function (_, reject) {
|
|
1395
|
+
setTimeout(function () {
|
|
1396
|
+
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1397
|
+
}, initTimeoutMs);
|
|
1398
|
+
});
|
|
1399
|
+
},
|
|
1378
1400
|
/**
|
|
1379
1401
|
* Initializer
|
|
1380
1402
|
*
|
|
@@ -1423,7 +1445,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1423
1445
|
// wait for webex instance to be ready before attempting
|
|
1424
1446
|
// to update the service catalogs
|
|
1425
1447
|
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
1426
|
-
var warmed, supertoken, email;
|
|
1448
|
+
var warmed, supertoken, _this14$webex$config, _this14$webex$config$, email;
|
|
1427
1449
|
return _regenerator.default.wrap(function (_context4) {
|
|
1428
1450
|
while (1) switch (_context4.prev = _context4.next) {
|
|
1429
1451
|
case 0:
|
|
@@ -1439,23 +1461,34 @@ var Services = _webexPlugin.default.extend({
|
|
|
1439
1461
|
return _context4.abrupt("return");
|
|
1440
1462
|
case 2:
|
|
1441
1463
|
supertoken = _this14.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1442
|
-
if (supertoken && supertoken.access_token) {
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
_this14.initServiceCatalogs().catch(function (error) {
|
|
1446
|
-
_this14.initFailed = true;
|
|
1447
|
-
_this14.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1448
|
-
});
|
|
1449
|
-
} else {
|
|
1450
|
-
email = _this14.webex.config.email;
|
|
1451
|
-
_this14.collectPreauthCatalog(email ? {
|
|
1452
|
-
email: email
|
|
1453
|
-
} : undefined).catch(function (error) {
|
|
1454
|
-
_this14.initFailed = true;
|
|
1455
|
-
_this14.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1456
|
-
});
|
|
1464
|
+
if (!(supertoken && supertoken.access_token)) {
|
|
1465
|
+
_context4.next = 3;
|
|
1466
|
+
break;
|
|
1457
1467
|
}
|
|
1468
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1469
|
+
// postauth catalog is collected.
|
|
1470
|
+
_this14.initServiceCatalogs().catch(function (error) {
|
|
1471
|
+
_this14.initFailed = true;
|
|
1472
|
+
_this14.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1473
|
+
});
|
|
1474
|
+
_context4.next = 5;
|
|
1475
|
+
break;
|
|
1458
1476
|
case 3:
|
|
1477
|
+
email = _this14.webex.config.email;
|
|
1478
|
+
if (!(((_this14$webex$config = _this14.webex.config) === null || _this14$webex$config === void 0 ? void 0 : (_this14$webex$config$ = _this14$webex$config.services) === null || _this14$webex$config$ === void 0 ? void 0 : _this14$webex$config$.skipPreauthCatalogOnUnauthenticated) === true)) {
|
|
1479
|
+
_context4.next = 4;
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
_this14.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
|
|
1483
|
+
return _context4.abrupt("return");
|
|
1484
|
+
case 4:
|
|
1485
|
+
_this14.collectPreauthCatalog(email ? {
|
|
1486
|
+
email: email
|
|
1487
|
+
} : undefined).catch(function (error) {
|
|
1488
|
+
_this14.initFailed = true;
|
|
1489
|
+
_this14.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1490
|
+
});
|
|
1491
|
+
case 5:
|
|
1459
1492
|
case "end":
|
|
1460
1493
|
return _context4.stop();
|
|
1461
1494
|
}
|
|
@@ -1478,8 +1511,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1478
1511
|
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1479
1512
|
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1480
1513
|
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1481
|
-
var _this15$webex$config, _this15$webex$config
|
|
1482
|
-
var warmed, supertoken, initTimeoutMs, initServiceCatalogsTimeout, email;
|
|
1514
|
+
var warmed, supertoken, _this15$webex$config, _this15$webex$config$, email;
|
|
1483
1515
|
return _regenerator.default.wrap(function (_context5) {
|
|
1484
1516
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1485
1517
|
case 0:
|
|
@@ -1497,38 +1529,19 @@ var Services = _webexPlugin.default.extend({
|
|
|
1497
1529
|
case 2:
|
|
1498
1530
|
return _context5.abrupt("return");
|
|
1499
1531
|
case 3:
|
|
1500
|
-
supertoken = _this15.webex.credentials.supertoken; //
|
|
1501
|
-
// `services.ready` false forever - that would stall `webex.ready` and
|
|
1502
|
-
// leave consumers waiting on it indefinitely. Timeout is configurable via
|
|
1503
|
-
// `config.services.catalogInitTimeout` (defaults to 15s in config).
|
|
1504
|
-
initTimeoutMs = (_this15$webex$config = _this15.webex.config) === null || _this15$webex$config === void 0 ? void 0 : (_this15$webex$config$ = _this15$webex$config.services) === null || _this15$webex$config$ === void 0 ? void 0 : _this15$webex$config$.catalogInitTimeout;
|
|
1505
|
-
initServiceCatalogsTimeout = new _promise.default(function (_, reject) {
|
|
1506
|
-
setTimeout(function () {
|
|
1507
|
-
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1508
|
-
}, initTimeoutMs);
|
|
1509
|
-
}); // Validate if the supertoken exists.
|
|
1532
|
+
supertoken = _this15.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1510
1533
|
if (supertoken && supertoken.access_token) {
|
|
1511
1534
|
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1512
1535
|
// postauth catalog is collected - even if it loses the timeout race
|
|
1513
|
-
//
|
|
1514
|
-
_promise.default.race([_this15.initServiceCatalogs(),
|
|
1536
|
+
// below, so a slow fetch still eventually flips `catalog.isReady`.
|
|
1537
|
+
_promise.default.race([_this15.initServiceCatalogs(), _this15._makeInitTimeout()]).catch(function (error) {
|
|
1515
1538
|
_this15.initFailed = true;
|
|
1516
1539
|
_this15.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1517
1540
|
}).finally(function () {
|
|
1518
1541
|
return _this15._finalizeReady();
|
|
1519
1542
|
});
|
|
1520
1543
|
} else {
|
|
1521
|
-
email = _this15.webex.config.email;
|
|
1522
|
-
_promise.default.race([_this15.collectPreauthCatalog(email ? {
|
|
1523
|
-
email: email
|
|
1524
|
-
} : undefined), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1525
|
-
_this15.initFailed = true;
|
|
1526
|
-
_this15.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1527
|
-
}).finally(function () {
|
|
1528
|
-
return _this15._finalizeReady();
|
|
1529
|
-
});
|
|
1530
|
-
|
|
1531
|
-
// Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1544
|
+
email = _this15.webex.config.email; // Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1532
1545
|
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1533
1546
|
_this15.listenToOnce(_this15.webex, 'change:canAuthorize', function () {
|
|
1534
1547
|
if (_this15.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
@@ -1538,6 +1551,23 @@ var Services = _webexPlugin.default.extend({
|
|
|
1538
1551
|
});
|
|
1539
1552
|
}
|
|
1540
1553
|
});
|
|
1554
|
+
if (((_this15$webex$config = _this15.webex.config) === null || _this15$webex$config === void 0 ? void 0 : (_this15$webex$config$ = _this15$webex$config.services) === null || _this15$webex$config$ === void 0 ? void 0 : _this15$webex$config$.skipPreauthCatalogOnUnauthenticated) === true) {
|
|
1555
|
+
// Skip the preauth catalog fetch (it will be collected manually
|
|
1556
|
+
// later), but still finalize `services.ready` so `webex.ready` is not
|
|
1557
|
+
// stalled while unauthenticated. No timeout is created here so there
|
|
1558
|
+
// is no stray timer or unhandled rejection.
|
|
1559
|
+
_this15.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
|
|
1560
|
+
_this15._finalizeReady();
|
|
1561
|
+
} else {
|
|
1562
|
+
_promise.default.race([_this15.collectPreauthCatalog(email ? {
|
|
1563
|
+
email: email
|
|
1564
|
+
} : undefined), _this15._makeInitTimeout()]).catch(function (error) {
|
|
1565
|
+
_this15.initFailed = true;
|
|
1566
|
+
_this15.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1567
|
+
}).finally(function () {
|
|
1568
|
+
return _this15._finalizeReady();
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1541
1571
|
}
|
|
1542
1572
|
case 4:
|
|
1543
1573
|
case "end":
|
|
@@ -1546,7 +1576,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1546
1576
|
}, _callee5);
|
|
1547
1577
|
})));
|
|
1548
1578
|
},
|
|
1549
|
-
version: "3.12.0-llmrefactor.
|
|
1579
|
+
version: "3.12.0-llmrefactor.3"
|
|
1550
1580
|
});
|
|
1551
1581
|
/* eslint-enable no-underscore-dangle */
|
|
1552
1582
|
var _default = exports.default = Services;
|