@hyperjump/json-schema-core
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -519,2 +519,4 @@ define(['exports'], function (exports) { 'use strict'; | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -531,17 +533,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -567,3 +569,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -801,18 +803,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1079,3 +1066,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1085,2 +1072,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1113,3 +1101,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1122,8 +1110,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1163,10 +1151,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1181,15 +1168,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1202,3 +1188,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1208,2 +1194,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1226,6 +1236,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1250,2 +1260,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1255,4 +1266,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1262,12 +1274,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1280,3 +1290,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1303,8 +1313,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1327,3 +1347,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1330,0 +1350,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),w=e=>e.value&&e.value[b]?e.value[b]:e.value,g=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:t.value[e]}),O=n((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=n((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=n((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),j=n((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),P=n((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var A={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:j,some:P},x=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function K(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var C={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+K(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(J.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+N(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=N(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function N(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const J=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=C.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ke={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Le={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ke}},Ce=Le.Core,Ue=Le.Schema,qe=Le.Instance,ze=Le.Keywords;e.Core=Ce,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Le,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function K(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var _={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+K(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==r){var i,a,s;for(x.lastIndex=r;a=x.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},z=async e=>Object.entries(await e),C=n(async(e,t)=>(await t).map(e)),q=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),R=n(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),U=n(async(e,t)=>{const r=await C(e,t);return(await Promise.all(r)).some(e=>e)}),W=n(async(e,t)=>{const r=await C(e,t);return(await Promise.all(r)).every(e=>e)}),B=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:z,map:C,filter:R,reduce:q,some:U,every:W,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([z,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(Z.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const Z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var N=fetch;const{internalValue:G,isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y=Symbol("$__dynamicJref"),ee={},te={},re=(e,t)=>{const r=e in te?te[e]:e;if(r in ee)return ee[r][t]},ne={},oe={},ie=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=re(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=fe(i,e[o]||""),s=Q(a)[0];let c;i&&(oe[i]=s),re(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(te[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};ne[s]={id:s,schemaVersion:n,schema:ae(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ae=(e,t,r,n,o,i)=>{if(H(e)){const a=re(r,"idToken"),s=re(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=fe(t,n),[i,c]=Q(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ie(e,fe(t,i),r),{[X]:n}}const c=re(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=re(r,"recursiveAnchorToken");if(n===y.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ae(s,t,r,y.append(a,n),o,i),e),{});const l=re(r,"jrefToken");if("string"==typeof e[l])return e[X]=e[l],e;const f=re(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[X]:e[f],[G]:e[f]});const d=re(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[Y]:e[d],[G]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ae(e,t,r,y.append(a,n),o,i)):e},se=e=>ne[oe[e]]||ne[e],ce=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ue=async(e,t=ce,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:he(t),o=fe(n,e),[i,a]=Q(o);if(!(e=>e in ne||e in oe)(i)){const e=await N(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=_.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ie(await e.json(),i)}const s=se(i),c=a&&"/"!==a[0]?pe(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return le(u)},le=e=>H(e.value)&&X in e.value?ue(e.value[X],e):H(e.value)&&Y in e.value?ue(e.value[Y],e,!0):e,fe=(e,t)=>{const r=F(e,t),n=Q(e)[0];if(n&&"file"===de(r)&&"file"!==de(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},de=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},pe=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ye=e=>e.value&&e.value[G]?e.value[G]:e.value,ve=(e,t)=>{const r=se(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:ye(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return le(n)},be=n((e,t)=>D.pipeline([ye,D.map(async(r,n)=>e(await ve(n,t),n)),D.all],t));var me={setConfig:(e,t,r)=>{ee[e]||(ee[e]={}),ee[e][t]=r},getConfig:re,add:ie,get:ue,markValidated:e=>{ne[e].validated=!0},uri:he,value:ye,has:(e,t)=>e in ye(t),step:ve,entries:e=>D.pipeline([ye,Object.keys,D.map(async t=>[t,await ve(t,e)]),D.all],e),map:be};const we="FLAG",ge="BASIC",Oe="DETAILED",Ee="VERBOSE";let $e=Oe,je=!0;const Pe=(e,t)=>(n,o=we)=>{if(![we,ge,Oe,Ee].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ae(o,i));return _e(t,n,e),r.unsubscribe(a),i[0]},Ae=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&xe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ge&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Se(i))break}(e===Ee||e!==we&&!i.valid)&&r.push(i),t[0]=i}},xe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Se(e)),Se=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ve={},Ie=e=>Ve[e],Te=e=>e in Ve,ke={},Ke={},Le=async(e,t)=>{if(!Te(e.schemaVersion+"#validate")){const t=await me.get(e.schemaVersion);(me.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in ke)Object.entries(ke[e]).forEach(([e,r])=>{((e,t)=>{Ve[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(je&&!e.validated){if(me.markValidated(e.id),!(e.schemaVersion in Ke)){const t=await me.get(e.schemaVersion),r={},n=await Le(t,r);Ke[t.id]=Pe(r,n)}const t=A.cons(e.schema,e.id),r=Ke[e.schemaVersion](t,$e);if(!r.valid)throw r}return await Ie(e.schemaVersion+"#validate").compile(e,t),me.uri(e)},_e=(e,t,r)=>{const[n]=r[e];return Ie(n).interpret(e,t,r)};var ze={validate:async(e,t,r)=>{const n={},o=await Le(e,n),i=(e,t=we)=>Pe(n,o)(A.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{$e=e},setShouldMetaValidate:e=>{je=e},FLAG:we,BASIC:ge,DETAILED:Oe,VERBOSE:Ee,getKeyword:Ie,hasKeyword:Te,defineVocabulary:(e,t)=>{ke[e]=t},compileSchema:Le,interpretSchema:_e,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=me.uri(e);if(!(r in t)){t[r]=!1;const n=me.value(e);t[r]=[e.schemaVersion+"#validate",me.uri(e),"boolean"==typeof n?n:await D.pipeline([me.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ze.getKeyword(r).compile(n,t,e);return[r,me.uri(n),o]}),D.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ze.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:A.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:A.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ze.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ze.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},qe={Core:ze,Schema:me,Instance:A,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Re=qe.Core,Ue=qe.Schema,We=qe.Instance,Be=qe.Keywords;e.Core=Re,e.Instance=We,e.Keywords=Be,e.Schema=Ue,e.default=qe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -521,2 +521,4 @@ 'use strict'; | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -533,17 +535,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -569,3 +571,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -803,18 +805,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1081,3 +1068,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1087,2 +1074,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1115,3 +1103,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1124,8 +1112,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1165,10 +1153,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1183,15 +1170,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1204,3 +1190,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1210,2 +1196,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1228,6 +1238,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1252,2 +1262,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1257,4 +1268,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1264,12 +1276,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1282,3 +1292,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1305,8 +1315,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1329,3 +1349,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1332,0 +1352,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,p(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||d(t)){const o=e.shift();i(e,p(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(d(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},d=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[p(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),$=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),x=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),A=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:$,reduce:E,every:x,some:A},j=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),m=e=>e.value&&e.value[v]?e.value[v]:e.value,w=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:t.value[e]}),g=r((e,t)=>m(t).map((r,n)=>e(w(n,t),n))),O=r((e,t)=>m(t).map((e,r)=>w(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>m(r).reduce((t,n,o)=>e(t,w(o,r),o),t)),$=r((e,t)=>Object.keys(m(t)).every((r,n)=>e(w(r,t),n))),x=r((e,t)=>Object.keys(m(t)).some((r,n)=>e(w(r,t),n)));var j={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:m,step:w,entries:e=>Object.keys(m(e)).map(t=>[t,w(t,e)]),map:g,filter:O,reduce:E,every:$,some:x},P=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,A=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,S=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,T=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(j.lastIndex=r;a=j.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?M(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+Z(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=Z(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:M(e)}};function M(e){return e+("/"===e[e.length-1]?"":"/")}function Z(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];let c;i&&(re[i]=s),ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},oe=(e,t,r,n,o,i)=>{if(G(e)){const a=ee(r,"idToken"),s=ee(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=se(t,n),[i,c]=H(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ne(e,se(t,i),r),{[Q]:n}}if("string"===ee(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===h.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=oe(s,t,r,h.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>oe(e,t,r,h.append(a,n),o,i)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),pe=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},de=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await pe(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:pe,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await pe(t,e)]),D.all],e),map:de};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",$e(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ee(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},Ee=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ae={},Pe=e=>Ae[e],je=e=>e in Ae,Se={},Ie={},Ve=async(e,t)=>{if(!je(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{Ae[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=P.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:Pe,hasKeyword:je,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;exports.Core=Le,exports.Instance=Ue,exports.Keywords=qe,exports.Schema=Ce,exports.default=Ke; | ||
*/function k(e){var t=String(e);if(S.test(t))return t;if(t.length>0&&!A.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(I,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!T.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!S.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+k(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!T.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(P.lastIndex=r;a=P.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},_=async e=>Object.entries(await e),z=r(async(e,t)=>(await t).map(e)),C=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),q=r(async(e,t,r={})=>C(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),R=r(async(e,t)=>{const r=await z(e,t);return(await Promise.all(r)).some(e=>e)}),U=r(async(e,t)=>{const r=await z(e,t);return(await Promise.all(r)).every(e=>e)}),W=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),B={entries:_,map:z,filter:q,reduce:C,some:R,every:U,pipeline:W,all:e=>Promise.all(e),allValues:e=>W([_,C(async(e,[t,r])=>(e[t]=await r,e),{})],e)},D=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(M.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?F(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+J(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=J(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:F(e)}};function F(e){return e+("/"===e[e.length-1]?"":"/")}function J(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const M=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var Z=fetch;const{internalValue:N,isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X=Symbol("$__dynamicJref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=le(i,e[o]||""),s=H(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(G(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=le(t,n),[i,c]=H(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,le(t,i),r),{[Q]:n}}const c=te(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=te(r,"recursiveAnchorToken");if(n===h.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,h.append(a,n),o,i),e),{});const l=te(r,"jrefToken");if("string"==typeof e[l])return e[Q]=e[l],e;const f=te(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[Q]:e[f],[N]:e[f]});const d=te(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[X]:e[d],[N]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,h.append(a,n),o,i)):e},ae=e=>re[ne[e]]||re[e],se=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ce=async(e,t=se,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:pe(t),o=le(n,e),[i,a]=H(o);if(!(e=>e in re||e in ne)(i)){const e=await Z(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=ae(i),c=a&&"/"!==a[0]?de(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return ue(u)},ue=e=>G(e.value)&&Q in e.value?ce(e.value[Q],e):G(e.value)&&X in e.value?ce(e.value[X],e,!0):e,le=(e,t)=>{const r=D(e,t),n=H(e)[0];if(n&&"file"===fe(r)&&"file"!==fe(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},fe=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},de=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},pe=e=>`${e.id}#${encodeURI(e.pointer)}`,he=e=>e.value&&e.value[N]?e.value[N]:e.value,ye=(e,t)=>{const r=ae(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:he(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return ue(n)},ve=r((e,t)=>B.pipeline([he,B.map(async(r,n)=>e(await ye(n,t),n)),B.all],t));var be={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:ce,markValidated:e=>{re[e].validated=!0},uri:pe,value:he,has:(e,t)=>e in he(t),step:ye,entries:e=>B.pipeline([he,Object.keys,B.map(async t=>[t,await ye(t,e)]),B.all],e),map:ve};const me="FLAG",we="BASIC",ge="DETAILED",Oe="VERBOSE";let Ee=ge,$e=!0;const xe=(e,r)=>(n,o=me)=>{if(![me,we,ge,Oe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",je(o,i));return Le(r,n,e),t.unsubscribe(a),i[0]},je=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Pe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===we&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Ae(i))break}(e===Oe||e!==me&&!i.valid)&&r.push(i),t[0]=i}},Pe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Ae(e)),Ae=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Se={},Ve=e=>Se[e],Ie=e=>e in Se,Te={},ke={},Ke=async(e,t)=>{if(!Ie(e.schemaVersion+"#validate")){const t=await be.get(e.schemaVersion);(be.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Te)Object.entries(Te[e]).forEach(([e,r])=>{((e,t)=>{Se[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if($e&&!e.validated){if(be.markValidated(e.id),!(e.schemaVersion in ke)){const t=await be.get(e.schemaVersion),r={},n=await Ke(t,r);ke[t.id]=xe(r,n)}const t=j.cons(e.schema,e.id),r=ke[e.schemaVersion](t,Ee);if(!r.valid)throw r}return await Ve(e.schemaVersion+"#validate").compile(e,t),be.uri(e)},Le=(e,t,r)=>{const[n]=r[e];return Ve(n).interpret(e,t,r)};var _e={validate:async(e,t,r)=>{const n={},o=await Ke(e,n),i=(e,t=me)=>xe(n,o)(j.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{Ee=e},setShouldMetaValidate:e=>{$e=e},FLAG:me,BASIC:we,DETAILED:ge,VERBOSE:Oe,getKeyword:Ve,hasKeyword:Ie,defineVocabulary:(e,t)=>{Te[e]=t},compileSchema:Ke,interpretSchema:Le,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ve(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ve(o).collectEvaluatedItems(e,t,r,n)}};var ze={compile:async(e,t)=>{const r=be.uri(e);if(!(r in t)){t[r]=!1;const n=be.value(e);t[r]=[e.schemaVersion+"#validate",be.uri(e),"boolean"==typeof n?n:await B.pipeline([be.entries,B.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),B.filter(([t])=>_e.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),B.map(async([r,n])=>{const o=await _e.getKeyword(r).compile(n,t,e);return[r,be.uri(n),o]}),B.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=_e.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:j.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:j.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&_e.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&_e.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ce={Core:_e,Schema:be,Instance:j,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:ze}},qe=Ce.Core,Re=Ce.Schema,Ue=Ce.Instance,We=Ce.Keywords;exports.Core=qe,exports.Instance=Ue,exports.Keywords=We,exports.Schema=Re,exports.default=Ce; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -517,2 +517,4 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -529,17 +531,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -565,3 +567,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -799,18 +801,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1077,3 +1064,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1083,2 +1070,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1111,3 +1099,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1120,8 +1108,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1161,10 +1149,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1179,15 +1166,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1200,3 +1186,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1206,2 +1192,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1224,6 +1234,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1248,2 +1258,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1253,4 +1264,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1260,12 +1272,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1278,3 +1288,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1301,8 +1311,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1325,3 +1345,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1328,0 +1348,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),$=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),A=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),x=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:$,reduce:E,every:A,some:x},j=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),m=e=>e.value&&e.value[v]?e.value[v]:e.value,w=(e,t)=>Object.freeze({...t,pointer:h.append(e,t.pointer),value:t.value[e]}),g=r((e,t)=>m(t).map((r,n)=>e(w(n,t),n))),O=r((e,t)=>m(t).map((e,r)=>w(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>m(r).reduce((t,n,o)=>e(t,w(o,r),o),t)),$=r((e,t)=>Object.keys(m(t)).every((r,n)=>e(w(r,t),n))),j=r((e,t)=>Object.keys(m(t)).some((r,n)=>e(w(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:m,step:w,entries:e=>Object.keys(m(e)).map(t=>[t,w(t,e)]),map:g,filter:O,reduce:E,every:$,some:j},A=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,P=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,S=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,T=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(j.lastIndex=r;a=j.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];let c;i&&(re[i]=s),ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},oe=(e,t,r,n,o,i)=>{if(G(e)){const a=ee(r,"idToken"),s=ee(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=se(t,n),[i,c]=H(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ne(e,se(t,i),r),{[Q]:n}}if("string"===ee(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===h.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=oe(s,t,r,h.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>oe(e,t,r,h.append(a,n),o,i)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),de=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},pe=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await de(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:de,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await de(t,e)]),D.all],e),map:pe};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",$e(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ee(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Ae(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},Ee=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Ae(e)),Ae=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Pe=e=>xe[e],je=e=>e in xe,Se={},Ie={},Ve=async(e,t)=>{if(!je(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=P.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:Pe,hasKeyword:je,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;export default Ke;export{Le as Core,Ue as Instance,qe as Keywords,Ce as Schema}; | ||
*/function k(e){var t=String(e);if(S.test(t))return t;if(t.length>0&&!P.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(I,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!T.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!S.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+k(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!T.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(A.lastIndex=r;a=A.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},z=async e=>Object.entries(await e),C=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),R=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=r(async(e,t)=>{const r=await C(e,t);return(await Promise.all(r)).some(e=>e)}),U=r(async(e,t)=>{const r=await C(e,t);return(await Promise.all(r)).every(e=>e)}),W=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),B={entries:z,map:C,filter:R,reduce:q,some:_,every:U,pipeline:W,all:e=>Promise.all(e),allValues:e=>W([z,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},D=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(Z.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?F(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+J(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=J(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:F(e)}};function F(e){return e+("/"===e[e.length-1]?"":"/")}function J(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const Z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var M=fetch;const{internalValue:N,isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X=Symbol("$__dynamicJref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=le(i,e[o]||""),s=H(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(G(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=le(t,n),[i,c]=H(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,le(t,i),r),{[Q]:n}}const c=te(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=te(r,"recursiveAnchorToken");if(n===h.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,h.append(a,n),o,i),e),{});const l=te(r,"jrefToken");if("string"==typeof e[l])return e[Q]=e[l],e;const f=te(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[Q]:e[f],[N]:e[f]});const d=te(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[X]:e[d],[N]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,h.append(a,n),o,i)):e},ae=e=>re[ne[e]]||re[e],se=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ce=async(e,t=se,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:pe(t),o=le(n,e),[i,a]=H(o);if(!(e=>e in re||e in ne)(i)){const e=await M(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=ae(i),c=a&&"/"!==a[0]?de(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:h.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return ue(u)},ue=e=>G(e.value)&&Q in e.value?ce(e.value[Q],e):G(e.value)&&X in e.value?ce(e.value[X],e,!0):e,le=(e,t)=>{const r=D(e,t),n=H(e)[0];if(n&&"file"===fe(r)&&"file"!==fe(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},fe=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},de=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},pe=e=>`${e.id}#${encodeURI(e.pointer)}`,he=e=>e.value&&e.value[N]?e.value[N]:e.value,ye=(e,t)=>{const r=ae(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:h.append(e,t.pointer),schema:r.schema,value:he(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return ue(n)},ve=r((e,t)=>B.pipeline([he,B.map(async(r,n)=>e(await ye(n,t),n)),B.all],t));var be={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:ce,markValidated:e=>{re[e].validated=!0},uri:pe,value:he,has:(e,t)=>e in he(t),step:ye,entries:e=>B.pipeline([he,Object.keys,B.map(async t=>[t,await ye(t,e)]),B.all],e),map:ve};const me="FLAG",we="BASIC",ge="DETAILED",Oe="VERBOSE";let Ee=ge,$e=!0;const je=(e,r)=>(n,o=me)=>{if(![me,we,ge,Oe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",xe(o,i));return Le(r,n,e),t.unsubscribe(a),i[0]},xe=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===we&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===Oe||e!==me&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Se={},Ve=e=>Se[e],Ie=e=>e in Se,Te={},ke={},Ke=async(e,t)=>{if(!Ie(e.schemaVersion+"#validate")){const t=await be.get(e.schemaVersion);(be.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Te)Object.entries(Te[e]).forEach(([e,r])=>{((e,t)=>{Se[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if($e&&!e.validated){if(be.markValidated(e.id),!(e.schemaVersion in ke)){const t=await be.get(e.schemaVersion),r={},n=await Ke(t,r);ke[t.id]=je(r,n)}const t=x.cons(e.schema,e.id),r=ke[e.schemaVersion](t,Ee);if(!r.valid)throw r}return await Ve(e.schemaVersion+"#validate").compile(e,t),be.uri(e)},Le=(e,t,r)=>{const[n]=r[e];return Ve(n).interpret(e,t,r)};var ze={validate:async(e,t,r)=>{const n={},o=await Ke(e,n),i=(e,t=me)=>je(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{Ee=e},setShouldMetaValidate:e=>{$e=e},FLAG:me,BASIC:we,DETAILED:ge,VERBOSE:Oe,getKeyword:Ve,hasKeyword:Ie,defineVocabulary:(e,t)=>{Te[e]=t},compileSchema:Ke,interpretSchema:Le,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ve(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ve(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=be.uri(e);if(!(r in t)){t[r]=!1;const n=be.value(e);t[r]=[e.schemaVersion+"#validate",be.uri(e),"boolean"==typeof n?n:await B.pipeline([be.entries,B.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),B.filter(([t])=>ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),B.map(async([r,n])=>{const o=await ze.getKeyword(r).compile(n,t,e);return[r,be.uri(n),o]}),B.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ze.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ze.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ze.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},qe={Core:ze,Schema:be,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Re=qe.Core,_e=qe.Schema,Ue=qe.Instance,We=qe.Keywords;export default qe;export{Re as Core,Ue as Instance,We as Keywords,_e as Schema}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -520,2 +520,4 @@ var JSC = (function (exports) { | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -532,17 +534,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -568,3 +570,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -802,18 +804,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1080,3 +1067,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1086,2 +1073,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1114,3 +1102,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1123,8 +1111,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1164,10 +1152,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1182,15 +1169,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1203,3 +1189,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1209,2 +1195,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1227,6 +1237,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1251,2 +1261,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1256,4 +1267,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1263,12 +1275,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1281,3 +1291,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1304,8 +1314,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1328,3 +1348,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1331,0 +1351,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),w=e=>e.value&&e.value[b]?e.value[b]:e.value,g=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:t.value[e]}),O=n((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=n((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=n((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),j=n((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),A=n((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:j,some:A},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,x=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;return e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,e}({}); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!x.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},z=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),R=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),_=n(async(e,t,r={})=>R(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),U=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),W=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),B=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),J={entries:z,map:q,filter:_,reduce:R,some:U,every:W,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([z,R(async(e,[t,r])=>(e[t]=await r,e),{})],e)},D=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(M.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?F(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+Z(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=Z(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:F(e)}};function F(e){return e+("/"===e[e.length-1]?"":"/")}function Z(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const M=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var N=fetch;const{internalValue:G,isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y=Symbol("$__dynamicJref"),ee={},te={},re=(e,t)=>{const r=e in te?te[e]:e;if(r in ee)return ee[r][t]},ne={},oe={},ie=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=re(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=fe(i,e[o]||""),s=Q(a)[0];let c;i&&(oe[i]=s),re(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(te[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};ne[s]={id:s,schemaVersion:n,schema:ae(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ae=(e,t,r,n,o,i)=>{if(H(e)){const a=re(r,"idToken"),s=re(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=fe(t,n),[i,c]=Q(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ie(e,fe(t,i),r),{[X]:n}}const c=re(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=re(r,"recursiveAnchorToken");if(n===y.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ae(s,t,r,y.append(a,n),o,i),e),{});const l=re(r,"jrefToken");if("string"==typeof e[l])return e[X]=e[l],e;const f=re(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[X]:e[f],[G]:e[f]});const d=re(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[Y]:e[d],[G]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ae(e,t,r,y.append(a,n),o,i)):e},se=e=>ne[oe[e]]||ne[e],ce=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ue=async(e,t=ce,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:he(t),o=fe(n,e),[i,a]=Q(o);if(!(e=>e in ne||e in oe)(i)){const e=await N(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ie(await e.json(),i)}const s=se(i),c=a&&"/"!==a[0]?pe(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return le(u)},le=e=>H(e.value)&&X in e.value?ue(e.value[X],e):H(e.value)&&Y in e.value?ue(e.value[Y],e,!0):e,fe=(e,t)=>{const r=D(e,t),n=Q(e)[0];if(n&&"file"===de(r)&&"file"!==de(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},de=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},pe=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ye=e=>e.value&&e.value[G]?e.value[G]:e.value,ve=(e,t)=>{const r=se(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:ye(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return le(n)},be=n((e,t)=>J.pipeline([ye,J.map(async(r,n)=>e(await ve(n,t),n)),J.all],t));var me={setConfig:(e,t,r)=>{ee[e]||(ee[e]={}),ee[e][t]=r},getConfig:re,add:ie,get:ue,markValidated:e=>{ne[e].validated=!0},uri:he,value:ye,has:(e,t)=>e in ye(t),step:ve,entries:e=>J.pipeline([ye,Object.keys,J.map(async t=>[t,await ve(t,e)]),J.all],e),map:be};const we="FLAG",ge="BASIC",Oe="DETAILED",Ee="VERBOSE";let $e=Oe,je=!0;const Ae=(e,t)=>(n,o=we)=>{if(![we,ge,Oe,Ee].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Pe(o,i));return Le(t,n,e),r.unsubscribe(a),i[0]},Pe=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Se(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ge&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===Ee||e!==we&&!i.valid)&&r.push(i),t[0]=i}},Se=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ve={},Ie=e=>Ve[e],Te=e=>e in Ve,ke={},Ce={},Ke=async(e,t)=>{if(!Te(e.schemaVersion+"#validate")){const t=await me.get(e.schemaVersion);(me.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in ke)Object.entries(ke[e]).forEach(([e,r])=>{((e,t)=>{Ve[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(je&&!e.validated){if(me.markValidated(e.id),!(e.schemaVersion in Ce)){const t=await me.get(e.schemaVersion),r={},n=await Ke(t,r);Ce[t.id]=Ae(r,n)}const t=P.cons(e.schema,e.id),r=Ce[e.schemaVersion](t,$e);if(!r.valid)throw r}return await Ie(e.schemaVersion+"#validate").compile(e,t),me.uri(e)},Le=(e,t,r)=>{const[n]=r[e];return Ie(n).interpret(e,t,r)};var ze={validate:async(e,t,r)=>{const n={},o=await Ke(e,n),i=(e,t=we)=>Ae(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{$e=e},setShouldMetaValidate:e=>{je=e},FLAG:we,BASIC:ge,DETAILED:Oe,VERBOSE:Ee,getKeyword:Ie,hasKeyword:Te,defineVocabulary:(e,t)=>{ke[e]=t},compileSchema:Ke,interpretSchema:Le,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedItems(e,t,r,n)}};var qe={compile:async(e,t)=>{const r=me.uri(e);if(!(r in t)){t[r]=!1;const n=me.value(e);t[r]=[e.schemaVersion+"#validate",me.uri(e),"boolean"==typeof n?n:await J.pipeline([me.entries,J.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),J.filter(([t])=>ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),J.map(async([r,n])=>{const o=await ze.getKeyword(r).compile(n,t,e);return[r,me.uri(n),o]}),J.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ze.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ze.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ze.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Re={Core:ze,Schema:me,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:qe}},_e=Re.Core,Ue=Re.Schema,We=Re.Instance,Be=Re.Keywords;return e.Core=_e,e.Instance=We,e.Keywords=Be,e.Schema=Ue,e.default=Re,e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -522,2 +522,4 @@ System.register('JSC', [], function (exports) { | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -534,17 +536,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -570,3 +572,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -804,18 +806,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1082,3 +1069,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1088,2 +1075,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1116,3 +1104,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1125,8 +1113,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1166,10 +1154,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1184,15 +1171,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1205,3 +1191,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1211,2 +1197,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1229,6 +1239,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1253,2 +1263,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1258,4 +1269,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1265,12 +1277,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1283,3 +1293,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1306,8 +1316,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1330,3 +1350,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1579,4 +1599,4 @@ }; | ||
var lib$1 = { Core: core, Schema: schema, Instance: instance, Keywords: keywords }; | ||
exports('default', lib$1);var lib_1 = exports('Core', lib$1.Core); | ||
var lib$1 = exports('default', { Core: core, Schema: schema, Instance: instance, Keywords: keywords }); | ||
var lib_1 = exports('Core', lib$1.Core); | ||
var lib_2 = exports('Schema', lib$1.Schema); | ||
@@ -1583,0 +1603,0 @@ var lib_3 = exports('Instance', lib$1.Instance); |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),w=e=>e.value&&e.value[b]?e.value[b]:e.value,g=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:t.value[e]}),O=n((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=n((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=n((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),j=n((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),S=n((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var A={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:j,some:S},P=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,x=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}};e("default",Ke);e("Core",Ke.Core),e("Schema",Ke.Schema),e("Instance",Ke.Instance),e("Keywords",Ke.Keywords)}}})); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!x.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(P.lastIndex=r;a=P.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},z=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),R=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),_=n(async(e,t,r={})=>R(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),U=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),W=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),B=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),J={entries:z,map:q,filter:_,reduce:R,some:U,every:W,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([z,R(async(e,[t,r])=>(e[t]=await r,e),{})],e)},D=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(M.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?F(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+Z(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=Z(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:F(e)}};function F(e){return e+("/"===e[e.length-1]?"":"/")}function Z(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const M=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var N=fetch;const{internalValue:G,isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y=Symbol("$__dynamicJref"),ee={},te={},re=(e,t)=>{const r=e in te?te[e]:e;if(r in ee)return ee[r][t]},ne={},oe={},ie=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=re(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=fe(i,e[o]||""),s=Q(a)[0];let c;i&&(oe[i]=s),re(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(te[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};ne[s]={id:s,schemaVersion:n,schema:ae(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ae=(e,t,r,n,o,i)=>{if(H(e)){const a=re(r,"idToken"),s=re(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=fe(t,n),[i,c]=Q(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ie(e,fe(t,i),r),{[X]:n}}const c=re(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=re(r,"recursiveAnchorToken");if(n===y.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ae(s,t,r,y.append(a,n),o,i),e),{});const l=re(r,"jrefToken");if("string"==typeof e[l])return e[X]=e[l],e;const f=re(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[X]:e[f],[G]:e[f]});const d=re(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[Y]:e[d],[G]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ae(e,t,r,y.append(a,n),o,i)):e},se=e=>ne[oe[e]]||ne[e],ce=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ue=async(e,t=ce,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:he(t),o=fe(n,e),[i,a]=Q(o);if(!(e=>e in ne||e in oe)(i)){const e=await N(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ie(await e.json(),i)}const s=se(i),c=a&&"/"!==a[0]?pe(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return le(u)},le=e=>H(e.value)&&X in e.value?ue(e.value[X],e):H(e.value)&&Y in e.value?ue(e.value[Y],e,!0):e,fe=(e,t)=>{const r=D(e,t),n=Q(e)[0];if(n&&"file"===de(r)&&"file"!==de(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},de=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},pe=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ye=e=>e.value&&e.value[G]?e.value[G]:e.value,ve=(e,t)=>{const r=se(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:ye(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return le(n)},be=n((e,t)=>J.pipeline([ye,J.map(async(r,n)=>e(await ve(n,t),n)),J.all],t));var me={setConfig:(e,t,r)=>{ee[e]||(ee[e]={}),ee[e][t]=r},getConfig:re,add:ie,get:ue,markValidated:e=>{ne[e].validated=!0},uri:he,value:ye,has:(e,t)=>e in ye(t),step:ve,entries:e=>J.pipeline([ye,Object.keys,J.map(async t=>[t,await ve(t,e)]),J.all],e),map:be};const we="FLAG",ge="BASIC",Oe="DETAILED",Ee="VERBOSE";let $e=Oe,je=!0;const Se=(e,t)=>(n,o=we)=>{if(![we,ge,Oe,Ee].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ae(o,i));return Le(t,n,e),r.unsubscribe(a),i[0]},Ae=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Pe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ge&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===Ee||e!==we&&!i.valid)&&r.push(i),t[0]=i}},Pe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ve={},Ie=e=>Ve[e],Te=e=>e in Ve,ke={},Ce={},Ke=async(e,t)=>{if(!Te(e.schemaVersion+"#validate")){const t=await me.get(e.schemaVersion);(me.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in ke)Object.entries(ke[e]).forEach(([e,r])=>{((e,t)=>{Ve[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(je&&!e.validated){if(me.markValidated(e.id),!(e.schemaVersion in Ce)){const t=await me.get(e.schemaVersion),r={},n=await Ke(t,r);Ce[t.id]=Se(r,n)}const t=A.cons(e.schema,e.id),r=Ce[e.schemaVersion](t,$e);if(!r.valid)throw r}return await Ie(e.schemaVersion+"#validate").compile(e,t),me.uri(e)},Le=(e,t,r)=>{const[n]=r[e];return Ie(n).interpret(e,t,r)};var ze={validate:async(e,t,r)=>{const n={},o=await Ke(e,n),i=(e,t=we)=>Se(n,o)(A.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{$e=e},setShouldMetaValidate:e=>{je=e},FLAG:we,BASIC:ge,DETAILED:Oe,VERBOSE:Ee,getKeyword:Ie,hasKeyword:Te,defineVocabulary:(e,t)=>{ke[e]=t},compileSchema:Ke,interpretSchema:Le,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedItems(e,t,r,n)}};var qe={compile:async(e,t)=>{const r=me.uri(e);if(!(r in t)){t[r]=!1;const n=me.value(e);t[r]=[e.schemaVersion+"#validate",me.uri(e),"boolean"==typeof n?n:await J.pipeline([me.entries,J.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),J.filter(([t])=>ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),J.map(async([r,n])=>{const o=await ze.getKeyword(r).compile(n,t,e);return[r,me.uri(n),o]}),J.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ze.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:A.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:A.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ze.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ze.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Re=e("default",{Core:ze,Schema:me,Instance:A,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:qe}});e("Core",Re.Core),e("Schema",Re.Schema),e("Instance",Re.Instance),e("Keywords",Re.Keywords)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -523,2 +523,4 @@ (function (global, factory) { | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -535,17 +537,17 @@ | ||
var common = { isObject, splitUrl }; | ||
var common = { internalValue, isObject, splitUrl }; | ||
const { splitUrl: splitUrl$1 } = common; | ||
const { internalValue: internalValue$1 } = common; | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance }); | ||
const get$1 = (url, contextDoc = nil$1) => Object.freeze({ ...contextDoc, pointer: splitUrl$1(url)[1] }); | ||
const nil$1 = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil$1, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => jsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue$1]) ? doc.value[internalValue$1] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$1(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -571,3 +573,3 @@ const entries = (doc) => Object.keys(value(doc)) | ||
var instance = { cons, get: get$1, uri, value, step, entries, map, filter, reduce, every, some }; | ||
var instance = { cons, uri, value, step, entries, map, filter, reduce, every, some }; | ||
@@ -805,18 +807,3 @@ /*! | ||
var reduce$1 = justCurryIt(async (fn, acc, doc) => { | ||
return (await doc).reduce(async (acc, item) => { | ||
let resolvedAcc; | ||
try { | ||
resolvedAcc = await acc; | ||
} catch (e) { | ||
try { | ||
await item; | ||
} catch (e) { | ||
// If we've already encountered an error, ignore subsequent errors. | ||
} | ||
return acc; | ||
} | ||
return fn(resolvedAcc, item); | ||
}, acc); | ||
return (await doc).reduce(async (acc, item) => fn(await acc, item), acc); | ||
}); | ||
@@ -1083,3 +1070,3 @@ | ||
const { isObject: isObject$1, splitUrl: splitUrl$2 } = common; | ||
const { internalValue: internalValue$2, isObject: isObject$1, splitUrl: splitUrl$1 } = common; | ||
@@ -1089,2 +1076,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -1117,3 +1105,3 @@ // Config | ||
// Schema Version | ||
const schemaVersion = splitUrl$2(schema["$schema"] || defaultSchemaVersion)[0]; | ||
const schemaVersion = splitUrl$1(schema["$schema"] || defaultSchemaVersion)[0]; | ||
if (!schemaVersion) { | ||
@@ -1126,8 +1114,8 @@ throw Error("Couldn't determine schema version"); | ||
const idToken = getConfig(schemaVersion, "idToken"); | ||
const externalId = splitUrl$2(url)[0]; | ||
if (!externalId && !splitUrl$2(schema[idToken] || "")[0]) { | ||
const externalId = splitUrl$1(url)[0]; | ||
if (!externalId && !splitUrl$1(schema[idToken] || "")[0]) { | ||
throw Error("Couldn't determine an identifier for the schema"); | ||
} | ||
const internalUrl = safeResolveUrl(externalId, schema[idToken] || ""); | ||
const id = splitUrl$2(internalUrl)[0]; | ||
const id = splitUrl$1(internalUrl)[0]; | ||
if (externalId) { | ||
@@ -1167,10 +1155,9 @@ schemaStoreAlias[externalId] = id; | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
const ref = subject[idToken]; | ||
const resolvedUrl = safeResolveUrl(id, ref); | ||
const [schemaId, fragment] = splitUrl$2(resolvedUrl); | ||
const [schemaId, fragment] = splitUrl$1(resolvedUrl); | ||
delete subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -1185,15 +1172,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === jsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -1206,3 +1192,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -1212,2 +1198,26 @@ acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue$2]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue$2]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -1230,6 +1240,6 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const get$1 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
const [id, fragment] = splitUrl$2(resolvedUrl); | ||
const [id, fragment] = splitUrl$1(resolvedUrl); | ||
@@ -1254,2 +1264,3 @@ if (!hasStoredSchema(id)) { | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -1259,4 +1270,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: jsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -1266,12 +1278,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value$1(doc); | ||
if (isObject$1(docValue) && internalJref in docValue) { | ||
return get$2(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject$1(docValue) && typeof docValue["$ref"] === "string") { | ||
return get$2(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get$2(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get$2(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject$1(doc.value) && internalJref in doc.value) { | ||
return get$1(doc.value[internalJref], doc); | ||
} else if (isObject$1(doc.value) && internalDynamicJref in doc.value) { | ||
return get$1(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -1284,3 +1294,3 @@ return doc; | ||
const resolvedUrl = urlResolveBrowser(contextUrl, url); | ||
const contextId = splitUrl$2(contextUrl)[0]; | ||
const contextId = splitUrl$1(contextUrl)[0]; | ||
if (contextId && getScheme(resolvedUrl) === "file" && getScheme(contextId) !== "file") { | ||
@@ -1307,8 +1317,18 @@ throw Error(`Can't access file '${resolvedUrl}' resource from network context '${contextUrl}'`); | ||
const uri$1 = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value$1 = (doc) => jsonPointer.get(doc.pointer, doc.schema); | ||
const value$1 = (doc) => (doc.value && doc.value[internalValue$2]) ? doc.value[internalValue$2] : doc.value; | ||
const has = (key, doc) => key in value$1(doc); | ||
const step$1 = (key, doc) => { | ||
const keyPointer = jsonPointer.append(key, doc.pointer); | ||
return get$2(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: jsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value$1(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -1331,3 +1351,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$1, markValidated, | ||
uri: uri$1, value: value$1, has, step: step$1, entries: entries$2, map: map$2 | ||
@@ -1334,0 +1354,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),j=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),x=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:j,some:x},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={internalValue:Symbol("$__value"),isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{internalValue:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),w=e=>e.value&&e.value[b]?e.value[b]:e.value,g=(e,t)=>Object.freeze({...t,pointer:y.append(e,t.pointer),value:t.value[e]}),O=n((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=n((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=n((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),j=n((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),x=n((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:j,some:x},A=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+J(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=J(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function J(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),je(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||je(e)),je=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Pe=e=>xe[e],Se=e=>e in xe,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=P.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Pe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(A.lastIndex=r;a=A.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},_=async e=>Object.entries(await e),z=n(async(e,t)=>(await t).map(e)),q=n(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),R=n(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),U=n(async(e,t)=>{const r=await z(e,t);return(await Promise.all(r)).some(e=>e)}),W=n(async(e,t)=>{const r=await z(e,t);return(await Promise.all(r)).every(e=>e)}),B=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),J={entries:_,map:z,filter:R,reduce:q,some:U,every:W,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([_,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},D=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(Z.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?F(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:F(e)}};function F(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const Z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var N=fetch;const{internalValue:G,isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y=Symbol("$__dynamicJref"),ee={},te={},re=(e,t)=>{const r=e in te?te[e]:e;if(r in ee)return ee[r][t]},ne={},oe={},ie=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=re(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=fe(i,e[o]||""),s=Q(a)[0];let c;i&&(oe[i]=s),re(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(te[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};ne[s]={id:s,schemaVersion:n,schema:ae(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ae=(e,t,r,n,o,i)=>{if(H(e)){const a=re(r,"idToken"),s=re(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=fe(t,n),[i,c]=Q(o);if(delete e[a],c&&a===s&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ie(e,fe(t,i),r),{[X]:n}}const c=re(r,"dynamicAnchorToken");"string"==typeof e[c]&&(i["#"+e[c]]=t,e[s]=e[c],delete e[c]);const u=re(r,"recursiveAnchorToken");if(n===y.nil&&!0===e[u]&&(i["#"]=t,delete e[u]),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}e=Object.entries(e).reduce((e,[a,s])=>(e[a]=ae(s,t,r,y.append(a,n),o,i),e),{});const l=re(r,"jrefToken");if("string"==typeof e[l])return e[X]=e[l],e;const f=re(r,"jsrefToken");"string"==typeof e[f]&&(e[f]={[X]:e[f],[G]:e[f]});const d=re(r,"dynamicJsrefToken");return"string"==typeof e[d]&&(e[d]={[Y]:e[d],[G]:e[d]}),e}return Array.isArray(e)?e.map((e,a)=>ae(e,t,r,y.append(a,n),o,i)):e},se=e=>ne[oe[e]]||ne[e],ce=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ue=async(e,t=ce,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:he(t),o=fe(n,e),[i,a]=Q(o);if(!(e=>e in ne||e in oe)(i)){const e=await N(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ie(await e.json(),i)}const s=se(i),c=a&&"/"!==a[0]?pe(s,a):a,u=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:c,schema:s.schema,value:y.get(c,s.schema),recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated});return le(u)},le=e=>H(e.value)&&X in e.value?ue(e.value[X],e):H(e.value)&&Y in e.value?ue(e.value[Y],e,!0):e,fe=(e,t)=>{const r=D(e,t),n=Q(e)[0];if(n&&"file"===de(r)&&"file"!==de(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},de=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},pe=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},he=e=>`${e.id}#${encodeURI(e.pointer)}`,ye=e=>e.value&&e.value[G]?e.value[G]:e.value,ve=(e,t)=>{const r=se(t.id),n=Object.freeze({id:t.id,schemaVersion:t.schemaVersion,vocabulary:t.vocabulary,pointer:y.append(e,t.pointer),schema:r.schema,value:ye(t)[e],recursiveAnchors:t.recursiveAnchors,validated:r.validated});return le(n)},be=n((e,t)=>J.pipeline([ye,J.map(async(r,n)=>e(await ve(n,t),n)),J.all],t));var me={setConfig:(e,t,r)=>{ee[e]||(ee[e]={}),ee[e][t]=r},getConfig:re,add:ie,get:ue,markValidated:e=>{ne[e].validated=!0},uri:he,value:ye,has:(e,t)=>e in ye(t),step:ve,entries:e=>J.pipeline([ye,Object.keys,J.map(async t=>[t,await ve(t,e)]),J.all],e),map:be};const we="FLAG",ge="BASIC",Oe="DETAILED",Ee="VERBOSE";let $e=Oe,je=!0;const xe=(e,t)=>(n,o=we)=>{if(![we,ge,Oe,Ee].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Pe(o,i));return Le(t,n,e),r.unsubscribe(a),i[0]},Pe=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ge&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Se(i))break}(e===Ee||e!==we&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Se(e)),Se=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ve={},Ie=e=>Ve[e],Te=e=>e in Ve,ke={},Ce={},Ke=async(e,t)=>{if(!Te(e.schemaVersion+"#validate")){const t=await me.get(e.schemaVersion);(me.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in ke)Object.entries(ke[e]).forEach(([e,r])=>{((e,t)=>{Ve[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(je&&!e.validated){if(me.markValidated(e.id),!(e.schemaVersion in Ce)){const t=await me.get(e.schemaVersion),r={},n=await Ke(t,r);Ce[t.id]=xe(r,n)}const t=P.cons(e.schema,e.id),r=Ce[e.schemaVersion](t,$e);if(!r.valid)throw r}return await Ie(e.schemaVersion+"#validate").compile(e,t),me.uri(e)},Le=(e,t,r)=>{const[n]=r[e];return Ie(n).interpret(e,t,r)};var _e={validate:async(e,t,r)=>{const n={},o=await Ke(e,n),i=(e,t=we)=>xe(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{$e=e},setShouldMetaValidate:e=>{je=e},FLAG:we,BASIC:ge,DETAILED:Oe,VERBOSE:Ee,getKeyword:Ie,hasKeyword:Te,defineVocabulary:(e,t)=>{ke[e]=t},compileSchema:Ke,interpretSchema:Le,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ie(o).collectEvaluatedItems(e,t,r,n)}};var ze={compile:async(e,t)=>{const r=me.uri(e);if(!(r in t)){t[r]=!1;const n=me.value(e);t[r]=[e.schemaVersion+"#validate",me.uri(e),"boolean"==typeof n?n:await J.pipeline([me.entries,J.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),J.filter(([t])=>_e.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),J.map(async([r,n])=>{const o=await _e.getKeyword(r).compile(n,t,e);return[r,me.uri(n),o]}),J.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=_e.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&_e.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&_e.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},qe={Core:_e,Schema:me,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:ze}},Re=qe.Core,Ue=qe.Schema,We=qe.Instance,Be=qe.Keywords;e.Core=Re,e.Instance=We,e.Keywords=Be,e.Schema=Ue,e.default=qe,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
@@ -0,1 +1,3 @@ | ||
const internalValue = Symbol("$__value"); | ||
const isObject = (value) => typeof value === "object" && !Array.isArray(value) && value !== null; | ||
@@ -12,2 +14,2 @@ | ||
module.exports = { isObject, splitUrl }; | ||
module.exports = { internalValue, isObject, splitUrl }; |
const JsonPointer = require("@hyperjump/json-pointer"); | ||
const curry = require("just-curry-it"); | ||
const { splitUrl } = require("./common"); | ||
const { internalValue } = require("./common"); | ||
const nil = Object.freeze({ id: "", pointer: "", instance: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil, id, instance }); | ||
const get = (url, contextDoc = nil) => Object.freeze({ ...contextDoc, pointer: splitUrl(url)[1] }); | ||
const nil = Object.freeze({ id: "", pointer: "", instance: undefined, value: undefined }); | ||
const cons = (instance, id = "") => Object.freeze({ ...nil, id, instance, value: instance }); | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => JsonPointer.get(doc.pointer, doc.instance); | ||
const value = (doc) => (doc.value && doc.value[internalValue]) ? doc.value[internalValue] : doc.value; | ||
const step = (key, doc) => { | ||
const keyPointer = JsonPointer.append(key, doc.pointer); | ||
return get(`#${encodeURI(keyPointer)}`, doc); | ||
}; | ||
const step = (key, doc) => Object.freeze({ | ||
...doc, | ||
pointer: JsonPointer.append(key, doc.pointer), | ||
value: doc.value[key] | ||
}); | ||
@@ -36,2 +36,2 @@ const entries = (doc) => Object.keys(value(doc)) | ||
module.exports = { cons, get, uri, value, step, entries, map, filter, reduce, every, some }; | ||
module.exports = { cons, uri, value, step, entries, map, filter, reduce, every, some }; |
@@ -5,4 +5,4 @@ const contentTypeParser = require("content-type"); | ||
const JsonPointer = require("@hyperjump/json-pointer"); | ||
const resolveUrl = require("./url-resolve-browser"); | ||
const { isObject, splitUrl } = require("./common"); | ||
const resolveUrl = require("url-resolve-browser"); | ||
const { internalValue, isObject, splitUrl } = require("./common"); | ||
const fetch = require("./fetch"); | ||
@@ -12,2 +12,3 @@ | ||
const internalJref = Symbol("$__jref"); | ||
const internalDynamicJref = Symbol("$__dynamicJref"); | ||
@@ -88,3 +89,2 @@ // Config | ||
const anchorToken = getConfig(schemaVersion, "anchorToken"); | ||
if (typeof subject[idToken] === "string") { | ||
@@ -96,3 +96,3 @@ const ref = subject[idToken]; | ||
if (fragment) { | ||
if (fragment && idToken === anchorToken) { | ||
subject[anchorToken] = anchorToken !== idToken ? encodeURI(fragment) : `#${encodeURI(fragment)}`; | ||
@@ -107,15 +107,14 @@ } | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === JsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
const dynamicAnchorToken = getConfig(schemaVersion, "dynamicAnchorToken"); | ||
if (typeof subject[dynamicAnchorToken] === "string") { | ||
recursiveAnchors[`#${subject[dynamicAnchorToken]}`] = id; | ||
subject[anchorToken] = subject[dynamicAnchorToken]; | ||
delete subject[dynamicAnchorToken]; | ||
} | ||
const recursiveAnchorToken = getConfig(schemaVersion, "recursiveAnchorToken"); | ||
if (pointer === JsonPointer.nil && subject[recursiveAnchorToken] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject[recursiveAnchorToken]; | ||
} | ||
@@ -128,3 +127,3 @@ if (typeof subject[anchorToken] === "string") { | ||
return Object.entries(subject) | ||
subject = Object.entries(subject) | ||
.reduce((acc, [key, value]) => { | ||
@@ -134,2 +133,26 @@ acc[key] = processSchema(value, id, schemaVersion, JsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
}, {}); | ||
const jrefToken = getConfig(schemaVersion, "jrefToken"); | ||
if (typeof subject[jrefToken] === "string") { | ||
subject[internalJref] = subject[jrefToken]; | ||
return subject; | ||
} | ||
const jsrefToken = getConfig(schemaVersion, "jsrefToken"); | ||
if (typeof subject[jsrefToken] === "string") { | ||
subject[jsrefToken] = { | ||
[internalJref]: subject[jsrefToken], | ||
[internalValue]: subject[jsrefToken] | ||
}; | ||
} | ||
const dynamicJsrefToken = getConfig(schemaVersion, "dynamicJsrefToken"); | ||
if (typeof subject[dynamicJsrefToken] === "string") { | ||
subject[dynamicJsrefToken] = { | ||
[internalDynamicJref]: subject[dynamicJsrefToken], | ||
[internalValue]: subject[dynamicJsrefToken] | ||
}; | ||
} | ||
return subject; | ||
} else if (Array.isArray(subject)) { | ||
@@ -175,2 +198,3 @@ return subject.map((item, ndx) => processSchema(item, id, schemaVersion, JsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
const storedSchema = getStoredSchema(id); | ||
const pointer = fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment; | ||
const doc = Object.freeze({ | ||
@@ -180,4 +204,5 @@ id: storedSchema.id, | ||
vocabulary: storedSchema.vocabulary, | ||
pointer: fragment && fragment[0] !== "/" ? getAnchorPointer(storedSchema, fragment) : fragment, | ||
pointer: pointer, | ||
schema: storedSchema.schema, | ||
value: JsonPointer.get(pointer, storedSchema.schema), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
@@ -187,12 +212,10 @@ validated: storedSchema.validated | ||
// Follow references | ||
const docValue = value(doc); | ||
if (isObject(docValue) && internalJref in docValue) { | ||
return get(docValue[internalJref], doc); | ||
} else if (getConfig(doc.schemaVersion, "jsonReference") && isObject(docValue) && typeof docValue["$ref"] === "string") { | ||
return get(docValue["$ref"], doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordReference") && typeof docValue === "string" && doc.pointer.endsWith("/$ref")) { | ||
return get(docValue, doc); | ||
} else if (getConfig(doc.schemaVersion, "keywordRecursiveReference") && typeof docValue === "string" && doc.pointer.endsWith("/$recursiveRef")) { | ||
return get(docValue, doc, true); | ||
return followReferences(doc); | ||
}; | ||
const followReferences = (doc) => { | ||
if (isObject(doc.value) && internalJref in doc.value) { | ||
return get(doc.value[internalJref], doc); | ||
} else if (isObject(doc.value) && internalDynamicJref in doc.value) { | ||
return get(doc.value[internalDynamicJref], doc, true); | ||
} else { | ||
@@ -227,8 +250,18 @@ return doc; | ||
const uri = (doc) => `${doc.id}#${encodeURI(doc.pointer)}`; | ||
const value = (doc) => JsonPointer.get(doc.pointer, doc.schema); | ||
const value = (doc) => (doc.value && doc.value[internalValue]) ? doc.value[internalValue] : doc.value; | ||
const has = (key, doc) => key in value(doc); | ||
const step = (key, doc) => { | ||
const keyPointer = JsonPointer.append(key, doc.pointer); | ||
return get(`#${encodeURI(keyPointer)}`, doc); | ||
const storedSchema = getStoredSchema(doc.id); | ||
const nextDoc = Object.freeze({ | ||
id: doc.id, | ||
schemaVersion: doc.schemaVersion, | ||
vocabulary: doc.vocabulary, | ||
pointer: JsonPointer.append(key, doc.pointer), | ||
schema: storedSchema.schema, | ||
value: value(doc)[key], | ||
recursiveAnchors: doc.recursiveAnchors, | ||
validated: storedSchema.validated | ||
}); | ||
return followReferences(nextDoc); | ||
}; | ||
@@ -235,0 +268,0 @@ |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -40,3 +40,3 @@ "main": "lib/index.js", | ||
"nock": "^9.6.1", | ||
"rollup": "^2.7.2", | ||
"rollup": "^2.12.1", | ||
"rollup-plugin-terser": "^5.3.0" | ||
@@ -46,7 +46,8 @@ }, | ||
"@hyperjump/json-pointer": "^0.8.0", | ||
"@hyperjump/pact": "^0.1.0", | ||
"@hyperjump/pact": "^0.1.2", | ||
"content-type": "^1.0.4", | ||
"make-fetch-happen": "^8.0.4", | ||
"pubsub-js": "^1.8.0" | ||
"make-fetch-happen": "^8.0.7", | ||
"pubsub-js": "^1.8.0", | ||
"url-resolve-browser": "^1.2.0" | ||
} | ||
} |
@@ -388,4 +388,5 @@ # Hyperjump - JSON Schema Core | ||
In addition to this documentation you should be able to look at the | ||
[JSV](https://github.com/hyperjump-io/json-schema-validator) code to see an example of how | ||
to add your custom plugins because it's all implemented the same way. | ||
[JSV](https://github.com/hyperjump-io/json-schema-validator) code to see an | ||
example of how to add your custom plugins because it's all implemented the same | ||
way. | ||
@@ -395,23 +396,19 @@ ### References | ||
allows you to configure which version(s) of `$ref`s you want to support. There | ||
are four types of references. | ||
are several types of references. | ||
* **JSON Reference**: *(draft-04)* References are defined in a separate spec | ||
from JSON Schema. The JSON Schema spec only constrains `$ref` in how URIs are | ||
resolved with respect to `id`. | ||
* **JSON Reference**: *(draft-04/06/07)* In draft-04, references were defined in | ||
a separate spec from JSON Schema. The JSON Schema spec only constrained `$ref` | ||
in how URIs are resolved with respect to `id`. Then in draft-06/07, JSON | ||
Schema absorbed the JSON Reference spec and further constrained `$ref` to only | ||
be allowed where schemas are allowed. JSC doesn't support this constraint | ||
because it can't be done in a keyword agnostic way. | ||
* **JSON Schema Reference**: *(draft-06/7)* The JSON Schema spec absorbed the | ||
JSON Reference spec and further constrained `$ref` to only be allowed where | ||
schemas are allowed. JSC doesn't support this type of reference because I | ||
haven't figured out how to do it a keyword agnostic way. You can use JSON | ||
References instead and it will just be a little more lenient about where | ||
references are allowed. | ||
* **JSON Schema Reference**: *(draft-2019-09)* In draft 2019-09, a reference was | ||
changed from being an object with a `$ref` property to the value of a `$ref` | ||
keyword. This allowed `$ref` to behave more like a keyword. | ||
* **Keyword Reference**: *(draft-2019-09)* A reference was changed from being an | ||
object with a `$ref` property to the value of a `$ref` keyword. This allowed | ||
`$ref` to behave more like a keyword. | ||
* **Dynamic JSON Schema Reference**: *(draft-2019-09)* In draft 2019-09, the | ||
concept of a dynamic scope reference was added to make it easier to extend | ||
recursive schemas. This was added to support building custom meta-schemas. | ||
* **Keyword Recursive Reference**: *(draft-2019-09)* Along with | ||
`$recursiveAnchor`, this new type of reference was added to the spec to make | ||
it easier to write custom meta-schemas. | ||
References can be configured by `$schema` identifier. When you create a custom | ||
@@ -426,7 +423,7 @@ meta-schema, you will need to configure which types of references your schema | ||
// Configure draft-2019-09 style references | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "keywordReference", true); | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "keywordRecursiveReference", true); | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "jsrefToken", "$ref"); | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "dynamicJsrefToken", "$recursiveRef"); | ||
// Configure draft-04/6/7 style references | ||
Schema.setConfig("http://json-schema.org/draft-04/schema", "jsonReference", true); | ||
Schema.setConfig("http://json-schema.org/draft-04/schema", "jrefToken", "$ref"); | ||
``` | ||
@@ -450,3 +447,7 @@ | ||
* **$recursiveAnchor**: *(draft-2019-09)* Dynamic scope same-document reference. | ||
Value is a boolean that is only allowed at the root of a schema. | ||
* **$dynamicAnchor**: *(draft-2019-09)* Dynamic scope same-document reference. | ||
Value is a string and works like `$anchor`. | ||
In draft-2019-09, `$id` was redefined from being a resolution scope modifier to | ||
@@ -470,2 +471,3 @@ being an inlined reference. This means that JSON Pointers can not cross into | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "anchorToken", "$anchor"); | ||
Schema.setConfig("https://json-schema.org/draft/2019-09/schema", "recursiveAnchorToken", "$recursiveAnchor"); | ||
@@ -472,0 +474,0 @@ // Configure draft-06/7 style references |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1526110
602
6
37
8840
+ Addedurl-resolve-browser@^1.2.0
+ Addedurl-resolve-browser@1.2.0(transitive)
Updated@hyperjump/pact@^0.1.2
Updatedmake-fetch-happen@^8.0.7