@webex/webex-core 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.10
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 +23 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/interceptors/catalog-url.js +87 -0
- package/dist/interceptors/catalog-url.js.map +1 -0
- package/dist/interceptors/payload-transformer.js +25 -4
- package/dist/interceptors/payload-transformer.js.map +1 -1
- package/dist/lib/batcher.js +1 -1
- package/dist/lib/credentials/credentials.js +56 -1
- package/dist/lib/credentials/credentials.js.map +1 -1
- package/dist/lib/credentials/token.js +1 -1
- package/dist/lib/services/service-catalog.js +102 -8
- package/dist/lib/services/service-catalog.js.map +1 -1
- package/dist/lib/services/services.js +74 -44
- package/dist/lib/services/services.js.map +1 -1
- package/dist/lib/services-v2/service-catalog.js +8 -1
- package/dist/lib/services-v2/service-catalog.js.map +1 -1
- package/dist/lib/services-v2/services-v2.js +76 -45
- package/dist/lib/services-v2/services-v2.js.map +1 -1
- package/dist/plugins/logger.js +1 -1
- package/dist/webex-core.js +11 -3
- package/dist/webex-core.js.map +1 -1
- package/package.json +12 -12
- package/src/config.js +25 -0
- package/src/index.js +1 -0
- package/src/interceptors/catalog-url.js +66 -0
- package/src/interceptors/payload-transformer.js +23 -1
- package/src/lib/credentials/credentials.js +43 -0
- package/src/lib/services/service-catalog.js +106 -6
- package/src/lib/services/services.js +65 -30
- package/src/lib/services-v2/service-catalog.ts +10 -1
- package/src/lib/services-v2/services-v2.ts +70 -30
- package/src/webex-core.js +8 -0
- package/test/integration/spec/services/services.js +148 -113
- package/test/integration/spec/services-v2/services-v2.js +134 -99
- package/test/unit/spec/credentials/credentials.js +114 -1
- package/test/unit/spec/interceptors/catalog-url.js +224 -0
- package/test/unit/spec/interceptors/payload-transformer.js +119 -1
- package/test/unit/spec/services/service-catalog.js +275 -0
- package/test/unit/spec/services/services.js +135 -2
- package/test/unit/spec/services-v2/service-catalog.ts +41 -0
- package/test/unit/spec/services-v2/services-v2.ts +158 -2
- package/test/unit/spec/webex-core.js +77 -1
|
@@ -1075,9 +1075,11 @@ var Services = _webexPlugin.default.extend({
|
|
|
1075
1075
|
authorization: token
|
|
1076
1076
|
};
|
|
1077
1077
|
}
|
|
1078
|
-
|
|
1078
|
+
var sendRequest = function sendRequest() {
|
|
1079
1079
|
return _this7.request(requestObject);
|
|
1080
|
-
}
|
|
1080
|
+
};
|
|
1081
|
+
var responsePromise = this.webex.internal.newMetrics ? this.webex.internal.newMetrics.callDiagnosticLatencies.measureLatency(sendRequest, 'internal.get.u2c.time') : sendRequest();
|
|
1082
|
+
return responsePromise.then(function (_ref12) {
|
|
1081
1083
|
var body = _ref12.body;
|
|
1082
1084
|
return body;
|
|
1083
1085
|
});
|
|
@@ -1434,6 +1436,26 @@ var Services = _webexPlugin.default.extend({
|
|
|
1434
1436
|
}, _callee4);
|
|
1435
1437
|
}))();
|
|
1436
1438
|
},
|
|
1439
|
+
/**
|
|
1440
|
+
* Build a promise that rejects once the catalog init timeout elapses. Race
|
|
1441
|
+
* this against catalog collection so a hung request never leaves
|
|
1442
|
+
* `services.ready` false forever - that would stall `webex.ready` and leave
|
|
1443
|
+
* consumers waiting on it indefinitely. Timeout is configurable via
|
|
1444
|
+
* `config.services.catalogInitTimeout` (defaults to 15s in config). Created
|
|
1445
|
+
* lazily so paths that skip catalog collection never schedule a stray timer.
|
|
1446
|
+
*
|
|
1447
|
+
* @private
|
|
1448
|
+
* @returns {Promise<never>}
|
|
1449
|
+
*/
|
|
1450
|
+
_makeInitTimeout: function _makeInitTimeout() {
|
|
1451
|
+
var _this$webex$config3, _this$webex$config3$s;
|
|
1452
|
+
var initTimeoutMs = (_this$webex$config3 = this.webex.config) === null || _this$webex$config3 === void 0 ? void 0 : (_this$webex$config3$s = _this$webex$config3.services) === null || _this$webex$config3$s === void 0 ? void 0 : _this$webex$config3$s.catalogInitTimeout;
|
|
1453
|
+
return new _promise.default(function (_, reject) {
|
|
1454
|
+
setTimeout(function () {
|
|
1455
|
+
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1456
|
+
}, initTimeoutMs);
|
|
1457
|
+
});
|
|
1458
|
+
},
|
|
1437
1459
|
/**
|
|
1438
1460
|
* Initializer
|
|
1439
1461
|
*
|
|
@@ -1488,7 +1510,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1488
1510
|
// this can cause a race condition because credentials may
|
|
1489
1511
|
// not be valid when services is initialized
|
|
1490
1512
|
this.listenToOnce(this.webex, 'ready', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
1491
|
-
var cachedCatalog, supertoken, email;
|
|
1513
|
+
var cachedCatalog, supertoken, _this11$webex$config, _this11$webex$config$, email;
|
|
1492
1514
|
return _regenerator.default.wrap(function (_context5) {
|
|
1493
1515
|
while (1) switch (_context5.prev = _context5.next) {
|
|
1494
1516
|
case 0:
|
|
@@ -1504,23 +1526,34 @@ var Services = _webexPlugin.default.extend({
|
|
|
1504
1526
|
return _context5.abrupt("return");
|
|
1505
1527
|
case 2:
|
|
1506
1528
|
supertoken = _this11.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1507
|
-
if (supertoken && supertoken.access_token) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
_this11.initServiceCatalogs().catch(function (error) {
|
|
1511
|
-
_this11.initFailed = true;
|
|
1512
|
-
_this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1513
|
-
});
|
|
1514
|
-
} else {
|
|
1515
|
-
email = _this11.webex.config.email;
|
|
1516
|
-
_this11.collectPreauthCatalog(email ? {
|
|
1517
|
-
email: email
|
|
1518
|
-
} : undefined).catch(function (error) {
|
|
1519
|
-
_this11.initFailed = true;
|
|
1520
|
-
_this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1521
|
-
});
|
|
1529
|
+
if (!(supertoken && supertoken.access_token)) {
|
|
1530
|
+
_context5.next = 3;
|
|
1531
|
+
break;
|
|
1522
1532
|
}
|
|
1533
|
+
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1534
|
+
// postauth catalog is collected.
|
|
1535
|
+
_this11.initServiceCatalogs().catch(function (error) {
|
|
1536
|
+
_this11.initFailed = true;
|
|
1537
|
+
_this11.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1538
|
+
});
|
|
1539
|
+
_context5.next = 5;
|
|
1540
|
+
break;
|
|
1523
1541
|
case 3:
|
|
1542
|
+
email = _this11.webex.config.email;
|
|
1543
|
+
if (!(((_this11$webex$config = _this11.webex.config) === null || _this11$webex$config === void 0 ? void 0 : (_this11$webex$config$ = _this11$webex$config.services) === null || _this11$webex$config$ === void 0 ? void 0 : _this11$webex$config$.skipPreauthCatalogOnUnauthenticated) === true)) {
|
|
1544
|
+
_context5.next = 4;
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
_this11.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
|
|
1548
|
+
return _context5.abrupt("return");
|
|
1549
|
+
case 4:
|
|
1550
|
+
_this11.collectPreauthCatalog(email ? {
|
|
1551
|
+
email: email
|
|
1552
|
+
} : undefined).catch(function (error) {
|
|
1553
|
+
_this11.initFailed = true;
|
|
1554
|
+
_this11.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1555
|
+
});
|
|
1556
|
+
case 5:
|
|
1524
1557
|
case "end":
|
|
1525
1558
|
return _context5.stop();
|
|
1526
1559
|
}
|
|
@@ -1543,8 +1576,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1543
1576
|
// catalogs. We listen for 'loaded' instead of 'ready' because `services.ready`
|
|
1544
1577
|
// now blocks `webex.ready` - listening to 'ready' would deadlock.
|
|
1545
1578
|
this.listenToOnce(this.webex, 'loaded', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
1546
|
-
var _this12$webex$config, _this12$webex$config
|
|
1547
|
-
var cachedCatalog, supertoken, initTimeoutMs, initServiceCatalogsTimeout, email;
|
|
1579
|
+
var cachedCatalog, supertoken, _this12$webex$config, _this12$webex$config$, email;
|
|
1548
1580
|
return _regenerator.default.wrap(function (_context6) {
|
|
1549
1581
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1550
1582
|
case 0:
|
|
@@ -1562,38 +1594,19 @@ var Services = _webexPlugin.default.extend({
|
|
|
1562
1594
|
case 2:
|
|
1563
1595
|
return _context6.abrupt("return");
|
|
1564
1596
|
case 3:
|
|
1565
|
-
supertoken = _this12.webex.credentials.supertoken; //
|
|
1566
|
-
// `services.ready` false forever - that would stall `webex.ready` and
|
|
1567
|
-
// leave consumers waiting on it indefinitely. Timeout is configurable via
|
|
1568
|
-
// `config.services.catalogInitTimeout` (defaults to 15s in config).
|
|
1569
|
-
initTimeoutMs = (_this12$webex$config = _this12.webex.config) === null || _this12$webex$config === void 0 ? void 0 : (_this12$webex$config$ = _this12$webex$config.services) === null || _this12$webex$config$ === void 0 ? void 0 : _this12$webex$config$.catalogInitTimeout;
|
|
1570
|
-
initServiceCatalogsTimeout = new _promise.default(function (_, reject) {
|
|
1571
|
-
setTimeout(function () {
|
|
1572
|
-
return reject(new Error("services: init timed out after ".concat(initTimeoutMs, "ms")));
|
|
1573
|
-
}, initTimeoutMs);
|
|
1574
|
-
}); // Validate if the supertoken exists.
|
|
1597
|
+
supertoken = _this12.webex.credentials.supertoken; // Validate if the supertoken exists.
|
|
1575
1598
|
if (supertoken && supertoken.access_token) {
|
|
1576
1599
|
// `initServiceCatalogs` marks the catalog ready internally once the
|
|
1577
1600
|
// postauth catalog is collected - even if it loses the timeout race
|
|
1578
|
-
//
|
|
1579
|
-
_promise.default.race([_this12.initServiceCatalogs(),
|
|
1601
|
+
// below, so a slow fetch still eventually flips `catalog.isReady`.
|
|
1602
|
+
_promise.default.race([_this12.initServiceCatalogs(), _this12._makeInitTimeout()]).catch(function (error) {
|
|
1580
1603
|
_this12.initFailed = true;
|
|
1581
1604
|
_this12.logger.error("services: failed to init initial services when credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1582
1605
|
}).finally(function () {
|
|
1583
1606
|
return _this12._finalizeReady();
|
|
1584
1607
|
});
|
|
1585
1608
|
} else {
|
|
1586
|
-
email = _this12.webex.config.email;
|
|
1587
|
-
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1588
|
-
email: email
|
|
1589
|
-
} : undefined), initServiceCatalogsTimeout]).catch(function (error) {
|
|
1590
|
-
_this12.initFailed = true;
|
|
1591
|
-
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1592
|
-
}).finally(function () {
|
|
1593
|
-
return _this12._finalizeReady();
|
|
1594
|
-
});
|
|
1595
|
-
|
|
1596
|
-
// Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1609
|
+
email = _this12.webex.config.email; // Handle fresh login: 'loaded' fires before OAuth completes, so listen
|
|
1597
1610
|
// for `canAuthorize` flipping true and then collect the postauth catalog.
|
|
1598
1611
|
_this12.listenToOnce(_this12.webex, 'change:canAuthorize', function () {
|
|
1599
1612
|
if (_this12.webex.canAuthorize && !catalog.status.postauth.ready) {
|
|
@@ -1603,6 +1616,23 @@ var Services = _webexPlugin.default.extend({
|
|
|
1603
1616
|
});
|
|
1604
1617
|
}
|
|
1605
1618
|
});
|
|
1619
|
+
if (((_this12$webex$config = _this12.webex.config) === null || _this12$webex$config === void 0 ? void 0 : (_this12$webex$config$ = _this12$webex$config.services) === null || _this12$webex$config$ === void 0 ? void 0 : _this12$webex$config$.skipPreauthCatalogOnUnauthenticated) === true) {
|
|
1620
|
+
// Skip the preauth catalog fetch (it will be collected manually
|
|
1621
|
+
// later), but still finalize `services.ready` so `webex.ready` is not
|
|
1622
|
+
// stalled while unauthenticated. No timeout is created here so there
|
|
1623
|
+
// is no stray timer or unhandled rejection.
|
|
1624
|
+
_this12.logger.info('services: skipping preauth catalog collection while unauthenticated as per the config');
|
|
1625
|
+
_this12._finalizeReady();
|
|
1626
|
+
} else {
|
|
1627
|
+
_promise.default.race([_this12.collectPreauthCatalog(email ? {
|
|
1628
|
+
email: email
|
|
1629
|
+
} : undefined), _this12._makeInitTimeout()]).catch(function (error) {
|
|
1630
|
+
_this12.initFailed = true;
|
|
1631
|
+
_this12.logger.error("services: failed to init initial services when no credentials available, ".concat(error === null || error === void 0 ? void 0 : error.message));
|
|
1632
|
+
}).finally(function () {
|
|
1633
|
+
return _this12._finalizeReady();
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1606
1636
|
}
|
|
1607
1637
|
case 4:
|
|
1608
1638
|
case "end":
|
|
@@ -1611,7 +1641,7 @@ var Services = _webexPlugin.default.extend({
|
|
|
1611
1641
|
}, _callee6);
|
|
1612
1642
|
})));
|
|
1613
1643
|
},
|
|
1614
|
-
version: "3.12.0-llmrefactor.
|
|
1644
|
+
version: "3.12.0-llmrefactor.10"
|
|
1615
1645
|
});
|
|
1616
1646
|
/* eslint-enable no-underscore-dangle */
|
|
1617
1647
|
var _default = exports.default = Services;
|