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