@hyperjump/json-schema 0.18.2 → 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 +143 -6
- 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 +143 -6
- 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 +143 -6
- 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 +143 -6
- 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 +143 -6
- 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 +143 -6
- 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 +5 -3
|
@@ -61,8 +61,14 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
61
61
|
(function (root, factory){
|
|
62
62
|
|
|
63
63
|
var PubSub = {};
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
|
|
65
|
+
if (root.PubSub) {
|
|
66
|
+
PubSub = root.PubSub;
|
|
67
|
+
console.warn("PubSub already loaded, using existing version");
|
|
68
|
+
} else {
|
|
69
|
+
root.PubSub = PubSub;
|
|
70
|
+
factory(PubSub);
|
|
71
|
+
}
|
|
66
72
|
// CommonJS and Node.js module support
|
|
67
73
|
{
|
|
68
74
|
if (module !== undefined && module.exports) {
|
|
@@ -645,7 +651,70 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
645
651
|
return resolvedUrl;
|
|
646
652
|
};
|
|
647
653
|
|
|
648
|
-
|
|
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 };
|
|
649
718
|
|
|
650
719
|
const nil$2 = "";
|
|
651
720
|
|
|
@@ -798,6 +867,10 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
798
867
|
const value$2 = (ref) => ref[$__value];
|
|
799
868
|
|
|
800
869
|
var reference = { cons: cons$1, isReference, href, value: value$2 };
|
|
870
|
+
reference.cons;
|
|
871
|
+
reference.isReference;
|
|
872
|
+
reference.href;
|
|
873
|
+
reference.value;
|
|
801
874
|
|
|
802
875
|
const { jsonTypeOf: jsonTypeOf$1 } = common$1;
|
|
803
876
|
|
|
@@ -1147,7 +1220,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1147
1220
|
|
|
1148
1221
|
var fetch_browser = fetch;
|
|
1149
1222
|
|
|
1150
|
-
const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl } = common$1;
|
|
1223
|
+
const { jsonTypeOf, splitUrl: splitUrl$3, safeResolveUrl, pathRelative } = common$1;
|
|
1151
1224
|
|
|
1152
1225
|
|
|
1153
1226
|
|
|
@@ -1377,10 +1450,73 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1377
1450
|
|
|
1378
1451
|
const length = (doc) => value(doc).length;
|
|
1379
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
|
+
|
|
1380
1515
|
var schema$5 = {
|
|
1381
1516
|
setConfig, getConfig,
|
|
1382
1517
|
add: add$1, get, markValidated,
|
|
1383
|
-
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length
|
|
1518
|
+
uri, value, getAnchorPointer, typeOf, has, step, keys, entries, map, length,
|
|
1519
|
+
toSchema
|
|
1384
1520
|
};
|
|
1385
1521
|
schema$5.setConfig;
|
|
1386
1522
|
schema$5.getConfig;
|
|
@@ -1397,6 +1533,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1397
1533
|
schema$5.entries;
|
|
1398
1534
|
schema$5.map;
|
|
1399
1535
|
schema$5.length;
|
|
1536
|
+
schema$5.toSchema;
|
|
1400
1537
|
|
|
1401
1538
|
class InvalidSchemaError$1 extends Error {
|
|
1402
1539
|
constructor(output) {
|
|
@@ -1725,7 +1862,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1725
1862
|
keywords$1.metaData;
|
|
1726
1863
|
keywords$1.validate;
|
|
1727
1864
|
|
|
1728
|
-
var lib$1 = { Core: core$2, Schema: schema$5, Instance: instance, Keywords: keywords$1, InvalidSchemaError: invalidSchemaError };
|
|
1865
|
+
var lib$1 = { Core: core$2, Schema: schema$5, Instance: instance, Reference: reference, Keywords: keywords$1, InvalidSchemaError: invalidSchemaError };
|
|
1729
1866
|
|
|
1730
1867
|
const { Core: Core$v, Schema: Schema$N, Instance: Instance$B } = lib$1;
|
|
1731
1868
|
|