@scalar/json-magic 0.4.3 → 0.5.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.
Files changed (106) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +10 -0
  3. package/dist/bundle/bundle.d.ts +0 -10
  4. package/dist/bundle/bundle.d.ts.map +1 -1
  5. package/dist/bundle/bundle.js +27 -29
  6. package/dist/bundle/bundle.js.map +2 -2
  7. package/dist/bundle/plugins/fetch-urls/index.d.ts.map +1 -1
  8. package/dist/bundle/plugins/fetch-urls/index.js +2 -2
  9. package/dist/bundle/plugins/fetch-urls/index.js.map +2 -2
  10. package/dist/bundle/plugins/parse-json/index.d.ts.map +1 -1
  11. package/dist/bundle/plugins/parse-json/index.js +1 -1
  12. package/dist/bundle/plugins/parse-json/index.js.map +2 -2
  13. package/dist/bundle/plugins/parse-yaml/index.d.ts.map +1 -1
  14. package/dist/bundle/plugins/parse-yaml/index.js +1 -1
  15. package/dist/bundle/plugins/parse-yaml/index.js.map +2 -2
  16. package/dist/bundle/plugins/read-files/index.d.ts.map +1 -1
  17. package/dist/bundle/plugins/read-files/index.js +1 -1
  18. package/dist/bundle/plugins/read-files/index.js.map +2 -2
  19. package/dist/helpers/convert-to-local-ref.d.ts +10 -0
  20. package/dist/helpers/convert-to-local-ref.d.ts.map +1 -0
  21. package/dist/helpers/convert-to-local-ref.js +26 -0
  22. package/dist/helpers/convert-to-local-ref.js.map +7 -0
  23. package/dist/helpers/escape-json-pointer.d.ts.map +1 -0
  24. package/dist/{utils → helpers}/escape-json-pointer.js.map +1 -1
  25. package/dist/helpers/get-schemas.d.ts +21 -0
  26. package/dist/helpers/get-schemas.d.ts.map +1 -0
  27. package/dist/helpers/get-schemas.js +37 -0
  28. package/dist/helpers/get-schemas.js.map +7 -0
  29. package/dist/helpers/get-segments-from-path.d.ts.map +1 -0
  30. package/dist/{utils → helpers}/get-segments-from-path.js.map +1 -1
  31. package/dist/helpers/get-value-by-path.d.ts +24 -0
  32. package/dist/helpers/get-value-by-path.d.ts.map +1 -0
  33. package/dist/helpers/get-value-by-path.js +23 -0
  34. package/dist/helpers/get-value-by-path.js.map +7 -0
  35. package/dist/helpers/is-json-object.d.ts.map +1 -0
  36. package/dist/{utils → helpers}/is-json-object.js +1 -1
  37. package/dist/helpers/is-json-object.js.map +7 -0
  38. package/dist/helpers/is-object.d.ts.map +1 -0
  39. package/dist/{utils → helpers}/is-object.js.map +1 -1
  40. package/dist/helpers/is-yaml.d.ts.map +1 -0
  41. package/dist/{utils → helpers}/is-yaml.js.map +1 -1
  42. package/dist/{utils → helpers}/json-path-utils.d.ts +0 -11
  43. package/dist/helpers/json-path-utils.d.ts.map +1 -0
  44. package/dist/{utils → helpers}/json-path-utils.js +0 -9
  45. package/dist/helpers/json-path-utils.js.map +7 -0
  46. package/dist/helpers/normalize.d.ts.map +1 -0
  47. package/dist/{utils → helpers}/normalize.js.map +1 -1
  48. package/dist/helpers/unescape-json-pointer.d.ts.map +1 -0
  49. package/dist/{utils → helpers}/unescape-json-pointer.js.map +1 -1
  50. package/dist/magic-proxy/proxy.d.ts +35 -10
  51. package/dist/magic-proxy/proxy.d.ts.map +1 -1
  52. package/dist/magic-proxy/proxy.js +40 -20
  53. package/dist/magic-proxy/proxy.js.map +2 -2
  54. package/esbuild.ts +1 -0
  55. package/package.json +6 -1
  56. package/src/bundle/bundle.test.ts +462 -25
  57. package/src/bundle/bundle.ts +37 -36
  58. package/src/bundle/plugins/fetch-urls/index.ts +2 -2
  59. package/src/bundle/plugins/parse-json/index.ts +1 -1
  60. package/src/bundle/plugins/parse-yaml/index.ts +3 -2
  61. package/src/bundle/plugins/read-files/index.ts +1 -1
  62. package/src/helpers/convert-to-local-ref.test.ts +211 -0
  63. package/src/helpers/convert-to-local-ref.ts +43 -0
  64. package/src/helpers/get-schemas.test.ts +356 -0
  65. package/src/helpers/get-schemas.ts +80 -0
  66. package/src/helpers/get-value-by-path.test.ts +338 -0
  67. package/src/helpers/get-value-by-path.ts +44 -0
  68. package/src/{utils → helpers}/is-json-object.ts +1 -1
  69. package/src/{utils → helpers}/json-path-utils.ts +0 -19
  70. package/src/{utils → helpers}/normalize.test.ts +2 -1
  71. package/src/magic-proxy/proxy.test.ts +548 -0
  72. package/src/magic-proxy/proxy.ts +80 -31
  73. package/dist/utils/escape-json-pointer.d.ts.map +0 -1
  74. package/dist/utils/get-segments-from-path.d.ts.map +0 -1
  75. package/dist/utils/is-json-object.d.ts.map +0 -1
  76. package/dist/utils/is-json-object.js.map +0 -7
  77. package/dist/utils/is-object.d.ts.map +0 -1
  78. package/dist/utils/is-yaml.d.ts.map +0 -1
  79. package/dist/utils/json-path-utils.d.ts.map +0 -1
  80. package/dist/utils/json-path-utils.js.map +0 -7
  81. package/dist/utils/normalize.d.ts.map +0 -1
  82. package/dist/utils/unescape-json-pointer.d.ts.map +0 -1
  83. /package/dist/{utils → helpers}/escape-json-pointer.d.ts +0 -0
  84. /package/dist/{utils → helpers}/escape-json-pointer.js +0 -0
  85. /package/dist/{utils → helpers}/get-segments-from-path.d.ts +0 -0
  86. /package/dist/{utils → helpers}/get-segments-from-path.js +0 -0
  87. /package/dist/{utils → helpers}/is-json-object.d.ts +0 -0
  88. /package/dist/{utils → helpers}/is-object.d.ts +0 -0
  89. /package/dist/{utils → helpers}/is-object.js +0 -0
  90. /package/dist/{utils → helpers}/is-yaml.d.ts +0 -0
  91. /package/dist/{utils → helpers}/is-yaml.js +0 -0
  92. /package/dist/{utils → helpers}/normalize.d.ts +0 -0
  93. /package/dist/{utils → helpers}/normalize.js +0 -0
  94. /package/dist/{utils → helpers}/unescape-json-pointer.d.ts +0 -0
  95. /package/dist/{utils → helpers}/unescape-json-pointer.js +0 -0
  96. /package/src/{utils → helpers}/escape-json-pointer.test.ts +0 -0
  97. /package/src/{utils → helpers}/escape-json-pointer.ts +0 -0
  98. /package/src/{utils → helpers}/get-segments-from-path.test.ts +0 -0
  99. /package/src/{utils → helpers}/get-segments-from-path.ts +0 -0
  100. /package/src/{utils → helpers}/is-object.test.ts +0 -0
  101. /package/src/{utils → helpers}/is-object.ts +0 -0
  102. /package/src/{utils → helpers}/is-yaml.ts +0 -0
  103. /package/src/{utils → helpers}/json-path-utils.test.ts +0 -0
  104. /package/src/{utils → helpers}/normalize.ts +0 -0
  105. /package/src/{utils → helpers}/unescape-json-pointer.test.ts +0 -0
  106. /package/src/{utils → helpers}/unescape-json-pointer.ts +0 -0
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "git+https://github.com/scalar/scalar.git",
11
11
  "directory": "packages/json-magic"
