@hyperjump/json-schema 0.20.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 +42 -0
- package/dist/json-schema-amd.js +212 -135
- 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 +212 -135
- 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 +212 -135
- 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 +212 -135
- 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 +212 -135
- 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 +212 -135
- package/dist/json-schema-umd.js.map +1 -1
- package/dist/json-schema-umd.min.js +2 -2
- package/dist/json-schema-umd.min.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.mjs +1 -0
- 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,92 @@
|
|
|
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
|
+
};
|
|
2111
|
+
|
|
2112
|
+
var entries$2 = async (doc) => Object.entries(await doc);
|
|
2113
|
+
|
|
2114
|
+
const curry$7 = justCurryIt;
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
var map$3 = curry$7(async (fn, doc) => (await doc).map(fn));
|
|
2118
|
+
|
|
2119
|
+
const curry$6 = justCurryIt;
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
var reduce$2 = curry$6(async (fn, acc, doc) => {
|
|
2123
|
+
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc);
|
|
2124
|
+
});
|
|
2125
|
+
|
|
2126
|
+
const curry$5 = justCurryIt;
|
|
2127
|
+
const reduce$1 = reduce$2;
|
|
2128
|
+
|
|
2129
|
+
|
|
2130
|
+
var filter = curry$5(async (fn, doc, options = {}) => {
|
|
2131
|
+
return reduce$1(async (acc, item) => {
|
|
2132
|
+
return (await fn(item)) ? acc.concat([item]) : acc;
|
|
2133
|
+
}, [], doc, options);
|
|
2134
|
+
});
|
|
2135
|
+
|
|
2136
|
+
const curry$4 = justCurryIt;
|
|
2137
|
+
const map$2 = map$3;
|
|
2138
|
+
|
|
2139
|
+
|
|
2140
|
+
var some = curry$4(async (fn, doc) => {
|
|
2141
|
+
const results = await map$2(fn, doc);
|
|
2142
|
+
return (await Promise.all(results))
|
|
2143
|
+
.some((a) => a);
|
|
2144
|
+
});
|
|
2145
|
+
|
|
2146
|
+
const curry$3 = justCurryIt;
|
|
2147
|
+
const map$1 = map$3;
|
|
2148
|
+
|
|
2149
|
+
|
|
2150
|
+
var every = curry$3(async (fn, doc) => {
|
|
2151
|
+
const results = await map$1(fn, doc);
|
|
2152
|
+
return (await Promise.all(results))
|
|
2153
|
+
.every((a) => a);
|
|
2154
|
+
});
|
|
2155
|
+
|
|
2156
|
+
const curry$2 = justCurryIt;
|
|
2157
|
+
|
|
2158
|
+
|
|
2159
|
+
var pipeline$1 = curry$2((fns, doc) => {
|
|
2160
|
+
return fns.reduce(async (acc, fn) => fn(await acc), doc);
|
|
2161
|
+
});
|
|
2162
|
+
|
|
2163
|
+
var all = (doc) => Promise.all(doc);
|
|
2164
|
+
|
|
2165
|
+
const pipeline = pipeline$1;
|
|
2166
|
+
const entries$1 = entries$2;
|
|
2167
|
+
const reduce = reduce$2;
|
|
2168
|
+
|
|
2169
|
+
|
|
2170
|
+
var allValues = (doc) => {
|
|
2171
|
+
return pipeline([
|
|
2172
|
+
entries$1,
|
|
2173
|
+
reduce(async (acc, [propertyName, propertyValue]) => {
|
|
2174
|
+
acc[propertyName] = await propertyValue;
|
|
2175
|
+
return acc;
|
|
2176
|
+
}, {})
|
|
2177
|
+
], doc);
|
|
2178
|
+
};
|
|
2179
|
+
|
|
2180
|
+
var lib$2 = {
|
|
2181
|
+
entries: entries$2,
|
|
2182
|
+
map: map$3,
|
|
2183
|
+
filter: filter,
|
|
2184
|
+
reduce: reduce$2,
|
|
2185
|
+
some: some,
|
|
2186
|
+
every: every,
|
|
2187
|
+
pipeline: pipeline$1,
|
|
2188
|
+
all: all,
|
|
2189
|
+
allValues: allValues
|
|
2190
|
+
};
|
|
2191
|
+
|
|
2192
|
+
var fetch_browser = fetch;
|
|
2096
2193
|
|
|
2097
2194
|
var contentType = {};
|
|
2098
2195
|
|
|
@@ -2148,7 +2245,7 @@
|
|
|
2148
2245
|
*/
|
|
2149
2246
|
|
|
2150
2247
|
contentType.format = format$1;
|
|
2151
|
-
contentType.parse = parse;
|
|
2248
|
+
contentType.parse = parse$1;
|
|
2152
2249
|
|
|
2153
2250
|
/**
|
|
2154
2251
|
* Format object to media type.
|
|
@@ -2199,7 +2296,7 @@
|
|
|
2199
2296
|
* @public
|
|
2200
2297
|
*/
|
|
2201
2298
|
|
|
2202
|
-
function parse (string) {
|
|
2299
|
+
function parse$1 (string) {
|
|
2203
2300
|
if (!string) {
|
|
2204
2301
|
throw new TypeError('argument string is required')
|
|
2205
2302
|
}
|
|
@@ -2317,102 +2414,54 @@
|
|
|
2317
2414
|
this.type = type;
|
|
2318
2415
|
}
|
|
2319
2416
|
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
const curry$7 = justCurryIt;
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
var map$3 = curry$7(async (fn, doc) => (await doc).map(fn));
|
|
2326
|
-
|
|
2327
|
-
const curry$6 = justCurryIt;
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
var reduce$2 = curry$6(async (fn, acc, doc) => {
|
|
2331
|
-
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc);
|
|
2332
|
-
});
|
|
2333
|
-
|
|
2334
|
-
const curry$5 = justCurryIt;
|
|
2335
|
-
const reduce$1 = reduce$2;
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
var filter = curry$5(async (fn, doc, options = {}) => {
|
|
2339
|
-
return reduce$1(async (acc, item) => {
|
|
2340
|
-
return (await fn(item)) ? acc.concat([item]) : acc;
|
|
2341
|
-
}, [], doc, options);
|
|
2342
|
-
});
|
|
2343
|
-
|
|
2344
|
-
const curry$4 = justCurryIt;
|
|
2345
|
-
const map$2 = map$3;
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
var some = curry$4(async (fn, doc) => {
|
|
2349
|
-
const results = await map$2(fn, doc);
|
|
2350
|
-
return (await Promise.all(results))
|
|
2351
|
-
.some((a) => a);
|
|
2352
|
-
});
|
|
2353
|
-
|
|
2354
|
-
const curry$3 = justCurryIt;
|
|
2355
|
-
const map$1 = map$3;
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
var every = curry$3(async (fn, doc) => {
|
|
2359
|
-
const results = await map$1(fn, doc);
|
|
2360
|
-
return (await Promise.all(results))
|
|
2361
|
-
.every((a) => a);
|
|
2362
|
-
});
|
|
2363
|
-
|
|
2364
|
-
const curry$2 = justCurryIt;
|
|
2365
|
-
|
|
2417
|
+
const contentTypeParser = contentType;
|
|
2366
2418
|
|
|
2367
|
-
var pipeline$1 = curry$2((fns, doc) => {
|
|
2368
|
-
return fns.reduce(async (acc, fn) => fn(await acc), doc);
|
|
2369
|
-
});
|
|
2370
2419
|
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
const pipeline = pipeline$1;
|
|
2374
|
-
const entries$1 = entries$2;
|
|
2375
|
-
const reduce = reduce$2;
|
|
2420
|
+
const mediaTypePlugins = {};
|
|
2376
2421
|
|
|
2422
|
+
const addPlugin = (contentType, plugin) => {
|
|
2423
|
+
mediaTypePlugins[contentType] = plugin;
|
|
2424
|
+
};
|
|
2377
2425
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
}, {})
|
|
2385
|
-
], doc);
|
|
2426
|
+
const parse = (response) => {
|
|
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}`);
|
|
2430
|
+
}
|
|
2431
|
+
return mediaTypePlugins[contentType.type].parse(response, contentType.parameters);
|
|
2386
2432
|
};
|
|
2387
2433
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
all: all,
|
|
2397
|
-
allValues: allValues
|
|
2434
|
+
const getContentType = (path) => {
|
|
2435
|
+
for (const contentType in mediaTypePlugins) {
|
|
2436
|
+
if (mediaTypePlugins[contentType].matcher(path)) {
|
|
2437
|
+
return contentType;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
return "application/octet-stream";
|
|
2398
2442
|
};
|
|
2399
2443
|
|
|
2400
|
-
var
|
|
2444
|
+
var mediaTypes = { addPlugin, parse, getContentType };
|
|
2401
2445
|
|
|
2402
|
-
const contentTypeParser = contentType;
|
|
2403
2446
|
const curry$1 = justCurryIt;
|
|
2404
2447
|
const Pact$a = lib$2;
|
|
2405
2448
|
const JsonPointer = lib$3;
|
|
2406
2449
|
const { jsonTypeOf, resolveUrl: resolveUrl$1, urlFragment, pathRelative } = common$1;
|
|
2407
2450
|
const fetch$1 = fetch_browser;
|
|
2408
2451
|
const Reference$1 = reference;
|
|
2452
|
+
const MediaTypes$1 = mediaTypes;
|
|
2453
|
+
|
|
2409
2454
|
|
|
2455
|
+
const core201909Id = "https://json-schema.org/draft/2019-09/vocab/core";
|
|
2456
|
+
const core202012Id = "https://json-schema.org/draft/2020-12/vocab/core";
|
|
2410
2457
|
|
|
2411
2458
|
// Config
|
|
2412
2459
|
const config = {};
|
|
2413
2460
|
const dialectJsonSchemaVersion = {};
|
|
2414
2461
|
|
|
2415
2462
|
const setConfig = (jsonSchemaVersion, key, value) => {
|
|
2463
|
+
dialectJsonSchemaVersion[jsonSchemaVersion] = jsonSchemaVersion;
|
|
2464
|
+
|
|
2416
2465
|
if (!config[jsonSchemaVersion]) {
|
|
2417
2466
|
config[jsonSchemaVersion] = {};
|
|
2418
2467
|
}
|
|
@@ -2420,10 +2469,8 @@
|
|
|
2420
2469
|
};
|
|
2421
2470
|
|
|
2422
2471
|
const getConfig = (dialectId, key) => {
|
|
2423
|
-
const jsonSchemaVersion = dialectJsonSchemaVersion[dialectId]
|
|
2424
|
-
|
|
2425
|
-
return config[jsonSchemaVersion][key];
|
|
2426
|
-
}
|
|
2472
|
+
const jsonSchemaVersion = dialectJsonSchemaVersion[dialectId];
|
|
2473
|
+
return config[jsonSchemaVersion]?.[key];
|
|
2427
2474
|
};
|
|
2428
2475
|
|
|
2429
2476
|
// Schema Management
|
|
@@ -2432,6 +2479,7 @@
|
|
|
2432
2479
|
|
|
2433
2480
|
const add$1 = (schema, url = "", defaultSchemaVersion = "") => {
|
|
2434
2481
|
schema = JSON.parse(JSON.stringify(schema));
|
|
2482
|
+
const externalId = resolveUrl$1(url, "");
|
|
2435
2483
|
|
|
2436
2484
|
// Dialect / JSON Schema Version
|
|
2437
2485
|
const dialectId = resolveUrl$1(schema["$schema"] || defaultSchemaVersion, "");
|
|
@@ -2440,35 +2488,45 @@
|
|
|
2440
2488
|
}
|
|
2441
2489
|
delete schema["$schema"];
|
|
2442
2490
|
|
|
2443
|
-
|
|
2444
|
-
if (
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2491
|
+
// Determine JSON Schema version
|
|
2492
|
+
if (!(dialectId in dialectJsonSchemaVersion)) {
|
|
2493
|
+
if (schema?.$vocabulary?.[core201909Id] === true && dialectId === getSchemaIdentifier(schema, externalId, core201909Id)[0]) {
|
|
2494
|
+
// Self describing 2019-09 meta-schema
|
|
2495
|
+
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
2496
|
+
} else if (schema?.$vocabulary?.[core202012Id] === true && dialectId === getSchemaIdentifier(schema, externalId, core202012Id)[0]) {
|
|
2497
|
+
// Self describing 2020-12 meta-schema
|
|
2498
|
+
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
2499
|
+
} else {
|
|
2500
|
+
// Need to look at meta-schema to determine version
|
|
2501
|
+
const metaSchema = schemaStore[dialectId];
|
|
2502
|
+
if (!metaSchema) {
|
|
2503
|
+
throw Error(`Couldn't determine JSON Schema version for dialect: '${dialectId}'`);
|
|
2504
|
+
} else if (metaSchema.vocabulary[core201909Id] === true) {
|
|
2505
|
+
dialectJsonSchemaVersion[dialectId] = core201909Id;
|
|
2506
|
+
} else if (metaSchema.vocabulary[core202012Id] === true) {
|
|
2507
|
+
dialectJsonSchemaVersion[dialectId] = core202012Id;
|
|
2508
|
+
} else {
|
|
2509
|
+
// Assume the jsonSchemaVersion is the meta-schema's dialectId (non-standard behavior)
|
|
2510
|
+
dialectJsonSchemaVersion[dialectId] = dialectJsonSchemaVersion[metaSchema.dialectId];
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2450
2513
|
}
|
|
2451
2514
|
|
|
2452
|
-
// Identifier
|
|
2453
|
-
const
|
|
2454
|
-
|
|
2455
|
-
const externalId = resolveUrl$1(url, "");
|
|
2456
|
-
if (!externalId && !resolveUrl$1(schema[baseToken] || "", "")) {
|
|
2515
|
+
// Internal Identifier
|
|
2516
|
+
const [id, fragment] = getSchemaIdentifier(schema, externalId, dialectJsonSchemaVersion[dialectId]);
|
|
2517
|
+
if (!id) {
|
|
2457
2518
|
throw Error("Couldn't determine an identifier for the schema");
|
|
2458
2519
|
}
|
|
2459
|
-
const
|
|
2460
|
-
const id = resolveUrl$1(internalUrl, "");
|
|
2461
|
-
const fragment = urlFragment(internalUrl);
|
|
2520
|
+
const baseToken = getConfig(dialectId, "baseToken");
|
|
2462
2521
|
delete schema[baseToken];
|
|
2463
|
-
if (fragment && baseToken === anchorToken) {
|
|
2464
|
-
schema[anchorToken] = anchorToken !== baseToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`;
|
|
2465
|
-
}
|
|
2466
2522
|
if (externalId) {
|
|
2467
2523
|
schemaStoreAlias[externalId] = id;
|
|
2468
2524
|
}
|
|
2469
2525
|
|
|
2470
|
-
|
|
2471
|
-
|
|
2526
|
+
const anchorToken = getConfig(dialectId, "anchorToken");
|
|
2527
|
+
if (fragment && baseToken === anchorToken) {
|
|
2528
|
+
schema[anchorToken] = anchorToken !== baseToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`;
|
|
2529
|
+
}
|
|
2472
2530
|
|
|
2473
2531
|
// recursiveAnchor
|
|
2474
2532
|
const dynamicAnchors = {};
|
|
@@ -2504,6 +2562,12 @@
|
|
|
2504
2562
|
return id;
|
|
2505
2563
|
};
|
|
2506
2564
|
|
|
2565
|
+
const getSchemaIdentifier = (schema, externalId, jsonSchemaVersion) => {
|
|
2566
|
+
const baseToken = config[jsonSchemaVersion]?.["baseToken"];
|
|
2567
|
+
const internalUrl = resolveUrl$1(externalId, schema[baseToken] || "");
|
|
2568
|
+
return [resolveUrl$1(internalUrl, ""), urlFragment(internalUrl)];
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2507
2571
|
const processSchema = (subject, id, dialectId, pointer, anchors, dynamicAnchors) => {
|
|
2508
2572
|
if (jsonTypeOf(subject, "object")) {
|
|
2509
2573
|
const embeddedSchemaDialectId = typeof subject.$schema === "string" ? resolveUrl$1(subject.$schema, "") : dialectId;
|
|
@@ -2581,14 +2645,15 @@
|
|
|
2581
2645
|
throw Error(`Failed to retrieve schema with id: ${id}`);
|
|
2582
2646
|
}
|
|
2583
2647
|
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
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);
|
|
2589
2654
|
}
|
|
2590
2655
|
|
|
2591
|
-
add$1(
|
|
2656
|
+
add$1(schema, id);
|
|
2592
2657
|
}
|
|
2593
2658
|
|
|
2594
2659
|
const storedSchema = getStoredSchema(id);
|
|
@@ -2725,12 +2790,22 @@
|
|
|
2725
2790
|
|
|
2726
2791
|
var invalidSchemaError = InvalidSchemaError$3;
|
|
2727
2792
|
|
|
2793
|
+
const Schema$R = schema$5;
|
|
2794
|
+
|
|
2795
|
+
|
|
2796
|
+
const compile$O = (schema) => Schema$R.value(schema);
|
|
2797
|
+
const interpret$O = () => true;
|
|
2798
|
+
|
|
2799
|
+
var metaData$4 = { compile: compile$O, interpret: interpret$O };
|
|
2800
|
+
|
|
2728
2801
|
const curry = justCurryIt;
|
|
2729
2802
|
const PubSub$1 = pubsub.exports;
|
|
2730
2803
|
const { resolveUrl } = common$1;
|
|
2731
2804
|
const Instance$E = instance;
|
|
2732
|
-
const Schema$
|
|
2805
|
+
const Schema$Q = schema$5;
|
|
2733
2806
|
const InvalidSchemaError$2 = invalidSchemaError;
|
|
2807
|
+
const MediaTypes = mediaTypes;
|
|
2808
|
+
const metaData$3 = metaData$4;
|
|
2734
2809
|
|
|
2735
2810
|
|
|
2736
2811
|
const FLAG = "FLAG", BASIC = "BASIC", DETAILED = "DETAILED", VERBOSE = "VERBOSE";
|
|
@@ -2738,20 +2813,28 @@
|
|
|
2738
2813
|
let metaOutputFormat = DETAILED;
|
|
2739
2814
|
let shouldMetaValidate = true;
|
|
2740
2815
|
|
|
2816
|
+
MediaTypes.addPlugin("application/schema+json", {
|
|
2817
|
+
parse: async (response, contentTypeParameters) => [
|
|
2818
|
+
await response.json(),
|
|
2819
|
+
contentTypeParameters.schema || contentTypeParameters.profile
|
|
2820
|
+
],
|
|
2821
|
+
matcher: (path) => path.endsWith(".schema.json")
|
|
2822
|
+
});
|
|
2823
|
+
|
|
2741
2824
|
const validate$2 = async (schema, value = undefined, outputFormat = undefined) => {
|
|
2742
|
-
const compiled = await compile$
|
|
2743
|
-
const interpretAst = (value, outputFormat) => interpret$
|
|
2825
|
+
const compiled = await compile$N(schema);
|
|
2826
|
+
const interpretAst = (value, outputFormat) => interpret$N(compiled, Instance$E.cons(value), outputFormat);
|
|
2744
2827
|
|
|
2745
2828
|
return value === undefined ? interpretAst : interpretAst(value, outputFormat);
|
|
2746
2829
|
};
|
|
2747
2830
|
|
|
2748
|
-
const compile$
|
|
2831
|
+
const compile$N = async (schema) => {
|
|
2749
2832
|
const ast = { metaData: {} };
|
|
2750
2833
|
const schemaUri = await compileSchema(schema, ast);
|
|
2751
2834
|
return { ast, schemaUri };
|
|
2752
2835
|
};
|
|
2753
2836
|
|
|
2754
|
-
const interpret$
|
|
2837
|
+
const interpret$N = curry(({ ast, schemaUri }, value, outputFormat = FLAG) => {
|
|
2755
2838
|
if (![FLAG, BASIC, DETAILED, VERBOSE].includes(outputFormat)) {
|
|
2756
2839
|
throw Error(`The '${outputFormat}' error format is not supported`);
|
|
2757
2840
|
}
|
|
@@ -2805,7 +2888,7 @@
|
|
|
2805
2888
|
};
|
|
2806
2889
|
|
|
2807
2890
|
const _keywords = {};
|
|
2808
|
-
const getKeyword = (id) => _keywords[id];
|
|
2891
|
+
const getKeyword = (id) => _keywords[id] || metaData$3;
|
|
2809
2892
|
const hasKeyword = (id) => id in _keywords;
|
|
2810
2893
|
const addKeyword = (id, keywordHandler) => {
|
|
2811
2894
|
_keywords[id] = {
|
|
@@ -2826,10 +2909,10 @@
|
|
|
2826
2909
|
|
|
2827
2910
|
// Vocabularies
|
|
2828
2911
|
if (!hasKeyword(`${schema.dialectId}#validate`)) {
|
|
2829
|
-
const metaSchema = await Schema$
|
|
2912
|
+
const metaSchema = await Schema$Q.get(schema.dialectId);
|
|
2830
2913
|
|
|
2831
2914
|
// Check for mandatory vocabularies
|
|
2832
|
-
const mandatoryVocabularies = Schema$
|
|
2915
|
+
const mandatoryVocabularies = Schema$Q.getConfig(metaSchema.id, "mandatoryVocabularies") || [];
|
|
2833
2916
|
mandatoryVocabularies.forEach((vocabularyId) => {
|
|
2834
2917
|
if (!metaSchema.vocabulary[vocabularyId]) {
|
|
2835
2918
|
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`);
|
|
@@ -2852,13 +2935,13 @@
|
|
|
2852
2935
|
|
|
2853
2936
|
// Meta validation
|
|
2854
2937
|
if (shouldMetaValidate && !schema.validated) {
|
|
2855
|
-
Schema$
|
|
2938
|
+
Schema$Q.markValidated(schema.id);
|
|
2856
2939
|
|
|
2857
2940
|
// Compile
|
|
2858
2941
|
if (!(schema.dialectId in metaValidators)) {
|
|
2859
|
-
const metaSchema = await Schema$
|
|
2860
|
-
const compiledSchema = await compile$
|
|
2861
|
-
metaValidators[metaSchema.id] = interpret$
|
|
2942
|
+
const metaSchema = await Schema$Q.get(schema.dialectId);
|
|
2943
|
+
const compiledSchema = await compile$N(metaSchema);
|
|
2944
|
+
metaValidators[metaSchema.id] = interpret$N(compiledSchema);
|
|
2862
2945
|
}
|
|
2863
2946
|
|
|
2864
2947
|
// Interpret
|
|
@@ -2881,7 +2964,7 @@
|
|
|
2881
2964
|
};
|
|
2882
2965
|
|
|
2883
2966
|
const followReferences = async (doc) => {
|
|
2884
|
-
return Schema$
|
|
2967
|
+
return Schema$Q.typeOf(doc, "string") ? followReferences(await Schema$Q.get(Schema$Q.value(doc), doc)) : doc;
|
|
2885
2968
|
};
|
|
2886
2969
|
|
|
2887
2970
|
const interpretSchema = (schemaUri, instance, ast, dynamicAnchors) => {
|
|
@@ -2909,25 +2992,18 @@
|
|
|
2909
2992
|
};
|
|
2910
2993
|
|
|
2911
2994
|
const add = (schema, url = "", defaultSchemaVersion = "") => {
|
|
2912
|
-
const id = Schema$
|
|
2995
|
+
const id = Schema$Q.add(schema, url, defaultSchemaVersion);
|
|
2913
2996
|
delete metaValidators[id];
|
|
2914
2997
|
};
|
|
2915
2998
|
|
|
2916
2999
|
var core$2 = {
|
|
2917
|
-
validate: validate$2, compile: compile$
|
|
3000
|
+
validate: validate$2, compile: compile$N, interpret: interpret$N,
|
|
2918
3001
|
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE,
|
|
2919
3002
|
add, getKeyword, hasKeyword, defineVocabulary,
|
|
2920
|
-
compileSchema, interpretSchema, collectEvaluatedProperties: collectEvaluatedProperties$e, collectEvaluatedItems: collectEvaluatedItems$f
|
|
3003
|
+
compileSchema, interpretSchema, collectEvaluatedProperties: collectEvaluatedProperties$e, collectEvaluatedItems: collectEvaluatedItems$f,
|
|
3004
|
+
addMediaTypePlugin: MediaTypes.addPlugin
|
|
2921
3005
|
};
|
|
2922
3006
|
|
|
2923
|
-
const Schema$Q = schema$5;
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
const compile$N = (schema) => Schema$Q.value(schema);
|
|
2927
|
-
const interpret$N = () => true;
|
|
2928
|
-
|
|
2929
|
-
var metaData$3 = { compile: compile$N, interpret: interpret$N };
|
|
2930
|
-
|
|
2931
3007
|
const Pact$9 = lib$2;
|
|
2932
3008
|
const PubSub = pubsub.exports;
|
|
2933
3009
|
const Core$x = core$2;
|
|
@@ -2951,7 +3027,7 @@
|
|
|
2951
3027
|
typeof schemaValue === "boolean" ? schemaValue : await Pact$9.pipeline([
|
|
2952
3028
|
Schema$P.entries,
|
|
2953
3029
|
Pact$9.map(([keyword, keywordSchema]) => [`${schema.dialectId}#${keyword}`, keywordSchema]),
|
|
2954
|
-
Pact$9.filter(([keywordId]) =>
|
|
3030
|
+
Pact$9.filter(([keywordId]) => keywordId !== `${schema.dialectId}#validate`),
|
|
2955
3031
|
Pact$9.map(async ([keywordId, keywordSchema]) => {
|
|
2956
3032
|
const keywordAst = await Core$x.getKeyword(keywordId).compile(keywordSchema, ast, schema);
|
|
2957
3033
|
return [keywordId, Schema$P.uri(keywordSchema), keywordAst];
|
|
@@ -3027,7 +3103,7 @@
|
|
|
3027
3103
|
|
|
3028
3104
|
var validate$1 = { compile: compile$M, interpret: interpret$M, collectEvaluatedProperties: collectEvaluatedProperties$d, collectEvaluatedItems: collectEvaluatedItems$e };
|
|
3029
3105
|
|
|
3030
|
-
const metaData$2 = metaData$
|
|
3106
|
+
const metaData$2 = metaData$4;
|
|
3031
3107
|
const validate = validate$1;
|
|
3032
3108
|
|
|
3033
3109
|
|
|
@@ -5631,6 +5707,7 @@
|
|
|
5631
5707
|
interpret: Core.interpret,
|
|
5632
5708
|
setMetaOutputFormat: Core.setMetaOutputFormat,
|
|
5633
5709
|
setShouldMetaValidate: Core.setShouldMetaValidate,
|
|
5710
|
+
addMediaTypePlugin: Core.addMediaTypePlugin,
|
|
5634
5711
|
FLAG: Core.FLAG,
|
|
5635
5712
|
BASIC: Core.BASIC,
|
|
5636
5713
|
DETAILED: Core.DETAILED,
|