@hyperjump/json-schema-core
Advanced tools
Comparing version 0.10.2 to 0.11.0
@@ -1125,6 +1125,2 @@ define(['exports'], function (exports) { 'use strict'; | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1144,8 +1140,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1156,3 +1153,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1178,2 +1175,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1187,7 +1198,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1206,6 +1217,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1238,3 +1249,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1241,0 +1252,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},E=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),$=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),P=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),j=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),x=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var A={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:E,filter:$,reduce:P,every:j,some:x},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
define(["exports"],(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function K(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var C={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+K(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(J.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+N(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=N(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function N(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const J=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];i&&(ne[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},ie=(e,t,r,n,o)=>{if(H(e)){const i=te(r,"idToken"),a=te(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=ce(t,n),[s,c]=Q(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return oe(e,ce(t,s),r),{[X]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=ie(a,t,r,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>ie(e,t,r,y.append(i,n),o)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=C.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const Ee=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",$e(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Pe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),je(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Pe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||je(e)),je=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Ae=e=>xe[e],Se=e=>e in xe,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=Ee(r,n)}const t=A.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Ae(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Ae(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>Ee(n,o)(A.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Ae,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedItems(e,t,r,n)}};var Ke={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:A.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:A.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Le={Core:Re,Schema:ye,Instance:A,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ke}},Ce=Le.Core,Ue=Le.Schema,qe=Le.Instance,ze=Le.Keywords;e.Core=Ce,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Le,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function K(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function L(e){this.parameters=Object.create(null),this.type=e}var C={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+K(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new L(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(J.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+N(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=N(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function N(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const J=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=C.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ke={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Le={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ke}},Ce=Le.Core,Ue=Le.Schema,qe=Le.Instance,ze=Le.Keywords;e.Core=Ce,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Le,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -1127,6 +1127,2 @@ 'use strict'; | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1146,8 +1142,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1158,3 +1155,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1180,2 +1177,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1189,7 +1200,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1208,6 +1219,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1240,3 +1251,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1243,0 +1254,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),x=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),P=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var j={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:x,some:P},A=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,p(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||d(t)){const o=e.shift();i(e,p(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(d(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},d=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[p(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),$=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),x=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),A=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:$,reduce:E,every:x,some:A},j=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(A.lastIndex=r;a=A.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?M(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+Z(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=Z(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:M(e)}};function M(e){return e+("/"===e[e.length-1]?"":"/")}function Z(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];i&&(re[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},oe=(e,t,r,n,o)=>{if(G(e)){const i=ee(r,"idToken"),a=ee(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=se(t,n),[s,c]=H(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return ne(e,se(t,s),r),{[Q]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=oe(a,t,r,h.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>oe(e,t,r,h.append(i,n),o)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),de=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},pe=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await de(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:de,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await de(t,e)]),D.all],e),map:pe};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",Ee(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&$e(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},$e=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Pe={},je=e=>Pe[e],Ae=e=>e in Pe,Se={},Ie={},Ve=async(e,t)=>{if(!Ae(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{Pe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=j.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await je(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return je(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(j.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:je,hasKeyword:Ae,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return je(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return je(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:j.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:j.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:j,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;exports.Core=Le,exports.Instance=Ue,exports.Keywords=qe,exports.Schema=Ce,exports.default=Ke; | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(j.lastIndex=r;a=j.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?M(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+Z(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=Z(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:M(e)}};function M(e){return e+("/"===e[e.length-1]?"":"/")}function Z(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];let c;i&&(re[i]=s),ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},oe=(e,t,r,n,o,i)=>{if(G(e)){const a=ee(r,"idToken"),s=ee(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=se(t,n),[i,c]=H(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ne(e,se(t,i),r),{[Q]:n}}if("string"===ee(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===h.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=oe(s,t,r,h.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>oe(e,t,r,h.append(a,n),o,i)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),pe=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},de=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await pe(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:pe,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await pe(t,e)]),D.all],e),map:de};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",$e(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ee(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},Ee=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Ae={},Pe=e=>Ae[e],je=e=>e in Ae,Se={},Ie={},Ve=async(e,t)=>{if(!je(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{Ae[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=P.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:Pe,hasKeyword:je,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;exports.Core=Le,exports.Instance=Ue,exports.Keywords=qe,exports.Schema=Ce,exports.default=Ke; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -1123,6 +1123,2 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1142,8 +1138,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1154,3 +1151,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1176,2 +1173,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1185,7 +1196,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1204,6 +1215,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1236,3 +1247,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1239,0 +1250,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),E=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),$=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),x=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),P=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var j={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:E,reduce:$,every:x,some:P},A=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(t,r){!function(e,n){var o={};e.PubSub=o;var i=e.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==t&&t.exports&&(r=t.exports=o),r.PubSub=o,t.exports=r=o)}("object"==typeof window&&window||e)})),r=(t.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const n=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(l)},o=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:o(e,d(t,i,n),r,c(i,n))}}if(Array.isArray(t)){const n=[...t];return n[f(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:d(t,e[0],n)},i=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const o=e.shift();i(e,d(t,o,n),r,c(o,n))}else{t[f(t,e[0])]=r}},a=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=d(t,n,r);return{...t,[n]:a(e,o,c(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return d(t,e[0],r)}},s=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=d(t,n,r);s(e,o,c(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:d(t,e[0],r)},c=r((e,t)=>t+"/"+u(e)),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),l=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,d=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},p=e=>null===e||"object"!=typeof e;var h={nil:"",append:c,get:(e,t)=>{const r=n(e),o=e=>r.reduce(([e,t],r)=>[d(e,r,t),c(r,t)],[e,""])[0];return void 0===t?o:o(t)},set:(e,t,i)=>{const a=n(e),s=r((e,t)=>o(a,e,t,""));return void 0===t?s:s(t,i)},assign:(e,t,o)=>{const a=n(e),s=r((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,o)},unset:(e,t)=>{const r=n(e),o=e=>a(r,e,"");return void 0===t?o:o(t)},delete:(e,t)=>{const r=n(e),o=e=>s(r,e,"");return void 0===t?o:o(t)}};var y={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:v}=y,b=Object.freeze({id:"",pointer:"",instance:void 0}),m=(e,t=b)=>Object.freeze({...t,pointer:v(e)[1]}),w=e=>h.get(e.pointer,e.instance),g=(e,t)=>{const r=h.append(e,t.pointer);return m("#"+encodeURI(r),t)},O=r((e,t)=>w(t).map((r,n)=>e(g(n,t),n))),$=r((e,t)=>w(t).map((e,r)=>g(r,t)).filter((t,r)=>e(t,r))),E=r((e,t,r)=>w(r).reduce((t,n,o)=>e(t,g(o,r),o),t)),A=r((e,t)=>Object.keys(w(t)).every((r,n)=>e(g(r,t),n))),x=r((e,t)=>Object.keys(w(t)).some((r,n)=>e(g(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...b,id:t,instance:e}),get:m,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:w,step:g,entries:e=>Object.keys(w(e)).map(t=>[t,g(t,e)]),map:O,filter:$,reduce:E,every:A,some:x},j=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,S=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,I=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,V=/\\([\u000b\u0020-\u00ff])/g,T=/([\\"])/g,k=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(A.lastIndex=r;a=A.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];i&&(re[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},oe=(e,t,r,n,o)=>{if(G(e)){const i=ee(r,"idToken"),a=ee(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=se(t,n),[s,c]=H(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return ne(e,se(t,s),r),{[Q]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=oe(a,t,r,h.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>oe(e,t,r,h.append(i,n),o)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),de=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},pe=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await de(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:de,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await de(t,e)]),D.all],e),map:pe};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",Ee(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&$e(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},$e=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Pe={},je=e=>Pe[e],Ae=e=>e in Pe,Se={},Ie={},Ve=async(e,t)=>{if(!Ae(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{Pe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=j.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await je(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return je(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(j.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:je,hasKeyword:Ae,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return je(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return je(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:j.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:j.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:j,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;export default Ke;export{Le as Core,Ue as Instance,qe as Keywords,Ce as Schema}; | ||
*/function R(e){var t=String(e);if(I.test(t))return t;if(t.length>0&&!S.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(T,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!k.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!I.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+R(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!k.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(j.lastIndex=r;a=j.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(V,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},C=async e=>Object.entries(await e),U=r(async(e,t)=>(await t).map(e)),q=r(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),z=r(async(e,t,r={})=>q(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),W=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).some(e=>e)}),_=r(async(e,t)=>{const r=await U(e,t);return(await Promise.all(r)).every(e=>e)}),B=r((e,t)=>e.reduce(async(e,t)=>t(await e),t)),D={entries:C,map:U,filter:z,reduce:q,some:W,every:_,pipeline:B,all:e=>Promise.all(e),allValues:e=>B([C,q(async(e,[t,r])=>(e[t]=await r,e),{})],e)},F=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var J=fetch;const{isObject:G,splitUrl:H}=y,Q=Symbol("$__jref"),X={},Y={},ee=(e,t)=>{const r=e in Y?Y[e]:e;if(r in X)return X[r][t]},te={},re={},ne=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=H(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=ee(n,"idToken"),i=H(t)[0];if(!i&&!H(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=se(i,e[o]||""),s=H(a)[0];let c;i&&(re[i]=s),ee(n,"vocabulary")&&G(e)&&"$vocabulary"in e?(Y[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};te[s]={id:s,schemaVersion:n,schema:oe(e,s,n,h.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},oe=(e,t,r,n,o,i)=>{if(G(e)){const a=ee(r,"idToken"),s=ee(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=se(t,n),[i,c]=H(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return ne(e,se(t,i),r),{[Q]:n}}if("string"===ee(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===h.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=oe(s,t,r,h.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>oe(e,t,r,h.append(a,n),o,i)):e},ie=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),ae=async(e,t=ie,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:le(t),o=se(n,e),[i,a]=H(o);if(!(e=>e in te||e in re)(i)){const e=await J(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}ne(await e.json(),i)}const s=(e=>te[re[e]]||te[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?ue(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=fe(c);return G(u)&&Q in u?ae(u[Q],c):ee(c.schemaVersion,"jsonReference")&&G(u)&&"string"==typeof u.$ref?ae(u.$ref,c):ee(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?ae(u,c):ee(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?ae(u,c,!0):c},se=(e,t)=>{const r=F(e,t),n=H(e)[0];if(n&&"file"===ce(r)&&"file"!==ce(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ce=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},ue=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},le=e=>`${e.id}#${encodeURI(e.pointer)}`,fe=e=>h.get(e.pointer,e.schema),de=(e,t)=>{const r=h.append(e,t.pointer);return ae("#"+encodeURI(r),t)},pe=r((e,t)=>D.pipeline([fe,D.map(async(r,n)=>e(await de(n,t),n)),D.all],t));var he={setConfig:(e,t,r)=>{X[e]||(X[e]={}),X[e][t]=r},getConfig:ee,add:ne,get:ae,markValidated:e=>{te[e].validated=!0},uri:le,value:fe,has:(e,t)=>e in fe(t),step:de,entries:e=>D.pipeline([fe,Object.keys,D.map(async t=>[t,await de(t,e)]),D.all],e),map:pe};const ye="FLAG",ve="BASIC",be="DETAILED",me="VERBOSE";let we=be,ge=!0;const Oe=(e,r)=>(n,o=ye)=>{if(![ye,ve,be,me].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=t.subscribe("result",$e(o,i));return Te(r,n,e),t.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ee(r[r.length-1],i);){const t=r.pop();let n=[];if(e===ve&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Ae(i))break}(e===me||e!==ye&&!i.valid)&&r.push(i),t[0]=i}},Ee=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Ae(e)),Ae=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Pe=e=>xe[e],je=e=>e in xe,Se={},Ie={},Ve=async(e,t)=>{if(!je(e.schemaVersion+"#validate")){const t=await he.get(e.schemaVersion);(he.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Se)Object.entries(Se[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(ge&&!e.validated){if(he.markValidated(e.id),!(e.schemaVersion in Ie)){const t=await he.get(e.schemaVersion),r={},n=await Ve(t,r);Ie[t.id]=Oe(r,n)}const t=P.cons(e.schema,e.id),r=Ie[e.schemaVersion](t,we);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),he.uri(e)},Te=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var ke={validate:async(e,t,r)=>{const n={},o=await Ve(e,n),i=(e,t=ye)=>Oe(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{we=e},setShouldMetaValidate:e=>{ge=e},FLAG:ye,BASIC:ve,DETAILED:be,VERBOSE:me,getKeyword:Pe,hasKeyword:je,defineVocabulary:(e,t)=>{Se[e]=t},compileSchema:Ve,interpretSchema:Te,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Re={compile:async(e,t)=>{const r=he.uri(e);if(!(r in t)){t[r]=!1;const n=he.value(e);t[r]=[e.schemaVersion+"#validate",he.uri(e),"boolean"==typeof n?n:await D.pipeline([he.entries,D.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),D.filter(([t])=>ke.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),D.map(async([r,n])=>{const o=await ke.getKeyword(r).compile(n,t,e);return[r,he.uri(n),o]}),D.all],e)]}},interpret:(e,r,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=ke.getKeyword(e).interpret(i,r,n);return t.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(r),valid:a}),a});return t.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(r),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&ke.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&ke.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:ke,Schema:he,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Re}},Le=Ke.Core,Ce=Ke.Schema,Ue=Ke.Instance,qe=Ke.Keywords;export default Ke;export{Le as Core,Ue as Instance,qe as Keywords,Ce as Schema}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -1126,6 +1126,2 @@ var JSC = (function (exports) { | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1145,8 +1141,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1157,3 +1154,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1179,2 +1176,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1188,7 +1199,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1207,6 +1218,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1239,3 +1250,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1242,0 +1253,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},E=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),$=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),P=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),j=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),x=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var A={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:E,filter:$,reduce:P,every:j,some:x},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var JSC=function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];i&&(ne[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},ie=(e,t,r,n,o)=>{if(H(e)){const i=te(r,"idToken"),a=te(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=ce(t,n),[s,c]=Q(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return oe(e,ce(t,s),r),{[X]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=ie(a,t,r,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>ie(e,t,r,y.append(i,n),o)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const Ee=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",$e(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Pe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),je(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Pe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||je(e)),je=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Ae=e=>xe[e],Se=e=>e in xe,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=Ee(r,n)}const t=A.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Ae(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Ae(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>Ee(n,o)(A.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Ae,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:A.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:A.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:A,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;return e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,e}({}); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;return e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1128,6 +1128,2 @@ System.register('JSC', [], function (exports) { | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1147,8 +1143,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1159,3 +1156,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1181,2 +1178,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1190,7 +1201,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1209,6 +1220,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1241,3 +1252,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1244,0 +1255,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},E=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),$=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),P=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),j=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),x=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var S={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:E,filter:$,reduce:P,every:j,some:x},A=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),P=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),j=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var x={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:P,some:j},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(A.lastIndex=r;a=A.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];i&&(ne[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},ie=(e,t,r,n,o)=>{if(H(e)){const i=te(r,"idToken"),a=te(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=ce(t,n),[s,c]=Q(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return oe(e,ce(t,s),r),{[X]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=ie(a,t,r,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>ie(e,t,r,y.append(i,n),o)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const Ee=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",$e(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Pe(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),je(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Pe=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||je(e)),je=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Se=e=>xe[e],Ae=e=>e in xe,Ie={},Ve={},Te=async(e,t)=>{if(!Ae(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=Ee(r,n)}const t=S.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Se(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Se(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>Ee(n,o)(S.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Se,hasKeyword:Ae,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Se(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Se(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:S.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:S.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:S,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}};e("default",Ke);e("Core",Ke.Core),e("Schema",Ke.Schema),e("Instance",Ke.Instance),e("Keywords",Ke.Keywords)}}})); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},Z=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?J(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+M(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=M(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:J(e)}};function J(e){return e+("/"===e[e.length-1]?"":"/")}function M(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=Z(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),Pe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||Pe(e)),Pe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),je={},xe=e=>je[e],Se=e=>e in je,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{je[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=x.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await xe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return xe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(x.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:xe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return xe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:x.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:x.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:x,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}};e("default",Ke);e("Core",Ke.Core),e("Schema",Ke.Schema),e("Instance",Ke.Instance),e("Keywords",Ke.Keywords)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -1129,6 +1129,2 @@ (function (global, factory) { | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -1148,8 +1144,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, jsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -1160,3 +1157,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject$1(subject)) { | ||
@@ -1182,2 +1179,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === jsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -1191,7 +1202,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, jsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, jsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -1210,6 +1221,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil$2 = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get$2 = async (url, contextDoc = nil$2, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri$1(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri$1(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -1242,3 +1253,3 @@ const [id, fragment] = splitUrl$2(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -1245,0 +1256,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},E=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),$=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),j=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),x=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),P=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var A={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:E,filter:$,reduce:j,every:x,some:P},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).JSC={})}(this,(function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(t,n){var o={};t.PubSub=o;var i=t.define;!function(e){var t={},r=-1;function n(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function o(e,t,r){try{e(t,r)}catch(e){setTimeout(function(e){return function(){throw e}}(e),0)}}function i(e,t,r){e(t,r)}function a(e,r,n,a){var s,c=t[r],u=a?i:o;if(t.hasOwnProperty(r))for(s in c)c.hasOwnProperty(s)&&u(c[s],e,n)}function s(e,r,o,i){var s=function(e,t,r){return function(){var n=String(e),o=n.lastIndexOf(".");for(a(e,e,t,r);-1!==o;)o=(n=n.substr(0,o)).lastIndexOf("."),a(e,n,t,r)}}(e="symbol"==typeof e?e.toString():e,r,i);return!!function(e){for(var r=String(e),o=Boolean(t.hasOwnProperty(r)&&n(t[r])),i=r.lastIndexOf(".");!o&&-1!==i;)i=(r=r.substr(0,i)).lastIndexOf("."),o=Boolean(t.hasOwnProperty(r)&&n(t[r]));return o}(e)&&(!0===o?s():setTimeout(s,0),!0)}e.publish=function(t,r){return s(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return s(t,r,!0,e.immediateExceptions)},e.subscribe=function(e,n){if("function"!=typeof n)return!1;e="symbol"==typeof e?e.toString():e,t.hasOwnProperty(e)||(t[e]={});var o="uid_"+String(++r);return t[e][o]=n,o},e.subscribeOnce=function(t,r){var n=e.subscribe(t,(function(){e.unsubscribe(n),r.apply(this,arguments)}));return e},e.clearAllSubscriptions=function(){t={}},e.clearSubscriptions=function(e){var r;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&delete t[r]},e.countSubscriptions=function(e){var r,n=0;for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n++;return n},e.getSubscriptions=function(e){var r,n=[];for(r in t)t.hasOwnProperty(r)&&0===r.indexOf(e)&&n.push(r);return n},e.unsubscribe=function(r){var n,o,i,a="string"==typeof r&&(t.hasOwnProperty(r)||function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1}(r)),s=!a&&"string"==typeof r,c="function"==typeof r,u=!1;if(!a){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],s&&o[r]){delete o[r],u=r;break}if(c)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],u=!0)}return u}e.clearSubscriptions(r)}}(o),"function"==typeof i&&i.amd?i((function(){return o})):(void 0!==e&&e.exports&&(r=e.exports=o),r.PubSub=o,e.exports=r=o)}("object"==typeof window&&window||t)})),n=(r.PubSub,function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}});const o=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(f)},i=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:i(e,p(t,o,n),r,u(o,n))}}if(Array.isArray(t)){const n=[...t];return n[d(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:p(t,e[0],n)},a=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||h(t)){const o=e.shift();a(e,p(t,o,n),r,u(o,n))}else{t[d(t,e[0])]=r}},s=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=p(t,n,r);return{...t,[n]:s(e,o,u(n,r))}}if(Array.isArray(t))return t.filter((t,r)=>r!=e[0]);if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return p(t,e[0],r)}},c=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=p(t,n,r);c(e,o,u(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:p(t,e[0],r)},u=n((e,t)=>t+"/"+l(e)),l=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),f=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),d=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,p=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(h(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[d(e,t)]},h=e=>null===e||"object"!=typeof e;var y={nil:"",append:u,get:(e,t)=>{const r=o(e),n=e=>r.reduce(([e,t],r)=>[p(e,r,t),u(r,t)],[e,""])[0];return void 0===t?n:n(t)},set:(e,t,r)=>{const a=o(e),s=n((e,t)=>i(a,e,t,""));return void 0===t?s:s(t,r)},assign:(e,t,r)=>{const i=o(e),s=n((e,t)=>a(i,e,t,""));return void 0===t?s:s(t,r)},unset:(e,t)=>{const r=o(e),n=e=>s(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=o(e),n=e=>c(r,e,"");return void 0===t?n:n(t)}};var v={isObject:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,splitUrl:e=>{const t=e.indexOf("#"),r=-1===t?e.length:t,n=e.slice(0,r),o=e.slice(r+1);return[decodeURI(n),decodeURI(o)]}};const{splitUrl:b}=v,m=Object.freeze({id:"",pointer:"",instance:void 0}),w=(e,t=m)=>Object.freeze({...t,pointer:b(e)[1]}),g=e=>y.get(e.pointer,e.instance),O=(e,t)=>{const r=y.append(e,t.pointer);return w("#"+encodeURI(r),t)},$=n((e,t)=>g(t).map((r,n)=>e(O(n,t),n))),E=n((e,t)=>g(t).map((e,r)=>O(r,t)).filter((t,r)=>e(t,r))),A=n((e,t,r)=>g(r).reduce((t,n,o)=>e(t,O(o,r),o),t)),j=n((e,t)=>Object.keys(g(t)).every((r,n)=>e(O(r,t),n))),x=n((e,t)=>Object.keys(g(t)).some((r,n)=>e(O(r,t),n)));var P={cons:(e,t="")=>Object.freeze({...m,id:t,instance:e}),get:w,uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:g,step:O,entries:e=>Object.keys(g(e)).map(t=>[t,O(t,e)]),map:$,filter:E,reduce:A,every:j,some:x},S=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,I=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,V=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,T=/\\([\u000b\u0020-\u00ff])/g,k=/([\\"])/g,R=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/*! | ||
@@ -6,3 +6,3 @@ * content-type | ||
* MIT Licensed | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+J(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=J(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function J(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];i&&(ne[i]=s);const c=!!e.$recursiveAnchor;let u;delete e.$recursiveAnchor,te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,u=e.$vocabulary,delete e.$vocabulary):u=s===n?{[n]:!0}:{};const l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,l),anchors:l,recursiveAnchor:c,vocabulary:u,validated:!1}},ie=(e,t,r,n,o)=>{if(H(e)){const i=te(r,"idToken"),a=te(r,"anchorToken");if("string"==typeof e[i]){const n=e[i],o=ce(t,n),[s,c]=Q(o);if(delete e[i],c&&(e[a]=a!==i?encodeURI(c):"#"+encodeURI(c)),s!==t)return oe(e,ce(t,s),r),{[X]:n}}if("string"==typeof e[a]){const t=a!==i?e[a]:e[a].slice(1);o[t]=n,delete e[a]}return Object.entries(e).reduce((e,[i,a])=>(e[i]=ie(a,t,r,y.append(i,n),o),e),{})}return Array.isArray(e)?e.map((e,i)=>ie(e,t,r,y.append(i,n),o)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchor:!1}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchor?t.recursiveAnchor:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchor:t.recursiveAnchor||!!s.recursiveAnchor&&i,validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const Ee=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",$e(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},$e=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&je(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),xe(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},je=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||xe(e)),xe=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),Pe={},Ae=e=>Pe[e],Se=e=>e in Pe,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{Pe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=Ee(r,n)}const t=A.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Ae(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Ae(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>Ee(n,o)(A.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Ae,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Ae(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:A.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:A.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:A,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function C(e){var t=String(e);if(V.test(t))return t;if(t.length>0&&!I.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(k,"\\$1")+'"'}function K(e){this.parameters=Object.create(null),this.type=e}var L={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!R.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,i=Object.keys(t).sort(),a=0;a<i.length;a++){if(o=i[a],!V.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+C(t[o])}return n},parse:function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.substr(0,r).trim():t.trim();if(!R.test(n))throw new TypeError("invalid media type");var o=new K(n.toLowerCase());if(-1!==r){var i,a,s;for(S.lastIndex=r;a=S.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,i=a[1].toLowerCase(),'"'===(s=a[2])[0]&&(s=s.substr(1,s.length-2).replace(T,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},U=async e=>Object.entries(await e),q=n(async(e,t)=>(await t).map(e)),z=n(async(e,t,r)=>(await r).reduce(async(t,r)=>{let n;try{n=await t}catch(e){try{await r}catch(e){}return t}return e(n,r)},t)),W=n(async(e,t,r={})=>z(async(t,r)=>await e(r)?t.concat([r]):t,[],t,r)),_=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).some(e=>e)}),B=n(async(e,t)=>{const r=await q(e,t);return(await Promise.all(r)).every(e=>e)}),D=n((e,t)=>e.reduce(async(e,t)=>t(await e),t)),F={entries:U,map:q,filter:W,reduce:z,some:_,every:B,pipeline:D,all:e=>Promise.all(e),allValues:e=>D([U,z(async(e,[t,r])=>(e[t]=await r,e),{})],e)},M=function(e,t){if(e=e.trim(),(t=t.trim()).startsWith("about:"))return t;const r=function(e){const t={host:"",path:"",query:"",protocol:""};let r=e,n=e.indexOf("//");t.protocol=r.substring(0,n),n+=2;const o=e.indexOf("/",n),i=e.indexOf("?"),a=e.indexOf("#");-1!==a&&(r=r.substring(0,a));if(-1!==i){const e=r.substring(i);t.query=e,r=r.substring(0,i)}if(-1!==o){const e=r.substring(0,o);t.host=e,r=r.substring(o),t.path=r}else t.host=r;return t}(e),n=function(e){const t={href:e,hash:"",query:"",netPath:!1,absolutePath:!1,relativePath:!1};if(N.test(e))return t.netPath=!0,t;"/"===e[0]?t.absolutePath=!0:""!==e&&(t.relativePath=!0);let r=e;const n=e.indexOf("?"),o=e.indexOf("#");if(-1!==o){const e=r.substring(o);t.hash=e,r=r.substring(0,o)}if(-1!==n){const e=r.substring(n);t.query=e,r=r.substring(0,n)}return t.path=r,t}(t);if(!r.protocol&&!n.netPath)throw new Error("Error, protocol is not specified");if(n.netPath)return n.href.startsWith("//")&&(n.href=r.protocol+n.href),function(e){const t=e.indexOf("//")+2,r=!e.includes("/",t),n=!e.includes("?",t),o=!e.includes("#",t);return r&&n&&o}(n.href)?Z(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+J(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,a=r.path,s=r.host;return 0===e.length?i=a:(a=a.substring(0,a.lastIndexOf("/")),i=J(a+"/"+e)),s+=""!==i||t||o?i+t+o:"/",s}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:Z(e)}};function Z(e){return e+("/"===e[e.length-1]?"":"/")}function J(e){let t=e.split("/");""===t[0]&&(t=t.slice(1));let r=[];return t.forEach((e,n)=>{"."!==e&&(".."===e?r.pop():""===e&&n!==t.length-1||r.push(e))}),"/"+r.join("/")}const N=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");var G=fetch;const{isObject:H,splitUrl:Q}=v,X=Symbol("$__jref"),Y={},ee={},te=(e,t)=>{const r=e in ee?ee[e]:e;if(r in Y)return Y[r][t]},re={},ne={},oe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=Q(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=te(n,"idToken"),i=Q(t)[0];if(!i&&!Q(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const a=ce(i,e[o]||""),s=Q(a)[0];let c;i&&(ne[i]=s),te(n,"vocabulary")&&H(e)&&"$vocabulary"in e?(ee[s]=n,c=e.$vocabulary,delete e.$vocabulary):c=s===n?{[n]:!0}:{};const u={},l={};re[s]={id:s,schemaVersion:n,schema:ie(e,s,n,y.nil,u,l),anchors:u,recursiveAnchors:l,vocabulary:c,validated:!1}},ie=(e,t,r,n,o,i)=>{if(H(e)){const a=te(r,"idToken"),s=te(r,"anchorToken");if("string"==typeof e[a]){const n=e[a],o=ce(t,n),[i,c]=Q(o);if(delete e[a],c&&(e[s]=s!==a?encodeURI(c):"#"+encodeURI(c)),i!==t)return oe(e,ce(t,i),r),{[X]:n}}if("string"===te(r,"recursiveAnchorType")?"string"==typeof e.$recursiveAnchor&&(i["#"+e.$recursiveAnchor]=t,e[s]=e.$recursiveAnchor,delete e.$recursiveAnchor):n===y.nil&&!0===e.$recursiveAnchor&&(i["#"]=t,delete e.$recursiveAnchor),"string"==typeof e[s]){const t=s!==a?e[s]:e[s].slice(1);o[t]=n,delete e[s]}return Object.entries(e).reduce((e,[a,s])=>(e[a]=ie(s,t,r,y.append(a,n),o,i),e),{})}return Array.isArray(e)?e.map((e,a)=>ie(e,t,r,y.append(a,n),o,i)):e},ae=Object.freeze({id:"",schemaVersion:void 0,pointer:"",schema:void 0,recursiveAnchors:{}}),se=async(e,t=ae,r=!1)=>{const n=r&&t.recursiveAnchors[e]?t.recursiveAnchors[e]:fe(t),o=ce(n,e),[i,a]=Q(o);if(!(e=>e in re||e in ne)(i)){const e=await G(i,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+i);if(e.headers.has("content-type")){const t=L.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${i} is not a schema. Found a document with media type: ${t}`)}oe(await e.json(),i)}const s=(e=>re[ne[e]]||re[e])(i),c=Object.freeze({id:s.id,schemaVersion:s.schemaVersion,vocabulary:s.vocabulary,pointer:a&&"/"!==a[0]?le(s,a):a,schema:s.schema,recursiveAnchors:{...s.recursiveAnchors,...t.recursiveAnchors},validated:s.validated}),u=de(c);return H(u)&&X in u?se(u[X],c):te(c.schemaVersion,"jsonReference")&&H(u)&&"string"==typeof u.$ref?se(u.$ref,c):te(c.schemaVersion,"keywordReference")&&"string"==typeof u&&c.pointer.endsWith("/$ref")?se(u,c):te(c.schemaVersion,"keywordRecursiveReference")&&"string"==typeof u&&c.pointer.endsWith("/$recursiveRef")?se(u,c,!0):c},ce=(e,t)=>{const r=M(e,t),n=Q(e)[0];if(n&&"file"===ue(r)&&"file"!==ue(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r},ue=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""},le=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},fe=e=>`${e.id}#${encodeURI(e.pointer)}`,de=e=>y.get(e.pointer,e.schema),pe=(e,t)=>{const r=y.append(e,t.pointer);return se("#"+encodeURI(r),t)},he=n((e,t)=>F.pipeline([de,F.map(async(r,n)=>e(await pe(n,t),n)),F.all],t));var ye={setConfig:(e,t,r)=>{Y[e]||(Y[e]={}),Y[e][t]=r},getConfig:te,add:oe,get:se,markValidated:e=>{re[e].validated=!0},uri:fe,value:de,has:(e,t)=>e in de(t),step:pe,entries:e=>F.pipeline([de,Object.keys,F.map(async t=>[t,await pe(t,e)]),F.all],e),map:he};const ve="FLAG",be="BASIC",me="DETAILED",we="VERBOSE";let ge=me,Oe=!0;const $e=(e,t)=>(n,o=ve)=>{if(![ve,be,me,we].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=r.subscribe("result",Ee(o,i));return ke(t,n,e),r.unsubscribe(a),i[0]},Ee=(e,t)=>{const r=[];return(n,o)=>{const i={...o,errors:[]};for(;r.length>0&&Ae(r[r.length-1],i);){const t=r.pop();let n=[];if(e===be&&(n=t.errors,delete t.errors),i.errors.unshift(t,...n),je(i))break}(e===we||e!==ve&&!i.valid)&&r.push(i),t[0]=i}},Ae=(e,t)=>e.instanceLocation.startsWith(t.instanceLocation)&&(e.absoluteKeywordLocation.startsWith(t.absoluteKeywordLocation)||je(e)),je=e=>e.keyword.endsWith("#$ref")||e.keyword.endsWith("#$recursiveRef"),xe={},Pe=e=>xe[e],Se=e=>e in xe,Ie={},Ve={},Te=async(e,t)=>{if(!Se(e.schemaVersion+"#validate")){const t=await ye.get(e.schemaVersion);(ye.getConfig(t.id,"mandatoryVocabularies")||[]).forEach(e=>{if(!t.vocabulary[e])throw Error(`Vocabulary '${e}' must be explicitly declared and required`)}),Object.entries(t.vocabulary).forEach(([e,r])=>{if(e in Ie)Object.entries(Ie[e]).forEach(([e,r])=>{((e,t)=>{xe[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&0,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)});else if(r)throw Error("Missing required vocabulary: "+e)})}if(Oe&&!e.validated){if(ye.markValidated(e.id),!(e.schemaVersion in Ve)){const t=await ye.get(e.schemaVersion),r={},n=await Te(t,r);Ve[t.id]=$e(r,n)}const t=P.cons(e.schema,e.id),r=Ve[e.schemaVersion](t,ge);if(!r.valid)throw r}return await Pe(e.schemaVersion+"#validate").compile(e,t),ye.uri(e)},ke=(e,t,r)=>{const[n]=r[e];return Pe(n).interpret(e,t,r)};var Re={validate:async(e,t,r)=>{const n={},o=await Te(e,n),i=(e,t=ve)=>$e(n,o)(P.cons(e),t);return void 0===t?i:i(t,r)},setMetaOutputFormat:e=>{ge=e},setShouldMetaValidate:e=>{Oe=e},FLAG:ve,BASIC:be,DETAILED:me,VERBOSE:we,getKeyword:Pe,hasKeyword:Se,defineVocabulary:(e,t)=>{Ie[e]=t},compileSchema:Te,interpretSchema:ke,collectEvaluatedProperties:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedProperties(e,t,r,n)},collectEvaluatedItems:(e,t,r,n)=>{const[o]=r[e];return Pe(o).collectEvaluatedItems(e,t,r,n)}};var Ce={compile:async(e,t)=>{const r=ye.uri(e);if(!(r in t)){t[r]=!1;const n=ye.value(e);t[r]=[e.schemaVersion+"#validate",ye.uri(e),"boolean"==typeof n?n:await F.pipeline([ye.entries,F.map(([t,r])=>[`${e.schemaVersion}#${t}`,r]),F.filter(([t])=>Re.hasKeyword(t)&&t!==e.schemaVersion+"#validate"),F.map(async([r,n])=>{const o=await Re.getKeyword(r).compile(n,t,e);return[r,ye.uri(n),o]}),F.all],e)]}},interpret:(e,t,n)=>{const[o,i,a]=n[e],s="boolean"==typeof a?a:a.every(([e,o,i])=>{const a=Re.getKeyword(e).interpret(i,t,n);return r.publishSync("result",{keyword:e,absoluteKeywordLocation:o,instanceLocation:P.uri(t),valid:a}),a});return r.publishSync("result",{keyword:o,absoluteKeywordLocation:i,instanceLocation:P.uri(t),valid:s}),s},collectEvaluatedProperties:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedProperties")).reduce((e,[n,,o])=>{const i=e&&Re.getKeyword(n).collectEvaluatedProperties(o,t,r);return i&&e.concat(i)},[])},collectEvaluatedItems:(e,t,r,n=!1)=>{const o=r[e][2];return"boolean"==typeof o?!!o&&[]:o.filter(([e])=>!n||!e.endsWith("#unevaluatedItems")).reduce((e,[n,,o])=>{const i=!1!==e&&Re.getKeyword(n).collectEvaluatedItems(o,t,r);return!1!==i&&Math.max(e,i)},0)}},Ke={Core:Re,Schema:ye,Instance:P,Keywords:{metaData:{compile:()=>{},interpret:()=>!0},validate:Ce}},Le=Ke.Core,Ue=Ke.Schema,qe=Ke.Instance,ze=Ke.Keywords;e.Core=Le,e.Instance=qe,e.Keywords=ze,e.Schema=Ue,e.default=Ke,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
@@ -56,6 +56,2 @@ const contentTypeParser = require("content-type"); | ||
// Recursive Anchor | ||
const recursiveAnchor = !!schema["$recursiveAnchor"]; | ||
delete schema["$recursiveAnchor"]; | ||
// Vocabulary | ||
@@ -75,8 +71,9 @@ let vocabulary; | ||
const anchors = {}; | ||
const recursiveAnchors = {}; | ||
schemaStore[id] = { | ||
id: id, | ||
schemaVersion: schemaVersion, | ||
schema: processSchema(schema, id, schemaVersion, JsonPointer.nil, anchors), | ||
schema: processSchema(schema, id, schemaVersion, JsonPointer.nil, anchors, recursiveAnchors), | ||
anchors: anchors, | ||
recursiveAnchor: recursiveAnchor, | ||
recursiveAnchors: recursiveAnchors, | ||
vocabulary: vocabulary, | ||
@@ -87,3 +84,3 @@ validated: false | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors) => { | ||
const processSchema = (subject, id, schemaVersion, pointer, anchors, recursiveAnchors) => { | ||
if (isObject(subject)) { | ||
@@ -109,2 +106,16 @@ const idToken = getConfig(schemaVersion, "idToken"); | ||
if (getConfig(schemaVersion, "recursiveAnchorType") === "string") { | ||
if (typeof subject["$recursiveAnchor"] === "string") { | ||
recursiveAnchors[`#${subject["$recursiveAnchor"]}`] = id; | ||
subject[anchorToken] = subject["$recursiveAnchor"]; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} else { | ||
if (pointer === JsonPointer.nil && subject["$recursiveAnchor"] === true) { | ||
recursiveAnchors["#"] = id; | ||
delete subject["$recursiveAnchor"]; | ||
} | ||
} | ||
if (typeof subject[anchorToken] === "string") { | ||
@@ -118,7 +129,7 @@ const anchor = anchorToken !== idToken ? subject[anchorToken] : subject[anchorToken].slice(1); | ||
.reduce((acc, [key, value]) => { | ||
acc[key] = processSchema(value, id, schemaVersion, JsonPointer.append(key, pointer), anchors); | ||
acc[key] = processSchema(value, id, schemaVersion, JsonPointer.append(key, pointer), anchors, recursiveAnchors); | ||
return acc; | ||
}, {}); | ||
} else if (Array.isArray(subject)) { | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, JsonPointer.append(ndx, pointer), anchors)); | ||
return subject.map((item, ndx) => processSchema(item, id, schemaVersion, JsonPointer.append(ndx, pointer), anchors, recursiveAnchors)); | ||
} else { | ||
@@ -137,6 +148,6 @@ return subject; | ||
// Schema Retrieval | ||
const nil = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchor: false }); | ||
const nil = Object.freeze({ id: "", schemaVersion: undefined, pointer: "", schema: undefined, recursiveAnchors: {} }); | ||
const get = async (url, contextDoc = nil, recursive = false) => { | ||
const contextUrl = recursive && contextDoc.recursiveAnchor ? contextDoc.recursiveAnchor : uri(contextDoc); | ||
const contextUrl = recursive && contextDoc.recursiveAnchors[url] ? contextDoc.recursiveAnchors[url] : uri(contextDoc); | ||
const resolvedUrl = safeResolveUrl(contextUrl, url); | ||
@@ -169,3 +180,3 @@ const [id, fragment] = splitUrl(resolvedUrl); | ||
schema: storedSchema.schema, | ||
recursiveAnchor: contextDoc.recursiveAnchor || (storedSchema.recursiveAnchor ? id : false), | ||
recursiveAnchors: { ...storedSchema.recursiveAnchors, ...contextDoc.recursiveAnchors }, | ||
validated: storedSchema.validated | ||
@@ -172,0 +183,0 @@ }); |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.10.2", | ||
"version": "0.11.0", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -444,5 +444,6 @@ # Hyperjump - JSON Schema Core | ||
* **$anchor**: *(draft-2019-09)* Same as same-document reference draft 2019-09 | ||
`$id`s. | ||
* **$anchor**: *(draft-2019-09)* Same-document reference. | ||
* **$recursiveAnchor**: *(draft-2019-09)* Dynamic scope same-document reference. | ||
In draft-2019-09, `$id` was redefined from being a resolution scope modifier to | ||
@@ -449,0 +450,0 @@ being an inlined reference. This means that JSON Pointers can not cross into |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1507498
8881
600