@hyperjump/json-schema-core
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -1078,3 +1078,4 @@ define(['exports'], function (exports) { 'use strict'; | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1129,2 +1130,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1163,3 +1168,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1227,3 +1233,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1306,26 +1312,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1332,0 +1340,0 @@ // Meta validation |
@@ -1,2 +0,2 @@ | ||
define(["exports"],(function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var i={};r.PubSub=i;var o=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function i(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?o:i;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,i,o){var s=function(e,r,t){return function(){var n=String(e),i=n.lastIndexOf(".");for(a(e,e,r,t);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,o);return!!function(e){for(var t=String(e),i=Boolean(r.hasOwnProperty(t)&&n(r[t])),o=t.lastIndexOf(".");!i&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),i=Boolean(r.hasOwnProperty(t)&&n(r[t]));return i}(e)&&(!0===i?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var i="uid_"+String(++t);return r[e][i]=n,i},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,i,o,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(i=r[n],s&&i[t]){delete i[t],u=t;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(delete i[o],u=!0)}return u}e.clearSubscriptions(t)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==e&&e.exports&&(t=e.exports=i),t.PubSub=i,e.exports=t=i)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},i=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.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(p)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const i=e.shift();return{...r,[i]:a(e,h(r,i,n),t,f(i,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:h(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||d(r)){const i=e.shift();s(e,h(r,i,n),t,f(i,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=h(r,n,t);return{...r,[n]:c(e,i,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return h(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=h(r,n,t);u(e,i,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:h(r,e[0],t)},f=i((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),p=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),h=(e,r,t="")=>{if(d(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},d=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=o(e),n=e=>t.reduce(([e,r],t)=>[h(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=o(e),s=i((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=o(e),a=i((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=o(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=o(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,m=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,r=m)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return v(`#${encodeURI(t)}`,r)},O=i((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=i((e,r,t)=>w(t).reduce((r,n,i)=>e(r,g(i,t),i),r)),E=i((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),j=i((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var x={cons:(e,r="")=>Object.freeze({...m,id:r,instance:e}),get:v,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:j},S=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
define(["exports"],(function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var o={};r.PubSub=o;var i=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},o=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(d)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:a(e,p(r,o,n),t,f(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||h(r)){const o=e.shift();s(e,p(r,o,n),t,f(o,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(r,n,t);return{...r,[n]:c(e,o,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(r,n,t);u(e,o,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},f=o((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),d=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(h(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=i(e),s=o((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=i(e),a=o((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,v=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=v)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},O=o((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=o((e,r,t)=>w(t).reduce((r,n,o)=>e(r,g(o,t),o),r)),E=o((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),j=o((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var x={cons:(e,r="")=>Object.freeze({...v,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:j},S=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function T(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(V,"\\$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 r=e.parameters,t=e.type;if(!t||!R.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var i,o=Object.keys(r).sort(),a=0;a<o.length;a++){if(i=o[a],!P.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+T(r[i])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!R.test(n))throw new TypeError("invalid media type");var i=new k(n.toLowerCase());if(-1!==t){var o,a,s;for(S.lastIndex=t;a=S.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,o=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),i.parameters[o]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return i}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==o){const e=t.substring(o);r.query=e,t=t.substring(0,o)}if(-1!==i){const e=t.substring(0,i);r.host=e,t=t.substring(i),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=t.substring(i);r.hash=e,t=t.substring(0,i)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:i}=n;return t.host+z(e)+r+i}if(n.relativePath){const{path:e,query:r,hash:i}=n;let o,a=t.path,s=t.host;return 0===e.length?o=a:(a=a.substring(0,a.lastIndexOf("/")),o=z(a+"/"+e)),s+=""!==o||r||i?o+r+i:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),i=!e.includes("#",r);return t&&n&&i}var _=fetch;const{isObject:W,splitUrl:B}=n,J=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},M={},G=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=B(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=Z(n,"idToken"),o=B(r)[0],a=Y(o,e[i]||""),s=B(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");o&&(M[o]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:H(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},H=(e,r,t,n,i)=>{if(W(e)){const o=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=Y(r,n),[s,c]=B(i);if(delete e[o],c&&(e[a]=a!==o?encodeURI(c):`#${encodeURI(c)}`),s!==r)return G(e,Y(r,s),t),{[J]:n}}if("string"==typeof e[a]){const r=a!==o?e[a]:e[a].slice(1);i[r]=n,delete e[a]}return Object.entries(e).reduce((e,[o,a])=>(e[o]=H(a,r,t,y.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>H(e,r,t,y.append(o,n),i)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),i=Y(n,e),[o,a]=B(i);if(!(e=>e in N||e in M)(o)){const e=await _(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const r=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${o} is not a schema. Found a document with media type: ${r}`)}G(await e.json(),o)}const s=(e=>N[e]||N[M[e]])(o),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&o,validated:s.validated}),u=ne(c);return W(u)&&J in u?X(u[J],c):Z(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),ie=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},oe=i((e,r)=>ne(r).map(async(t,n)=>e(await ie(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:G,get:X,markValidated:e=>{N[e].validated=!0},uri:te,value:ne,step:ie,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,ie(r,e)]),map:oe};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const pe=(e,r)=>(n,i=se)=>{if(![se,ce,ue,fe].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const a=t.subscribe("result",he(i,o));return Oe(r,n,e),t.unsubscribe(a),o[0]},he=(e,r)=>{const t=[];return(n,i)=>{const o={...i,errors:[]};for(;t.length>0&&de(t[t.length-1],o);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),o.errors.unshift(r,...n),ye(o))break}(e===fe||e!==se&&!o.valid)&&t.push(o),r[0]=o}},de=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},me=e=>be[e],ve={},we={},ge=async(e,r,t=!1)=>{if(!e.validated){if(ae.markValidated(e.id),t&&((ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in ve)Object.entries(ve[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=pe(t,n)}const r=x.cons(e.schema,e.id),n=we[e.schemaVersion](r,le);if(!n.valid)throw n}return await me(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return me(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},i=await ge(e,n),o=(e,r=se)=>pe(n,i)(x.cons(e),r);return void 0===r?o:o(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:me,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{ve[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),xe=i(async(e,r)=>(await r).map(e)),Se=i(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=i(async(e,r,t={})=>Se(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=i(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).some(e=>e)}),Ie=i(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).every(e=>e)}),Ve=i((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Re={entries:je,map:xe,filter:Ae,reduce:Se,some:Pe,every:Ie,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([je,Se(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Te={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await Re.pipeline([ae.entries,Re.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Re.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),Re.map(async([e,t])=>{const n=await t,i=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),i]}),Re.all],e)]}},interpret:(e,r,n)=>{const[i,o,a]=n[e],s="boolean"==typeof a?a:a.every(([e,i,o])=>{const a=$e.getKeyword(e).interpret(o,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:x.uri(r),valid:a}),a});return t.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:x.uri(r),valid:s}),s}},ke={JsonSchema:$e,Schema:ae,Instance:x,Keywords:{metaData:Ee,validate:Te}},Le=ke.JsonSchema,Ue=ke.Schema,qe=ke.Instance,ze=ke.Keywords;e.Instance=qe,e.JsonSchema=Le,e.Keywords=ze,e.Schema=Ue,e.default=ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function L(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function R(e){this.parameters=Object.create(null),this.type=e}var T={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!k.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!P.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+L(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new R(n.toLowerCase());if(-1!==t){var i,a,s;for(S.lastIndex=t;a=S.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=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(t!==r.length)throw new TypeError("invalid parameter format")}return o}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+z(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=z(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var _=fetch;const{isObject:W,splitUrl:B}=n,J=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},M={},G=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=B(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=Z(n,"idToken"),i=B(r)[0],a=Y(i,e[o]||""),s=B(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(M[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:H(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},H=(e,r,t,n,o)=>{if(W(e)){const i=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=Y(r,n),[s,c]=B(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return G(e,Y(r,s),t),{[J]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=H(a,r,t,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>H(e,r,t,y.append(i,n),o)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),o=Y(n,e),[i,a]=B(o);if(!(e=>e in N||e in M)(i)){const e=await _(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 r=T.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}G(await e.json(),i)}const s=(e=>N[e]||N[M[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=ne(c);return W(u)&&J in u?X(u[J],c):Z(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),oe=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},ie=o((e,r)=>ne(r).map(async(t,n)=>e(await oe(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:G,get:X,markValidated:e=>{N[e].validated=!0},markVocabularyLoaded:e=>{N[e].vocabularyLoaded=!0},uri:te,value:ne,step:oe,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,oe(r,e)]),map:ie};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const de=(e,r)=>(n,o=se)=>{if(![se,ce,ue,fe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",pe(o,i));return Oe(r,n,e),t.unsubscribe(a),i[0]},pe=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&he(t[t.length-1],i);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),ye(i))break}(e===fe||e!==se&&!i.valid)&&t.push(i),r[0]=i}},he=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},ve=e=>be[e],me={},we={},ge=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ae.markVocabularyLoaded(e.id),(ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ae.markValidated(e.id),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=de(t,n)}const r=x.cons(e.schema,e.id),t=we[e.schemaVersion](r,le);if(!t.valid)throw t}return await ve(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return ve(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},o=await ge(e,n),i=(e,r=se)=>de(n,o)(x.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:ve,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),xe=o(async(e,r)=>(await r).map(e)),Se=o(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=o(async(e,r,t={})=>Se(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=o(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).some(e=>e)}),Ve=o(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=o((e,r)=>e.reduce(async(e,r)=>r(await e),r)),ke={entries:je,map:xe,filter:Ae,reduce:Se,some:Pe,every:Ve,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([je,Se(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Le={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await ke.pipeline([ae.entries,ke.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),ke.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),ke.map(async([e,t])=>{const n=await t,o=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),o]}),ke.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:x.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(r),valid:s}),s}},Re={JsonSchema:$e,Schema:ae,Instance:x,Keywords:{metaData:Ee,validate:Le}},Te=Re.JsonSchema,Ue=Re.Schema,qe=Re.Instance,ze=Re.Keywords;e.Instance=qe,e.JsonSchema=Te,e.Keywords=ze,e.Schema=Ue,e.default=Re,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -1080,3 +1080,4 @@ 'use strict'; | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1131,2 +1132,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1165,3 +1170,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1229,3 +1235,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1308,26 +1314,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1334,0 +1342,0 @@ // Meta validation |
@@ -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 r=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(r,t){!function(e,n){var i={};e.PubSub=i;var o=e.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function i(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,r,t){e(r,t)}function s(e,t,n,s){var a,c=r[t],u=s?o:i;if(r.hasOwnProperty(t))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function a(e,t,i,o){var a=function(e,r,t){return function(){var n=String(e),i=n.lastIndexOf(".");for(s(e,e,r,t);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),s(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,o);return!!function(e){for(var t=String(e),i=Boolean(r.hasOwnProperty(t)&&n(r[t])),o=t.lastIndexOf(".");!i&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),i=Boolean(r.hasOwnProperty(t)&&n(r[t]));return i}(e)&&(!0===i?a():setTimeout(a,0),!0)}e.publish=function(r,t){return a(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return a(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var i="uid_"+String(++t);return r[e][i]=n,i},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,i,o,s="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),a=!s&&"string"==typeof t,c="function"==typeof t,u=!1;if(!s){for(n in r)if(r.hasOwnProperty(n)){if(i=r[n],a&&i[t]){delete i[t],u=t;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(delete i[o],u=!0)}return u}e.clearSubscriptions(t)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==r&&r.exports&&(t=r.exports=i),t.PubSub=i,r.exports=t=i)}("object"==typeof window&&window||e)}));r.PubSub;var t={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},n=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const i=e.shift();return{...r,[i]:o(e,p(r,i,n),t,u(i,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||h(r)){const i=e.shift();s(e,p(r,i,n),t,u(i,n))}else{r[e[0]]=t}},a=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=p(r,n,t);return{...r,[n]:a(e,i,u(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},c=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=p(r,n,t);c(e,i,u(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},u=n((e,r)=>r+"/"+f(e)),f=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(h(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},h=e=>null===e||"object"!=typeof e;var d={nil:"",append:u,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),u(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const s=i(e),a=n((e,r)=>o(s,e,r,""));return void 0===r?a:a(r,t)},assign:(e,r,t)=>{const o=i(e),a=n((e,r)=>s(o,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=i(e),n=e=>a(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:y}=t,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=b)=>Object.freeze({...r,pointer:y(e)[1]}),v=e=>d.get(e.pointer,e.instance),w=(e,r)=>{const t=d.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},g=n((e,r)=>v(r).map((t,n)=>e(w(n,r),n))),O=n((e,r,t)=>v(t).reduce((r,n,i)=>e(r,w(i,t),i),r)),$=n((e,r)=>Object.keys(v(r)).every((t,n)=>e(w(t,r),n))),x=n((e,r)=>Object.keys(v(r)).some((t,n)=>e(w(t,r),n)));var E={cons:(e,r="")=>Object.freeze({...b,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:v,step:w,entries:e=>Object.keys(v(e)).map(r=>[r,w(r,e)]),map:g,reduce:O,every:$,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]+$/,A=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,P=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,V=/^[!#$%&'*+.^_`|~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 r=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(r,t){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==r&&r.exports&&(t=r.exports=o),t.PubSub=o,r.exports=t=o)}("object"==typeof window&&window||e)}));r.PubSub;var t={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},n=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.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(l)},i=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:i(e,d(r,o,n),t,u(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:d(r,e[0],n)},a=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||p(r)){const o=e.shift();a(e,d(r,o,n),t,u(o,n))}else{r[e[0]]=t}},s=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(r,n,t);return{...r,[n]:s(e,o,u(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return d(r,e[0],t)}},c=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(r,n,t);c(e,o,u(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:d(r,e[0],t)},u=n((e,r)=>r+"/"+f(e)),f=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),d=(e,r,t="")=>{if(p(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:u,get:(e,r)=>{const t=o(e),n=e=>t.reduce(([e,r],t)=>[d(e,t,r),u(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const a=o(e),s=n((e,r)=>i(a,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const i=o(e),s=n((e,r)=>a(i,e,r,""));return void 0===r?s:s(r,t)},unset:(e,r)=>{const t=o(e),n=e=>s(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=o(e),n=e=>c(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:y}=t,b=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,r=b)=>Object.freeze({...r,pointer:y(e)[1]}),m=e=>h.get(e.pointer,e.instance),w=(e,r)=>{const t=h.append(e,r.pointer);return v(`#${encodeURI(t)}`,r)},g=n((e,r)=>m(r).map((t,n)=>e(w(n,r),n))),O=n((e,r,t)=>m(t).reduce((r,n,o)=>e(r,w(o,t),o),r)),$=n((e,r)=>Object.keys(m(r)).every((t,n)=>e(w(t,r),n))),x=n((e,r)=>Object.keys(m(r)).some((t,n)=>e(w(t,r),n)));var E={cons:(e,r="")=>Object.freeze({...b,id:r,instance:e}),get:v,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:m,step:w,entries:e=>Object.keys(m(e)).map(r=>[r,w(r,e)]),map:g,reduce:O,every:$,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]+$/,A=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,P=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var r=String(e);if(A.test(r))return r;if(r.length>0&&!S.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function T(e){this.parameters=Object.create(null),this.type=e}var k={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!V.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var i,o=Object.keys(r).sort(),s=0;s<o.length;s++){if(i=o[s],!A.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+R(r[i])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!V.test(n))throw new TypeError("invalid media type");var i=new T(n.toLowerCase());if(-1!==t){var o,s,a;for(j.lastIndex=t;s=j.exec(r);){if(s.index!==t)throw new TypeError("invalid parameter format");t+=s[0].length,o=s[1].toLowerCase(),'"'===(a=s[2])[0]&&(a=a.substr(1,a.length-2).replace(P,"$1")),i.parameters[o]=a}if(t!==r.length)throw new TypeError("invalid parameter format")}return i}},L=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return K(r)?U(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),s=e.indexOf("#");-1!==s&&(t=t.substring(0,s));if(-1!==o){const e=t.substring(o);r.query=e,t=t.substring(0,o)}if(-1!==i){const e=t.substring(0,i);r.host=e,t=t.substring(i),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:U(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(z.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=t.substring(i);r.hash=e,t=t.substring(0,i)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),K(n.href)?U(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:i}=n;return t.host+q(e)+r+i}if(n.relativePath){const{path:e,query:r,hash:i}=n;let o,s=t.path,a=t.host;return 0===e.length?o=s:(s=s.substring(0,s.lastIndexOf("/")),o=q(s+"/"+e)),a+=""!==o||r||i?o+r+i:"/",a}};function U(e){return e+("/"===e[e.length-1]?"":"/")}function q(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function K(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),i=!e.includes("#",r);return t&&n&&i}var C=fetch;const{isObject:_,splitUrl:W}=t,B=Symbol("$__jref"),J={},D={},F=(e,r)=>{const t=e in D?D[e]:e;if(t in J)return J[t][r]},Z={},N={},M=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=W(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=F(n,"idToken"),o=W(r)[0],s=X(o,e[i]||""),a=W(s)[0];if(!a)throw Error("Couldn't determine an identifier for the schema");o&&(N[o]=a);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,F(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(D[a]=n,u=e.$vocabulary,delete e.$vocabulary):u=a===n?{[n]:!0}:{};const f={};Z[a]={id:a,schemaVersion:n,schema:G(e,a,n,d.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},G=(e,r,t,n,i)=>{if(_(e)){const o=F(t,"idToken"),s=F(t,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=X(r,n),[a,c]=W(i);if(delete e[o],c&&(e[s]=s!==o?encodeURI(c):`#${encodeURI(c)}`),a!==r)return M(e,X(r,a),t),{[B]:n}}if("string"==typeof e[s]){const r=s!==o?e[s]:e[s].slice(1);i[r]=n,delete e[s]}return Object.entries(e).reduce((e,[o,s])=>(e[o]=G(s,r,t,d.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>G(e,r,t,d.append(o,n),i)):e},H=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),Q=async(e,r=H,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:re(r),i=X(n,e),[o,s]=W(i);if(!(e=>e in Z||e in N)(o)){const e=await C(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const r=k.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${o} is not a schema. Found a document with media type: ${r}`)}M(await e.json(),o)}const a=(e=>Z[e]||Z[N[e]])(o),c=Object.freeze({id:a.id,schemaVersion:a.schemaVersion,vocabulary:a.vocabulary,pointer:s&&"/"!==s[0]?ee(a,s):s,schema:a.schema,recursiveAnchor:r.recursiveAnchor||!!a.recursiveAnchor&&o,validated:a.validated}),u=te(c);return _(u)&&B in u?Q(u[B],c):F(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?Q(u.$ref,c):F(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?Q(u,c):F(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?Q(u,c,!0):c},X=(e,r)=>{const t=L(e,r);if("file"===Y(t)&&"file"!==Y(e))throw Error("Can't access file resource from network context");return t},Y=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},ee=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},re=e=>`${e.id}#${encodeURI(e.pointer)}`,te=e=>d.get(e.pointer,e.schema),ne=(e,r)=>{const t=d.append(e,r.pointer);return Q(`#${encodeURI(t)}`,r)},ie=n((e,r)=>te(r).map(async(t,n)=>e(await ne(n,r),n)));var oe={setConfig:(e,r,t)=>{J[e]||(J[e]={}),J[e][r]=t},getConfig:F,add:M,get:Q,markValidated:e=>{Z[e].validated=!0},uri:re,value:te,step:ne,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=d.append(e,t.join("/"));return Q(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(te(e)).map(r=>[r,ne(r,e)]),map:ie};const se="FLAG",ae="BASIC",ce="DETAILED",ue="VERBOSE";let fe=ce;const le=(e,t)=>(n,i=se)=>{if(![se,ae,ce,ue].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const s=r.subscribe("result",pe(i,o));return ge(t,n,e),r.unsubscribe(s),o[0]},pe=(e,r)=>{const t=[];return(n,i)=>{const o={...i,errors:[]};for(;t.length>0&&he(t[t.length-1],o);){const r=t.pop();let n=[];if(e===ae&&(n=r.errors,delete r.errors),o.errors.unshift(r,...n),de(o))break}(e===ue||e!==se&&!o.valid)&&t.push(o),r[0]=o}},he=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||de(e)),de=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),ye={},be=e=>ye[e],me={},ve={},we=async(e,r,t=!1)=>{if(!e.validated){if(oe.markValidated(e.id),t&&((oe.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{ye[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!(e.schemaVersion in ve)){const r=await oe.get(e.schemaVersion),t={},n=await we(r,t,!0);ve[e.schemaVersion]=le(t,n)}const r=E.cons(e.schema,e.id),n=ve[e.schemaVersion](r,fe);if(!n.valid)throw n}return await be(`${e.schemaVersion}#validate`).compile(e,r),oe.uri(e)},ge=(e,r,t)=>{const[n]=t[e];return be(n).interpret(e,r,t)};var Oe={validate:async(e,r,t)=>{const n={},i=await we(e,n),o=(e,r=se)=>le(n,i)(E.cons(e),r);return void 0===r?o:o(r,t)},setMetaOutputFormat:e=>{fe=e},FLAG:se,BASIC:ae,DETAILED:ce,VERBOSE:ue,getKeyword:be,hasKeyword:e=>e in ye,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:we,interpretSchema:ge};var $e={compile:()=>{},interpret:()=>!0},xe=async e=>Object.entries(await e),Ee=n(async(e,r)=>(await r).map(e)),je=n(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Se=n(async(e,r,t={})=>je(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Ae=n(async(e,r)=>{const t=await Ee(e,r);return(await Promise.all(t)).some(e=>e)}),Pe=n(async(e,r)=>{const t=await Ee(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=n((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Ve={entries:xe,map:Ee,filter:Se,reduce:je,some:Ae,every:Pe,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([xe,je(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Re={compile:async(e,r)=>{const t=oe.uri(e);if(!(t in r)){r[t]=!1;const n=oe.value(e);r[t]=[`${e.schemaVersion}#validate`,oe.uri(e),"boolean"==typeof n?n:await Ve.pipeline([oe.entries,Ve.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Ve.filter(([e])=>Oe.hasKeyword(e)&&"validate"!==e),Ve.map(async([e,t])=>{const n=await t,i=await Oe.getKeyword(e).compile(n,r);return[e,oe.uri(n),i]}),Ve.all],e)]}},interpret:(e,t,n)=>{const[i,o,s]=n[e],a="boolean"==typeof s?s:s.every(([e,i,o])=>{const s=Oe.getKeyword(e).interpret(o,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:E.uri(t),valid:s}),s});return r.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:E.uri(t),valid:a}),a}},Te={JsonSchema:Oe,Schema:oe,Instance:E,Keywords:{metaData:$e,validate:Re}},ke=Te.JsonSchema,Le=Te.Schema,Ue=Te.Instance,qe=Te.Keywords;exports.Instance=Ue,exports.JsonSchema=ke,exports.Keywords=qe,exports.Schema=Le,exports.default=Te; | ||
*/function k(e){var r=String(e);if(A.test(r))return r;if(r.length>0&&!S.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(V,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var R={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!I.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!A.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+k(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!I.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==t){var i,a,s;for(j.lastIndex=t;a=j.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(P,"$1")),o.parameters[i]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return o}},T=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return K(r)?U(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:U(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(z.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),K(n.href)?U(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+q(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=q(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function U(e){return e+("/"===e[e.length-1]?"":"/")}function q(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function K(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var C=fetch;const{isObject:_,splitUrl:W}=t,B=Symbol("$__jref"),J={},D={},F=(e,r)=>{const t=e in D?D[e]:e;if(t in J)return J[t][r]},Z={},N={},M=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=W(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=F(n,"idToken"),i=W(r)[0],a=X(i,e[o]||""),s=W(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(N[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,F(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(D[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};Z[s]={id:s,schemaVersion:n,schema:G(e,s,n,h.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},G=(e,r,t,n,o)=>{if(_(e)){const i=F(t,"idToken"),a=F(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=X(r,n),[s,c]=W(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return M(e,X(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=G(a,r,t,h.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>G(e,r,t,h.append(i,n),o)):e},H=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),Q=async(e,r=H,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:re(r),o=X(n,e),[i,a]=W(o);if(!(e=>e in Z||e in N)(i)){const e=await C(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 r=R.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}M(await e.json(),i)}const s=(e=>Z[e]||Z[N[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ee(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=te(c);return _(u)&&B in u?Q(u[B],c):F(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?Q(u.$ref,c):F(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?Q(u,c):F(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?Q(u,c,!0):c},X=(e,r)=>{const t=T(e,r);if("file"===Y(t)&&"file"!==Y(e))throw Error("Can't access file resource from network context");return t},Y=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},ee=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},re=e=>`${e.id}#${encodeURI(e.pointer)}`,te=e=>h.get(e.pointer,e.schema),ne=(e,r)=>{const t=h.append(e,r.pointer);return Q(`#${encodeURI(t)}`,r)},oe=n((e,r)=>te(r).map(async(t,n)=>e(await ne(n,r),n)));var ie={setConfig:(e,r,t)=>{J[e]||(J[e]={}),J[e][r]=t},getConfig:F,add:M,get:Q,markValidated:e=>{Z[e].validated=!0},markVocabularyLoaded:e=>{Z[e].vocabularyLoaded=!0},uri:re,value:te,step:ne,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=h.append(e,t.join("/"));return Q(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(te(e)).map(r=>[r,ne(r,e)]),map:oe};const ae="FLAG",se="BASIC",ce="DETAILED",ue="VERBOSE";let fe=ce;const le=(e,t)=>(n,o=ae)=>{if(![ae,se,ce,ue].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",de(o,i));return ge(t,n,e),r.unsubscribe(a),i[0]},de=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&pe(t[t.length-1],i);){const r=t.pop();let n=[];if(e===se&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),he(i))break}(e===ue||e!==ae&&!i.valid)&&t.push(i),r[0]=i}},pe=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||he(e)),he=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),ye={},be=e=>ye[e],ve={},me={},we=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ie.markVocabularyLoaded(e.id),(ie.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in ve)Object.entries(ve[r]).forEach(([r,t])=>{ye[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ie.markValidated(e.id),!(e.schemaVersion in me)){const r=await ie.get(e.schemaVersion),t={},n=await we(r,t,!0);me[e.schemaVersion]=le(t,n)}const r=E.cons(e.schema,e.id),t=me[e.schemaVersion](r,fe);if(!t.valid)throw t}return await be(`${e.schemaVersion}#validate`).compile(e,r),ie.uri(e)},ge=(e,r,t)=>{const[n]=t[e];return be(n).interpret(e,r,t)};var Oe={validate:async(e,r,t)=>{const n={},o=await we(e,n),i=(e,r=ae)=>le(n,o)(E.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{fe=e},FLAG:ae,BASIC:se,DETAILED:ce,VERBOSE:ue,getKeyword:be,hasKeyword:e=>e in ye,defineVocabulary:(e,r)=>{ve[e]=r},compileSchema:we,interpretSchema:ge};var $e={compile:()=>{},interpret:()=>!0},xe=async e=>Object.entries(await e),Ee=n(async(e,r)=>(await r).map(e)),je=n(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Se=n(async(e,r,t={})=>je(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Ae=n(async(e,r)=>{const t=await Ee(e,r);return(await Promise.all(t)).some(e=>e)}),Pe=n(async(e,r)=>{const t=await Ee(e,r);return(await Promise.all(t)).every(e=>e)}),Ve=n((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Ie={entries:xe,map:Ee,filter:Se,reduce:je,some:Ae,every:Pe,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([xe,je(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var ke={compile:async(e,r)=>{const t=ie.uri(e);if(!(t in r)){r[t]=!1;const n=ie.value(e);r[t]=[`${e.schemaVersion}#validate`,ie.uri(e),"boolean"==typeof n?n:await Ie.pipeline([ie.entries,Ie.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Ie.filter(([e])=>Oe.hasKeyword(e)&&"validate"!==e),Ie.map(async([e,t])=>{const n=await t,o=await Oe.getKeyword(e).compile(n,r);return[e,ie.uri(n),o]}),Ie.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Oe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:E.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:E.uri(t),valid:s}),s}},Le={JsonSchema:Oe,Schema:ie,Instance:E,Keywords:{metaData:$e,validate:ke}},Re=Le.JsonSchema,Te=Le.Schema,Ue=Le.Instance,qe=Le.Keywords;exports.Instance=Ue,exports.JsonSchema=Re,exports.Keywords=qe,exports.Schema=Te,exports.default=Le; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -1076,3 +1076,4 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1127,2 +1128,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1161,3 +1166,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1225,3 +1231,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1304,26 +1310,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1330,0 +1338,0 @@ // Meta validation |
@@ -1,2 +0,2 @@ | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(r,t){!function(e,n){var i={};e.PubSub=i;var o=e.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function i(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?o:i;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,i,o){var s=function(e,r,t){return function(){var n=String(e),i=n.lastIndexOf(".");for(a(e,e,r,t);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,o);return!!function(e){for(var t=String(e),i=Boolean(r.hasOwnProperty(t)&&n(r[t])),o=t.lastIndexOf(".");!i&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),i=Boolean(r.hasOwnProperty(t)&&n(r[t]));return i}(e)&&(!0===i?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var i="uid_"+String(++t);return r[e][i]=n,i},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,i,o,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(i=r[n],s&&i[t]){delete i[t],u=t;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(delete i[o],u=!0)}return u}e.clearSubscriptions(t)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==r&&r.exports&&(t=r.exports=i),t.PubSub=i,r.exports=t=i)}("object"==typeof window&&window||e)}));r.PubSub;var t={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},n=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const i=e.shift();return{...r,[i]:o(e,p(r,i,n),t,u(i,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},a=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||h(r)){const i=e.shift();a(e,p(r,i,n),t,u(i,n))}else{r[e[0]]=t}},s=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=p(r,n,t);return{...r,[n]:s(e,i,u(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},c=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=p(r,n,t);c(e,i,u(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},u=n((e,r)=>r+"/"+f(e)),f=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(h(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},h=e=>null===e||"object"!=typeof e;var d={nil:"",append:u,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),u(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const a=i(e),s=n((e,r)=>o(a,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const o=i(e),s=n((e,r)=>a(o,e,r,""));return void 0===r?s:s(r,t)},unset:(e,r)=>{const t=i(e),n=e=>s(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:y}=t,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=b)=>Object.freeze({...r,pointer:y(e)[1]}),v=e=>d.get(e.pointer,e.instance),w=(e,r)=>{const t=d.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},g=n((e,r)=>v(r).map((t,n)=>e(w(n,r),n))),O=n((e,r,t)=>v(t).reduce((r,n,i)=>e(r,w(i,t),i),r)),$=n((e,r)=>Object.keys(v(r)).every((t,n)=>e(w(t,r),n))),E=n((e,r)=>Object.keys(v(r)).some((t,n)=>e(w(t,r),n)));var j={cons:(e,r="")=>Object.freeze({...b,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:v,step:w,entries:e=>Object.keys(v(e)).map(r=>[r,w(r,e)]),map:g,reduce:O,every:$,some:E},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]+$/,A=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,P=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,V=/^[!#$%&'*+.^_`|~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 r=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(r,t){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==r&&r.exports&&(t=r.exports=o),t.PubSub=o,r.exports=t=o)}("object"==typeof window&&window||e)}));r.PubSub;var t={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},n=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.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(l)},i=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:i(e,d(r,o,n),t,u(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:d(r,e[0],n)},a=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||p(r)){const o=e.shift();a(e,d(r,o,n),t,u(o,n))}else{r[e[0]]=t}},s=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(r,n,t);return{...r,[n]:s(e,o,u(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return d(r,e[0],t)}},c=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(r,n,t);c(e,o,u(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:d(r,e[0],t)},u=n((e,r)=>r+"/"+f(e)),f=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),d=(e,r,t="")=>{if(p(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:u,get:(e,r)=>{const t=o(e),n=e=>t.reduce(([e,r],t)=>[d(e,t,r),u(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const a=o(e),s=n((e,r)=>i(a,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const i=o(e),s=n((e,r)=>a(i,e,r,""));return void 0===r?s:s(r,t)},unset:(e,r)=>{const t=o(e),n=e=>s(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=o(e),n=e=>c(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:y}=t,b=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,r=b)=>Object.freeze({...r,pointer:y(e)[1]}),m=e=>h.get(e.pointer,e.instance),w=(e,r)=>{const t=h.append(e,r.pointer);return v(`#${encodeURI(t)}`,r)},g=n((e,r)=>m(r).map((t,n)=>e(w(n,r),n))),O=n((e,r,t)=>m(t).reduce((r,n,o)=>e(r,w(o,t),o),r)),$=n((e,r)=>Object.keys(m(r)).every((t,n)=>e(w(t,r),n))),E=n((e,r)=>Object.keys(m(r)).some((t,n)=>e(w(t,r),n)));var j={cons:(e,r="")=>Object.freeze({...b,id:r,instance:e}),get:v,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:m,step:w,entries:e=>Object.keys(m(e)).map(r=>[r,w(r,e)]),map:g,reduce:O,every:$,some:E},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]+$/,A=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,P=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var r=String(e);if(A.test(r))return r;if(r.length>0&&!S.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function T(e){this.parameters=Object.create(null),this.type=e}var k={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!V.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var i,o=Object.keys(r).sort(),a=0;a<o.length;a++){if(i=o[a],!A.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+R(r[i])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!V.test(n))throw new TypeError("invalid media type");var i=new T(n.toLowerCase());if(-1!==t){var o,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,o=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(P,"$1")),i.parameters[o]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return i}},L=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return K(r)?U(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==o){const e=t.substring(o);r.query=e,t=t.substring(0,o)}if(-1!==i){const e=t.substring(0,i);r.host=e,t=t.substring(i),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:U(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(z.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=t.substring(i);r.hash=e,t=t.substring(0,i)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),K(n.href)?U(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:i}=n;return t.host+q(e)+r+i}if(n.relativePath){const{path:e,query:r,hash:i}=n;let o,a=t.path,s=t.host;return 0===e.length?o=a:(a=a.substring(0,a.lastIndexOf("/")),o=q(a+"/"+e)),s+=""!==o||r||i?o+r+i:"/",s}};function U(e){return e+("/"===e[e.length-1]?"":"/")}function q(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function K(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),i=!e.includes("#",r);return t&&n&&i}var C=fetch;const{isObject:W,splitUrl:_}=t,B=Symbol("$__jref"),J={},D={},F=(e,r)=>{const t=e in D?D[e]:e;if(t in J)return J[t][r]},Z={},N={},G=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=_(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=F(n,"idToken"),o=_(r)[0],a=X(o,e[i]||""),s=_(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");o&&(N[o]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,F(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(D[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};Z[s]={id:s,schemaVersion:n,schema:H(e,s,n,d.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},H=(e,r,t,n,i)=>{if(W(e)){const o=F(t,"idToken"),a=F(t,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=X(r,n),[s,c]=_(i);if(delete e[o],c&&(e[a]=a!==o?encodeURI(c):`#${encodeURI(c)}`),s!==r)return G(e,X(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==o?e[a]:e[a].slice(1);i[r]=n,delete e[a]}return Object.entries(e).reduce((e,[o,a])=>(e[o]=H(a,r,t,d.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>H(e,r,t,d.append(o,n),i)):e},M=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),Q=async(e,r=M,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:re(r),i=X(n,e),[o,a]=_(i);if(!(e=>e in Z||e in N)(o)){const e=await C(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const r=k.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${o} is not a schema. Found a document with media type: ${r}`)}G(await e.json(),o)}const s=(e=>Z[e]||Z[N[e]])(o),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ee(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&o,validated:s.validated}),u=te(c);return W(u)&&B in u?Q(u[B],c):F(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?Q(u.$ref,c):F(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?Q(u,c):F(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?Q(u,c,!0):c},X=(e,r)=>{const t=L(e,r);if("file"===Y(t)&&"file"!==Y(e))throw Error("Can't access file resource from network context");return t},Y=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},ee=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},re=e=>`${e.id}#${encodeURI(e.pointer)}`,te=e=>d.get(e.pointer,e.schema),ne=(e,r)=>{const t=d.append(e,r.pointer);return Q(`#${encodeURI(t)}`,r)},ie=n((e,r)=>te(r).map(async(t,n)=>e(await ne(n,r),n)));var oe={setConfig:(e,r,t)=>{J[e]||(J[e]={}),J[e][r]=t},getConfig:F,add:G,get:Q,markValidated:e=>{Z[e].validated=!0},uri:re,value:te,step:ne,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=d.append(e,t.join("/"));return Q(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(te(e)).map(r=>[r,ne(r,e)]),map:ie};const ae="FLAG",se="BASIC",ce="DETAILED",ue="VERBOSE";let fe=ce;const le=(e,t)=>(n,i=ae)=>{if(![ae,se,ce,ue].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const a=r.subscribe("result",pe(i,o));return ge(t,n,e),r.unsubscribe(a),o[0]},pe=(e,r)=>{const t=[];return(n,i)=>{const o={...i,errors:[]};for(;t.length>0&&he(t[t.length-1],o);){const r=t.pop();let n=[];if(e===se&&(n=r.errors,delete r.errors),o.errors.unshift(r,...n),de(o))break}(e===ue||e!==ae&&!o.valid)&&t.push(o),r[0]=o}},he=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||de(e)),de=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),ye={},be=e=>ye[e],me={},ve={},we=async(e,r,t=!1)=>{if(!e.validated){if(oe.markValidated(e.id),t&&((oe.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{ye[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!(e.schemaVersion in ve)){const r=await oe.get(e.schemaVersion),t={},n=await we(r,t,!0);ve[e.schemaVersion]=le(t,n)}const r=j.cons(e.schema,e.id),n=ve[e.schemaVersion](r,fe);if(!n.valid)throw n}return await be(`${e.schemaVersion}#validate`).compile(e,r),oe.uri(e)},ge=(e,r,t)=>{const[n]=t[e];return be(n).interpret(e,r,t)};var Oe={validate:async(e,r,t)=>{const n={},i=await we(e,n),o=(e,r=ae)=>le(n,i)(j.cons(e),r);return void 0===r?o:o(r,t)},setMetaOutputFormat:e=>{fe=e},FLAG:ae,BASIC:se,DETAILED:ce,VERBOSE:ue,getKeyword:be,hasKeyword:e=>e in ye,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:we,interpretSchema:ge};var $e={compile:()=>{},interpret:()=>!0},Ee=async e=>Object.entries(await e),je=n(async(e,r)=>(await r).map(e)),xe=n(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Se=n(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Ae=n(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).some(e=>e)}),Pe=n(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=n((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Ve={entries:Ee,map:je,filter:Se,reduce:xe,some:Ae,every:Pe,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([Ee,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Re={compile:async(e,r)=>{const t=oe.uri(e);if(!(t in r)){r[t]=!1;const n=oe.value(e);r[t]=[`${e.schemaVersion}#validate`,oe.uri(e),"boolean"==typeof n?n:await Ve.pipeline([oe.entries,Ve.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Ve.filter(([e])=>Oe.hasKeyword(e)&&"validate"!==e),Ve.map(async([e,t])=>{const n=await t,i=await Oe.getKeyword(e).compile(n,r);return[e,oe.uri(n),i]}),Ve.all],e)]}},interpret:(e,t,n)=>{const[i,o,a]=n[e],s="boolean"==typeof a?a:a.every(([e,i,o])=>{const a=Oe.getKeyword(e).interpret(o,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:j.uri(t),valid:a}),a});return r.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:j.uri(t),valid:s}),s}},Te={JsonSchema:Oe,Schema:oe,Instance:j,Keywords:{metaData:$e,validate:Re}},ke=Te.JsonSchema,Le=Te.Schema,Ue=Te.Instance,qe=Te.Keywords;export default Te;export{Ue as Instance,ke as JsonSchema,qe as Keywords,Le as Schema}; | ||
*/function k(e){var r=String(e);if(A.test(r))return r;if(r.length>0&&!S.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(V,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var R={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!I.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!A.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+k(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!I.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==t){var i,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(P,"$1")),o.parameters[i]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return o}},T=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return K(r)?U(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:U(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(z.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),K(n.href)?U(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+q(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=q(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function U(e){return e+("/"===e[e.length-1]?"":"/")}function q(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const z=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function K(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var C=fetch;const{isObject:W,splitUrl:_}=t,B=Symbol("$__jref"),J={},D={},F=(e,r)=>{const t=e in D?D[e]:e;if(t in J)return J[t][r]},Z={},N={},G=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=_(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=F(n,"idToken"),i=_(r)[0],a=X(i,e[o]||""),s=_(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(N[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,F(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(D[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};Z[s]={id:s,schemaVersion:n,schema:H(e,s,n,h.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},H=(e,r,t,n,o)=>{if(W(e)){const i=F(t,"idToken"),a=F(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=X(r,n),[s,c]=_(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return G(e,X(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=H(a,r,t,h.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>H(e,r,t,h.append(i,n),o)):e},M=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),Q=async(e,r=M,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:re(r),o=X(n,e),[i,a]=_(o);if(!(e=>e in Z||e in N)(i)){const e=await C(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 r=R.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}G(await e.json(),i)}const s=(e=>Z[e]||Z[N[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ee(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=te(c);return W(u)&&B in u?Q(u[B],c):F(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?Q(u.$ref,c):F(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?Q(u,c):F(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?Q(u,c,!0):c},X=(e,r)=>{const t=T(e,r);if("file"===Y(t)&&"file"!==Y(e))throw Error("Can't access file resource from network context");return t},Y=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},ee=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},re=e=>`${e.id}#${encodeURI(e.pointer)}`,te=e=>h.get(e.pointer,e.schema),ne=(e,r)=>{const t=h.append(e,r.pointer);return Q(`#${encodeURI(t)}`,r)},oe=n((e,r)=>te(r).map(async(t,n)=>e(await ne(n,r),n)));var ie={setConfig:(e,r,t)=>{J[e]||(J[e]={}),J[e][r]=t},getConfig:F,add:G,get:Q,markValidated:e=>{Z[e].validated=!0},markVocabularyLoaded:e=>{Z[e].vocabularyLoaded=!0},uri:re,value:te,step:ne,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=h.append(e,t.join("/"));return Q(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(te(e)).map(r=>[r,ne(r,e)]),map:oe};const ae="FLAG",se="BASIC",ce="DETAILED",ue="VERBOSE";let fe=ce;const le=(e,t)=>(n,o=ae)=>{if(![ae,se,ce,ue].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",de(o,i));return ge(t,n,e),r.unsubscribe(a),i[0]},de=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&pe(t[t.length-1],i);){const r=t.pop();let n=[];if(e===se&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),he(i))break}(e===ue||e!==ae&&!i.valid)&&t.push(i),r[0]=i}},pe=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||he(e)),he=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),ye={},be=e=>ye[e],ve={},me={},we=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ie.markVocabularyLoaded(e.id),(ie.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in ve)Object.entries(ve[r]).forEach(([r,t])=>{ye[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ie.markValidated(e.id),!(e.schemaVersion in me)){const r=await ie.get(e.schemaVersion),t={},n=await we(r,t,!0);me[e.schemaVersion]=le(t,n)}const r=j.cons(e.schema,e.id),t=me[e.schemaVersion](r,fe);if(!t.valid)throw t}return await be(`${e.schemaVersion}#validate`).compile(e,r),ie.uri(e)},ge=(e,r,t)=>{const[n]=t[e];return be(n).interpret(e,r,t)};var Oe={validate:async(e,r,t)=>{const n={},o=await we(e,n),i=(e,r=ae)=>le(n,o)(j.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{fe=e},FLAG:ae,BASIC:se,DETAILED:ce,VERBOSE:ue,getKeyword:be,hasKeyword:e=>e in ye,defineVocabulary:(e,r)=>{ve[e]=r},compileSchema:we,interpretSchema:ge};var $e={compile:()=>{},interpret:()=>!0},Ee=async e=>Object.entries(await e),je=n(async(e,r)=>(await r).map(e)),xe=n(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Se=n(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Ae=n(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).some(e=>e)}),Pe=n(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).every(e=>e)}),Ve=n((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Ie={entries:Ee,map:je,filter:Se,reduce:xe,some:Ae,every:Pe,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([Ee,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var ke={compile:async(e,r)=>{const t=ie.uri(e);if(!(t in r)){r[t]=!1;const n=ie.value(e);r[t]=[`${e.schemaVersion}#validate`,ie.uri(e),"boolean"==typeof n?n:await Ie.pipeline([ie.entries,Ie.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Ie.filter(([e])=>Oe.hasKeyword(e)&&"validate"!==e),Ie.map(async([e,t])=>{const n=await t,o=await Oe.getKeyword(e).compile(n,r);return[e,ie.uri(n),o]}),Ie.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Oe.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:j.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:j.uri(t),valid:s}),s}},Le={JsonSchema:Oe,Schema:ie,Instance:j,Keywords:{metaData:$e,validate:ke}},Re=Le.JsonSchema,Te=Le.Schema,Ue=Le.Instance,qe=Le.Keywords;export default Le;export{Ue as Instance,Re as JsonSchema,qe as Keywords,Te as Schema}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -1079,3 +1079,4 @@ var JSC = (function (exports) { | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1130,2 +1131,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1164,3 +1169,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1228,3 +1234,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1307,26 +1313,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1333,0 +1341,0 @@ // Meta validation |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var i={};r.PubSub=i;var o=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function i(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?o:i;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,i,o){var s=function(e,r,t){return function(){var n=String(e),i=n.lastIndexOf(".");for(a(e,e,r,t);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,o);return!!function(e){for(var t=String(e),i=Boolean(r.hasOwnProperty(t)&&n(r[t])),o=t.lastIndexOf(".");!i&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),i=Boolean(r.hasOwnProperty(t)&&n(r[t]));return i}(e)&&(!0===i?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var i="uid_"+String(++t);return r[e][i]=n,i},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,i,o,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(i=r[n],s&&i[t]){delete i[t],u=t;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(delete i[o],u=!0)}return u}e.clearSubscriptions(t)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==e&&e.exports&&(t=e.exports=i),t.PubSub=i,e.exports=t=i)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},i=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.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(h)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const i=e.shift();return{...r,[i]:a(e,p(r,i,n),t,f(i,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||d(r)){const i=e.shift();s(e,p(r,i,n),t,f(i,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=p(r,n,t);return{...r,[n]:c(e,i,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=p(r,n,t);u(e,i,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},f=i((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),h=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(d(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},d=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=o(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=o(e),s=i((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=o(e),a=i((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=o(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=o(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,m=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,r=m)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return v(`#${encodeURI(t)}`,r)},O=i((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=i((e,r,t)=>w(t).reduce((r,n,i)=>e(r,g(i,t),i),r)),E=i((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),j=i((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var S={cons:(e,r="")=>Object.freeze({...m,id:r,instance:e}),get:v,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:j},x=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var JSC=function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var o={};r.PubSub=o;var i=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},o=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(d)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:a(e,h(r,o,n),t,f(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:h(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||p(r)){const o=e.shift();s(e,h(r,o,n),t,f(o,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=h(r,n,t);return{...r,[n]:c(e,o,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return h(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=h(r,n,t);u(e,o,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:h(r,e[0],t)},f=o((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),d=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),h=(e,r,t="")=>{if(p(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},p=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[h(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=i(e),s=o((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=i(e),a=o((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,v=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=v)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},O=o((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=o((e,r,t)=>w(t).reduce((r,n,o)=>e(r,g(o,t),o),r)),E=o((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),j=o((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var S={cons:(e,r="")=>Object.freeze({...v,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:j},x=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function T(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(V,"\\$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 r=e.parameters,t=e.type;if(!t||!R.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var i,o=Object.keys(r).sort(),a=0;a<o.length;a++){if(i=o[a],!P.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+T(r[i])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!R.test(n))throw new TypeError("invalid media type");var i=new k(n.toLowerCase());if(-1!==t){var o,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,o=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),i.parameters[o]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return i}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==o){const e=t.substring(o);r.query=e,t=t.substring(0,o)}if(-1!==i){const e=t.substring(0,i);r.host=e,t=t.substring(i),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=t.substring(i);r.hash=e,t=t.substring(0,i)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:i}=n;return t.host+z(e)+r+i}if(n.relativePath){const{path:e,query:r,hash:i}=n;let o,a=t.path,s=t.host;return 0===e.length?o=a:(a=a.substring(0,a.lastIndexOf("/")),o=z(a+"/"+e)),s+=""!==o||r||i?o+r+i:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),i=!e.includes("#",r);return t&&n&&i}var W=fetch;const{isObject:_,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},G={},H=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=Z(n,"idToken"),o=J(r)[0],a=Y(o,e[i]||""),s=J(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");o&&(G[o]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:M(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},M=(e,r,t,n,i)=>{if(_(e)){const o=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=Y(r,n),[s,c]=J(i);if(delete e[o],c&&(e[a]=a!==o?encodeURI(c):`#${encodeURI(c)}`),s!==r)return H(e,Y(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==o?e[a]:e[a].slice(1);i[r]=n,delete e[a]}return Object.entries(e).reduce((e,[o,a])=>(e[o]=M(a,r,t,y.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>M(e,r,t,y.append(o,n),i)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),i=Y(n,e),[o,a]=J(i);if(!(e=>e in N||e in G)(o)){const e=await W(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const r=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${o} is not a schema. Found a document with media type: ${r}`)}H(await e.json(),o)}const s=(e=>N[e]||N[G[e]])(o),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&o,validated:s.validated}),u=ne(c);return _(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),ie=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},oe=i((e,r)=>ne(r).map(async(t,n)=>e(await ie(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:H,get:X,markValidated:e=>{N[e].validated=!0},uri:te,value:ne,step:ie,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,ie(r,e)]),map:oe};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const he=(e,r)=>(n,i=se)=>{if(![se,ce,ue,fe].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const a=t.subscribe("result",pe(i,o));return Oe(r,n,e),t.unsubscribe(a),o[0]},pe=(e,r)=>{const t=[];return(n,i)=>{const o={...i,errors:[]};for(;t.length>0&&de(t[t.length-1],o);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),o.errors.unshift(r,...n),ye(o))break}(e===fe||e!==se&&!o.valid)&&t.push(o),r[0]=o}},de=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},me=e=>be[e],ve={},we={},ge=async(e,r,t=!1)=>{if(!e.validated){if(ae.markValidated(e.id),t&&((ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in ve)Object.entries(ve[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=he(t,n)}const r=S.cons(e.schema,e.id),n=we[e.schemaVersion](r,le);if(!n.valid)throw n}return await me(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return me(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},i=await ge(e,n),o=(e,r=se)=>he(n,i)(S.cons(e),r);return void 0===r?o:o(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:me,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{ve[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),Se=i(async(e,r)=>(await r).map(e)),xe=i(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=i(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=i(async(e,r)=>{const t=await Se(e,r);return(await Promise.all(t)).some(e=>e)}),Ie=i(async(e,r)=>{const t=await Se(e,r);return(await Promise.all(t)).every(e=>e)}),Ve=i((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Re={entries:je,map:Se,filter:Ae,reduce:xe,some:Pe,every:Ie,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([je,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Te={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await Re.pipeline([ae.entries,Re.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Re.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),Re.map(async([e,t])=>{const n=await t,i=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),i]}),Re.all],e)]}},interpret:(e,r,n)=>{const[i,o,a]=n[e],s="boolean"==typeof a?a:a.every(([e,i,o])=>{const a=$e.getKeyword(e).interpret(o,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:S.uri(r),valid:a}),a});return t.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:S.uri(r),valid:s}),s}},ke={JsonSchema:$e,Schema:ae,Instance:S,Keywords:{metaData:Ee,validate:Te}},Le=ke.JsonSchema,Ue=ke.Schema,qe=ke.Instance,ze=ke.Keywords;return e.Instance=qe,e.JsonSchema=Le,e.Keywords=ze,e.Schema=Ue,e.default=ke,e}({}); | ||
*/function L(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function R(e){this.parameters=Object.create(null),this.type=e}var T={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!k.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!P.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+L(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new R(n.toLowerCase());if(-1!==t){var i,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=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(t!==r.length)throw new TypeError("invalid parameter format")}return o}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+z(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=z(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var W=fetch;const{isObject:_,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},G={},H=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=Z(n,"idToken"),i=J(r)[0],a=Y(i,e[o]||""),s=J(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(G[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:M(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},M=(e,r,t,n,o)=>{if(_(e)){const i=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=Y(r,n),[s,c]=J(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return H(e,Y(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=M(a,r,t,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>M(e,r,t,y.append(i,n),o)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),o=Y(n,e),[i,a]=J(o);if(!(e=>e in N||e in G)(i)){const e=await W(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 r=T.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}H(await e.json(),i)}const s=(e=>N[e]||N[G[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=ne(c);return _(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),oe=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},ie=o((e,r)=>ne(r).map(async(t,n)=>e(await oe(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:H,get:X,markValidated:e=>{N[e].validated=!0},markVocabularyLoaded:e=>{N[e].vocabularyLoaded=!0},uri:te,value:ne,step:oe,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,oe(r,e)]),map:ie};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const de=(e,r)=>(n,o=se)=>{if(![se,ce,ue,fe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",he(o,i));return Oe(r,n,e),t.unsubscribe(a),i[0]},he=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&pe(t[t.length-1],i);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),ye(i))break}(e===fe||e!==se&&!i.valid)&&t.push(i),r[0]=i}},pe=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},ve=e=>be[e],me={},we={},ge=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ae.markVocabularyLoaded(e.id),(ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ae.markValidated(e.id),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=de(t,n)}const r=S.cons(e.schema,e.id),t=we[e.schemaVersion](r,le);if(!t.valid)throw t}return await ve(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return ve(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},o=await ge(e,n),i=(e,r=se)=>de(n,o)(S.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:ve,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),Se=o(async(e,r)=>(await r).map(e)),xe=o(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=o(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=o(async(e,r)=>{const t=await Se(e,r);return(await Promise.all(t)).some(e=>e)}),Ve=o(async(e,r)=>{const t=await Se(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=o((e,r)=>e.reduce(async(e,r)=>r(await e),r)),ke={entries:je,map:Se,filter:Ae,reduce:xe,some:Pe,every:Ve,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([je,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Le={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await ke.pipeline([ae.entries,ke.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),ke.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),ke.map(async([e,t])=>{const n=await t,o=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),o]}),ke.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:S.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:S.uri(r),valid:s}),s}},Re={JsonSchema:$e,Schema:ae,Instance:S,Keywords:{metaData:Ee,validate:Le}},Te=Re.JsonSchema,Ue=Re.Schema,qe=Re.Instance,ze=Re.Keywords;return e.Instance=qe,e.JsonSchema=Te,e.Keywords=ze,e.Schema=Ue,e.default=Re,e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1081,3 +1081,4 @@ System.register('JSC', [], function (exports) { | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1132,2 +1133,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1166,3 +1171,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1230,3 +1236,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1309,26 +1315,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1335,0 +1343,0 @@ // Meta validation |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var i={};r.PubSub=i;var o=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function i(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?o:i;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,i,o){var s=function(e,r,t){return function(){var n=String(e),i=n.lastIndexOf(".");for(a(e,e,r,t);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,o);return!!function(e){for(var t=String(e),i=Boolean(r.hasOwnProperty(t)&&n(r[t])),o=t.lastIndexOf(".");!i&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),i=Boolean(r.hasOwnProperty(t)&&n(r[t]));return i}(e)&&(!0===i?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var i="uid_"+String(++t);return r[e][i]=n,i},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,i,o,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(i=r[n],s&&i[t]){delete i[t],u=t;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===t&&(delete i[o],u=!0)}return u}e.clearSubscriptions(t)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==e&&e.exports&&(t=e.exports=i),t.PubSub=i,e.exports=t=i)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},i=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.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(h)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const i=e.shift();return{...r,[i]:a(e,p(r,i,n),t,f(i,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||d(r)){const i=e.shift();s(e,p(r,i,n),t,f(i,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=p(r,n,t);return{...r,[n]:c(e,i,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=p(r,n,t);u(e,i,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},f=i((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),h=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(d(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},d=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=o(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=o(e),s=i((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=o(e),a=i((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=o(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=o(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,m=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,r=m)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return v(`#${encodeURI(t)}`,r)},O=i((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=i((e,r,t)=>w(t).reduce((r,n,i)=>e(r,g(i,t),i),r)),E=i((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),S=i((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var j={cons:(e,r="")=>Object.freeze({...m,id:r,instance:e}),get:v,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:S},x=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var o={};r.PubSub=o;var i=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},o=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(d)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:a(e,h(r,o,n),t,f(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:h(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||p(r)){const o=e.shift();s(e,h(r,o,n),t,f(o,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=h(r,n,t);return{...r,[n]:c(e,o,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return h(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=h(r,n,t);u(e,o,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:h(r,e[0],t)},f=o((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),d=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),h=(e,r,t="")=>{if(p(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},p=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[h(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=i(e),s=o((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=i(e),a=o((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,v=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=v)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},O=o((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=o((e,r,t)=>w(t).reduce((r,n,o)=>e(r,g(o,t),o),r)),E=o((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),S=o((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var j={cons:(e,r="")=>Object.freeze({...v,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:S},x=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function T(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(V,"\\$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 r=e.parameters,t=e.type;if(!t||!R.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var i,o=Object.keys(r).sort(),a=0;a<o.length;a++){if(i=o[a],!P.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+T(r[i])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!R.test(n))throw new TypeError("invalid media type");var i=new k(n.toLowerCase());if(-1!==t){var o,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=a[0].length,o=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(I,"$1")),i.parameters[o]=s}if(t!==r.length)throw new TypeError("invalid parameter format")}return i}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==o){const e=t.substring(o);r.query=e,t=t.substring(0,o)}if(-1!==i){const e=t.substring(0,i);r.host=e,t=t.substring(i),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=t.substring(i);r.hash=e,t=t.substring(0,i)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:i}=n;return t.host+z(e)+r+i}if(n.relativePath){const{path:e,query:r,hash:i}=n;let o,a=t.path,s=t.host;return 0===e.length?o=a:(a=a.substring(0,a.lastIndexOf("/")),o=z(a+"/"+e)),s+=""!==o||r||i?o+r+i:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),i=!e.includes("#",r);return t&&n&&i}var W=fetch;const{isObject:_,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},G={},H=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=Z(n,"idToken"),o=J(r)[0],a=Y(o,e[i]||""),s=J(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");o&&(G[o]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:M(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},M=(e,r,t,n,i)=>{if(_(e)){const o=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=Y(r,n),[s,c]=J(i);if(delete e[o],c&&(e[a]=a!==o?encodeURI(c):`#${encodeURI(c)}`),s!==r)return H(e,Y(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==o?e[a]:e[a].slice(1);i[r]=n,delete e[a]}return Object.entries(e).reduce((e,[o,a])=>(e[o]=M(a,r,t,y.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>M(e,r,t,y.append(o,n),i)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),i=Y(n,e),[o,a]=J(i);if(!(e=>e in N||e in G)(o)){const e=await W(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const r=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${o} is not a schema. Found a document with media type: ${r}`)}H(await e.json(),o)}const s=(e=>N[e]||N[G[e]])(o),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&o,validated:s.validated}),u=ne(c);return _(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),ie=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},oe=i((e,r)=>ne(r).map(async(t,n)=>e(await ie(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:H,get:X,markValidated:e=>{N[e].validated=!0},uri:te,value:ne,step:ie,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,ie(r,e)]),map:oe};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const he=(e,r)=>(n,i=se)=>{if(![se,ce,ue,fe].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const a=t.subscribe("result",pe(i,o));return Oe(r,n,e),t.unsubscribe(a),o[0]},pe=(e,r)=>{const t=[];return(n,i)=>{const o={...i,errors:[]};for(;t.length>0&&de(t[t.length-1],o);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),o.errors.unshift(r,...n),ye(o))break}(e===fe||e!==se&&!o.valid)&&t.push(o),r[0]=o}},de=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},me=e=>be[e],ve={},we={},ge=async(e,r,t=!1)=>{if(!e.validated){if(ae.markValidated(e.id),t&&((ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in ve)Object.entries(ve[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=he(t,n)}const r=j.cons(e.schema,e.id),n=we[e.schemaVersion](r,le);if(!n.valid)throw n}return await me(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return me(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},i=await ge(e,n),o=(e,r=se)=>he(n,i)(j.cons(e),r);return void 0===r?o:o(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:me,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{ve[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},Se=async e=>Object.entries(await e),je=i(async(e,r)=>(await r).map(e)),xe=i(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=i(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=i(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).some(e=>e)}),Ie=i(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).every(e=>e)}),Ve=i((e,r)=>e.reduce(async(e,r)=>r(await e),r)),Re={entries:Se,map:je,filter:Ae,reduce:xe,some:Pe,every:Ie,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([Se,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Te={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await Re.pipeline([ae.entries,Re.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),Re.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),Re.map(async([e,t])=>{const n=await t,i=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),i]}),Re.all],e)]}},interpret:(e,r,n)=>{const[i,o,a]=n[e],s="boolean"==typeof a?a:a.every(([e,i,o])=>{const a=$e.getKeyword(e).interpret(o,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:j.uri(r),valid:a}),a});return t.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:j.uri(r),valid:s}),s}},ke={JsonSchema:$e,Schema:ae,Instance:j,Keywords:{metaData:Ee,validate:Te}};e("default",ke);e("JsonSchema",ke.JsonSchema),e("Schema",ke.Schema),e("Instance",ke.Instance),e("Keywords",ke.Keywords)}}})); | ||
*/function L(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function R(e){this.parameters=Object.create(null),this.type=e}var T={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!k.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!P.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+L(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new R(n.toLowerCase());if(-1!==t){var i,a,s;for(x.lastIndex=t;a=x.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=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(t!==r.length)throw new TypeError("invalid parameter format")}return o}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+z(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=z(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var W=fetch;const{isObject:_,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},G={},H=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=Z(n,"idToken"),i=J(r)[0],a=Y(i,e[o]||""),s=J(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(G[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&_(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:M(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},M=(e,r,t,n,o)=>{if(_(e)){const i=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=Y(r,n),[s,c]=J(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return H(e,Y(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=M(a,r,t,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>M(e,r,t,y.append(i,n),o)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),o=Y(n,e),[i,a]=J(o);if(!(e=>e in N||e in G)(i)){const e=await W(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 r=T.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}H(await e.json(),i)}const s=(e=>N[e]||N[G[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=ne(c);return _(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&_(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),oe=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},ie=o((e,r)=>ne(r).map(async(t,n)=>e(await oe(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:H,get:X,markValidated:e=>{N[e].validated=!0},markVocabularyLoaded:e=>{N[e].vocabularyLoaded=!0},uri:te,value:ne,step:oe,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,oe(r,e)]),map:ie};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const de=(e,r)=>(n,o=se)=>{if(![se,ce,ue,fe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",he(o,i));return Oe(r,n,e),t.unsubscribe(a),i[0]},he=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&pe(t[t.length-1],i);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),ye(i))break}(e===fe||e!==se&&!i.valid)&&t.push(i),r[0]=i}},pe=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},ve=e=>be[e],me={},we={},ge=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ae.markVocabularyLoaded(e.id),(ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ae.markValidated(e.id),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=de(t,n)}const r=j.cons(e.schema,e.id),t=we[e.schemaVersion](r,le);if(!t.valid)throw t}return await ve(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return ve(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},o=await ge(e,n),i=(e,r=se)=>de(n,o)(j.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:ve,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},Se=async e=>Object.entries(await e),je=o(async(e,r)=>(await r).map(e)),xe=o(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=o(async(e,r,t={})=>xe(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=o(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).some(e=>e)}),Ve=o(async(e,r)=>{const t=await je(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=o((e,r)=>e.reduce(async(e,r)=>r(await e),r)),ke={entries:Se,map:je,filter:Ae,reduce:xe,some:Pe,every:Ve,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([Se,xe(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Le={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await ke.pipeline([ae.entries,ke.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),ke.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),ke.map(async([e,t])=>{const n=await t,o=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),o]}),ke.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}},Re={JsonSchema:$e,Schema:ae,Instance:j,Keywords:{metaData:Ee,validate:Le}};e("default",Re);e("JsonSchema",Re.JsonSchema),e("Schema",Re.Schema),e("Instance",Re.Instance),e("Keywords",Re.Keywords)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -1082,3 +1082,4 @@ (function (global, factory) { | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -1133,2 +1134,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -1167,3 +1172,4 @@ const nil$2 = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -1231,3 +1237,3 @@ | ||
setConfig, getConfig, | ||
add, get: get$2, markValidated, | ||
add, get: get$2, markValidated, markVocabularyLoaded, | ||
uri: uri$1, value: value$1, step: step$1, sibling, entries: entries$1, map: map$1 | ||
@@ -1310,26 +1316,28 @@ }; | ||
const compileSchema = async (schema$1, ast, isMetaSchema = false) => { | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
if (isMetaSchema && !schema$1.vocabularyLoaded) { | ||
schema.markVocabularyLoaded(schema$1.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(schema.getConfig(schema$1.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema$1.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema$1.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema$1.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema$1.validated) { | ||
schema.markValidated(schema$1.id); | ||
@@ -1336,0 +1344,0 @@ // Meta validation |
@@ -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 i={};t.PubSub=i;var o=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 i(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function o(e,t,r){e(t,r)}function s(e,r,n,s){var a,c=t[r],u=s?o:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function a(e,r,i,o){var a=function(e,t,r){return function(){var n=String(e),i=n.lastIndexOf(".");for(s(e,e,t,r);-1!==i;)i=(n=n.substr(0,i)).lastIndexOf("."),s(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,o);return!!function(e){for(var r=String(e),i=Boolean(t.hasOwnProperty(r)&&n(t[r])),o=r.lastIndexOf(".");!i&&-1!==o;)o=(r=r.substr(0,o)).lastIndexOf("."),i=Boolean(t.hasOwnProperty(r)&&n(t[r]));return i}(e)&&(!0===i?a():setTimeout(a,0),!0)}e.publish=function(t,r){return a(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return a(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 i="uid_"+String(++r);return t[e][i]=n,i},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,i,o,s="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)),a=!s&&"string"==typeof r,c="function"==typeof r,u=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(i=t[n],a&&i[r]){delete i[r],u=r;break}if(c)for(o in i)i.hasOwnProperty(o)&&i[o]===r&&(delete i[o],u=!0)}return u}e.clearSubscriptions(r)}}(i),"function"==typeof o&&o.amd?o((function(){return i})):(void 0!==e&&e.exports&&(r=e.exports=i),r.PubSub=i,e.exports=r=i)}("object"==typeof window&&window||t)}));r.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[t,r=""]=e.split("#",2);return[decodeURI(t),decodeURI(r)]}},i=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(p)},s=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:s(e,d(t,i,n),r,f(i,n))}}if(Array.isArray(t)){const n={...t};return n[e[0]]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const i=e.shift();a(e,d(t,i,n),r,f(i,n))}else{t[e[0]]=r}},c=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=d(t,n,r);return{...t,[n]:c(e,i,f(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)}},u=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=d(t,n,r);u(e,i,f(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)},f=i((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),p=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),d=(e,t,r="")=>{if(h(e))throw Error(`Value at '${r}' is a scalar and can't be indexed`);if(!(t in e))throw Error(`Value at '${r}' does not have index '${t}'`);return e[t]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[d(e,r,t),f(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const n=o(e),a=i((e,t)=>s(n,e,t,""));return void 0===t?a:a(t,r)},assign:(e,t,r)=>{const n=o(e),s=i((e,t)=>a(n,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>u(r,e,"");return void 0===t?n:n(t)}};const{splitUrl:b}=n,m=Object.freeze({id:"",pointer:"",instance:void 0}),v=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,t)=>{const r=y.append(e,t.pointer);return v(`#${encodeURI(r)}`,t)},O=i((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),$=i((e,t,r)=>w(r).reduce((t,n,i)=>e(t,g(i,r),i),t)),E=i((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),j=i((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:v,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,reduce:$,every:E,some:j},S=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,I=/\\([\u000b\u0020-\u00ff])/g,V=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).JSC={})}(this,(function(e){"use strict";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,r){return e(r={exports:{}},r.exports),r.exports}((function(e,t){!function(r,n){var o={};r.PubSub=o;var i=r.define;!function(e){var r={},t=-1;function n(e){var r;for(r in e)if(e.hasOwnProperty(r))return!0;return!1}function o(e,r,t){try{e(r,t)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,r,t){e(r,t)}function a(e,t,n,a){var s,c=r[t],u=a?i:o;if(r.hasOwnProperty(t))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,t,o,i){var s=function(e,r,t){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,r,t);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,r,t)}}(e="symbol"==typeof e?e.toString():e,t,i);return!!function(e){for(var t=String(e),o=Boolean(r.hasOwnProperty(t)&&n(r[t])),i=t.lastIndexOf(".");!o&&-1!==i;)i=(t=t.substr(0,i)).lastIndexOf("."),o=Boolean(r.hasOwnProperty(t)&&n(r[t]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(r,t){return s(r,t,!1,e.immediateExceptions)},e.publishSync=function(r,t){return s(r,t,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,r.hasOwnProperty(e)||(r[e]={});var o="uid_"+String(++t);return r[e][o]=n,o},e.subscribeOnce=function(r,t){var n=e.subscribe(r,(function(){e.unsubscribe(n),t.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){r={}},e.clearSubscriptions=function(e){var t;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&delete r[t]},e.countSubscriptions=function(e){var t,n=0;for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var t,n=[];for(t in r)r.hasOwnProperty(t)&&0===t.indexOf(e)&&n.push(t);return n},e.unsubscribe=function(t){var n,o,i,a="string"==typeof t&&(r.hasOwnProperty(t)||function(e){var t;for(t in r)if(r.hasOwnProperty(t)&&0===t.indexOf(e))return!0;return!1}(t)),s=!a&&"string"==typeof t,c="function"==typeof t,u=!1;if(!a){for(n in r)if(r.hasOwnProperty(n)){if(o=r[n],s&&o[t]){delete o[t],u=t;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===t&&(delete o[i],u=!0)}return u}e.clearSubscriptions(t)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o)}("object"==typeof window&&window||r)}));t.PubSub;var n={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const[r,t=""]=e.split("#",2);return[decodeURI(r),decodeURI(t)]}},o=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}};const i=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(d)},a=(e,r,t,n)=>{if(0===e.length)return t;if(e.length>1){const o=e.shift();return{...r,[o]:a(e,p(r,o,n),t,f(o,n))}}if(Array.isArray(r)){const n={...r};return n[e[0]]=t,n}return"object"==typeof r&&null!==r?{...r,[e[0]]:t}:p(r,e[0],n)},s=(e,r,t,n)=>{if(0!==e.length)if(1!==e.length||h(r)){const o=e.shift();s(e,p(r,o,n),t,f(o,n))}else{r[e[0]]=t}},c=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(r,n,t);return{...r,[n]:c(e,o,f(n,t))}}if(Array.isArray(r))return r.filter((r,t)=>t!=e[0]);if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return p(r,e[0],t)}},u=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(r,n,t);u(e,o,f(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:p(r,e[0],t)},f=o((e,r)=>r+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),d=e=>e.toString().replace(/~0/g,"~").replace(/~1/g,"/"),p=(e,r,t="")=>{if(h(e))throw Error(`Value at '${t}' is a scalar and can't be indexed`);if(!(r in e))throw Error(`Value at '${t}' does not have index '${r}'`);return e[r]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:f,get:(e,r)=>{const t=i(e),n=e=>t.reduce(([e,r],t)=>[p(e,t,r),f(t,r)],[e,""])[0];return void 0===r?n:n(r)},set:(e,r,t)=>{const n=i(e),s=o((e,r)=>a(n,e,r,""));return void 0===r?s:s(r,t)},assign:(e,r,t)=>{const n=i(e),a=o((e,r)=>s(n,e,r,""));return void 0===r?a:a(r,t)},unset:(e,r)=>{const t=i(e),n=e=>c(t,e,"");return void 0===r?n:n(r)},delete:(e,r)=>{const t=i(e),n=e=>u(t,e,"");return void 0===r?n:n(r)}};const{splitUrl:b}=n,v=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,r=v)=>Object.freeze({...r,pointer:b(e)[1]}),w=e=>y.get(e.pointer,e.instance),g=(e,r)=>{const t=y.append(e,r.pointer);return m(`#${encodeURI(t)}`,r)},O=o((e,r)=>w(r).map((t,n)=>e(g(n,r),n))),$=o((e,r,t)=>w(t).reduce((r,n,o)=>e(r,g(o,t),o),r)),E=o((e,r)=>Object.keys(w(r)).every((t,n)=>e(g(t,r),n))),j=o((e,r)=>Object.keys(w(r)).some((t,n)=>e(g(t,r),n)));var x={cons:(e,r="")=>Object.freeze({...v,id:r,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(r=>[r,g(r,e)]),map:O,reduce:$,every:E,some:j},S=/; *([!#$%&'*+.^_`|~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]+$/,P=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,I=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function T(e){var t=String(e);if(P.test(t))return t;if(t.length>0&&!A.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(V,"\\$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 i,o=Object.keys(t).sort(),s=0;s<o.length;s++){if(i=o[s],!P.test(i))throw new TypeError("invalid parameter name");n+="; "+i+"="+T(t[i])}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 i=new k(n.toLowerCase());if(-1!==r){var o,s,a;for(S.lastIndex=r;s=S.exec(t);){if(s.index!==r)throw new TypeError("invalid parameter format");r+=s[0].length,o=s[1].toLowerCase(),'"'===(a=s[2])[0]&&(a=a.substr(1,a.length-2).replace(I,"$1")),i.parameters[o]=a}if(r!==t.length)throw new TypeError("invalid parameter format")}return i}},U=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;if(""===e)return C(t)?q(t):t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");t.protocol=r.substring(0,n),n+=2;const i=e.indexOf("/",n),o=e.indexOf("?"),s=e.indexOf("#");-1!==s&&(r=r.substring(0,s));if(-1!==o){const e=r.substring(o);t.query=e,r=r.substring(0,o)}if(-1!==i){const e=r.substring(0,i);t.host=e,r=r.substring(i),t.path=r}else t.host=r;return t}(e);if(""===t){const{host:e,path:t,query:n}=r;return t||n?e+t+n:q(e)}const n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:t.relativePath=!0;let r=e;const n=e.indexOf("?"),i=e.indexOf("#");if(-1!==i){const e=r.substring(i);t.hash=e,r=r.substring(0,i)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:i}=n;return r.host+z(e)+t+i}if(n.relativePath){const{path:e,query:t,hash:i}=n;let o,s=r.path,a=r.host;return 0===e.length?o=s:(s=s.substring(0,s.lastIndexOf("/")),o=z(s+"/"+e)),a+=""!==o||t||i?o+t+i:"/",a}};function q(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 K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),i=!e.includes("#",t);return r&&n&&i}var _=fetch;const{isObject:W,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,t)=>{const r=e in F?F[e]:e;if(r in D)return D[r][t]},N={},M={},G=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const i=Z(n,"idToken"),o=J(t)[0],s=Y(o,e[i]||""),a=J(s)[0];if(!a)throw Error("Couldn't determine an identifier for the schema");o&&(M[o]=a);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(F[a]=n,u=e.$vocabulary,delete e.$vocabulary):u=a===n?{[n]:!0}:{};const f={};N[a]={id:a,schemaVersion:n,schema:H(e,a,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1}},H=(e,t,r,n,i)=>{if(W(e)){const o=Z(r,"idToken"),s=Z(r,"anchorToken");if("string"==typeof e[o]){const n=e[o],i=Y(t,n),[a,c]=J(i);if(delete e[o],c&&(e[s]=s!==o?encodeURI(c):`#${encodeURI(c)}`),a!==t)return G(e,Y(t,a),r),{[B]:n}}if("string"==typeof e[s]){const t=s!==o?e[s]:e[s].slice(1);i[t]=n,delete e[s]}return Object.entries(e).reduce((e,[o,s])=>(e[o]=H(s,t,r,y.append(o,n),i),e),{})}return Array.isArray(e)?e.map((e,o)=>H(e,t,r,y.append(o,n),i)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,t=Q,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:re(t),i=Y(n,e),[o,s]=J(i);if(!(e=>e in N||e in M)(o)){const e=await _(o,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error(`Failed to retrieve schema with id: ${o}`);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${o} is not a schema. Found a document with media type: ${t}`)}G(await e.json(),o)}const a=(e=>N[e]||N[M[e]])(o),c=Object.freeze({id:a.id,schemaVersion:a.schemaVersion,vocabulary:a.vocabulary,pointer:s&&"/"!==s[0]?te(a,s):s,schema:a.schema,recursiveAnchor:t.recursiveAnchor||!!a.recursiveAnchor&&o,validated:a.validated}),u=ne(c);return W(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,t)=>{const r=U(e,t);if("file"===ee(r)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return r},ee=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},te=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(t)}'`);return e.anchors[t]},re=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),ie=(e,t)=>{const r=y.append(e,t.pointer);return X(`#${encodeURI(r)}`,t)},oe=i((e,t)=>ne(t).map(async(r,n)=>e(await ie(n,t),n)));var se={setConfig:(e,t,r)=>{D[e]||(D[e]={}),D[e][t]=r},getConfig:Z,add:G,get:X,markValidated:e=>{N[e].validated=!0},uri:re,value:ne,step:ie,sibling:(e,t)=>{const r=t.pointer.split("/");r.pop();const n=y.append(e,r.join("/"));return X(`#${encodeURI(n)}`,t)},entries:e=>Object.keys(ne(e)).map(t=>[t,ie(t,e)]),map:oe};const ae="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const pe=(e,t)=>(n,i=ae)=>{if(![ae,ce,ue,fe].includes(i))throw Error(`The '${i}' error format is not supported`);let o=[];const s=r.subscribe("result",de(i,o));return Oe(t,n,e),r.unsubscribe(s),o[0]},de=(e,t)=>{const r=[];return(n,i)=>{const o={...i,errors:[]};for(;r.length>0&&he(r[r.length-1],o);){const t=r.pop();let n=[];if(e===ce&&(n=t.errors,delete t.errors),o.errors.unshift(t,...n),ye(o))break}(e===fe||e!==ae&&!o.valid)&&r.push(o),t[0]=o}},he=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},me=e=>be[e],ve={},we={},ge=async(e,t,r=!1)=>{if(!e.validated){if(se.markValidated(e.id),r&&((se.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(t=>{if(!e.vocabulary[t])throw Error(`Vocabulary '${t}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([t,r])=>{if(t in ve)Object.entries(ve[t]).forEach(([t,r])=>{be[`${e.id}#${t}`]=r});else if(r)throw Error(`Missing required vocabulary: ${t}`)})),!(e.schemaVersion in we)){const t=await se.get(e.schemaVersion),r={},n=await ge(t,r,!0);we[e.schemaVersion]=pe(r,n)}const t=x.cons(e.schema,e.id),n=we[e.schemaVersion](t,le);if(!n.valid)throw n}return await me(`${e.schemaVersion}#validate`).compile(e,t),se.uri(e)},Oe=(e,t,r)=>{const[n]=r[e];return me(n).interpret(e,t,r)};var $e={validate:async(e,t,r)=>{const n={},i=await ge(e,n),o=(e,t=ae)=>pe(n,i)(x.cons(e),t);return void 0===t?o:o(t,r)},setMetaOutputFormat:e=>{le=e},FLAG:ae,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:me,hasKeyword:e=>e in be,defineVocabulary:(e,t)=>{ve[e]=t},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),xe=i(async(e,t)=>(await t).map(e)),Se=i(async(e,t,r)=>(await r).reduce(async(t,r)=>e(await t,r),t)),Ae=i(async(e,t,r={})=>Se(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),Pe=i(async(e,t)=>{const r=await xe(e,t);return(await Promise.all(r)).some(e=>e)}),Ie=i(async(e,t)=>{const r=await xe(e,t);return(await Promise.all(r)).every(e=>e)}),Ve=i((e,t)=>e.reduce(async(e,t)=>t(await e),t)),Re={entries:je,map:xe,filter:Ae,reduce:Se,some:Pe,every:Ie,pipeline:Ve,all:e=>Promise.all(e),allValues:e=>Ve([je,Se(async(e,[t,r])=>(e[t]=await r,e),{})],e)};var Te={compile:async(e,t)=>{const r=se.uri(e);if(!(r in t)){t[r]=!1;const n=se.value(e);t[r]=[`${e.schemaVersion}#validate`,se.uri(e),"boolean"==typeof n?n:await Re.pipeline([se.entries,Re.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),Re.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),Re.map(async([e,r])=>{const n=await r,i=await $e.getKeyword(e).compile(n,t);return[e,se.uri(n),i]}),Re.all],e)]}},interpret:(e,t,n)=>{const[i,o,s]=n[e],a="boolean"==typeof s?s:s.every(([e,i,o])=>{const s=$e.getKeyword(e).interpret(o,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s});return r.publishSync("result",{keyword:i,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a}},ke={JsonSchema:$e,Schema:se,Instance:x,Keywords:{metaData:Ee,validate:Te}},Le=ke.JsonSchema,Ue=ke.Schema,qe=ke.Instance,ze=ke.Keywords;e.Instance=qe,e.JsonSchema=Le,e.Keywords=ze,e.Schema=Ue,e.default=ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function L(e){var r=String(e);if(P.test(r))return r;if(r.length>0&&!A.test(r))throw new TypeError("invalid parameter value");return'"'+r.replace(I,"\\$1")+'"'}function R(e){this.parameters=Object.create(null),this.type=e}var T={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var r=e.parameters,t=e.type;if(!t||!k.test(t))throw new TypeError("invalid type");var n=t;if(r&&"object"==typeof r)for(var o,i=Object.keys(r).sort(),a=0;a<i.length;a++){if(o=i[a],!P.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+L(r[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var r="object"==typeof e?function(e){var r;"function"==typeof e.getHeader?r=e.getHeader("content-type"):"object"==typeof e.headers&&(r=e.headers&&e.headers["content-type"]);if("string"!=typeof r)throw new TypeError("content-type header is missing from object");return r}(e):e;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var t=r.indexOf(";"),n=-1!==t?r.substr(0,t).trim():r.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new R(n.toLowerCase());if(-1!==t){var i,a,s;for(S.lastIndex=t;a=S.exec(r);){if(a.index!==t)throw new TypeError("invalid parameter format");t+=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(t!==r.length)throw new TypeError("invalid parameter format")}return o}},U=function(e,r){if(e=e.trim(),(r=r.trim()).startsWith("about:"))return r;if(""===e)return C(r)?q(r):r;const t=function(e){const r={host:"",path:"",query:"",protocol:""};let t=e,n=e.indexOf("//");if(-1===n)throw new Error("Error, protocol is not specified");r.protocol=t.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(t=t.substring(0,a));if(-1!==i){const e=t.substring(i);r.query=e,t=t.substring(0,i)}if(-1!==o){const e=t.substring(0,o);r.host=e,t=t.substring(o),r.path=t}else r.host=t;return r}(e);if(""===r){const{host:e,path:r,query:n}=t;return r||n?e+r+n:q(e)}const n=function(e){const r={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(K.test(e))return r.netPath=!0,r;"/"===e[0]?r.absolutePath=!0:r.relativePath=!0;let t=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=t.substring(o);r.hash=e,t=t.substring(0,o)}if(-1!==n){const e=t.substring(n);r.query=e,t=t.substring(0,n)}return r.path=t,r}(r);if(n.netPath)return n.href.startsWith("//")&&(n.href=t.protocol+n.href),C(n.href)?q(n.href):n.href;if(n.absolutePath){const{path:e,query:r,hash:o}=n;return t.host+z(e)+r+o}if(n.relativePath){const{path:e,query:r,hash:o}=n;let i,a=t.path,s=t.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=z(a+"/"+e)),s+=""!==i||r||o?i+r+o:"/",s}};function q(e){return e+("/"===e[e.length-1]?"":"/")}function z(e){let r=e.split("/");""===r[0]&&(r=r.slice(1));let t=[];return r.forEach((e,n)=>{"."!==e&&(".."===e?t.pop():""===e&&n!==r.length-1||t.push(e))}),"/"+t.join("/")}const K=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");function C(e){const r=e.indexOf("//")+2,t=!e.includes("/",r),n=!e.includes("?",r),o=!e.includes("#",r);return t&&n&&o}var _=fetch;const{isObject:W,splitUrl:J}=n,B=Symbol("$__jref"),D={},F={},Z=(e,r)=>{const t=e in F?F[e]:e;if(t in D)return D[t][r]},N={},M={},G=(e,r="",t="")=>{e=JSON.parse(JSON.stringify(e));const n=J(e.$schema||t)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=Z(n,"idToken"),i=J(r)[0],a=Y(i,e[o]||""),s=J(a)[0];if(!s)throw Error("Couldn't determine an identifier for the schema");i&&(M[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,Z(n,"vocabulary")&&W(e)&&"$vocabulary"in e?(F[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const f={};N[s]={id:s,schemaVersion:n,schema:H(e,s,n,y.nil,f),anchors:f,recursiveAnchor:c,vocabulary:u,validated:!1,vocabularyLoaded:!1}},H=(e,r,t,n,o)=>{if(W(e)){const i=Z(t,"idToken"),a=Z(t,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=Y(r,n),[s,c]=J(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):`#${encodeURI(c)}`),s!==r)return G(e,Y(r,s),t),{[B]:n}}if("string"==typeof e[a]){const r=a!==i?e[a]:e[a].slice(1);o[r]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=H(a,r,t,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>H(e,r,t,y.append(i,n),o)):e},Q=Object.freeze({id:"http://",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),X=async(e,r=Q,t=!1)=>{const n=t&&r.recursiveAnchor?r.recursiveAnchor:te(r),o=Y(n,e),[i,a]=J(o);if(!(e=>e in N||e in M)(i)){const e=await _(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 r=T.parse(e.headers.get("content-type")).type;if("application/schema+json"!==r)throw Error(`${i} is not a schema. Found a document with media type: ${r}`)}G(await e.json(),i)}const s=(e=>N[e]||N[M[e]])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?re(s,a):a,schema:s.schema,recursiveAnchor:r.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated,vocabularyLoaded:s.vocabularyLoaded}),u=ne(c);return W(u)&&B in u?X(u[B],c):Z(c.schemaVersion,"jsonReference")&&W(u)&&"string"==typeof u.$ref?X(u.$ref,c):Z(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?X(u,c):Z(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?X(u,c,!0):c},Y=(e,r)=>{const t=U(e,r);if("file"===ee(t)&&"file"!==ee(e))throw Error("Can't access file resource from network context");return t},ee=e=>{const r=e.match(/^(.+):\/\//);return r?r[1]:""},re=(e,r)=>{if(!(r in e.anchors))throw Error(`No such anchor '${encodeURI(id)}#${encodeURI(r)}'`);return e.anchors[r]},te=e=>`${e.id}#${encodeURI(e.pointer)}`,ne=e=>y.get(e.pointer,e.schema),oe=(e,r)=>{const t=y.append(e,r.pointer);return X(`#${encodeURI(t)}`,r)},ie=o((e,r)=>ne(r).map(async(t,n)=>e(await oe(n,r),n)));var ae={setConfig:(e,r,t)=>{D[e]||(D[e]={}),D[e][r]=t},getConfig:Z,add:G,get:X,markValidated:e=>{N[e].validated=!0},markVocabularyLoaded:e=>{N[e].vocabularyLoaded=!0},uri:te,value:ne,step:oe,sibling:(e,r)=>{const t=r.pointer.split("/");t.pop();const n=y.append(e,t.join("/"));return X(`#${encodeURI(n)}`,r)},entries:e=>Object.keys(ne(e)).map(r=>[r,oe(r,e)]),map:ie};const se="FLAG",ce="BASIC",ue="DETAILED",fe="VERBOSE";let le=ue;const de=(e,r)=>(n,o=se)=>{if(![se,ce,ue,fe].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",pe(o,i));return Oe(r,n,e),t.unsubscribe(a),i[0]},pe=(e,r)=>{const t=[];return(n,o)=>{const i={...o,errors:[]};for(;t.length>0&&he(t[t.length-1],i);){const r=t.pop();let n=[];if(e===ce&&(n=r.errors,delete r.errors),i.errors.unshift(r,...n),ye(i))break}(e===fe||e!==se&&!i.valid)&&t.push(i),r[0]=i}},he=(e,r)=>e.instanceLocation.startsWith(r.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(r.absoluteKeywordLocation)||ye(e)),ye=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),be={},ve=e=>be[e],me={},we={},ge=async(e,r,t=!1)=>{if(t&&!e.vocabularyLoaded&&(ae.markVocabularyLoaded(e.id),(ae.getConfig(e.schemaVersion,"mandatoryVocabularies")||[]).forEach(r=>{if(!e.vocabulary[r])throw Error(`Vocabulary '${r}' must be explicitly declared and required`)}),Object.entries(e.vocabulary).forEach(([r,t])=>{if(r in me)Object.entries(me[r]).forEach(([r,t])=>{be[`${e.id}#${r}`]=t});else if(t)throw Error(`Missing required vocabulary: ${r}`)})),!e.validated){if(ae.markValidated(e.id),!(e.schemaVersion in we)){const r=await ae.get(e.schemaVersion),t={},n=await ge(r,t,!0);we[e.schemaVersion]=de(t,n)}const r=x.cons(e.schema,e.id),t=we[e.schemaVersion](r,le);if(!t.valid)throw t}return await ve(`${e.schemaVersion}#validate`).compile(e,r),ae.uri(e)},Oe=(e,r,t)=>{const[n]=t[e];return ve(n).interpret(e,r,t)};var $e={validate:async(e,r,t)=>{const n={},o=await ge(e,n),i=(e,r=se)=>de(n,o)(x.cons(e),r);return void 0===r?i:i(r,t)},setMetaOutputFormat:e=>{le=e},FLAG:se,BASIC:ce,DETAILED:ue,VERBOSE:fe,getKeyword:ve,hasKeyword:e=>e in be,defineVocabulary:(e,r)=>{me[e]=r},compileSchema:ge,interpretSchema:Oe};var Ee={compile:()=>{},interpret:()=>!0},je=async e=>Object.entries(await e),xe=o(async(e,r)=>(await r).map(e)),Se=o(async(e,r,t)=>(await t).reduce(async(r,t)=>e(await r,t),r)),Ae=o(async(e,r,t={})=>Se(async(r,t)=>await e(t)?r.concat([t]):r,[],r,t)),Pe=o(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).some(e=>e)}),Ve=o(async(e,r)=>{const t=await xe(e,r);return(await Promise.all(t)).every(e=>e)}),Ie=o((e,r)=>e.reduce(async(e,r)=>r(await e),r)),ke={entries:je,map:xe,filter:Ae,reduce:Se,some:Pe,every:Ve,pipeline:Ie,all:e=>Promise.all(e),allValues:e=>Ie([je,Se(async(e,[r,t])=>(e[r]=await t,e),{})],e)};var Le={compile:async(e,r)=>{const t=ae.uri(e);if(!(t in r)){r[t]=!1;const n=ae.value(e);r[t]=[`${e.schemaVersion}#validate`,ae.uri(e),"boolean"==typeof n?n:await ke.pipeline([ae.entries,ke.map(([r,t])=>[`${e.schemaVersion}#${r}`,t]),ke.filter(([e])=>$e.hasKeyword(e)&&"validate"!==e),ke.map(async([e,t])=>{const n=await t,o=await $e.getKeyword(e).compile(n,r);return[e,ae.uri(n),o]}),ke.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:x.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(r),valid:s}),s}},Re={JsonSchema:$e,Schema:ae,Instance:x,Keywords:{metaData:Ee,validate:Le}},Te=Re.JsonSchema,Ue=Re.Schema,qe=Re.Instance,ze=Re.Keywords;e.Instance=qe,e.JsonSchema=Te,e.Keywords=ze,e.Schema=Ue,e.default=Re,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
@@ -81,26 +81,28 @@ const PubSub = require("pubsub-js"); | ||
const compileSchema = async (schema, ast, isMetaSchema = false) => { | ||
if (!schema.validated) { | ||
Schema.markValidated(schema.id); | ||
if (isMetaSchema && !schema.vocabularyLoaded) { | ||
Schema.markVocabularyLoaded(schema.id); | ||
if (isMetaSchema) { | ||
// Check for mandatory vocabularies | ||
(Schema.getConfig(schema.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
// Check for mandatory vocabularies | ||
(Schema.getConfig(schema.schemaVersion, "mandatoryVocabularies") || []).forEach((vocabularyId) => { | ||
if (!schema.vocabulary[vocabularyId]) { | ||
throw Error(`Vocabulary '${vocabularyId}' must be explicitly declared and required`); | ||
} | ||
}); | ||
// Load vocabularies | ||
Object.entries(schema.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
// Load vocabularies | ||
Object.entries(schema.vocabulary) | ||
.forEach(([vocabularyId, isRequired]) => { | ||
if (vocabularyId in _vocabularies) { | ||
Object.entries(_vocabularies[vocabularyId]) | ||
.forEach(([keyword, keywordHandler]) => { | ||
_keywords[`${schema.id}#${keyword}`] = keywordHandler; | ||
}); | ||
} else if (isRequired) { | ||
throw Error(`Missing required vocabulary: ${vocabularyId}`); | ||
} | ||
}); | ||
} | ||
if (!schema.validated) { | ||
Schema.markValidated(schema.id); | ||
@@ -107,0 +109,0 @@ // Meta validation |
@@ -80,3 +80,4 @@ const contentTypeParser = require("content-type"); | ||
vocabulary: vocabulary, | ||
validated: false | ||
validated: false, | ||
vocabularyLoaded: false | ||
}; | ||
@@ -131,2 +132,6 @@ }; | ||
const markVocabularyLoaded = (id) => { | ||
schemaStore[id].vocabularyLoaded = true; | ||
}; | ||
// Schema Retrieval | ||
@@ -165,3 +170,4 @@ const nil = Object.freeze({ id: "http://", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
validated: storedSchema.validated | ||
validated: storedSchema.validated, | ||
vocabularyLoaded: storedSchema.vocabularyLoaded | ||
}); | ||
@@ -229,4 +235,4 @@ | ||
setConfig, getConfig, | ||
add, get, markValidated, | ||
add, get, markValidated, markVocabularyLoaded, | ||
uri, value, step, sibling, entries, map | ||
}; |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
1401712
8402