@hyperjump/json-schema 0.18.4 → 0.18.5
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/json-schema-amd.js +130 -3
- package/dist/json-schema-amd.js.map +1 -1
- package/dist/json-schema-amd.min.js +1 -1
- package/dist/json-schema-amd.min.js.map +1 -1
- package/dist/json-schema-cjs.js +130 -3
- package/dist/json-schema-cjs.js.map +1 -1
- package/dist/json-schema-cjs.min.js +1 -1
- package/dist/json-schema-cjs.min.js.map +1 -1
- package/dist/json-schema-esm.js +130 -3
- package/dist/json-schema-esm.js.map +1 -1
- package/dist/json-schema-esm.min.js +1 -1
- package/dist/json-schema-esm.min.js.map +1 -1
- package/dist/json-schema-iife.js +130 -3
- package/dist/json-schema-iife.js.map +1 -1
- package/dist/json-schema-iife.min.js +1 -1
- package/dist/json-schema-iife.min.js.map +1 -1
- package/dist/json-schema-system.js +130 -3
- package/dist/json-schema-system.js.map +1 -1
- package/dist/json-schema-system.min.js +1 -1
- package/dist/json-schema-system.min.js.map +1 -1
- package/dist/json-schema-umd.js +130 -3
- package/dist/json-schema-umd.js.map +1 -1
- package/dist/json-schema-umd.min.js +1 -1
- package/dist/json-schema-umd.min.js.map +1 -1
- package/package.json +3 -2
|
@@ -651,7 +651,70 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
651
651
|
return resolvedUrl;
|
|
652
652
|
};
|
|
653
653
|
|
|
654
|
-
|
|
654
|
+
const CHAR_BACKWARD_SLASH = 47;
|
|
655
|
+
|
|
656
|
+
const pathRelative$1 = (from, to) => {
|
|
657
|
+
if (from === to) {
|
|
658
|
+
return "";
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
let toStart = 1;
|
|
662
|
+
const fromLen = from.length - 1;
|
|
663
|
+
const toLen = to.length - toStart;
|
|
664
|
+
|
|
665
|
+
// Compare paths to find the longest common path from root
|
|
666
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
667
|
+
let lastCommonSep = -1;
|
|
668
|
+
let i = 0;
|
|
669
|
+
for (; i < length; i++) {
|
|
670
|
+
const fromCode = from.charCodeAt(i + 1);
|
|
671
|
+
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
672
|
+
break;
|
|
673
|
+
} else if (fromCode === CHAR_BACKWARD_SLASH) {
|
|
674
|
+
lastCommonSep = i;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
if (toLen > length) {
|
|
679
|
+
if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
|
|
680
|
+
return to.slice(toStart + i + 1);
|
|
681
|
+
}
|
|
682
|
+
if (i === 0) {
|
|
683
|
+
return to.slice(toStart + i);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
if (fromLen > length) {
|
|
687
|
+
if (from.charCodeAt(i + 1) === CHAR_BACKWARD_SLASH) {
|
|
688
|
+
lastCommonSep = i;
|
|
689
|
+
} else if (length === 0) {
|
|
690
|
+
lastCommonSep = 0;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
let out = "";
|
|
695
|
+
// Generate the relative path based on the path difference between `to` and `from`
|
|
696
|
+
for (i = lastCommonSep + 2; i <= from.length; ++i) {
|
|
697
|
+
if (i === from.length || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
|
|
698
|
+
out += out.length === 0 ? ".." : "/..";
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
toStart += lastCommonSep;
|
|
703
|
+
|
|
704
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
705
|
+
// the common path parts
|
|
706
|
+
if (out.length > 0) {
|
|
707
|
+
return `${out}${to.slice(toStart, to.length)}`;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (to.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
|
|
711
|
+
++toStart;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
return to.slice(toStart, to.length);
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
var common$1 = { jsonTypeOf: jsonTypeOf$2, splitUrl: splitUrl$4, safeResolveUrl: safeResolveUrl$1, pathRelative: pathRelative$1 };
|
|
655
718
|
|
|
656
719
|
const nil$2 = "";
|
|
657
720
|
|
|
@@ -1157,7 +1220,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1157
1220
|
|
|
1158
1221
|
var fetch_browser = fetch;
|
|
1159
1222
|
|
|
1160
|
-
const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl } = common$1;
|
|
1223
|
+
const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl, pathRelative } = common$1;
|
|
1161
1224
|
|
|
1162
1225
|
|
|
1163
1226
|
|
|
@@ -1387,10 +1450,73 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1387
1450
|
|
|
1388
1451
|
const length = (doc) => value(doc).length;
|
|
1389
1452
|
|
|
1453
|
+
const toSchemaDefaultOptions = {
|
|
1454
|
+
parentId: "",
|
|
1455
|
+
parentDialect: "",
|
|
1456
|
+
includeEmbedded: true
|
|
1457
|
+
};
|
|
1458
|
+
const toSchema = (schemaDoc, options = {}) => {
|
|
1459
|
+
const fullOptions = { ...toSchemaDefaultOptions, ...options };
|
|
1460
|
+
|
|
1461
|
+
const schema = JSON.parse(JSON.stringify(schemaDoc.schema, (key, value) => {
|
|
1462
|
+
if (!reference.isReference(value)) {
|
|
1463
|
+
return value;
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
const refValue = reference.value(value);
|
|
1467
|
+
const embeddedDialect = refValue.$schema || schemaDoc.schemaVersion;
|
|
1468
|
+
const embeddedToken = getConfig(embeddedDialect, "embeddedToken");
|
|
1469
|
+
if (!fullOptions.includeEmbedded && embeddedToken in refValue) {
|
|
1470
|
+
return;
|
|
1471
|
+
} else {
|
|
1472
|
+
return reference.value(value);
|
|
1473
|
+
}
|
|
1474
|
+
}));
|
|
1475
|
+
|
|
1476
|
+
const dynamicAnchorToken = getConfig(schemaDoc.schemaVersion, "dynamicAnchorToken");
|
|
1477
|
+
Object.entries(schemaDoc.dynamicAnchors)
|
|
1478
|
+
.forEach(([anchor, uri]) => {
|
|
1479
|
+
const pointer = splitUrl$3(uri)[1];
|
|
1480
|
+
lib$3.assign(pointer, schema, {
|
|
1481
|
+
[dynamicAnchorToken]: anchor,
|
|
1482
|
+
...lib$3.get(pointer, schema)
|
|
1483
|
+
});
|
|
1484
|
+
});
|
|
1485
|
+
|
|
1486
|
+
const anchorToken = getConfig(schemaDoc.schemaVersion, "anchorToken");
|
|
1487
|
+
Object.entries(schemaDoc.anchors)
|
|
1488
|
+
.filter(([anchor]) => anchor !== "")
|
|
1489
|
+
.forEach(([anchor, pointer]) => {
|
|
1490
|
+
lib$3.assign(pointer, schema, {
|
|
1491
|
+
[anchorToken]: anchor,
|
|
1492
|
+
...lib$3.get(pointer, schema)
|
|
1493
|
+
});
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
const baseToken = getConfig(schemaDoc.schemaVersion, "baseToken");
|
|
1497
|
+
const id = relativeUri(fullOptions.parentId, schemaDoc.id);
|
|
1498
|
+
const dialect = fullOptions.parentDialect === schemaDoc.schemaVersion ? "" : schemaDoc.schemaVersion;
|
|
1499
|
+
return {
|
|
1500
|
+
...(id && { [baseToken]: id }),
|
|
1501
|
+
...(dialect && { $schema: dialect }),
|
|
1502
|
+
...schema
|
|
1503
|
+
};
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
const relativeUri = (from, to) => {
|
|
1507
|
+
if (to.startsWith("file://")) {
|
|
1508
|
+
const pathToSchema = from.slice(7, from.lastIndexOf("/"));
|
|
1509
|
+
return from === "" ? "" : pathRelative(pathToSchema, to.slice(7));
|
|
1510
|
+
} else {
|
|
1511
|
+
return to;
|
|
1512
|
+
}
|
|
1513
|
+
};
|
|
1514
|
+
|
|
1390
1515
|
var schema$5 = {
|
|
1391
1516
|
setConfig, getConfig,
|
|
1392
1517
|
add: add$1, get, markValidated,
|
|
1393
|
-
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length
|
|
1518
|
+
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length,
|
|
1519
|
+
toSchema
|
|
1394
1520
|
};
|
|
1395
1521
|
schema$5.setConfig;
|
|
1396
1522
|
schema$5.getConfig;
|
|
@@ -1407,6 +1533,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1407
1533
|
schema$5.entries;
|
|
1408
1534
|
schema$5.map;
|
|
1409
1535
|
schema$5.length;
|
|
1536
|
+
schema$5.toSchema;
|
|
1410
1537
|
|
|
1411
1538
|
class InvalidSchemaError$1 extends Error {
|
|
1412
1539
|
constructor(output) {
|