@hyperjump/json-schema 0.18.3 → 0.18.4

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.
@@ -646,70 +646,7 @@ const safeResolveUrl$1 = (contextUrl, url) => {
646
646
  return resolvedUrl;
647
647
  };
648
648
 
649
- const CHAR_BACKWARD_SLASH = 47;
650
-
651
- const pathRelative$1 = (from, to) => {
652
- if (from === to) {
653
- return "";
654
- }
655
-
656
- let toStart = 1;
657
- const fromLen = from.length - 1;
658
- const toLen = to.length - toStart;
659
-
660
- // Compare paths to find the longest common path from root
661
- const length = fromLen < toLen ? fromLen : toLen;
662
- let lastCommonSep = -1;
663
- let i = 0;
664
- for (; i < length; i++) {
665
- const fromCode = from.charCodeAt(i + 1);
666
- if (fromCode !== to.charCodeAt(toStart + i)) {
667
- break;
668
- } else if (fromCode === CHAR_BACKWARD_SLASH) {
669
- lastCommonSep = i;
670
- }
671
- }
672
-
673
- if (toLen > length) {
674
- if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
675
- return to.slice(toStart + i + 1);
676
- }
677
- if (i === 0) {
678
- return to.slice(toStart + i);
679
- }
680
- }
681
- if (fromLen > length) {
682
- if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) {
683
- lastCommonSep = i;
684
- } else if (length === 0) {
685
- lastCommonSep = 0;
686
- }
687
- }
688
-
689
- let out = "";
690
- // Generate the relative path based on the path difference between `to` and `from`
691
- for (i = lastCommonSep + 2; i <= from.length; ++i) {
692
- if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
693
- out += out.length === 0 ? ".." : "/..";
694
- }
695
- }
696
-
697
- toStart += lastCommonSep;
698
-
699
- // Lastly, append the rest of the destination (`to`) path that comes after
700
- // the common path parts
701
- if (out.length > 0) {
702
- return `${out}${to.slice(toStart, to.length)}`;
703
- }
704
-
705
- if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
706
- ++toStart;
707
- }
708
-
709
- return to.slice(toStart, to.length);
710
- };
711
-
712
- var common$1 = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$4, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 };
649
+ var common$1 = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$4, safeResolveUrl: safeResolveUrl$1 };
713
650
 
714
651
  const nil$2 = "";
715
652
 
@@ -1215,7 +1152,7 @@ lib$2.allValues;
1215
1152
 
1216
1153
  var fetch_browser = fetch;
1217
1154
 
1218
- const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl, pathRelative } = common$1;
1155
+ const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl } = common$1;
1219
1156
 
1220
1157
 
1221
1158
 
@@ -1445,73 +1382,10 @@ const map = justCurryIt((fn, doc) => lib$2.pipeline([
1445
1382
 
1446
1383
  const length = (doc) => value(doc).length;
1447
1384
 
1448
- const toSchemaDefaultOptions = {
1449
- parentId: "",
1450
- parentDialect: "",
1451
- includeEmbedded: true
1452
- };
1453
- const toSchema = (schemaDoc, options = {}) => {
1454
- const fullOptions = { ...toSchemaDefaultOptions, ...options };
1455
-
1456
- const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => {
1457
- if (!reference.isReference(value)) {
1458
- return value;
1459
- }
1460
-
1461
- const refValue = reference.value(value);
1462
- const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion;
1463
- const embeddedToken = getConfig(embeddedDialect, "embeddedToken");
1464
- if (!fullOptions.includeEmbedded && embeddedToken in refValue) {
1465
- return;
1466
- } else {
1467
- return reference.value(value);
1468
- }
1469
- }));
1470
-
1471
- const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken");
1472
- Object.entries(schemaDoc.dynamicAnchors)
1473
- .forEach(([anchor, uri]) => {
1474
- const pointer = splitUrl$3(uri)[1];
1475
- lib$3.assign(pointer, schema, {
1476
- [dynamicAnchorToken]: anchor,
1477
- ...lib$3.get(pointer, schema)
1478
- });
1479
- });
1480
-
1481
- const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken");
1482
- Object.entries(schemaDoc.anchors)
1483
- .filter(([anchor]) => anchor !== "")
1484
- .forEach(([anchor, pointer]) => {
1485
- lib$3.assign(pointer, schema, {
1486
- [anchorToken]: anchor,
1487
- ...lib$3.get(pointer, schema)
1488
- });
1489
- });
1490
-
1491
- const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken");
1492
- const id = relativeUri(fullOptions.parentId, schemaDoc.id);
1493
- const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion;
1494
- return {
1495
- ...(id && { [baseToken]: id }),
1496
- ...(dialect && { $schema: dialect }),
1497
- ...schema
1498
- };
1499
- };
1500
-
1501
- const relativeUri = (from, to) => {
1502
- if (to.startsWith("file://")) {
1503
- const pathToSchema = from.slice(7, from.lastIndexOf("/"));
1504
- return from === "" ? "" : pathRelative(pathToSchema, to.slice(7));
1505
- } else {
1506
- return to;
1507
- }
1508
- };
1509
-
1510
1385
  var schema$5 = {
1511
1386
  setConfig, getConfig,
1512
1387
  add: add$1, get, markValidated,
1513
- uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length,
1514
- toSchema
1388
+ uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length
1515
1389
  };
1516
1390
  schema$5.setConfig;
1517
1391
  schema$5.getConfig;
@@ -1528,7 +1402,6 @@ schema$5.keys;
1528
1402
  schema$5.entries;
1529
1403
  schema$5.map;
1530
1404
  schema$5.length;
1531
- schema$5.toSchema;
1532
1405
 
1533
1406
  class InvalidSchemaError$1 extends Error {
1534
1407
  constructor(output) {