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