@hyperjump/json-schema 0.22.0 → 0.23.0
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/README.md +9 -5
- package/dist/json-schema-amd.js +45 -15
- 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 +45 -15
- package/dist/json-schema-cjs.js.map +1 -1
- package/dist/json-schema-cjs.min.js +2 -2
- package/dist/json-schema-cjs.min.js.map +1 -1
- package/dist/json-schema-esm.js +45 -15
- 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 +45 -15
- 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 +45 -15
- 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 +45 -15
- 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 +2 -2
|
@@ -1914,7 +1914,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
1914
1914
|
return pointer.split("/").slice(1).map(unescape);
|
|
1915
1915
|
};
|
|
1916
1916
|
|
|
1917
|
-
const get$
|
|
1917
|
+
const get$2 = (pointer, value = undefined) => {
|
|
1918
1918
|
const ptr = compile$P(pointer);
|
|
1919
1919
|
|
|
1920
1920
|
const fn = (value) => ptr.reduce(([value, pointer], segment) => {
|
|
@@ -2033,7 +2033,7 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2033
2033
|
|
|
2034
2034
|
const isScalar = (value) => value === null || typeof value !== "object";
|
|
2035
2035
|
|
|
2036
|
-
var lib$3 = { nil: nil$2, append, get: get$
|
|
2036
|
+
var lib$3 = { nil: nil$2, append, get: get$2, set, assign, unset, remove };
|
|
2037
2037
|
|
|
2038
2038
|
const $__value = Symbol("$__value");
|
|
2039
2039
|
const $__href = Symbol("$__href");
|
|
@@ -2057,6 +2057,15 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2057
2057
|
|
|
2058
2058
|
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined });
|
|
2059
2059
|
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id: resolveUrl$2(id, ""), instance, value: instance });
|
|
2060
|
+
|
|
2061
|
+
const get$1 = (url, instance = nil$1) => {
|
|
2062
|
+
if (!url.startsWith("#")) {
|
|
2063
|
+
throw Error(`No JSON document found at '${url.split("#")[0]}'`);
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
return Object.freeze({ ...instance, pointer: url.substr(1) });
|
|
2067
|
+
};
|
|
2068
|
+
|
|
2060
2069
|
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`;
|
|
2061
2070
|
const value$1 = (doc) => Reference$2.isReference(doc.value) ? Reference$2.value(doc.value) : doc.value;
|
|
2062
2071
|
const has$1 = (key, doc) => key in value$1(doc);
|
|
@@ -2076,6 +2085,9 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2076
2085
|
const map$4 = curry$8((fn, doc) => value$1(doc)
|
|
2077
2086
|
.map((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2078
2087
|
|
|
2088
|
+
const forEach = curry$8((fn, doc) => value$1(doc)
|
|
2089
|
+
.forEach((item, ndx, array, thisArg) => fn(step$1(ndx, doc), ndx, array, thisArg)));
|
|
2090
|
+
|
|
2079
2091
|
const filter$1 = curry$8((fn, doc) => value$1(doc)
|
|
2080
2092
|
.map((item, ndx, array, thisArg) => step$1(ndx, doc))
|
|
2081
2093
|
.filter((item, ndx, array, thisArg) => fn(item, ndx, array, thisArg)));
|
|
@@ -2091,7 +2103,10 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2091
2103
|
|
|
2092
2104
|
const length$1 = (doc) => value$1(doc).length;
|
|
2093
2105
|
|
|
2094
|
-
var instance = {
|
|
2106
|
+
var instance = {
|
|
2107
|
+
nil: nil$1, cons, get: get$1, uri: uri$1, value: value$1, has: has$1, typeOf: typeOf$1, length: length$1,
|
|
2108
|
+
step: step$1, entries: entries$3, keys: keys$1, map: map$4, forEach, filter: filter$1, reduce: reduce$3, every: every$1, some: some$1
|
|
2109
|
+
};
|
|
2095
2110
|
|
|
2096
2111
|
var entries$2 = async (doc) => Object.entries(await doc);
|
|
2097
2112
|
|
|
@@ -2408,11 +2423,11 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2408
2423
|
};
|
|
2409
2424
|
|
|
2410
2425
|
const parse = (response) => {
|
|
2411
|
-
const contentType = contentTypeParser.parse(response.headers.get("content-type"))
|
|
2412
|
-
if (!(contentType in mediaTypePlugins)) {
|
|
2413
|
-
throw Error(`${response.url} is not a schema. Found a document with media type: ${contentType}`);
|
|
2426
|
+
const contentType = contentTypeParser.parse(response.headers.get("content-type"));
|
|
2427
|
+
if (!(contentType.type in mediaTypePlugins)) {
|
|
2428
|
+
throw Error(`${response.url} is not a schema. Found a document with media type: ${contentType.type}`);
|
|
2414
2429
|
}
|
|
2415
|
-
return mediaTypePlugins[contentType].parse(response);
|
|
2430
|
+
return mediaTypePlugins[contentType.type].parse(response, contentType.parameters);
|
|
2416
2431
|
};
|
|
2417
2432
|
|
|
2418
2433
|
const getContentType = (path) => {
|
|
@@ -2444,6 +2459,8 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2444
2459
|
const dialectJsonSchemaVersion = {};
|
|
2445
2460
|
|
|
2446
2461
|
const setConfig = (jsonSchemaVersion, key, value) => {
|
|
2462
|
+
dialectJsonSchemaVersion[jsonSchemaVersion] = jsonSchemaVersion;
|
|
2463
|
+
|
|
2447
2464
|
if (!config[jsonSchemaVersion]) {
|
|
2448
2465
|
config[jsonSchemaVersion] = {};
|
|
2449
2466
|
}
|
|
@@ -2470,23 +2487,25 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2470
2487
|
}
|
|
2471
2488
|
delete schema["$schema"];
|
|
2472
2489
|
|
|
2473
|
-
// JSON Schema version
|
|
2490
|
+
// Determine JSON Schema version
|
|
2474
2491
|
if (!(dialectId in dialectJsonSchemaVersion)) {
|
|
2475
2492
|
if (schema?.$vocabulary?.[core201909Id] === true && dialectId === getSchemaIdentifier(schema, externalId, core201909Id)[0]) {
|
|
2493
|
+
// Self describing 2019-09 meta-schema
|
|
2476
2494
|
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
2477
2495
|
} else if (schema?.$vocabulary?.[core202012Id] === true && dialectId === getSchemaIdentifier(schema, externalId, core202012Id)[0]) {
|
|
2496
|
+
// Self describing 2020-12 meta-schema
|
|
2478
2497
|
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
2479
|
-
} else if (dialectId === getSchemaIdentifier(schema, externalId, dialectId)[0]) {
|
|
2480
|
-
dialectJsonSchemaVersion[dialectId] = dialectId;
|
|
2481
|
-
} else if (!(dialectId in schemaStore)) {
|
|
2482
|
-
throw Error(`Couldn't determine JSON Schema version for dialect: '${dialectId}'`);
|
|
2483
2498
|
} else {
|
|
2499
|
+
// Need to look at meta-schema to determine version
|
|
2484
2500
|
const metaSchema = schemaStore[dialectId];
|
|
2485
|
-
if (metaSchema
|
|
2501
|
+
if (!metaSchema) {
|
|
2502
|
+
throw Error(`Couldn't determine JSON Schema version for dialect: '${dialectId}'`);
|
|
2503
|
+
} else if (metaSchema.vocabulary[core201909Id] === true) {
|
|
2486
2504
|
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
2487
2505
|
} else if (metaSchema.vocabulary[core202012Id] === true) {
|
|
2488
2506
|
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
2489
2507
|
} else {
|
|
2508
|
+
// Assume the jsonSchemaVersion is the meta-schema's dialectId (non-standard behavior)
|
|
2490
2509
|
dialectJsonSchemaVersion[dialectId] = dialectJsonSchemaVersion[metaSchema.dialectId];
|
|
2491
2510
|
}
|
|
2492
2511
|
}
|
|
@@ -2625,7 +2644,15 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2625
2644
|
throw Error(`Failed to retrieve schema with id: ${id}`);
|
|
2626
2645
|
}
|
|
2627
2646
|
|
|
2628
|
-
|
|
2647
|
+
const [schema, defaultDialectId] = await MediaTypes$1.parse(response);
|
|
2648
|
+
|
|
2649
|
+
// Make sure the meta-schema is loaded if this isn't a known dialect
|
|
2650
|
+
const dialectId = resolveUrl$1(schema.$schema, "") || defaultDialectId;
|
|
2651
|
+
if (id !== dialectId && !(dialectId in dialectJsonSchemaVersion)) {
|
|
2652
|
+
await get(dialectId);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
add$1(schema, id);
|
|
2629
2656
|
}
|
|
2630
2657
|
|
|
2631
2658
|
const storedSchema = getStoredSchema(id);
|
|
@@ -2786,7 +2813,10 @@ System.register('JsonSchema', [], (function (exports) {
|
|
|
2786
2813
|
let shouldMetaValidate = true;
|
|
2787
2814
|
|
|
2788
2815
|
MediaTypes.addPlugin("application/schema+json", {
|
|
2789
|
-
parse: async (response) =>
|
|
2816
|
+
parse: async (response, contentTypeParameters) => [
|
|
2817
|
+
await response.json(),
|
|
2818
|
+
contentTypeParameters.schema || contentTypeParameters.profile
|
|
2819
|
+
],
|
|
2790
2820
|
matcher: (path) => path.endsWith(".schema.json")
|
|
2791
2821
|
});
|
|
2792
2822
|
|