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