swagger-client 3.37.8 → 3.38.0
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/README.md +1 -1
- package/dist/swagger-client.browser.js +482 -574
- package/dist/swagger-client.browser.min.js +1 -1
- package/dist/swagger-client.browser.min.js.map +1 -1
- package/es/execute/index.js +11 -2
- package/es/helpers/each-operation.js +26 -1
- package/es/helpers/id-from-path-method/index.js +3 -1
- package/lib/execute/index.js +11 -2
- package/lib/helpers/each-operation.js +25 -1
- package/lib/helpers/id-from-path-method/index.js +3 -1
- package/package.json +16 -6
|
@@ -58,10 +58,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
58
58
|
/* harmony import */ var _oas3_parameter_builders_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(42276);
|
|
59
59
|
/* harmony import */ var _oas3_build_request_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(53044);
|
|
60
60
|
/* harmony import */ var _swagger2_build_request_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(77768);
|
|
61
|
-
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(
|
|
62
|
-
/* harmony import */ var
|
|
63
|
-
/* harmony import */ var
|
|
64
|
-
/* harmony import */ var _helpers_cookie_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(48009);
|
|
61
|
+
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(55971);
|
|
62
|
+
/* harmony import */ var _helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(50918);
|
|
63
|
+
/* harmony import */ var _helpers_cookie_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(48009);
|
|
65
64
|
|
|
66
65
|
|
|
67
66
|
|
|
@@ -79,6 +78,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
79
78
|
|
|
80
79
|
|
|
81
80
|
const arrayOrEmpty = ar => Array.isArray(ar) ? ar : [];
|
|
81
|
+
const HTTP_METHOD_TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
82
|
+
const isValidHttpMethod = method => typeof method === 'string' && HTTP_METHOD_TOKEN.test(method);
|
|
82
83
|
const findObjectOrArraySchema = (schema, {
|
|
83
84
|
recurse = true,
|
|
84
85
|
depth = 1
|
|
@@ -198,7 +199,7 @@ function execute({
|
|
|
198
199
|
const http = userHttp || fetch || _http_index_js__WEBPACK_IMPORTED_MODULE_9__["default"]; // Default to _our_ http
|
|
199
200
|
|
|
200
201
|
if (pathName && method && !operationId) {
|
|
201
|
-
operationId = (0,
|
|
202
|
+
operationId = (0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_15__.idFromPathMethodLegacy)(pathName, method);
|
|
202
203
|
}
|
|
203
204
|
const request = self.buildRequest({
|
|
204
205
|
spec,
|
|
@@ -238,7 +239,7 @@ function buildRequest(options) {
|
|
|
238
239
|
parameterBuilders,
|
|
239
240
|
baseURL
|
|
240
241
|
} = options;
|
|
241
|
-
const specIsOAS3 = (0,
|
|
242
|
+
const specIsOAS3 = (0,_helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_16__.isOpenAPI3)(spec);
|
|
242
243
|
if (!parameterBuilders) {
|
|
243
244
|
// user did not provide custom parameter builders
|
|
244
245
|
if (specIsOAS3) {
|
|
@@ -270,7 +271,7 @@ function buildRequest(options) {
|
|
|
270
271
|
if (userFetch) {
|
|
271
272
|
req.userFetch = userFetch;
|
|
272
273
|
}
|
|
273
|
-
const operationRaw = (0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_15__
|
|
274
|
+
const operationRaw = (0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_15__.getOperationRaw)(spec, operationId);
|
|
274
275
|
if (!operationRaw) {
|
|
275
276
|
throw new OperationNotFoundError(`Operation ${operationId} not found`);
|
|
276
277
|
}
|
|
@@ -279,6 +280,9 @@ function buildRequest(options) {
|
|
|
279
280
|
method,
|
|
280
281
|
pathName
|
|
281
282
|
} = operationRaw;
|
|
283
|
+
if (!isValidHttpMethod(method)) {
|
|
284
|
+
throw new Error('Invalid HTTP method');
|
|
285
|
+
}
|
|
282
286
|
baseURL = baseURL ?? baseUrl({
|
|
283
287
|
spec,
|
|
284
288
|
scheme,
|
|
@@ -287,6 +291,7 @@ function buildRequest(options) {
|
|
|
287
291
|
serverVariables,
|
|
288
292
|
pathName,
|
|
289
293
|
method,
|
|
294
|
+
operation,
|
|
290
295
|
serverVariableEncoder
|
|
291
296
|
});
|
|
292
297
|
req.url += baseURL;
|
|
@@ -301,7 +306,9 @@ function buildRequest(options) {
|
|
|
301
306
|
return req;
|
|
302
307
|
}
|
|
303
308
|
req.url += pathName; // Have not yet replaced the path parameters
|
|
304
|
-
|
|
309
|
+
// Standard operations are normalized by eachOperation; additionalOperations
|
|
310
|
+
// must retain the exact HTTP method token defined by the OAS 3.2 document.
|
|
311
|
+
req.method = method;
|
|
305
312
|
parameters = parameters || {};
|
|
306
313
|
const path = spec.paths[pathName] || {};
|
|
307
314
|
if (responseContentType) {
|
|
@@ -390,7 +397,7 @@ function buildRequest(options) {
|
|
|
390
397
|
// If the cookie convenience object exists in our request,
|
|
391
398
|
// serialize its content and then delete the cookie object.
|
|
392
399
|
if (req.cookies && Object.keys(req.cookies).length > 0) {
|
|
393
|
-
const cookieString = (0,
|
|
400
|
+
const cookieString = (0,_helpers_cookie_js__WEBPACK_IMPORTED_MODULE_17__.serialize)(req.cookies);
|
|
394
401
|
if ((0,ramda_adjunct__WEBPACK_IMPORTED_MODULE_3__["default"])(req.headers.Cookie)) {
|
|
395
402
|
req.headers.Cookie += `; ${cookieString}`;
|
|
396
403
|
} else {
|
|
@@ -412,7 +419,7 @@ const stripNonAlpha = str => str ? str.replace(/\W/g, '') : null;
|
|
|
412
419
|
|
|
413
420
|
// be careful when modifying this! it is a publicly-exposed method.
|
|
414
421
|
function baseUrl(obj) {
|
|
415
|
-
const specIsOAS3 = (0,
|
|
422
|
+
const specIsOAS3 = (0,_helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_16__.isOpenAPI3)(obj.spec);
|
|
416
423
|
return specIsOAS3 ? oas3BaseUrl(obj) : swagger2BaseUrl(obj);
|
|
417
424
|
}
|
|
418
425
|
const isNonEmptyServerList = value => Array.isArray(value) && value.length > 0;
|
|
@@ -420,6 +427,7 @@ function oas3BaseUrl({
|
|
|
420
427
|
spec,
|
|
421
428
|
pathName,
|
|
422
429
|
method,
|
|
430
|
+
operation,
|
|
423
431
|
server,
|
|
424
432
|
contextUrl,
|
|
425
433
|
serverVariables = {},
|
|
@@ -430,7 +438,7 @@ function oas3BaseUrl({
|
|
|
430
438
|
let selectedServerObj;
|
|
431
439
|
|
|
432
440
|
// compute the servers (this will be taken care of by ApiDOM refrator plugins in future
|
|
433
|
-
const operationLevelServers = spec?.paths?.[pathName]?.[(method || '').toLowerCase()]?.servers;
|
|
441
|
+
const operationLevelServers = operation?.servers ?? spec?.paths?.[pathName]?.[(method || '').toLowerCase()]?.servers;
|
|
434
442
|
const pathItemLevelServers = spec?.paths?.[pathName]?.servers;
|
|
435
443
|
const rootLevelServers = spec?.servers;
|
|
436
444
|
servers = isNonEmptyServerList(operationLevelServers) // eslint-disable-line no-nested-ternary
|
|
@@ -1392,6 +1400,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1392
1400
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1393
1401
|
/* harmony export */ "default": () => (/* binding */ eachOperation)
|
|
1394
1402
|
/* harmony export */ });
|
|
1403
|
+
/* harmony import */ var _openapi_predicates_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(50918);
|
|
1404
|
+
|
|
1405
|
+
|
|
1395
1406
|
// iterate over each operation, and fire a callback with details
|
|
1396
1407
|
// `find=true` will stop iterating, when the cb returns truthy
|
|
1397
1408
|
function eachOperation(spec, cb, find) {
|
|
@@ -1401,13 +1412,14 @@ function eachOperation(spec, cb, find) {
|
|
|
1401
1412
|
const {
|
|
1402
1413
|
paths
|
|
1403
1414
|
} = spec;
|
|
1415
|
+
const supportsAdditionalOperations = (0,_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_0__.isOpenAPI32)(spec);
|
|
1404
1416
|
|
|
1405
1417
|
// Iterate over the spec, collecting operations
|
|
1406
1418
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
1407
1419
|
for (const pathName in paths) {
|
|
1408
1420
|
// eslint-disable-next-line no-restricted-syntax, guard-for-in
|
|
1409
1421
|
for (const method in paths[pathName]) {
|
|
1410
|
-
if (method.toUpperCase() === 'PARAMETERS') {
|
|
1422
|
+
if (method.toUpperCase() === 'PARAMETERS' || method === 'additionalOperations') {
|
|
1411
1423
|
continue; // eslint-disable-line no-continue
|
|
1412
1424
|
}
|
|
1413
1425
|
const operation = paths[pathName][method];
|
|
@@ -1425,6 +1437,28 @@ function eachOperation(spec, cb, find) {
|
|
|
1425
1437
|
return operationObj;
|
|
1426
1438
|
}
|
|
1427
1439
|
}
|
|
1440
|
+
const {
|
|
1441
|
+
additionalOperations
|
|
1442
|
+
} = paths[pathName];
|
|
1443
|
+
if (supportsAdditionalOperations && additionalOperations && typeof additionalOperations === 'object') {
|
|
1444
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1445
|
+
for (const method of Object.keys(additionalOperations)) {
|
|
1446
|
+
const operation = additionalOperations[method];
|
|
1447
|
+
if (!operation || typeof operation !== 'object') {
|
|
1448
|
+
continue; // eslint-disable-line no-continue
|
|
1449
|
+
}
|
|
1450
|
+
const operationObj = {
|
|
1451
|
+
spec,
|
|
1452
|
+
pathName,
|
|
1453
|
+
method,
|
|
1454
|
+
operation
|
|
1455
|
+
};
|
|
1456
|
+
const cbValue = cb(operationObj);
|
|
1457
|
+
if (find && cbValue) {
|
|
1458
|
+
return operationObj;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1428
1462
|
}
|
|
1429
1463
|
return undefined;
|
|
1430
1464
|
}
|
|
@@ -1495,6 +1529,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1495
1529
|
/* harmony export */ });
|
|
1496
1530
|
/* harmony import */ var _replace_special_chars_with_underscore_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(47891);
|
|
1497
1531
|
|
|
1532
|
+
const STANDARD_HTTP_METHODS = new Set(['connect', 'delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'query', 'trace']);
|
|
1498
1533
|
function idFromPathMethod(pathName, method, {
|
|
1499
1534
|
v2OperationIdCompatibilityMode
|
|
1500
1535
|
} = {}) {
|
|
@@ -1503,7 +1538,8 @@ function idFromPathMethod(pathName, method, {
|
|
|
1503
1538
|
res = res || `${pathName.substring(1)}_${method}`;
|
|
1504
1539
|
return res.replace(/((_){2,})/g, '_').replace(/^(_)*/g, '').replace(/([_])*$/g, '');
|
|
1505
1540
|
}
|
|
1506
|
-
|
|
1541
|
+
const normalizedMethod = STANDARD_HTTP_METHODS.has(method.toLowerCase()) ? method.toLowerCase() : method;
|
|
1542
|
+
return `${normalizedMethod}${(0,_replace_special_chars_with_underscore_js__WEBPACK_IMPORTED_MODULE_0__["default"])(pathName)}`;
|
|
1507
1543
|
}
|
|
1508
1544
|
|
|
1509
1545
|
/***/ },
|
|
@@ -1520,6 +1556,37 @@ function idFromPathMethodLegacy(pathName, method) {
|
|
|
1520
1556
|
return `${method.toLowerCase()}-${pathName}`;
|
|
1521
1557
|
}
|
|
1522
1558
|
|
|
1559
|
+
/***/ },
|
|
1560
|
+
|
|
1561
|
+
/***/ 55971
|
|
1562
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
1563
|
+
|
|
1564
|
+
"use strict";
|
|
1565
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1566
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1567
|
+
/* harmony export */ eachOperation: () => (/* reexport safe */ _each_operation_js__WEBPACK_IMPORTED_MODULE_0__["default"]),
|
|
1568
|
+
/* harmony export */ findOperation: () => (/* reexport safe */ _find_operation_js__WEBPACK_IMPORTED_MODULE_1__["default"]),
|
|
1569
|
+
/* harmony export */ getOperationRaw: () => (/* reexport safe */ _get_operation_raw_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
|
|
1570
|
+
/* harmony export */ idFromPathMethod: () => (/* reexport safe */ _id_from_path_method_index_js__WEBPACK_IMPORTED_MODULE_4__["default"]),
|
|
1571
|
+
/* harmony export */ idFromPathMethodLegacy: () => (/* reexport safe */ _id_from_path_method_legacy_js__WEBPACK_IMPORTED_MODULE_5__["default"]),
|
|
1572
|
+
/* harmony export */ isHttpUrl: () => (/* reexport safe */ _is_http_url_js__WEBPACK_IMPORTED_MODULE_6__["default"]),
|
|
1573
|
+
/* harmony export */ opId: () => (/* reexport safe */ _op_id_js__WEBPACK_IMPORTED_MODULE_3__["default"])
|
|
1574
|
+
/* harmony export */ });
|
|
1575
|
+
/* harmony import */ var _each_operation_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(28686);
|
|
1576
|
+
/* harmony import */ var _find_operation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71356);
|
|
1577
|
+
/* harmony import */ var _get_operation_raw_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(50324);
|
|
1578
|
+
/* harmony import */ var _op_id_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(37896);
|
|
1579
|
+
/* harmony import */ var _id_from_path_method_index_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(30658);
|
|
1580
|
+
/* harmony import */ var _id_from_path_method_legacy_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(47555);
|
|
1581
|
+
/* harmony import */ var _is_http_url_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(42396);
|
|
1582
|
+
|
|
1583
|
+
|
|
1584
|
+
|
|
1585
|
+
|
|
1586
|
+
|
|
1587
|
+
|
|
1588
|
+
|
|
1589
|
+
|
|
1523
1590
|
/***/ },
|
|
1524
1591
|
|
|
1525
1592
|
/***/ 42396
|
|
@@ -2193,8 +2260,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2193
2260
|
/* harmony export */ mapTagOperations: () => (/* binding */ mapTagOperations),
|
|
2194
2261
|
/* harmony export */ self: () => (/* binding */ self)
|
|
2195
2262
|
/* harmony export */ });
|
|
2196
|
-
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(
|
|
2197
|
-
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(37896);
|
|
2263
|
+
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55971);
|
|
2198
2264
|
|
|
2199
2265
|
const nullFn = () => null;
|
|
2200
2266
|
const normalizeArray = arg => Array.isArray(arg) ? arg : [arg];
|
|
@@ -2290,7 +2356,7 @@ function mapTagOperations({
|
|
|
2290
2356
|
}) {
|
|
2291
2357
|
const operationIdCounter = {};
|
|
2292
2358
|
const tagOperations = {}; // Will house all tags + operations
|
|
2293
|
-
(0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_0__
|
|
2359
|
+
(0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_0__.eachOperation)(spec, ({
|
|
2294
2360
|
pathName,
|
|
2295
2361
|
method,
|
|
2296
2362
|
operation
|
|
@@ -2302,7 +2368,7 @@ function mapTagOperations({
|
|
|
2302
2368
|
}
|
|
2303
2369
|
tagOperations[tag] = tagOperations[tag] || {};
|
|
2304
2370
|
const tagObj = tagOperations[tag];
|
|
2305
|
-
const id = (0,
|
|
2371
|
+
const id = (0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_0__.opId)(operation, pathName, method, {
|
|
2306
2372
|
v2OperationIdCompatibilityMode
|
|
2307
2373
|
});
|
|
2308
2374
|
const cbResult = cb({
|
|
@@ -54441,7 +54507,7 @@ function requireOmap() {
|
|
|
54441
54507
|
const _toString = Object.prototype.toString;
|
|
54442
54508
|
function resolveYamlOmap(data) {
|
|
54443
54509
|
if (data === null) return true;
|
|
54444
|
-
const objectKeys =
|
|
54510
|
+
const objectKeys = {};
|
|
54445
54511
|
const object = data;
|
|
54446
54512
|
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
54447
54513
|
const pair = object[index];
|
|
@@ -54455,8 +54521,8 @@ function requireOmap() {
|
|
|
54455
54521
|
}
|
|
54456
54522
|
}
|
|
54457
54523
|
if (!pairHasKey) return false;
|
|
54458
|
-
if (
|
|
54459
|
-
|
|
54524
|
+
if (_hasOwnProperty.call(objectKeys, pairKey)) return false;
|
|
54525
|
+
Object.defineProperty(objectKeys, pairKey, { value: true });
|
|
54460
54526
|
}
|
|
54461
54527
|
return true;
|
|
54462
54528
|
}
|
|
@@ -56649,557 +56715,400 @@ const {
|
|
|
56649
56715
|
"use strict";
|
|
56650
56716
|
__webpack_require__.r(__webpack_exports__);
|
|
56651
56717
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
56652
|
-
/* harmony export */ "default": () => (/* binding */
|
|
56718
|
+
/* harmony export */ "default": () => (/* binding */ traverse)
|
|
56653
56719
|
/* harmony export */ });
|
|
56654
|
-
|
|
56655
|
-
|
|
56656
|
-
|
|
56657
|
-
|
|
56658
|
-
|
|
56659
|
-
|
|
56660
|
-
|
|
56661
|
-
}
|
|
56662
|
-
|
|
56663
|
-
|
|
56664
|
-
|
|
56665
|
-
|
|
56666
|
-
|
|
56667
|
-
function
|
|
56668
|
-
|
|
56669
|
-
|
|
56670
|
-
|
|
56671
|
-
|
|
56672
|
-
|
|
56673
|
-
|
|
56674
|
-
|
|
56675
|
-
}
|
|
56676
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
56677
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
56678
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
56679
|
-
return Constructor;
|
|
56680
|
-
}
|
|
56681
|
-
function _instanceof(left, right) {
|
|
56682
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
56683
|
-
return !!right[Symbol.hasInstance](left);
|
|
56684
|
-
} else {
|
|
56685
|
-
return left instanceof right;
|
|
56686
|
-
}
|
|
56687
|
-
}
|
|
56688
|
-
function _iterable_to_array_limit(arr, i) {
|
|
56689
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
56690
|
-
if (_i == null) return;
|
|
56691
|
-
var _arr = [];
|
|
56692
|
-
var _n = true;
|
|
56693
|
-
var _d = false;
|
|
56694
|
-
var _s, _e;
|
|
56695
|
-
try {
|
|
56696
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
56697
|
-
_arr.push(_s.value);
|
|
56698
|
-
if (i && _arr.length === i) break;
|
|
56699
|
-
}
|
|
56700
|
-
} catch (err) {
|
|
56701
|
-
_d = true;
|
|
56702
|
-
_e = err;
|
|
56703
|
-
} finally{
|
|
56704
|
-
try {
|
|
56705
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
56706
|
-
} finally{
|
|
56707
|
-
if (_d) throw _e;
|
|
56708
|
-
}
|
|
56709
|
-
}
|
|
56710
|
-
return _arr;
|
|
56711
|
-
}
|
|
56712
|
-
function _non_iterable_rest() {
|
|
56713
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
56714
|
-
}
|
|
56715
|
-
function _sliced_to_array(arr, i) {
|
|
56716
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
56717
|
-
}
|
|
56718
|
-
function _type_of(obj) {
|
|
56719
|
-
"@swc/helpers - typeof";
|
|
56720
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
56720
|
+
//#region packages/neotraverse/src/legacy/index.ts
|
|
56721
|
+
const to_string = (obj) => Object.prototype.toString.call(obj);
|
|
56722
|
+
const is_typed_array = (value) => ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
56723
|
+
const is_array = Array.isArray;
|
|
56724
|
+
const is_boxed_primitive = (obj) => {
|
|
56725
|
+
const tag = to_string(obj);
|
|
56726
|
+
return tag === "[object Boolean]" || tag === "[object Number]" || tag === "[object String]";
|
|
56727
|
+
};
|
|
56728
|
+
const gopd = Object.getOwnPropertyDescriptor;
|
|
56729
|
+
const is_property_enumerable = Object.prototype.propertyIsEnumerable;
|
|
56730
|
+
const get_own_property_symbols = Object.getOwnPropertySymbols;
|
|
56731
|
+
const has_own_property = Object.prototype.hasOwnProperty;
|
|
56732
|
+
const is_unsafe_key = (key) => key === "__proto__" || key === "constructor" || key === "prototype";
|
|
56733
|
+
function safe_set(dst, key, value) {
|
|
56734
|
+
if (key === "__proto__") Object.defineProperty(dst, key, {
|
|
56735
|
+
value,
|
|
56736
|
+
writable: true,
|
|
56737
|
+
enumerable: true,
|
|
56738
|
+
configurable: true
|
|
56739
|
+
});
|
|
56740
|
+
else dst[key] = value;
|
|
56721
56741
|
}
|
|
56722
|
-
function
|
|
56723
|
-
|
|
56724
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
56725
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
56726
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56727
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56728
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
56742
|
+
function assert_within_depth(depth, max_depth) {
|
|
56743
|
+
if (max_depth !== void 0 && depth > max_depth) throw new RangeError(`neotraverse: maximum traversal depth (${max_depth}) exceeded`);
|
|
56729
56744
|
}
|
|
56730
|
-
var __typeError = function(msg) {
|
|
56731
|
-
throw TypeError(msg);
|
|
56732
|
-
};
|
|
56733
|
-
var __accessCheck = function(obj, member, msg) {
|
|
56734
|
-
return member.has(obj) || __typeError("Cannot " + msg);
|
|
56735
|
-
};
|
|
56736
|
-
var __privateGet = function(obj, member, getter) {
|
|
56737
|
-
return __accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj);
|
|
56738
|
-
};
|
|
56739
|
-
var __privateAdd = function(obj, member, value) {
|
|
56740
|
-
return member.has(obj) ? __typeError("Cannot add the same private member more than once") : _instanceof(member, WeakSet) ? member.add(obj) : member.set(obj, value);
|
|
56741
|
-
};
|
|
56742
|
-
var __privateSet = function(obj, member, value, setter) {
|
|
56743
|
-
return __accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value;
|
|
56744
|
-
};
|
|
56745
|
-
// src/index.ts
|
|
56746
|
-
var to_string = function(obj) {
|
|
56747
|
-
return Object.prototype.toString.call(obj);
|
|
56748
|
-
};
|
|
56749
|
-
var is_typed_array = function(value) {
|
|
56750
|
-
return ArrayBuffer.isView(value) && !_instanceof(value, DataView);
|
|
56751
|
-
};
|
|
56752
|
-
var is_date = function(obj) {
|
|
56753
|
-
return to_string(obj) === "[object Date]";
|
|
56754
|
-
};
|
|
56755
|
-
var is_regexp = function(obj) {
|
|
56756
|
-
return to_string(obj) === "[object RegExp]";
|
|
56757
|
-
};
|
|
56758
|
-
var is_error = function(obj) {
|
|
56759
|
-
return to_string(obj) === "[object Error]";
|
|
56760
|
-
};
|
|
56761
|
-
var is_boolean = function(obj) {
|
|
56762
|
-
return to_string(obj) === "[object Boolean]";
|
|
56763
|
-
};
|
|
56764
|
-
var is_number = function(obj) {
|
|
56765
|
-
return to_string(obj) === "[object Number]";
|
|
56766
|
-
};
|
|
56767
|
-
var is_string = function(obj) {
|
|
56768
|
-
return to_string(obj) === "[object String]";
|
|
56769
|
-
};
|
|
56770
|
-
var is_array = Array.isArray;
|
|
56771
|
-
var gopd = Object.getOwnPropertyDescriptor;
|
|
56772
|
-
var is_property_enumerable = Object.prototype.propertyIsEnumerable;
|
|
56773
|
-
var get_own_property_symbols = Object.getOwnPropertySymbols;
|
|
56774
|
-
var has_own_property = Object.prototype.hasOwnProperty;
|
|
56775
56745
|
function own_enumerable_keys(obj) {
|
|
56776
|
-
|
|
56777
|
-
|
|
56778
|
-
|
|
56779
|
-
|
|
56780
|
-
res.push(symbols[i]);
|
|
56781
|
-
}
|
|
56782
|
-
}
|
|
56783
|
-
return res;
|
|
56746
|
+
const res = Object.keys(obj);
|
|
56747
|
+
const symbols = get_own_property_symbols(obj);
|
|
56748
|
+
for (let i = 0; i < symbols.length; i++) if (is_property_enumerable.call(obj, symbols[i])) res.push(symbols[i]);
|
|
56749
|
+
return res;
|
|
56784
56750
|
}
|
|
56785
|
-
function
|
|
56786
|
-
|
|
56787
|
-
|
|
56751
|
+
function is_non_writable(object, key) {
|
|
56752
|
+
var _gopd;
|
|
56753
|
+
return !((_gopd = gopd(object, key)) === null || _gopd === void 0 ? void 0 : _gopd.writable);
|
|
56788
56754
|
}
|
|
56789
56755
|
function copy(src, options) {
|
|
56790
|
-
|
|
56791
|
-
|
|
56792
|
-
|
|
56793
|
-
|
|
56794
|
-
|
|
56795
|
-
|
|
56796
|
-
|
|
56797
|
-
|
|
56798
|
-
|
|
56799
|
-
|
|
56800
|
-
|
|
56801
|
-
|
|
56802
|
-
|
|
56803
|
-
|
|
56804
|
-
|
|
56805
|
-
|
|
56806
|
-
|
|
56807
|
-
dst = Object.create(Object.getPrototypeOf(src));
|
|
56808
|
-
}
|
|
56809
|
-
var iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
|
56810
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
56811
|
-
try {
|
|
56812
|
-
for(var _iterator = iterator_function(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
56813
|
-
var key = _step.value;
|
|
56814
|
-
dst[key] = src[key];
|
|
56815
|
-
}
|
|
56816
|
-
} catch (err) {
|
|
56817
|
-
_didIteratorError = true;
|
|
56818
|
-
_iteratorError = err;
|
|
56819
|
-
} finally{
|
|
56820
|
-
try {
|
|
56821
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
56822
|
-
_iterator.return();
|
|
56823
|
-
}
|
|
56824
|
-
} finally{
|
|
56825
|
-
if (_didIteratorError) {
|
|
56826
|
-
throw _iteratorError;
|
|
56827
|
-
}
|
|
56828
|
-
}
|
|
56829
|
-
}
|
|
56830
|
-
return dst;
|
|
56831
|
-
}
|
|
56832
|
-
return src;
|
|
56756
|
+
if (typeof src === "object" && src !== null) {
|
|
56757
|
+
let dst;
|
|
56758
|
+
if (is_array(src)) dst = [];
|
|
56759
|
+
else if (is_typed_array(src)) return src.slice();
|
|
56760
|
+
else if (is_boxed_primitive(src)) return Object(src);
|
|
56761
|
+
else {
|
|
56762
|
+
const tag = to_string(src);
|
|
56763
|
+
if (tag === "[object Date]" && typeof src.getTime === "function") dst = new Date(src.getTime());
|
|
56764
|
+
else if (tag === "[object RegExp]" && typeof src.source === "string") dst = new RegExp(src);
|
|
56765
|
+
else if (tag === "[object Error]") dst = { message: src.message };
|
|
56766
|
+
else dst = Object.create(Object.getPrototypeOf(src));
|
|
56767
|
+
}
|
|
56768
|
+
const iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
|
56769
|
+
for (const key of iterator_function(src)) safe_set(dst, key, src[key]);
|
|
56770
|
+
return dst;
|
|
56771
|
+
}
|
|
56772
|
+
return src;
|
|
56833
56773
|
}
|
|
56834
|
-
|
|
56835
|
-
|
|
56836
|
-
|
|
56774
|
+
const empty_null = {
|
|
56775
|
+
includeSymbols: false,
|
|
56776
|
+
immutable: false
|
|
56837
56777
|
};
|
|
56838
|
-
function walk(root, cb) {
|
|
56839
|
-
|
|
56840
|
-
|
|
56841
|
-
|
|
56842
|
-
|
|
56843
|
-
|
|
56844
|
-
|
|
56845
|
-
|
|
56846
|
-
|
|
56847
|
-
|
|
56848
|
-
|
|
56849
|
-
|
|
56850
|
-
|
|
56851
|
-
|
|
56852
|
-
|
|
56853
|
-
|
|
56854
|
-
|
|
56855
|
-
|
|
56856
|
-
|
|
56857
|
-
|
|
56858
|
-
|
|
56859
|
-
|
|
56860
|
-
|
|
56861
|
-
|
|
56862
|
-
|
|
56863
|
-
|
|
56864
|
-
|
|
56865
|
-
|
|
56866
|
-
|
|
56867
|
-
|
|
56868
|
-
|
|
56869
|
-
|
|
56870
|
-
|
|
56871
|
-
|
|
56872
|
-
|
|
56873
|
-
|
|
56874
|
-
|
|
56875
|
-
|
|
56876
|
-
|
|
56877
|
-
|
|
56878
|
-
|
|
56879
|
-
|
|
56880
|
-
|
|
56881
|
-
|
|
56882
|
-
|
|
56883
|
-
|
|
56884
|
-
|
|
56885
|
-
|
|
56886
|
-
|
|
56887
|
-
|
|
56888
|
-
|
|
56889
|
-
|
|
56890
|
-
|
|
56891
|
-
|
|
56892
|
-
|
|
56893
|
-
|
|
56894
|
-
|
|
56895
|
-
|
|
56896
|
-
|
|
56897
|
-
|
|
56898
|
-
|
|
56899
|
-
|
|
56900
|
-
|
|
56901
|
-
|
|
56902
|
-
|
|
56903
|
-
|
|
56904
|
-
|
|
56905
|
-
|
|
56906
|
-
|
|
56907
|
-
|
|
56908
|
-
|
|
56909
|
-
|
|
56910
|
-
|
|
56911
|
-
|
|
56912
|
-
|
|
56913
|
-
|
|
56914
|
-
|
|
56915
|
-
|
|
56916
|
-
|
|
56917
|
-
|
|
56918
|
-
|
|
56919
|
-
|
|
56920
|
-
|
|
56921
|
-
|
|
56922
|
-
|
|
56923
|
-
|
|
56924
|
-
|
|
56925
|
-
|
|
56926
|
-
|
|
56927
|
-
|
|
56928
|
-
|
|
56929
|
-
|
|
56930
|
-
|
|
56931
|
-
|
|
56932
|
-
|
|
56933
|
-
|
|
56934
|
-
|
|
56935
|
-
|
|
56936
|
-
|
|
56937
|
-
|
|
56938
|
-
|
|
56939
|
-
|
|
56940
|
-
|
|
56941
|
-
|
|
56942
|
-
|
|
56943
|
-
|
|
56944
|
-
|
|
56945
|
-
|
|
56946
|
-
|
|
56947
|
-
|
|
56948
|
-
|
|
56949
|
-
|
|
56950
|
-
|
|
56951
|
-
|
|
56952
|
-
|
|
56953
|
-
|
|
56954
|
-
|
|
56955
|
-
|
|
56956
|
-
|
|
56957
|
-
|
|
56958
|
-
|
|
56959
|
-
|
|
56960
|
-
|
|
56961
|
-
|
|
56962
|
-
|
|
56963
|
-
|
|
56964
|
-
|
|
56965
|
-
|
|
56966
|
-
|
|
56967
|
-
|
|
56968
|
-
|
|
56969
|
-
|
|
56970
|
-
|
|
56971
|
-
|
|
56972
|
-
|
|
56973
|
-
|
|
56974
|
-
|
|
56975
|
-
|
|
56976
|
-
|
|
56977
|
-
|
|
56978
|
-
|
|
56979
|
-
|
|
56980
|
-
|
|
56981
|
-
|
|
56982
|
-
|
|
56983
|
-
|
|
56984
|
-
|
|
56985
|
-
|
|
56986
|
-
|
|
56987
|
-
|
|
56988
|
-
|
|
56989
|
-
|
|
56990
|
-
|
|
56991
|
-
|
|
56992
|
-
|
|
56993
|
-
|
|
56994
|
-
|
|
56995
|
-
|
|
56996
|
-
|
|
56997
|
-
|
|
56998
|
-
|
|
56999
|
-
|
|
57000
|
-
|
|
57001
|
-
|
|
57002
|
-
|
|
57003
|
-
|
|
57004
|
-
|
|
57005
|
-
|
|
57006
|
-
|
|
57007
|
-
|
|
57008
|
-
|
|
57009
|
-
|
|
57010
|
-
|
|
57011
|
-
|
|
57012
|
-
|
|
57013
|
-
|
|
57014
|
-
|
|
57015
|
-
|
|
57016
|
-
|
|
57017
|
-
|
|
57018
|
-
|
|
57019
|
-
|
|
57020
|
-
|
|
57021
|
-
|
|
57022
|
-
|
|
57023
|
-
|
|
57024
|
-
|
|
57025
|
-
|
|
57026
|
-
|
|
57027
|
-
|
|
57028
|
-
|
|
57029
|
-
|
|
57030
|
-
|
|
57031
|
-
|
|
57032
|
-
|
|
57033
|
-
|
|
57034
|
-
|
|
57035
|
-
|
|
57036
|
-
|
|
57037
|
-
|
|
57038
|
-
|
|
57039
|
-
|
|
57040
|
-
|
|
57041
|
-
|
|
57042
|
-
|
|
57043
|
-
|
|
57044
|
-
|
|
57045
|
-
|
|
57046
|
-
|
|
57047
|
-
|
|
57048
|
-
|
|
57049
|
-
|
|
57050
|
-
|
|
57051
|
-
|
|
57052
|
-
|
|
57053
|
-
|
|
57054
|
-
|
|
57055
|
-
|
|
57056
|
-
|
|
57057
|
-
|
|
57058
|
-
|
|
57059
|
-
|
|
57060
|
-
|
|
57061
|
-
|
|
57062
|
-
|
|
57063
|
-
|
|
57064
|
-
|
|
57065
|
-
|
|
57066
|
-
|
|
57067
|
-
|
|
57068
|
-
|
|
57069
|
-
|
|
57070
|
-
|
|
57071
|
-
|
|
57072
|
-
|
|
57073
|
-
|
|
57074
|
-
|
|
57075
|
-
|
|
57076
|
-
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
|
|
57081
|
-
|
|
57082
|
-
|
|
57083
|
-
|
|
57084
|
-
|
|
57085
|
-
|
|
57086
|
-
|
|
57087
|
-
}
|
|
57088
|
-
},
|
|
57089
|
-
{
|
|
57090
|
-
/**
|
|
57091
|
-
* Return an `Array` of every possible non-cyclic path in the object.
|
|
57092
|
-
* Paths are `Array`s of string keys.
|
|
57093
|
-
*/ key: "paths",
|
|
57094
|
-
value: function paths() {
|
|
57095
|
-
var acc = [];
|
|
57096
|
-
this.forEach(function() {
|
|
57097
|
-
acc.push(this.path);
|
|
57098
|
-
});
|
|
57099
|
-
return acc;
|
|
57100
|
-
}
|
|
57101
|
-
},
|
|
57102
|
-
{
|
|
57103
|
-
/**
|
|
57104
|
-
* Return an `Array` of every node in the object.
|
|
57105
|
-
*/ key: "nodes",
|
|
57106
|
-
value: function nodes() {
|
|
57107
|
-
var acc = [];
|
|
57108
|
-
this.forEach(function() {
|
|
57109
|
-
acc.push(this.node);
|
|
57110
|
-
});
|
|
57111
|
-
return acc;
|
|
57112
|
-
}
|
|
57113
|
-
},
|
|
57114
|
-
{
|
|
57115
|
-
/**
|
|
57116
|
-
* Create a deep clone of the object.
|
|
57117
|
-
*/ key: "clone",
|
|
57118
|
-
value: function clone() {
|
|
57119
|
-
var parents = [];
|
|
57120
|
-
var nodes = [];
|
|
57121
|
-
var options = __privateGet(this, _options);
|
|
57122
|
-
if (is_typed_array(__privateGet(this, _value))) {
|
|
57123
|
-
return __privateGet(this, _value).slice();
|
|
57124
|
-
}
|
|
57125
|
-
return function clone(src) {
|
|
57126
|
-
for(var i = 0; i < parents.length; i++){
|
|
57127
|
-
if (parents[i] === src) {
|
|
57128
|
-
return nodes[i];
|
|
57129
|
-
}
|
|
57130
|
-
}
|
|
57131
|
-
if ((typeof src === "undefined" ? "undefined" : _type_of(src)) === "object" && src !== null) {
|
|
57132
|
-
var dst = copy(src, options);
|
|
57133
|
-
parents.push(src);
|
|
57134
|
-
nodes.push(dst);
|
|
57135
|
-
var iteratorFunction = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
|
57136
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
57137
|
-
try {
|
|
57138
|
-
for(var _iterator = iteratorFunction(src)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
57139
|
-
var key = _step.value;
|
|
57140
|
-
dst[key] = clone(src[key]);
|
|
57141
|
-
}
|
|
57142
|
-
} catch (err) {
|
|
57143
|
-
_didIteratorError = true;
|
|
57144
|
-
_iteratorError = err;
|
|
57145
|
-
} finally{
|
|
57146
|
-
try {
|
|
57147
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
57148
|
-
_iterator.return();
|
|
57149
|
-
}
|
|
57150
|
-
} finally{
|
|
57151
|
-
if (_didIteratorError) {
|
|
57152
|
-
throw _iteratorError;
|
|
57153
|
-
}
|
|
57154
|
-
}
|
|
57155
|
-
}
|
|
57156
|
-
parents.pop();
|
|
57157
|
-
nodes.pop();
|
|
57158
|
-
return dst;
|
|
57159
|
-
}
|
|
57160
|
-
return src;
|
|
57161
|
-
}(__privateGet(this, _value));
|
|
57162
|
-
}
|
|
57163
|
-
}
|
|
57164
|
-
]);
|
|
57165
|
-
return Traverse;
|
|
57166
|
-
}();
|
|
57167
|
-
_value = new WeakMap();
|
|
57168
|
-
_options = new WeakMap();
|
|
57169
|
-
var traverse = function(obj, options) {
|
|
57170
|
-
return new Traverse(obj, options);
|
|
56778
|
+
function walk(root, cb, options = empty_null) {
|
|
56779
|
+
const path = [];
|
|
56780
|
+
const parents = [];
|
|
56781
|
+
let alive = true;
|
|
56782
|
+
const iterator_function = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
|
56783
|
+
const immutable = !!options.immutable;
|
|
56784
|
+
const max_depth = options.maxDepth;
|
|
56785
|
+
return (function walker(node_) {
|
|
56786
|
+
assert_within_depth(path.length, max_depth);
|
|
56787
|
+
const node = immutable ? copy(node_, options) : node_;
|
|
56788
|
+
const modifiers = {};
|
|
56789
|
+
let keep_going = true;
|
|
56790
|
+
const state = {
|
|
56791
|
+
node,
|
|
56792
|
+
node_,
|
|
56793
|
+
path: path.slice(),
|
|
56794
|
+
parent: parents[parents.length - 1],
|
|
56795
|
+
parents,
|
|
56796
|
+
key: path[path.length - 1],
|
|
56797
|
+
isRoot: path.length === 0,
|
|
56798
|
+
level: path.length,
|
|
56799
|
+
circular: void 0,
|
|
56800
|
+
isLeaf: false,
|
|
56801
|
+
notLeaf: true,
|
|
56802
|
+
notRoot: true,
|
|
56803
|
+
isFirst: false,
|
|
56804
|
+
isLast: false,
|
|
56805
|
+
update: function(x, stopHere = false) {
|
|
56806
|
+
if (!state.isRoot) safe_set(state.parent.node, state.key, x);
|
|
56807
|
+
state.node = x;
|
|
56808
|
+
if (stopHere) keep_going = false;
|
|
56809
|
+
},
|
|
56810
|
+
delete: function(stopHere) {
|
|
56811
|
+
delete state.parent.node[state.key];
|
|
56812
|
+
if (stopHere) keep_going = false;
|
|
56813
|
+
},
|
|
56814
|
+
remove: function(stopHere) {
|
|
56815
|
+
if (is_array(state.parent.node)) state.parent.node.splice(state.key, 1);
|
|
56816
|
+
else delete state.parent.node[state.key];
|
|
56817
|
+
if (stopHere) keep_going = false;
|
|
56818
|
+
},
|
|
56819
|
+
keys: null,
|
|
56820
|
+
before: function(f) {
|
|
56821
|
+
modifiers.before = f;
|
|
56822
|
+
},
|
|
56823
|
+
after: function(f) {
|
|
56824
|
+
modifiers.after = f;
|
|
56825
|
+
},
|
|
56826
|
+
pre: function(f) {
|
|
56827
|
+
modifiers.pre = f;
|
|
56828
|
+
},
|
|
56829
|
+
post: function(f) {
|
|
56830
|
+
modifiers.post = f;
|
|
56831
|
+
},
|
|
56832
|
+
stop: function() {
|
|
56833
|
+
alive = false;
|
|
56834
|
+
},
|
|
56835
|
+
block: function() {
|
|
56836
|
+
keep_going = false;
|
|
56837
|
+
}
|
|
56838
|
+
};
|
|
56839
|
+
if (!alive) return state;
|
|
56840
|
+
function update_state() {
|
|
56841
|
+
if (typeof state.node === "object" && state.node !== null) {
|
|
56842
|
+
if (!state.keys || state.node_ !== state.node) state.keys = iterator_function(state.node);
|
|
56843
|
+
state.isLeaf = state.keys.length === 0;
|
|
56844
|
+
for (let i = 0; i < parents.length; i++) if (parents[i].node_ === node_) {
|
|
56845
|
+
state.circular = parents[i];
|
|
56846
|
+
break;
|
|
56847
|
+
}
|
|
56848
|
+
} else {
|
|
56849
|
+
state.isLeaf = true;
|
|
56850
|
+
state.keys = null;
|
|
56851
|
+
}
|
|
56852
|
+
state.notLeaf = !state.isLeaf;
|
|
56853
|
+
state.notRoot = !state.isRoot;
|
|
56854
|
+
}
|
|
56855
|
+
update_state();
|
|
56856
|
+
const ret = cb.call(state, state.node);
|
|
56857
|
+
if (ret !== void 0 && state.update) state.update(ret);
|
|
56858
|
+
if (modifiers.before) modifiers.before.call(state, state.node);
|
|
56859
|
+
if (!keep_going) return state;
|
|
56860
|
+
if (typeof state.node === "object" && state.node !== null && !state.circular) {
|
|
56861
|
+
var _state$keys;
|
|
56862
|
+
parents.push(state);
|
|
56863
|
+
update_state();
|
|
56864
|
+
const keys = (_state$keys = state.keys) !== null && _state$keys !== void 0 ? _state$keys : [];
|
|
56865
|
+
for (let index = 0; index < keys.length; index++) {
|
|
56866
|
+
const key = keys[index];
|
|
56867
|
+
path.push(key);
|
|
56868
|
+
if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
|
|
56869
|
+
const child = walker(state.node[key]);
|
|
56870
|
+
if (immutable && has_own_property.call(state.node, key) && !is_non_writable(state.node, key)) safe_set(state.node, key, child.node);
|
|
56871
|
+
child.isLast = index === keys.length - 1;
|
|
56872
|
+
child.isFirst = index === 0;
|
|
56873
|
+
if (modifiers.post) modifiers.post.call(state, child);
|
|
56874
|
+
path.pop();
|
|
56875
|
+
}
|
|
56876
|
+
parents.pop();
|
|
56877
|
+
}
|
|
56878
|
+
if (modifiers.after) modifiers.after.call(state, state.node);
|
|
56879
|
+
return state;
|
|
56880
|
+
})(root).node;
|
|
56881
|
+
}
|
|
56882
|
+
/**
|
|
56883
|
+
* @deprecated Import `Traverse` from `neotraverse/modern` instead
|
|
56884
|
+
*
|
|
56885
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56886
|
+
*/
|
|
56887
|
+
var Traverse = class {
|
|
56888
|
+
constructor(obj, options = empty_null) {
|
|
56889
|
+
this._value = obj;
|
|
56890
|
+
this._options = options;
|
|
56891
|
+
}
|
|
56892
|
+
/**
|
|
56893
|
+
* Get the element at the array `path`.
|
|
56894
|
+
*
|
|
56895
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56896
|
+
*/
|
|
56897
|
+
get(paths) {
|
|
56898
|
+
let node = this._value;
|
|
56899
|
+
for (let i = 0; node && i < paths.length; i++) {
|
|
56900
|
+
const key = paths[i];
|
|
56901
|
+
if (!has_own_property.call(node, key) || !this._options.includeSymbols && typeof key === "symbol") return;
|
|
56902
|
+
node = node[key];
|
|
56903
|
+
}
|
|
56904
|
+
return node;
|
|
56905
|
+
}
|
|
56906
|
+
/**
|
|
56907
|
+
* Return whether the element at the array `path` exists.
|
|
56908
|
+
*
|
|
56909
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56910
|
+
*/
|
|
56911
|
+
has(paths) {
|
|
56912
|
+
let node = this._value;
|
|
56913
|
+
for (let i = 0; node && i < paths.length; i++) {
|
|
56914
|
+
const key = paths[i];
|
|
56915
|
+
if (!has_own_property.call(node, key) || !this._options.includeSymbols && typeof key === "symbol") return false;
|
|
56916
|
+
node = node[key];
|
|
56917
|
+
}
|
|
56918
|
+
return true;
|
|
56919
|
+
}
|
|
56920
|
+
/**
|
|
56921
|
+
* Set the element at the array `path` to `value`.
|
|
56922
|
+
*
|
|
56923
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56924
|
+
*/
|
|
56925
|
+
set(path, value) {
|
|
56926
|
+
let node = this._value;
|
|
56927
|
+
let i = 0;
|
|
56928
|
+
for (i = 0; i < path.length - 1; i++) {
|
|
56929
|
+
const key = path[i];
|
|
56930
|
+
if (is_unsafe_key(key)) return value;
|
|
56931
|
+
if (!has_own_property.call(node, key)) node[key] = {};
|
|
56932
|
+
node = node[key];
|
|
56933
|
+
}
|
|
56934
|
+
if (is_unsafe_key(path[i])) return value;
|
|
56935
|
+
node[path[i]] = value;
|
|
56936
|
+
return value;
|
|
56937
|
+
}
|
|
56938
|
+
/**
|
|
56939
|
+
* Execute `fn` for each node in the object and return a new object with the results of the walk. To update nodes in the result use `this.update(value)`.
|
|
56940
|
+
*
|
|
56941
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56942
|
+
*/
|
|
56943
|
+
map(cb) {
|
|
56944
|
+
return walk(this._value, cb, {
|
|
56945
|
+
immutable: true,
|
|
56946
|
+
includeSymbols: !!this._options.includeSymbols,
|
|
56947
|
+
maxDepth: this._options.maxDepth
|
|
56948
|
+
});
|
|
56949
|
+
}
|
|
56950
|
+
/**
|
|
56951
|
+
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
|
56952
|
+
*
|
|
56953
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56954
|
+
*/
|
|
56955
|
+
forEach(cb) {
|
|
56956
|
+
this._value = walk(this._value, cb, this._options);
|
|
56957
|
+
return this._value;
|
|
56958
|
+
}
|
|
56959
|
+
/**
|
|
56960
|
+
* For each node in the object, perform a [left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) with the return value of `fn(acc, node)`.
|
|
56961
|
+
*
|
|
56962
|
+
* If `init` isn't specified, `init` is set to the root object for the first step and the root element is skipped.
|
|
56963
|
+
*
|
|
56964
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56965
|
+
*/
|
|
56966
|
+
reduce(cb, init) {
|
|
56967
|
+
const skip = arguments.length === 1;
|
|
56968
|
+
let acc = skip ? this._value : init;
|
|
56969
|
+
this.forEach(function(x) {
|
|
56970
|
+
if (!this.isRoot || !skip) acc = cb.call(this, acc, x);
|
|
56971
|
+
});
|
|
56972
|
+
return acc;
|
|
56973
|
+
}
|
|
56974
|
+
/**
|
|
56975
|
+
* Return an `Array` of every possible non-cyclic path in the object.
|
|
56976
|
+
* Paths are `Array`s of string keys.
|
|
56977
|
+
*
|
|
56978
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56979
|
+
*/
|
|
56980
|
+
paths() {
|
|
56981
|
+
const acc = [];
|
|
56982
|
+
this.forEach(function() {
|
|
56983
|
+
acc.push(this.path);
|
|
56984
|
+
});
|
|
56985
|
+
return acc;
|
|
56986
|
+
}
|
|
56987
|
+
/**
|
|
56988
|
+
* Return an `Array` of every node in the object.
|
|
56989
|
+
*
|
|
56990
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
56991
|
+
*/
|
|
56992
|
+
nodes() {
|
|
56993
|
+
const acc = [];
|
|
56994
|
+
this.forEach(function() {
|
|
56995
|
+
acc.push(this.node);
|
|
56996
|
+
});
|
|
56997
|
+
return acc;
|
|
56998
|
+
}
|
|
56999
|
+
/**
|
|
57000
|
+
* Create a deep clone of the object.
|
|
57001
|
+
*
|
|
57002
|
+
* @see https://neotraverse.puruvj.dev/legacy.html#methods
|
|
57003
|
+
*/
|
|
57004
|
+
clone() {
|
|
57005
|
+
const parents = [];
|
|
57006
|
+
const nodes = [];
|
|
57007
|
+
const options = this._options;
|
|
57008
|
+
const max_depth = options.maxDepth;
|
|
57009
|
+
if (is_typed_array(this._value)) return this._value.slice();
|
|
57010
|
+
return (function clone(src) {
|
|
57011
|
+
assert_within_depth(parents.length, max_depth);
|
|
57012
|
+
for (let i = 0; i < parents.length; i++) if (parents[i] === src) return nodes[i];
|
|
57013
|
+
if (typeof src === "object" && src !== null) {
|
|
57014
|
+
const dst = copy(src, options);
|
|
57015
|
+
if (is_typed_array(src) || is_boxed_primitive(src)) return dst;
|
|
57016
|
+
parents.push(src);
|
|
57017
|
+
nodes.push(dst);
|
|
57018
|
+
const iteratorFunction = options.includeSymbols ? own_enumerable_keys : Object.keys;
|
|
57019
|
+
for (const key of iteratorFunction(src)) safe_set(dst, key, clone(src[key]));
|
|
57020
|
+
parents.pop();
|
|
57021
|
+
nodes.pop();
|
|
57022
|
+
return dst;
|
|
57023
|
+
}
|
|
57024
|
+
return src;
|
|
57025
|
+
})(this._value);
|
|
57026
|
+
}
|
|
57171
57027
|
};
|
|
57172
|
-
traverse
|
|
57173
|
-
|
|
57028
|
+
const traverse = (obj, options) => {
|
|
57029
|
+
return new Traverse(obj, options);
|
|
57174
57030
|
};
|
|
57175
|
-
|
|
57176
|
-
|
|
57031
|
+
/**
|
|
57032
|
+
* Get the element at the array `path`.
|
|
57033
|
+
*
|
|
57034
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#get
|
|
57035
|
+
*/
|
|
57036
|
+
traverse.get = (obj, paths, options) => {
|
|
57037
|
+
return new Traverse(obj, options).get(paths);
|
|
57177
57038
|
};
|
|
57178
|
-
|
|
57179
|
-
|
|
57039
|
+
/**
|
|
57040
|
+
* Set the element at the array `path` to `value`.
|
|
57041
|
+
*
|
|
57042
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#get
|
|
57043
|
+
*/
|
|
57044
|
+
traverse.set = (obj, path, value, options) => {
|
|
57045
|
+
return new Traverse(obj, options).set(path, value);
|
|
57180
57046
|
};
|
|
57181
|
-
|
|
57182
|
-
|
|
57047
|
+
/**
|
|
57048
|
+
* Return whether the element at the array `path` exists.
|
|
57049
|
+
*
|
|
57050
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#get
|
|
57051
|
+
*/
|
|
57052
|
+
traverse.has = (obj, paths, options) => {
|
|
57053
|
+
return new Traverse(obj, options).has(paths);
|
|
57183
57054
|
};
|
|
57184
|
-
|
|
57185
|
-
|
|
57055
|
+
/**
|
|
57056
|
+
* Execute `fn` for each node in the object and return a new object with the results of the walk. To update nodes in the result use `this.update(value)`.
|
|
57057
|
+
*
|
|
57058
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#map
|
|
57059
|
+
*/
|
|
57060
|
+
traverse.map = (obj, cb, options) => {
|
|
57061
|
+
return new Traverse(obj, options).map(cb);
|
|
57186
57062
|
};
|
|
57187
|
-
|
|
57188
|
-
|
|
57063
|
+
/**
|
|
57064
|
+
* Execute `fn` for each node in the object but unlike `.map()`, when `this.update()` is called it updates the object in-place.
|
|
57065
|
+
*
|
|
57066
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#forEach
|
|
57067
|
+
*/
|
|
57068
|
+
traverse.forEach = (obj, cb, options) => {
|
|
57069
|
+
return new Traverse(obj, options).forEach(cb);
|
|
57189
57070
|
};
|
|
57190
|
-
|
|
57191
|
-
|
|
57071
|
+
/**
|
|
57072
|
+
* For each node in the object, perform a [left-fold](http://en.wikipedia.org/wiki/Fold_(higher-order_function)) with the return value of `fn(acc, node)`.
|
|
57073
|
+
*
|
|
57074
|
+
* If `init` isn't specified, `init` is set to the root object for the first step and the root element is skipped.
|
|
57075
|
+
*
|
|
57076
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#reduce
|
|
57077
|
+
*/
|
|
57078
|
+
traverse.reduce = (obj, cb, init, options) => {
|
|
57079
|
+
return new Traverse(obj, options).reduce(cb, init);
|
|
57192
57080
|
};
|
|
57193
|
-
|
|
57194
|
-
|
|
57081
|
+
/**
|
|
57082
|
+
* Return an `Array` of every possible non-cyclic path in the object.
|
|
57083
|
+
* Paths are `Array`s of string keys.
|
|
57084
|
+
*
|
|
57085
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#paths
|
|
57086
|
+
*/
|
|
57087
|
+
traverse.paths = (obj, options) => {
|
|
57088
|
+
return new Traverse(obj, options).paths();
|
|
57195
57089
|
};
|
|
57196
|
-
|
|
57197
|
-
|
|
57090
|
+
/**
|
|
57091
|
+
* Return an `Array` of every node in the object.
|
|
57092
|
+
*
|
|
57093
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#paths
|
|
57094
|
+
*/
|
|
57095
|
+
traverse.nodes = (obj, options) => {
|
|
57096
|
+
return new Traverse(obj, options).nodes();
|
|
57198
57097
|
};
|
|
57199
|
-
|
|
57200
|
-
|
|
57098
|
+
/**
|
|
57099
|
+
* Create a deep clone of the object.
|
|
57100
|
+
*
|
|
57101
|
+
* @see https://neotraverse.puruvj.dev/guide/api/core.html#clone
|
|
57102
|
+
*/
|
|
57103
|
+
traverse.clone = (obj, options) => {
|
|
57104
|
+
return new Traverse(obj, options).clone();
|
|
57105
|
+
};
|
|
57106
|
+
|
|
57107
|
+
//#endregion
|
|
57108
|
+
//#region packages/neotraverse/src/legacy/legacy.cts
|
|
57201
57109
|
|
|
57202
57110
|
|
|
57111
|
+
//#endregion
|
|
57203
57112
|
|
|
57204
57113
|
|
|
57205
57114
|
/***/ },
|
|
@@ -66454,18 +66363,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
66454
66363
|
/* harmony import */ var _resolver_strategies_openapi_3_2_apidom_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(12359);
|
|
66455
66364
|
/* harmony import */ var _interfaces_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(77281);
|
|
66456
66365
|
/* harmony import */ var _execute_index_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(32729);
|
|
66457
|
-
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(
|
|
66458
|
-
/* harmony import */ var
|
|
66459
|
-
/* harmony import */ var
|
|
66460
|
-
/* harmony import */ var
|
|
66461
|
-
/* harmony import */ var
|
|
66462
|
-
/* harmony import */ var
|
|
66463
|
-
/* harmony import */ var
|
|
66464
|
-
/* harmony import */ var
|
|
66465
|
-
/* harmony import */ var
|
|
66466
|
-
/* harmony import */ var
|
|
66467
|
-
/* harmony import */ var
|
|
66468
|
-
/* harmony import */ var _resolver_apidom_reference_dereference_strategies_openapi_3_2_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(12315);
|
|
66366
|
+
/* harmony import */ var _helpers_index_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(55971);
|
|
66367
|
+
/* harmony import */ var _helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(50918);
|
|
66368
|
+
/* harmony import */ var _resolver_apidom_reference_resolve_resolvers_http_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(636);
|
|
66369
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_json_index_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(92263);
|
|
66370
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_yaml_1_2_index_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(12787);
|
|
66371
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_openapi_json_3_1_index_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(89742);
|
|
66372
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_openapi_yaml_3_1_index_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(49575);
|
|
66373
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_openapi_json_3_2_index_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(90643);
|
|
66374
|
+
/* harmony import */ var _resolver_apidom_reference_parse_parsers_openapi_yaml_3_2_index_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(93282);
|
|
66375
|
+
/* harmony import */ var _resolver_apidom_reference_dereference_strategies_openapi_3_1_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(13764);
|
|
66376
|
+
/* harmony import */ var _resolver_apidom_reference_dereference_strategies_openapi_3_2_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(12315);
|
|
66469
66377
|
/* eslint-disable camelcase */
|
|
66470
66378
|
|
|
66471
66379
|
|
|
@@ -66512,29 +66420,29 @@ Swagger.clearCache = _resolver_strategies_openapi_2_index_js__WEBPACK_IMPORTED_M
|
|
|
66512
66420
|
Swagger.makeApisTagOperation = _interfaces_js__WEBPACK_IMPORTED_MODULE_10__.makeApisTagOperation;
|
|
66513
66421
|
Swagger.buildRequest = _execute_index_js__WEBPACK_IMPORTED_MODULE_11__.buildRequest;
|
|
66514
66422
|
Swagger.helpers = {
|
|
66515
|
-
opId: _helpers_index_js__WEBPACK_IMPORTED_MODULE_12__
|
|
66423
|
+
opId: _helpers_index_js__WEBPACK_IMPORTED_MODULE_12__.opId
|
|
66516
66424
|
};
|
|
66517
66425
|
Swagger.getBaseUrl = _execute_index_js__WEBPACK_IMPORTED_MODULE_11__.baseUrl;
|
|
66518
66426
|
Swagger.apidom = {
|
|
66519
66427
|
resolve: {
|
|
66520
66428
|
resolvers: {
|
|
66521
|
-
HTTPResolverSwaggerClient:
|
|
66429
|
+
HTTPResolverSwaggerClient: _resolver_apidom_reference_resolve_resolvers_http_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_14__["default"]
|
|
66522
66430
|
}
|
|
66523
66431
|
},
|
|
66524
66432
|
parse: {
|
|
66525
66433
|
parsers: {
|
|
66526
|
-
JsonParser:
|
|
66527
|
-
YamlParser:
|
|
66528
|
-
OpenApiJson3_1Parser:
|
|
66529
|
-
OpenApiYaml3_1Parser:
|
|
66530
|
-
OpenApiJson3_2Parser:
|
|
66531
|
-
OpenApiYaml3_2Parser:
|
|
66434
|
+
JsonParser: _resolver_apidom_reference_parse_parsers_json_index_js__WEBPACK_IMPORTED_MODULE_15__["default"],
|
|
66435
|
+
YamlParser: _resolver_apidom_reference_parse_parsers_yaml_1_2_index_js__WEBPACK_IMPORTED_MODULE_16__["default"],
|
|
66436
|
+
OpenApiJson3_1Parser: _resolver_apidom_reference_parse_parsers_openapi_json_3_1_index_js__WEBPACK_IMPORTED_MODULE_17__["default"],
|
|
66437
|
+
OpenApiYaml3_1Parser: _resolver_apidom_reference_parse_parsers_openapi_yaml_3_1_index_js__WEBPACK_IMPORTED_MODULE_18__["default"],
|
|
66438
|
+
OpenApiJson3_2Parser: _resolver_apidom_reference_parse_parsers_openapi_json_3_2_index_js__WEBPACK_IMPORTED_MODULE_19__["default"],
|
|
66439
|
+
OpenApiYaml3_2Parser: _resolver_apidom_reference_parse_parsers_openapi_yaml_3_2_index_js__WEBPACK_IMPORTED_MODULE_20__["default"]
|
|
66532
66440
|
}
|
|
66533
66441
|
},
|
|
66534
66442
|
dereference: {
|
|
66535
66443
|
strategies: {
|
|
66536
|
-
OpenApi3_1SwaggerClientDereferenceStrategy:
|
|
66537
|
-
OpenApi3_2SwaggerClientDereferenceStrategy:
|
|
66444
|
+
OpenApi3_1SwaggerClientDereferenceStrategy: _resolver_apidom_reference_dereference_strategies_openapi_3_1_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_21__["default"],
|
|
66445
|
+
OpenApi3_2SwaggerClientDereferenceStrategy: _resolver_apidom_reference_dereference_strategies_openapi_3_2_swagger_client_index_js__WEBPACK_IMPORTED_MODULE_22__["default"]
|
|
66538
66446
|
}
|
|
66539
66447
|
}
|
|
66540
66448
|
};
|
|
@@ -66601,7 +66509,7 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
|
|
|
66601
66509
|
spec
|
|
66602
66510
|
} = this;
|
|
66603
66511
|
const specUrl = this.url;
|
|
66604
|
-
if ((0,
|
|
66512
|
+
if ((0,_helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_13__.isOpenAPI2)(spec) && (0,_helpers_index_js__WEBPACK_IMPORTED_MODULE_12__.isHttpUrl)(specUrl)) {
|
|
66605
66513
|
const parsed = new URL(specUrl);
|
|
66606
66514
|
if (!spec.host) {
|
|
66607
66515
|
spec.host = parsed.host;
|
|
@@ -66612,7 +66520,7 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
|
|
|
66612
66520
|
if (!spec.basePath) {
|
|
66613
66521
|
spec.basePath = '/';
|
|
66614
66522
|
}
|
|
66615
|
-
} else if ((0,
|
|
66523
|
+
} else if ((0,_helpers_openapi_predicates_js__WEBPACK_IMPORTED_MODULE_13__.isOpenAPI3)(spec)) {
|
|
66616
66524
|
const isEmptyServerList = Array.isArray(spec.servers) && spec.servers.length === 0;
|
|
66617
66525
|
if (!spec.servers || isEmptyServerList) {
|
|
66618
66526
|
spec.servers = [_constants_js__WEBPACK_IMPORTED_MODULE_0__.DEFAULT_OPENAPI_3_SERVER];
|