12
12
  },
13
- "version": "0.4.3",
13
+ "version": "0.5.0",
14
14
  "engines": {
15
15
  "node": ">=20"
16
16
  },
@@ -45,6 +45,11 @@
45
45
  "import": "./dist/magic-proxy/index.js",
46
46
  "types": "./dist/magic-proxy/index.d.ts",
47
47
  "default": "./dist/magic-proxy/index.js"
48
+ },
49
+ "./helpers/escape-json-pointer": {
50
+ "import": "./dist/helpers/escape-json-pointer.js",
51
+ "types": "./dist/helpers/escape-json-pointer.ts",
52
+ "default": "./dist/helpers/escape-json-pointer.js"
48
53
  }
49
54
  },
50
55
  "dependencies": {
@@ -1,25 +1,27 @@
1
1
  import { randomUUID } from 'node:crypto'
2
2
  import fs from 'node:fs/promises'
3
+ import { setTimeout } from 'node:timers/promises'
4
+
5
+ import { consoleWarnSpy, resetConsoleSpies } from '@scalar/helpers/testing/console-spies'
3
6
  import fastify, { type FastifyInstance } from 'fastify'
4
7
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
8
+ import YAML from 'yaml'
9
+
10
+ import { parseJson } from '@/bundle/plugins/parse-json'
11
+ import { parseYaml } from '@/bundle/plugins/parse-yaml'
12
+ import { getHash } from '@/bundle/value-generator'
13
+
5
14
  import {
15
+ type LoaderPlugin,
6
16
  bundle,
7
- getNestedValue,
8
17
  isLocalRef,
9
18
  isRemoteUrl,
10
19
  prefixInternalRef,
11
20
  prefixInternalRefRecursive,
12
21
  setValueAtPath,
13
- type LoaderPlugin,
14
22
  } from './bundle'
15
23
  import { fetchUrls } from './plugins/fetch-urls'
16
24
  import { readFiles } from './plugins/read-files'
17
- import { setTimeout } from 'node:timers/promises'
18
- import { parseJson } from '@/bundle/plugins/parse-json'
19
- import { parseYaml } from '@/bundle/plugins/parse-yaml'
20
- import YAML from 'yaml'
21
- import { getHash } from '@/bundle/value-generator'
22
- import { consoleWarnSpy, resetConsoleSpies } from '@scalar/helpers/testing/console-spies'
23
25
 
24
26
  describe('bundle', () => {
25
27
  describe('external urls', () => {
@@ -1102,18 +1104,18 @@ describe('bundle', () => {
1102
1104
  $ref: `${url}/external/document.json`,
1103
1105
  },
1104
1106
  b: {
1105
- $ref: `${url}/chunk2#`,
1107
+ $ref: `${url}/chunk2`,
1106
1108
  $global: true,
1107
1109
  },
1108
1110
  a: {
1109
- $ref: `${url}/chunk1#`,
1111
+ $ref: `${url}/chunk1`,
1110
1112
  $global: true,
1111
1113
  },
1112
1114
  entry: {
1113
1115
  $ref: '#/a',
1114
1116
  },
1115
1117
  nonBundle: {
1116
- $ref: `${url}/chunk1#`,
1118
+ $ref: `${url}/chunk1`,
1117
1119
  },
1118
1120
  }
1119
1121
 
@@ -1145,7 +1147,7 @@ describe('bundle', () => {
1145
1147
  $ref: '#/a',
1146
1148
  },
1147
1149
  nonBundle: {
1148
- $ref: `http://localhost:${port}/chunk1#`,
1150
+ $ref: `http://localhost:${port}/chunk1`,
1149
1151
  },
1150
1152
  'x-ext': {
1151
1153
  [await getHash(`${url}/external/document.json`)]: {
@@ -1325,6 +1327,448 @@ describe('bundle', () => {
1325
1327
  'x-ext': { e53b62c: { message: 'some resolved external reference' } },
1326
1328
  })
1327
1329
  })
1330
+
1331
+ it('does not modify external URLs when already defined by $id property', async () => {
1332
+ const url = `http://localhost:${port}`
1333
+
1334
+ const input = {
1335
+ $id: 'https://example.com/root',
1336
+ components: {
1337
+ schemas: {
1338
+ User: {
1339
+ $id: `${url}/schema`,
1340
+ type: 'object',
1341
+ properties: {
1342
+ name: { type: 'string' },
1343
+ },
1344
+ },
1345
+ },
1346
+ },
1347
+ paths: {
1348
+ '/users': {
1349
+ get: {
1350
+ responses: {
1351
+ '200': {
1352
+ description: 'Success',
1353
+ content: {
1354
+ 'application/json': {
1355
+ schema: {
1356
+ $ref: `${url}/schema`,
1357
+ },
1358
+ },
1359
+ },
1360
+ },
1361
+ },
1362
+ },
1363
+ },
1364
+ },
1365
+ }
1366
+
1367
+ await bundle(input, {
1368
+ plugins: [fetchUrls(), readFiles()],
1369
+ treeShake: false,
1370
+ })
1371
+
1372
+ // The $ref should remain unchanged because the schema is already defined locally with $id
1373
+ expect(input.paths['/users'].get.responses['200'].content['application/json'].schema.$ref).toBe(`${url}/schema`)
1374
+
1375
+ // The external schema should not be bundled into x-ext
1376
+ expect(input['x-ext']).toBeUndefined()
1377
+
1378
+ // The local schema with $id should remain unchanged
1379
+ expect(input.components.schemas.User).toEqual({
1380
+ $id: `${url}/schema`,
1381
+ type: 'object',
1382
+ properties: {
1383
+ name: { type: 'string' },
1384
+ },
1385
+ })
1386
+ })
1387
+
1388
+ it('does not modify external URLs when already defined by $anchor property', async () => {
1389
+ const input = {
1390
+ $id: 'https://example.com/root',
1391
+ components: {
1392
+ schemas: {
1393
+ User: {
1394
+ $anchor: 'user-schema',
1395
+ type: 'object',
1396
+ properties: {
1397
+ name: { type: 'string' },
1398
+ },
1399
+ },
1400
+ },
1401
+ },
1402
+ paths: {
1403
+ '/users': {
1404
+ get: {
1405
+ responses: {
1406
+ '200': {
1407
+ description: 'Success',
1408
+ content: {
1409
+ 'application/json': {
1410
+ schema: {
1411
+ $ref: 'https://example.com/root/schema#user-schema',
1412
+ },
1413
+ },
1414
+ },
1415
+ },
1416
+ },
1417
+ },
1418
+ },
1419
+ },
1420
+ }
1421
+
1422
+ await bundle(input, {
1423
+ plugins: [fetchUrls(), readFiles()],
1424
+ treeShake: false,
1425
+ })
1426
+
1427
+ // The $ref should remain unchanged because the schema is already defined locally with $anchor
1428
+ expect(input.paths['/users'].get.responses['200'].content['application/json'].schema.$ref).toBe(
1429
+ 'https://example.com/root/schema#user-schema',
1430
+ )
1431
+
1432
+ // The external schema should not be bundled into x-ext
1433
+ expect(input['x-ext']).toBeUndefined()
1434
+
1435
+ // The local schema with $anchor should remain unchanged
1436
+ expect(input.components.schemas.User).toEqual({
1437
+ $anchor: 'user-schema',
1438
+ type: 'object',
1439
+ properties: {
1440
+ name: { type: 'string' },
1441
+ },
1442
+ })
1443
+ })
1444
+
1445
+ it('does not modify external URLs when prefix is already defined by $id', async () => {
1446
+ const url = `http://localhost:${port}`
1447
+
1448
+ const input = {
1449
+ $id: `${url}/schema`,
1450
+ components: {
1451
+ schemas: {
1452
+ User: {
1453
+ type: 'object',
1454
+ properties: {
1455
+ name: { type: 'string' },
1456
+ },
1457
+ },
1458
+ },
1459
+ },
1460
+ paths: {
1461
+ '/users': {
1462
+ get: {
1463
+ responses: {
1464
+ '200': {
1465
+ description: 'Success',
1466
+ content: {
1467
+ 'application/json': {
1468
+ schema: {
1469
+ $ref: `${url}/schema#/components/schemas/User`,
1470
+ },
1471
+ },
1472
+ },
1473
+ },
1474
+ },
1475
+ },
1476
+ },
1477
+ },
1478
+ }
1479
+
1480
+ await bundle(input, {
1481
+ plugins: [fetchUrls(), readFiles()],
1482
+ treeShake: false,
1483
+ })
1484
+
1485
+ // The $ref should remain unchanged because the prefix is already defined locally with $id
1486
+ expect(input.paths['/users'].get.responses['200'].content['application/json'].schema.$ref).toBe(
1487
+ `${url}/schema#/components/schemas/User`,
1488
+ )
1489
+
1490
+ // The external schema should not be bundled into x-ext
1491
+ expect(input['x-ext']).toBeUndefined()
1492
+
1493
+ // The local schema should remain unchanged
1494
+ expect(input.components.schemas.User).toEqual({
1495
+ type: 'object',
1496
+ properties: {
1497
+ name: { type: 'string' },
1498
+ },
1499
+ })
1500
+ })
1501
+
1502
+ it('prioritizes $id when resolving refs', async () => {
1503
+ const input = {
1504
+ $id: 'https://example.com/root',
1505
+ a: {
1506
+ b: {
1507
+ c: {
1508
+ $ref: '/b',
1509
+ },
1510
+ },
1511
+ },
1512
+ }
1513
+
1514
+ const fn = vi.fn()
1515
+
1516
+ await bundle(input, {
1517
+ treeShake: false,
1518
+ plugins: [
1519
+ {
1520
+ type: 'loader',
1521
+ validate: () => true,
1522
+ exec: async (value) => {
1523
+ fn(value)
1524
+ return {
1525
+ ok: true,
1526
+ data: {
1527
+ message: 'resolved value',
1528
+ },
1529
+ }
1530
+ },
1531
+ },
1532
+ ],
1533
+ })
1534
+
1535
+ expect(input).toEqual({
1536
+ '$id': 'https://example.com/root',
1537
+ 'a': {
1538
+ 'b': {
1539
+ 'c': {
1540
+ '$ref': '#/x-ext/69a42cc',
1541
+ },
1542
+ },
1543
+ },
1544
+ 'x-ext': {
1545
+ '69a42cc': {
1546
+ 'message': 'resolved value',
1547
+ },
1548
+ },
1549
+ })
1550
+
1551
+ expect(fn).toHaveBeenCalled()
1552
+ expect(fn).toHaveBeenCalledWith('https://example.com/b')
1553
+ })
1554
+
1555
+ it('prioritizes $id when resolving refs with origin #1', async () => {
1556
+ const url = `http://localhost:${port}`
1557
+
1558
+ const input = {
1559
+ $id: '/root',
1560
+ a: {
1561
+ b: {
1562
+ c: {
1563
+ $ref: '/b',
1564
+ },
1565
+ },
1566
+ },
1567
+ }
1568
+
1569
+ const fn = vi.fn()
1570
+
1571
+ await bundle(input, {
1572
+ treeShake: false,
1573
+ origin: url,
1574
+ plugins: [
1575
+ {
1576
+ type: 'loader',
1577
+ validate: () => true,
1578
+ exec: async (value) => {
1579
+ fn(value)
1580
+ return {
1581
+ ok: true,
1582
+ data: {
1583
+ message: 'resolved value',
1584
+ },
1585
+ }
1586
+ },
1587
+ },
1588
+ ],
1589
+ })
1590
+
1591
+ expect(input).toEqual({
1592
+ '$id': '/root',
1593
+ 'a': {
1594
+ 'b': {
1595
+ 'c': {
1596
+ '$ref': '#/x-ext/25c8e1f',
1597
+ },
1598
+ },
1599
+ },
1600
+ 'x-ext': {
1601
+ '25c8e1f': {
1602
+ 'message': 'resolved value',
1603
+ },
1604
+ },
1605
+ })
1606
+
1607
+ expect(fn).toHaveBeenCalled()
1608
+ expect(fn).toHaveBeenCalledWith('/b')
1609
+ })
1610
+
1611
+ it('prioritizes $id when resolving refs with origin #2', async () => {
1612
+ const url = `http://localhost:${port}`
1613
+
1614
+ const input = {
1615
+ $id: 'http://example.com/root',
1616
+ a: {
1617
+ b: {
1618
+ c: {
1619
+ $ref: '/b',
1620
+ },
1621
+ },
1622
+ },
1623
+ }
1624
+
1625
+ const fn = vi.fn()
1626
+
1627
+ await bundle(url, {
1628
+ treeShake: false,
1629
+ origin: url,
1630
+ plugins: [
1631
+ {
1632
+ type: 'loader',
1633
+ validate: () => true,
1634
+ exec: async (value) => {
1635
+ fn(value)
1636
+
1637
+ if (value === url) {
1638
+ return {
1639
+ ok: true,
1640
+ data: input,
1641
+ }
1642
+ }
1643
+
1644
+ return {
1645
+ ok: true,
1646
+ data: {
1647
+ message: 'resolved value',
1648
+ },
1649
+ }
1650
+ },
1651
+ },
1652
+ ],
1653
+ })
1654
+
1655
+ expect(input).toEqual({
1656
+ '$id': 'http://example.com/root',
1657
+ 'a': {
1658
+ 'b': {
1659
+ 'c': {
1660
+ '$ref': '#/x-ext/943da6f',
1661
+ },
1662
+ },
1663
+ },
1664
+ 'x-ext': {
1665
+ '943da6f': {
1666
+ 'message': 'resolved value',
1667
+ },
1668
+ },
1669
+ })
1670
+
1671
+ expect(fn).toHaveBeenCalledTimes(2)
1672
+ expect(fn.mock.calls[0][0]).toBe(url)
1673
+ expect(fn.mock.calls[1][0]).toBe('http://example.com/b')
1674
+ })
1675
+
1676
+ it('correctly bundles when doing a partial bundle with $anchor on a different context', async () => {
1677
+ const input = {
1678
+ a: {
1679
+ b: {
1680
+ c: {
1681
+ $ref: '#/e/f',
1682
+ },
1683
+ },
1684
+ },
1685
+ e: {
1686
+ $id: 'https://example.com/e',
1687
+ $anchor: 'my-anchor',
1688
+ f: {
1689
+ $ref: '#my-anchor',
1690
+ },
1691
+ g: {
1692
+ $ref: 'http://example.com',
1693
+ },
1694
+ },
1695
+ }
1696
+
1697
+ const fn = vi.fn()
1698
+
1699
+ await bundle(input.a, {
1700
+ treeShake: false,
1701
+ plugins: [
1702
+ {
1703
+ type: 'loader',
1704
+ validate: () => true,
1705
+ exec: async (value) => {
1706
+ fn(value)
1707
+ if (value === 'http://example.com') {
1708
+ return {
1709
+ ok: true,
1710
+ data: {
1711
+ message: 'resolved value',
1712
+ },
1713
+ }
1714
+ }
1715
+ return { ok: false }
1716
+ },
1717
+ },
1718
+ ],
1719
+ root: input,
1720
+ urlMap: true,
1721
+ cache: new Map(),
1722
+ })
1723
+
1724
+ expect(input).toEqual({
1725
+ 'a': {
1726
+ 'b': {
1727
+ 'c': {
1728
+ '$ref': '#/e/f',
1729
+ },
1730
+ },
1731
+ },
1732
+ 'e': {
1733
+ '$anchor': 'my-anchor',
1734
+ '$id': 'https://example.com/e',
1735
+ 'f': {
1736
+ '$ref': '#my-anchor',
1737
+ },
1738
+ 'g': {
1739
+ '$ref': '#/x-ext/89dce6a',
1740
+ },
1741
+ },
1742
+ 'x-ext': {
1743
+ '89dce6a': {
1744
+ 'message': 'resolved value',
1745
+ },
1746
+ },
1747
+ 'x-ext-urls': {
1748
+ '89dce6a': 'http://example.com',
1749
+ },
1750
+ })
1751
+ })
1752
+
1753
+ it('treats internal root pointers as internal references', async () => {
1754
+ resetConsoleSpies()
1755
+
1756
+ const input = {
1757
+ a: {
1758
+ $ref: '#/',
1759
+ },
1760
+ }
1761
+
1762
+ await bundle(input, { plugins: [fetchUrls()], treeShake: false })
1763
+
1764
+ expect(input).toEqual({
1765
+ a: {
1766
+ $ref: '#/',
1767
+ },
1768
+ })
1769
+
1770
+ expect(consoleWarnSpy).toHaveBeenCalledTimes(0)
1771
+ })
1328
1772
  })
1329
1773
 
1330
1774
  describe('local files', () => {
@@ -1405,7 +1849,9 @@ describe('bundle', () => {
1405
1849
  }
1406
1850
  const bName = randomUUID()
1407
1851
 
1408
- await fs.mkdir('./nested')
1852
+ await fs.mkdir('./nested').catch(() => {
1853
+ return
1854
+ })
1409
1855
  await fs.writeFile(`./nested/${bName}`, JSON.stringify(b))
1410
1856
  await fs.writeFile(`./nested/${cName}`, JSON.stringify(c))
1411
1857
 
@@ -1449,7 +1895,9 @@ describe('bundle', () => {
1449
1895
  }
1450
1896
  const bName = randomUUID()
1451
1897
 
1452
- await fs.mkdir('./nested')
1898
+ await fs.mkdir('./nested').catch(() => {
1899
+ return
1900
+ })
1453
1901
  await fs.writeFile(`./nested/${bName}`, JSON.stringify(b))
1454
1902
  await fs.writeFile(`./nested/${cName}`, JSON.stringify(c))
1455
1903
 
@@ -2333,17 +2781,6 @@ describe('isLocalRef', () => {
2333
2781
  })
2334
2782
  })
2335
2783
 
2336
- describe('getNestedValue', () => {
2337
- it.each([
2338
- [{ a: { b: { c: 'hello' } } }, ['a', 'b', 'c'], 'hello'],
2339
- [{ a: { b: { c: 'hello' } } }, [], { a: { b: { c: 'hello' } } }],
2340
- [{ foo: { bar: { baz: 42 } } }, ['foo', 'bar', 'baz'], 42],
2341
- [{ foo: { bar: { baz: 42 } } }, ['foo', 'non-existing', 'baz'], undefined],
2342
- ])('gets nested value', (a, b, c) => {
2343
- expect(getNestedValue(a, b)).toEqual(c)
2344
- })
2345
- })
2346
-
2347
2784
  describe('prefixInternalRef', () => {
2348
2785
  it.each([
2349
2786
  ['#/hello', ['prefix'], '#/prefix/hello'],