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