@hyperjump/json-schema-core
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -1197,2 +1197,4 @@ define(['exports'], function (exports) { 'use strict'; | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1533,6 +1535,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1539,0 +1546,0 @@ }; |
@@ -6,3 +6,3 @@ define(["exports"],(function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],u=o?s:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function u(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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,a,i=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||i(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],l=!0)}return l}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports),a=(o.PubSub,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),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}});function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const u={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=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)]},f=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>u[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=a(e,t),n=l(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||S(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(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 E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(S(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},S=e=>null===e||"object"!=typeof e;var j={nil:"",append:m,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};const $=Symbol("$__value"),P=Symbol("$__href");var A=(e,t)=>Object.freeze({[P]:e,[$]:t}),x=e=>e&&void 0!==e[P],T=e=>e[P],I=e=>e[$];const{jsonTypeOf:k}=d,V=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),U=e=>x(e.value)?I(e.value):e.value,z=t(((e,t)=>k(U(e),t))),K=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:U(t)[e]}),L=t(((e,t)=>U(t).map(((r,n,o,a)=>e(K(n,t),n,o,a))))),C=t(((e,t)=>U(t).map(((e,r,n,o)=>K(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),R=t(((e,t,r)=>U(r).reduce(((t,n,o)=>e(t,K(o,r),o)),t))),q=t(((e,t)=>U(t).every(((r,n,o,a)=>e(K(n,t),n,o,a))))),_=t(((e,t)=>U(t).some(((r,n,o,a)=>e(K(n,t),n,o,a)))));var D={cons:(e,t="")=>Object.freeze({...V,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:U,has:(e,t)=>e in U(t),typeOf:z,step:K,entries:e=>Object.keys(U(e)).map((t=>[t,K(t,e)])),keys:e=>Object.keys(U(e)),map:L,filter:C,reduce:R,every:q,some:_,length:e=>U(e).length},N=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,B=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Z=/\\([\u000b\u0020-\u00ff])/g,M=/([\\"])/g,W=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function J(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(M,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+J(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(!W.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),A(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return A(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],be=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=be)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?me(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:me,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Pe;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Le=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Ce(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],_e=e=>e in Re,De={},Ne={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Le({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Me={validate:async(e,t,r)=>{const n=await Ke(e),o=(e,t=Te)=>Le(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:Ke,interpret:Le,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>$e.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Me.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Me.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Me.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Me.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Me.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={Core:Me,Schema:$e,Instance:D,Keywords:{metaData:We,validate:Je}},He=Ge.Core,Qe=Ge.Schema,Xe=Ge.Instance,Ye=Ge.Keywords;e.Core=He,e.Instance=Xe,e.Keywords=Ye,e.Schema=Qe,e.default=Ge,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function J(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(M,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+J(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(!W.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};return de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},de[c]},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),A(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return A(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],be=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=be)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?me(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:me,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Pe;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ke=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Le=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Ce(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Ce=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],_e=e=>e in Re,De={},Ne={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Le({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Me={validate:async(e,t,r)=>{const n=await Ke(e),o=(e,t=Te)=>Le(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:Ke,interpret:Le,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const{id:n}=$e.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>$e.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Me.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Me.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Me.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Me.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Me.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={Core:Me,Schema:$e,Instance:D,Keywords:{metaData:We,validate:Je}},He=Ge.Core,Qe=Ge.Schema,Xe=Ge.Instance,Ye=Ge.Keywords;e.Core=He,e.Instance=Xe,e.Keywords=Ye,e.Schema=Qe,e.default=Ge,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-amd.min.js.map |
@@ -1199,2 +1199,4 @@ 'use strict'; | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1535,6 +1537,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1541,0 +1548,0 @@ }; |
@@ -6,3 +6,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=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)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],u=o?s:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function u(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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,a,i=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||i(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],l=!0)}return l}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports),o=(n.PubSub,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),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}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(s.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)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}});function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=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)]},l=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=o(e,t),n=u(e)[0];if(n&&"file"===l(r)&&"file"!==l(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=e(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var S={nil:"",append:b,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=d(t),a=e(((e,t)=>p(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=d(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};const j=Symbol("$__value"),x=Symbol("$__href");var $=(e,t)=>Object.freeze({[x]:e,[j]:t}),P=e=>e&&void 0!==e[x],A=e=>e[x],T=e=>e[j];const{jsonTypeOf:I}=f,k=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),V=e=>P(e.value)?T(e.value):e.value,U=e(((e,t)=>I(V(e),t))),z=(e,t)=>Object.freeze({...t,pointer:S.append(e,t.pointer),value:V(t)[e]}),K=e(((e,t)=>V(t).map(((r,n,o,a)=>e(z(n,t),n,o,a))))),L=e(((e,t)=>V(t).map(((e,r,n,o)=>z(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=e(((e,t,r)=>V(r).reduce(((t,n,o)=>e(t,z(o,r),o)),t))),R=e(((e,t)=>V(t).every(((r,n,o,a)=>e(z(n,t),n,o,a))))),q=e(((e,t)=>V(t).some(((r,n,o,a)=>e(z(n,t),n,o,a)))));var _={cons:(e,t="")=>Object.freeze({...k,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:V,has:(e,t)=>e in V(t),typeOf:U,step:z,entries:e=>Object.keys(V(e)).map((t=>[t,z(t,e)])),keys:e=>Object.keys(V(e)),map:K,filter:L,reduce:C,every:R,some:q,length:e=>V(e).length},D=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,N=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,F=/\\([\u000b\u0020-\u00ff])/g,Z=/([\\"])/g,M=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!M.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(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(!M.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(D.lastIndex=r;i=D.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(F,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=e((async(e,t)=>(await t).map(e))),X=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=e((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ae,splitUrl:ie,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=ie(t)[0];if(!i&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(i,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(de[i]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ae(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},he=(e,t,r,n,o,a)=>{if(ae(e,"object")){const i="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),$(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return $(e[d],e);for(let i in e)e[i]=he(e[i],t,r,S.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>he(e,t,r,S.append(i,n),o,a))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ie(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const a=ye(n),i="/"!==o[0]?we(a,o):o,s=Object.freeze({...a,pointer:i,value:S.get(i,a.schema)});return me(s)},me=e=>P(e.value)?be(A(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>P(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return me(n)},Se=e(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:be,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ae(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class xe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=xe;const{splitUrl:Pe}=f,Ae="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ke=e((({ast:e,schemaUri:t},r,o=Ae)=>{if(![Ae,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=n.subscribe("result",Le(o,a));return Be(t,r,e,{}),n.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Ae&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Re=e=>Ce[e],qe=e=>e in Ce,_e={},De={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in De)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);De[t.id]=Ke({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),a=Pe(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Ae)=>Ke(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ke,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Ae,BASIC:Te,DETAILED:Ie,VERBOSE:ke,getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>je.value(e),interpret:()=>!0};var We={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Je={Core:Ze,Schema:je,Instance:_,Keywords:{metaData:Me,validate:We}},Ge=Je.Core,He=Je.Schema,Qe=Je.Instance,Xe=Je.Keywords;exports.Core=Ge,exports.Instance=Qe,exports.Keywords=Xe,exports.Schema=He,exports.default=Je; | ||
*/function W(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function J(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!M.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(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(!M.test(n))throw new TypeError("invalid media type");var o=new J(n.toLowerCase());if(-1!==r){var a,i,s;for(D.lastIndex=r;i=D.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(F,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=e((async(e,t)=>(await t).map(e))),X=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=e((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ae,splitUrl:ie,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=ie(t)[0];if(!i&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(i,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(de[i]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ae(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};return fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},fe[c]},he=(e,t,r,n,o,a)=>{if(ae(e,"object")){const i="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),$(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return $(e[d],e);for(let i in e)e[i]=he(e[i],t,r,S.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>he(e,t,r,S.append(i,n),o,a))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ie(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const a=ye(n),i="/"!==o[0]?we(a,o):o,s=Object.freeze({...a,pointer:i,value:S.get(i,a.schema)});return me(s)},me=e=>P(e.value)?be(A(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>P(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return me(n)},Se=e(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:be,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ae(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class xe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var $e=xe;const{splitUrl:Pe}=f,Ae="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ke=e((({ast:e,schemaUri:t},r,o=Ae)=>{if(![Ae,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=n.subscribe("result",Le(o,a));return Be(t,r,e,{}),n.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Ae&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Re=e=>Ce[e],qe=e=>e in Ce,_e={},De={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in De)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);De[t.id]=Ke({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new $e(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),a=Pe(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Ae)=>Ke(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ke,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Ae,BASIC:Te,DETAILED:Ie,VERBOSE:ke,add:(e,t="",r="")=>{const{id:n}=je.add(e,t,r);delete De[n]},getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>je.value(e),interpret:()=>!0};var We={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Je={Core:Ze,Schema:je,Instance:_,Keywords:{metaData:Me,validate:We}},Ge=Je.Core,He=Je.Schema,Qe=Je.Instance,Xe=Je.Keywords;exports.Core=Ge,exports.Instance=Qe,exports.Keywords=Xe,exports.Schema=He,exports.default=Je; | ||
//# sourceMappingURL=json-schema-core-cjs.min.js.map |
@@ -1195,2 +1195,4 @@ var justCurryIt = curry; | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1531,6 +1533,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1537,0 +1544,0 @@ }; |
@@ -6,3 +6,3 @@ var e=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)))}}};var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n=(function(e,r){var n;n={},("object"==typeof window&&window||t).PubSub=n,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],u=o?s:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function u(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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,a,i=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||i(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],l=!0)}return l}e.clearSubscriptions(r)}}(n),void 0!==e&&e.exports&&(r=e.exports=n),r.PubSub=n,e.exports=r=n}(r={exports:{}},r.exports),r.exports),o=(n.PubSub,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),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}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(s.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)?a(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+i(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,s=r.path,c=r.host;return 0===e.length?a=s:(s=s.substring(0,s.lastIndexOf("/")),a=i(s+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:a(e)}});function a(e){return e+("/"===e[e.length-1]?"":"/")}function i(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=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)]},l=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=o(e,t),n=u(e)[0];if(n&&"file"===l(r)&&"file"!==l(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,O(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,m(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,m(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},m=e(((e,t)=>t+"/"+b(e))),b=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var S={nil:"",append:m,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(t,r,n)=>{const o=d(t),a=e(((e,t)=>p(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(t,r,n)=>{const o=d(t),a=e(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=d(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};const j=Symbol("$__value"),$=Symbol("$__href");var x=(e,t)=>Object.freeze({[$]:e,[j]:t}),A=e=>e&&void 0!==e[$],P=e=>e[$],T=e=>e[j];const{jsonTypeOf:I}=f,k=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),V=e=>A(e.value)?T(e.value):e.value,U=e(((e,t)=>I(V(e),t))),z=(e,t)=>Object.freeze({...t,pointer:S.append(e,t.pointer),value:V(t)[e]}),K=e(((e,t)=>V(t).map(((r,n,o,a)=>e(z(n,t),n,o,a))))),L=e(((e,t)=>V(t).map(((e,r,n,o)=>z(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),C=e(((e,t,r)=>V(r).reduce(((t,n,o)=>e(t,z(o,r),o)),t))),R=e(((e,t)=>V(t).every(((r,n,o,a)=>e(z(n,t),n,o,a))))),q=e(((e,t)=>V(t).some(((r,n,o,a)=>e(z(n,t),n,o,a)))));var D={cons:(e,t="")=>Object.freeze({...k,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:V,has:(e,t)=>e in V(t),typeOf:U,step:z,entries:e=>Object.keys(V(e)).map((t=>[t,z(t,e)])),keys:e=>Object.keys(V(e)),map:K,filter:L,reduce:C,every:R,some:q,length:e=>V(e).length},_=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,N=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,F=/\\([\u000b\u0020-\u00ff])/g,Z=/([\\"])/g,W=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function J(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function M(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+J(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(!W.test(n))throw new TypeError("invalid media type");var o=new M(n.toLowerCase());if(-1!==r){var a,i,s;for(_.lastIndex=r;i=_.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(F,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=e((async(e,t)=>(await t).map(e))),X=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=e((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ae,splitUrl:ie,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=ie(t)[0];if(!i&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(i,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(de[i]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ae(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},he=(e,t,r,n,o,a)=>{if(ae(e,"object")){const i="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),x(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x(e[d],e);for(let i in e)e[i]=he(e[i],t,r,S.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>he(e,t,r,S.append(i,n),o,a))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ie(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const a=ye(n),i="/"!==o[0]?we(a,o):o,s=Object.freeze({...a,pointer:i,value:S.get(i,a.schema)});return be(s)},be=e=>A(e.value)?me(P(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>A(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return be(n)},Se=e(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:me,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ae(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=$e;const{splitUrl:Ae}=f,Pe="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ke=e((({ast:e,schemaUri:t},r,o=Pe)=>{if(![Pe,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=n.subscribe("result",Le(o,a));return Be(t,r,e,{}),n.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Re=e=>Ce[e],qe=e=>e in Ce,De={},_e={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in _e)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);_e[t.id]=Ke({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=_e[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),a=Ae(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Pe)=>Ke(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ke,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Pe,BASIC:Te,DETAILED:Ie,VERBOSE:ke,getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>je.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={Core:Ze,Schema:je,Instance:D,Keywords:{metaData:We,validate:Je}},Ge=Me.Core,He=Me.Schema,Qe=Me.Instance,Xe=Me.Keywords;export default Me;export{Ge as Core,Qe as Instance,Xe as Keywords,He as Schema}; | ||
*/function J(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function M(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+J(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(!W.test(n))throw new TypeError("invalid media type");var o=new M(n.toLowerCase());if(-1!==r){var a,i,s;for(_.lastIndex=r;i=_.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(F,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=e((async(e,t)=>(await t).map(e))),X=e((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=e((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=e((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=e(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ae,splitUrl:ie,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ie(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),a=le(n,"anchorToken"),i=ie(t)[0];if(!i&&!ie(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(i,e[o]||""),[c,u]=ie(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(de[i]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=le(n,"vocabularyToken");ae(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};return fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},fe[c]},he=(e,t,r,n,o,a)=>{if(ae(e,"object")){const i="string"==typeof e.$schema?ie(e.$schema)[0]:r,s=le(i,"embeddedToken"),c=le(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),x(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x(e[d],e);for(let i in e)e[i]=he(e[i],t,r,S.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>he(e,t,r,S.append(i,n),o,a))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ie(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const a=ye(n),i="/"!==o[0]?we(a,o):o,s=Object.freeze({...a,pointer:i,value:S.get(i,a.schema)});return be(s)},be=e=>A(e.value)?me(P(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>A(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return be(n)},Se=e(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:me,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ae(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=$e;const{splitUrl:Ae}=f,Pe="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ke=e((({ast:e,schemaUri:t},r,o=Pe)=>{if(![Pe,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let a=[];const i=n.subscribe("result",Le(o,a));return Be(t,r,e,{}),n.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Pe&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Ce={},Re=e=>Ce[e],qe=e=>e in Ce,De={},_e={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Ce[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in _e)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);_e[t.id]=Ke({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=_e[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),a=Ae(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Pe)=>Ke(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ke,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Pe,BASIC:Te,DETAILED:Ie,VERBOSE:ke,add:(e,t="",r="")=>{const{id:n}=je.add(e,t,r);delete _e[n]},getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Fe(e,r);return Re(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>je.value(e),interpret:()=>!0};var Je={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[a,i,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(i,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Ze.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Me={Core:Ze,Schema:je,Instance:D,Keywords:{metaData:We,validate:Je}},Ge=Me.Core,He=Me.Schema,Qe=Me.Instance,Xe=Me.Keywords;export default Me;export{Ge as Core,Qe as Instance,Xe as Keywords,He as Schema}; | ||
//# sourceMappingURL=json-schema-core-esm.min.js.map |
@@ -1198,2 +1198,4 @@ var JSC = (function (exports) { | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1534,6 +1536,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1540,0 +1547,0 @@ }; |
@@ -6,3 +6,3 @@ var JSC=function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],u=o?s:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function u(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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,a,i=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||i(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],l=!0)}return l}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports),a=(o.PubSub,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),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}});function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const u={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=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)]},f=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>u[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=a(e,t),n=l(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,m(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||S(t)){const o=e.shift();y(e,E(t,o,n),r,m(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,m(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 E(t,e[0],r)}},b=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);b(e,o,m(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},m=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(S(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},S=e=>null===e||"object"!=typeof e;var j={nil:"",append:m,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),m(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=p(e),n=e=>b(r,e,"");return void 0===t?n:n(t)}};const $=Symbol("$__value"),P=Symbol("$__href");var A=(e,t)=>Object.freeze({[P]:e,[$]:t}),x=e=>e&&void 0!==e[P],T=e=>e[P],I=e=>e[$];const{jsonTypeOf:k}=d,V=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),U=e=>x(e.value)?I(e.value):e.value,z=t(((e,t)=>k(U(e),t))),C=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:U(t)[e]}),K=t(((e,t)=>U(t).map(((r,n,o,a)=>e(C(n,t),n,o,a))))),L=t(((e,t)=>U(t).map(((e,r,n,o)=>C(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),R=t(((e,t,r)=>U(r).reduce(((t,n,o)=>e(t,C(o,r),o)),t))),q=t(((e,t)=>U(t).every(((r,n,o,a)=>e(C(n,t),n,o,a))))),_=t(((e,t)=>U(t).some(((r,n,o,a)=>e(C(n,t),n,o,a)))));var D={cons:(e,t="")=>Object.freeze({...V,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:U,has:(e,t)=>e in U(t),typeOf:z,step:C,entries:e=>Object.keys(U(e)).map((t=>[t,C(t,e)])),keys:e=>Object.keys(U(e)),map:K,filter:L,reduce:R,every:q,some:_,length:e=>U(e).length},N=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,B=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Z=/\\([\u000b\u0020-\u00ff])/g,J=/([\\"])/g,M=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function W(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!M.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(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(!M.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),A(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return A(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],be=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=be)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?me(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:me,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Pe;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Ke=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Le(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],_e=e=>e in Re,De={},Ne={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Ke({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Je={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t=Te)=>Ke(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ke,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>$e.value(e),interpret:()=>!0};var We={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Je.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Je.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Je.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Je.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Je.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={Core:Je,Schema:$e,Instance:D,Keywords:{metaData:Me,validate:We}},He=Ge.Core,Qe=Ge.Schema,Xe=Ge.Instance,Ye=Ge.Keywords;return e.Core=He,e.Instance=Xe,e.Keywords=Ye,e.Schema=Qe,e.default=Ge,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
*/function W(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!M.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+W(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(!M.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};return de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},de[c]},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),A(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return A(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],be=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),me=async(e,t=be)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?me(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:me,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Pe extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Ae=Pe;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Ke=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Le(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],_e=e=>e in Re,De={},Ne={},Be=async(e,t)=>{if(!_e(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 De)Object.entries(De[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Ke({ast:r,schemaUri:n})}const t=D.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Ae(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Je={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t=Te)=>Ke(n,D.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ke,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const{id:n}=$e.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:_e,defineVocabulary:(e,t)=>{De[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var Me={compile:e=>$e.value(e),interpret:()=>!0};var We={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Je.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Je.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Je.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:D.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:D.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Je.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Je.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge={Core:Je,Schema:$e,Instance:D,Keywords:{metaData:Me,validate:We}},He=Ge.Core,Qe=Ge.Schema,Xe=Ge.Instance,Ye=Ge.Keywords;return e.Core=He,e.Instance=Xe,e.Keywords=Ye,e.Schema=Qe,e.default=Ge,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
//# sourceMappingURL=json-schema-core-iife.min.js.map |
@@ -1200,2 +1200,4 @@ System.register('JSC', [], function (exports) { | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1536,6 +1538,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1542,0 +1549,0 @@ }; |
@@ -6,3 +6,3 @@ System.register("JSC",[],(function(e){"use strict";return{execute:function(){var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n,o=(function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function a(e){return function(){throw e}}function i(e,t,r){try{e(t,r)}catch(e){setTimeout(a(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var a,c=t[r],u=o?s:i;if(t.hasOwnProperty(r))for(a in c)c.hasOwnProperty(a)&&u(c[a],e,n)}function u(e,t,r){return function(){var o=String(e),a=o.lastIndexOf(".");for(c(e,e,t,r);-1!==a;)a=(o=o.substr(0,a)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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,a,i=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||i(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(a in o)o.hasOwnProperty(a)&&o[a]===r&&(delete o[a],l=!0)}return l}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o}(n={exports:{}},n.exports),n.exports),a=(o.PubSub,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),a=e.indexOf("?"),i=e.indexOf("#");-1!==i&&(r=r.substring(0,i));if(-1!==a){const e=r.substring(a);t.query=e,r=r.substring(0,a)}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(c.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+s(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let a,i=r.path,c=r.host;return 0===e.length?a=i:(i=i.substring(0,i.lastIndexOf("/")),a=s(i+"/"+e)),c+=""!==a||t||o?a+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}});function i(e){return e+("/"===e[e.length-1]?"":"/")}function s(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 c=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const u={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},l=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)]},f=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var d={jsonTypeOf:(e,t)=>u[t](e),splitUrl:l,safeResolveUrl:(e,t)=>{const r=a(e,t),n=l(e)[0];if(n&&"file"===f(r)&&"file"!==f(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const p=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(g)},h=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:h(e,E(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[O(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:E(t,e[0],n)},y=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||S(t)){const o=e.shift();y(e,E(t,o,n),r,b(o,n))}else{t[O(t,e[0])]=r}},v=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=E(t,n,r);return{...t,[n]:v(e,o,b(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 E(t,e[0],r)}},m=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=E(t,n,r);m(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:E(t,e[0],r)},b=t(((e,t)=>t+"/"+w(e))),w=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),g=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),O=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,E=(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(S(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[O(e,t)]},S=e=>null===e||"object"!=typeof e;var j={nil:"",append:b,get:(e,t)=>{const r=p(e),n=e=>r.reduce((([e,t],r)=>[E(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=p(e),a=t(((e,t)=>h(o,e,t,"")));return void 0===r?a:a(r,n)},assign:(e,r,n)=>{const o=p(e),a=t(((e,t)=>y(o,e,t,"")));return void 0===r?a:a(r,n)},unset:(e,t)=>{const r=p(e),n=e=>v(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=p(e),n=e=>m(r,e,"");return void 0===t?n:n(t)}};const $=Symbol("$__value"),A=Symbol("$__href");var P=(e,t)=>Object.freeze({[A]:e,[$]:t}),x=e=>e&&void 0!==e[A],T=e=>e[A],I=e=>e[$];const{jsonTypeOf:k}=d,V=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),U=e=>x(e.value)?I(e.value):e.value,z=t(((e,t)=>k(U(e),t))),C=(e,t)=>Object.freeze({...t,pointer:j.append(e,t.pointer),value:U(t)[e]}),K=t(((e,t)=>U(t).map(((r,n,o,a)=>e(C(n,t),n,o,a))))),L=t(((e,t)=>U(t).map(((e,r,n,o)=>C(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),R=t(((e,t,r)=>U(r).reduce(((t,n,o)=>e(t,C(o,r),o)),t))),q=t(((e,t)=>U(t).every(((r,n,o,a)=>e(C(n,t),n,o,a))))),D=t(((e,t)=>U(t).some(((r,n,o,a)=>e(C(n,t),n,o,a)))));var _={cons:(e,t="")=>Object.freeze({...V,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:U,has:(e,t)=>e in U(t),typeOf:z,step:C,entries:e=>Object.keys(U(e)).map((t=>[t,C(t,e)])),keys:e=>Object.keys(U(e)),map:K,filter:L,reduce:R,every:q,some:D,length:e=>U(e).length},N=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,B=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,F=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,Z=/\\([\u000b\u0020-\u00ff])/g,J=/([\\"])/g,W=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function M(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+M(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(!W.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),P(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return P(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],me=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=me)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?be(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:be,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Ae;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Ke=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Le(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],De=e=>e in Re,_e={},Ne={},Be=async(e,t)=>{if(!De(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Ke({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Pe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Je={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t=Te)=>Ke(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ke,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,getKeyword:qe,hasKeyword:De,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>$e.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Je.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Je.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Je.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Je.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Je.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge=e("default",{Core:Je,Schema:$e,Instance:_,Keywords:{metaData:We,validate:Me}});e("Core",Ge.Core),e("Schema",Ge.Schema),e("Instance",Ge.Instance),e("Keywords",Ge.Keywords)}}})); | ||
*/function M(e){var t=String(e);if(F.test(t))return t;if(t.length>0&&!B.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(J,"\\$1")+'"'}function G(e){this.parameters=Object.create(null),this.type=e}var H={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!W.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var o,a=Object.keys(t).sort(),i=0;i<a.length;i++){if(o=a[i],!F.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+M(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(!W.test(n))throw new TypeError("invalid media type");var o=new G(n.toLowerCase());if(-1!==r){var a,i,s;for(N.lastIndex=r;i=N.exec(t);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,a=i[1].toLowerCase(),'"'===(s=i[2])[0]&&(s=s.substr(1,s.length-2).replace(Z,"$1")),o.parameters[a]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},Q=async e=>Object.entries(await e),X=t((async(e,t)=>(await t).map(e))),Y=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),ee=t((async(e,t,r={})=>Y((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),te=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).some((e=>e))})),re=t((async(e,t)=>{const r=await X(e,t);return(await Promise.all(r)).every((e=>e))})),ne=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),oe={entries:Q,map:X,filter:ee,reduce:Y,some:te,every:re,pipeline:ne,all:e=>Promise.all(e),allValues:e=>ne([Q,Y((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},ae=fetch;const{jsonTypeOf:ie,splitUrl:se,safeResolveUrl:ce}=d,ue={},le={},fe=(e,t)=>{const r=e in le?le[e]:e;if(r in ue)return ue[r][t]},de={},pe={},he=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=se(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=fe(n,"baseToken"),a=fe(n,"anchorToken"),i=se(t)[0];if(!i&&!se(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=ce(i,e[o]||""),[c,u]=se(s);delete e[o],u&&o===a&&(e[a]=a!==o?encodeURI(u):"#"+encodeURI(u)),i&&(pe[i]=c);const l={},f=fe(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[a]="",delete e[f]);const p=fe(n,"vocabularyToken");ie(e[p],"object")?(le[c]=n,d=e[p],delete e[p]):(le[c]=n,d={[n]:!0});const h={"":""};return de[c]={id:c,schemaVersion:n,schema:ye(e,c,n,j.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},de[c]},ye=(e,t,r,n,o,a)=>{if(ie(e,"object")){const i="string"==typeof e.$schema?se(e.$schema)[0]:r,s=fe(i,"embeddedToken"),c=fe(i,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=ce(t,e[s]);return e[s]=n,he(e,n,r),P(e[s],e)}const u=fe(r,"anchorToken"),l=fe(r,"dynamicAnchorToken");"string"==typeof e[l]&&(a[e[l]]=t,e[u]=e[l],delete e[l]);const f=fe(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=fe(r,"jrefToken");if("string"==typeof e[d])return P(e[d],e);for(let i in e)e[i]=ye(e[i],t,r,j.append(i,n),o,a);return e}return Array.isArray(e)?e.map(((e,i)=>ye(e,t,r,j.append(i,n),o,a))):e},ve=e=>de[pe[e]]||de[e],me=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:j.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=me)=>{const r=ce(Oe(t),e),[n,o]=se(r);if(!(e=>e in de||e in pe)(n)){const e=await ae(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=H.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}he(await e.json(),n)}const a=ve(n),i="/"!==o[0]?ge(a,o):o,s=Object.freeze({...a,pointer:i,value:j.get(i,a.schema)});return we(s)},we=e=>x(e.value)?be(T(e.value),e):e,ge=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},Oe=e=>`${e.id}#${encodeURI(e.pointer)}`,Ee=e=>x(e.value)?I(e.value):e.value,Se=(e,t)=>{const r=ve(t.id),n=Object.freeze({...t,pointer:j.append(e,t.pointer),value:Ee(t)[e],validated:r.validated});return we(n)},je=t(((e,t)=>oe.pipeline([Ee,oe.map((async(r,n)=>e(await Se(n,t),n))),oe.all],t)));var $e={setConfig:(e,t,r)=>{ue[e]||(ue[e]={}),ue[e][t]=r},getConfig:fe,add:he,get:be,markValidated:e=>{de[e].validated=!0},uri:Oe,value:Ee,getAnchorPointer:ge,typeOf:(e,t)=>ie(Ee(e),t),has:(e,t)=>e in Ee(t),step:Se,keys:e=>Object.keys(Ee(e)),entries:e=>oe.pipeline([Ee,Object.keys,oe.map((async t=>[t,await Se(t,e)])),oe.all],e),map:je,length:e=>Ee(e).length};class Ae extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var Pe=Ae;const{splitUrl:xe}=d,Te="FLAG",Ie="BASIC",ke="DETAILED",Ve="VERBOSE";let Ue=ke,ze=!0;const Ce=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Be(e,t)}},Ke=t((({ast:e,schemaUri:t},r,n=Te)=>{if(![Te,Ie,ke,Ve].includes(n))throw Error(`The '${n}' error format is not supported`);let a=[];const i=o.subscribe("result",Le(n,a));return Fe(t,r,e,{}),o.unsubscribe(i),a[0]})),Le=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a}=o,i={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:a,errors:[]};r.push(i)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Ie&&(o.push(...t.errors),delete t.errors),(e===Ve||e!==Te&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Re={},qe=e=>Re[e],De=e=>e in Re,_e={},Ne={},Be=async(e,t)=>{if(!De(e.schemaVersion+"#validate")){const t=await $e.get(e.schemaVersion);($e.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Re[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(ze&&!e.validated){if($e.markValidated(e.id),!(e.schemaVersion in Ne)){const t=await $e.get(e.schemaVersion),r={metaData:{}},n=await Be(t,r);Ne[t.id]=Ke({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=Ne[e.schemaVersion](t,Ue);if(!r.valid)throw new Pe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await qe(e.schemaVersion+"#validate").compile(e,t),$e.uri(e)},Fe=(e,t,r,n)=>{const o=Ze(e,r),a=xe(e)[0];return qe(o).interpret(e,t,r,{...r.metaData[a].dynamicAnchors,...n})},Ze=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Je={validate:async(e,t,r)=>{const n=await Ce(e),o=(e,t=Te)=>Ke(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:Ce,interpret:Ke,setMetaOutputFormat:e=>{Ue=e},setShouldMetaValidate:e=>{ze=e},FLAG:Te,BASIC:Ie,DETAILED:ke,VERBOSE:Ve,add:(e,t="",r="")=>{const{id:n}=$e.add(e,t,r);delete Ne[n]},getKeyword:qe,hasKeyword:De,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Be,interpretSchema:Fe,collectEvaluatedProperties:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const a=Ze(e,r);return qe(a).collectEvaluatedItems(e,t,r,n,o)}};var We={compile:e=>$e.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=$e.uri(e);if(!(r in t)){t[r]=!1;const n=$e.value(e);t[r]=[e.schemaVersion+"#validate",$e.uri(e),"boolean"==typeof n?n:await oe.pipeline([$e.entries,oe.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),oe.filter((([t])=>Je.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),oe.map((async([r,n])=>{const o=await Je.getKeyword(r).compile(n,t,e);return[r,$e.uri(n),o]})),oe.all],e)]}return r},interpret:(e,t,r,n)=>{const[a,i,s]=r[e];o.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,a,i])=>{o.publishSync("result.start");const s=Je.getKeyword(e).interpret(i,t,r,n);return o.publishSync("result",{keyword:e,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:s,ast:i}),o.publishSync("result.end"),s}));return o.publishSync("result",{keyword:a,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:c,ast:e}),o.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&[]:a.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,a])=>{const i=e&&Je.getKeyword(o).collectEvaluatedProperties(a,t,r,n);return!1!==i&&[...e,...i]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const a=r[e][2];return"boolean"==typeof a?!!a&&new Set:a.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,a])=>{const i=!1!==e&&Je.getKeyword(o).collectEvaluatedItems(a,t,r,n);return!1!==i&&new Set([...e,...i])}),new Set)}},Ge=e("default",{Core:Je,Schema:$e,Instance:_,Keywords:{metaData:We,validate:Me}});e("Core",Ge.Core),e("Schema",Ge.Schema),e("Instance",Ge.Instance),e("Keywords",Ge.Keywords)}}})); | ||
//# sourceMappingURL=json-schema-core-system.min.js.map |
@@ -1201,2 +1201,4 @@ (function (global, factory) { | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -1537,6 +1539,11 @@ | ||
const add$1 = (schema$1, url = "", defaultSchemaVersion = "") => { | ||
const { id } = schema.add(schema$1, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
var core = { | ||
validate, compile: compile$1, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add: add$1, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
@@ -1543,0 +1550,0 @@ }; |
@@ -6,3 +6,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JSC={})}(this,(function(e){"use strict";var t=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)))}}};var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){var n,o;n="object"==typeof window&&window||r,o={},n.PubSub=o,function(e){var t={},r=-1,n="*";function o(e){var t;for(t in e)if(e.hasOwnProperty(t))return!0;return!1}function i(e){return function(){throw e}}function a(e,t,r){try{e(t,r)}catch(e){setTimeout(i(e),0)}}function s(e,t,r){e(t,r)}function c(e,r,n,o){var i,c=t[r],u=o?s:a;if(t.hasOwnProperty(r))for(i in c)c.hasOwnProperty(i)&&u(c[i],e,n)}function u(e,t,r){return function(){var o=String(e),i=o.lastIndexOf(".");for(c(e,e,t,r);-1!==i;)i=(o=o.substr(0,i)).lastIndexOf("."),c(e,o,t,r);c(e,n,t,r)}}function l(e){var r=String(e);return Boolean(t.hasOwnProperty(r)&&o(t[r]))}function f(e){for(var t=String(e),r=l(t)||l(n),o=t.lastIndexOf(".");!r&&-1!==o;)o=(t=t.substr(0,o)).lastIndexOf("."),r=l(t);return r}function d(e,t,r,n){var o=u(e="symbol"==typeof e?e.toString():e,t,n);return!!f(e)&&(!0===r?o():setTimeout(o,0),!0)}e.publish=function(t,r){return d(t,r,!1,e.immediateExceptions)},e.publishSync=function(t,r){return d(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.subscribeAll=function(t){return e.subscribe(n,t)},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=function(e){var r;for(r in t)if(t.hasOwnProperty(r)&&0===r.indexOf(e))return!0;return!1},s="string"==typeof r&&(t.hasOwnProperty(r)||a(r)),c=!s&&"string"==typeof r,u="function"==typeof r,l=!1;if(!s){for(n in t)if(t.hasOwnProperty(n)){if(o=t[n],c&&o[r]){delete o[r],l=r;break}if(u)for(i in o)o.hasOwnProperty(i)&&o[i]===r&&(delete o[i],l=!0)}return l}e.clearSubscriptions(r)}}(o),void 0!==e&&e.exports&&(t=e.exports=o),t.PubSub=o,e.exports=t=o})),o=(n.PubSub,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(s.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)?i(n.href):n.href;if(n.absolutePath){const{path:e,query:t,hash:o}=n;return r.host+a(e)+t+o}if(n.relativePath){const{path:e,query:t,hash:o}=n;let i,s=r.path,c=r.host;return 0===e.length?i=s:(s=s.substring(0,s.lastIndexOf("/")),i=a(s+"/"+e)),c+=""!==i||t||o?i+t+o:"/",c}{const{host:e,path:t,query:o}=r;return t||o?e+t+o+n.hash:i(e)}});function i(e){return e+("/"===e[e.length-1]?"":"/")}function a(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 s=new RegExp("^([a-z][a-z0-9+.-]*:)?//","i");const c={null:e=>null===e,boolean:e=>"boolean"==typeof e,object:e=>"object"==typeof e&&!Array.isArray(e)&&null!==e,array:e=>Array.isArray(e),number:e=>"number"==typeof e,integer:e=>Number.isInteger(e),string:e=>"string"==typeof e},u=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)]},l=e=>{const t=e.match(/^(.+):\/\//);return t?t[1]:""};var f={jsonTypeOf:(e,t)=>c[t](e),splitUrl:u,safeResolveUrl:(e,t)=>{const r=o(e,t),n=u(e)[0];if(n&&"file"===l(r)&&"file"!==l(n))throw Error(`Can't access file '${r}' resource from network context '${e}'`);return r}};const d=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(w)},p=(e,t,r,n)=>{if(0===e.length)return r;if(e.length>1){const o=e.shift();return{...t,[o]:p(e,O(t,o,n),r,b(o,n))}}if(Array.isArray(t)){const n=[...t];return n[g(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:O(t,e[0],n)},h=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||E(t)){const o=e.shift();h(e,O(t,o,n),r,b(o,n))}else{t[g(t,e[0])]=r}},y=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=O(t,n,r);return{...t,[n]:y(e,o,b(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 O(t,e[0],r)}},v=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=O(t,n,r);v(e,o,b(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:O(t,e[0],r)},b=t(((e,t)=>t+"/"+m(e))),m=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),w=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),g=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,O=(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(E(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[g(e,t)]},E=e=>null===e||"object"!=typeof e;var S={nil:"",append:b,get:(e,t)=>{const r=d(e),n=e=>r.reduce((([e,t],r)=>[O(e,r,t),b(r,t)]),[e,""])[0];return void 0===t?n:n(t)},set:(e,r,n)=>{const o=d(e),i=t(((e,t)=>p(o,e,t,"")));return void 0===r?i:i(r,n)},assign:(e,r,n)=>{const o=d(e),i=t(((e,t)=>h(o,e,t,"")));return void 0===r?i:i(r,n)},unset:(e,t)=>{const r=d(e),n=e=>y(r,e,"");return void 0===t?n:n(t)},delete:(e,t)=>{const r=d(e),n=e=>v(r,e,"");return void 0===t?n:n(t)}};const j=Symbol("$__value"),$=Symbol("$__href");var x=(e,t)=>Object.freeze({[$]:e,[j]:t}),P=e=>e&&void 0!==e[$],A=e=>e[$],T=e=>e[j];const{jsonTypeOf:I}=f,k=Object.freeze({id:"",pointer:"",instance:void 0,value:void 0}),V=e=>P(e.value)?T(e.value):e.value,U=t(((e,t)=>I(V(e),t))),z=(e,t)=>Object.freeze({...t,pointer:S.append(e,t.pointer),value:V(t)[e]}),C=t(((e,t)=>V(t).map(((r,n,o,i)=>e(z(n,t),n,o,i))))),K=t(((e,t)=>V(t).map(((e,r,n,o)=>z(r,t))).filter(((t,r,n,o)=>e(t,r,n,o))))),L=t(((e,t,r)=>V(r).reduce(((t,n,o)=>e(t,z(o,r),o)),t))),R=t(((e,t)=>V(t).every(((r,n,o,i)=>e(z(n,t),n,o,i))))),q=t(((e,t)=>V(t).some(((r,n,o,i)=>e(z(n,t),n,o,i)))));var _={cons:(e,t="")=>Object.freeze({...k,id:t,instance:e,value:e}),uri:e=>`${e.id}#${encodeURI(e.pointer)}`,value:V,has:(e,t)=>e in V(t),typeOf:U,step:z,entries:e=>Object.keys(V(e)).map((t=>[t,z(t,e)])),keys:e=>Object.keys(V(e)),map:C,filter:K,reduce:L,every:R,some:q,length:e=>V(e).length},D=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,N=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,B=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,F=/\\([\u000b\u0020-\u00ff])/g,Z=/([\\"])/g,J=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
* MIT Licensed | ||
*/function M(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!J.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],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+M(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(!J.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var i,a,s;for(D.lastIndex=r;a=D.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(F,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=t((async(e,t)=>(await t).map(e))),X=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=t((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=t((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=t((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ie,splitUrl:ae,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),i=le(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(de[a]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[i]="",delete e[f]);const p=le(n,"vocabularyToken");ie(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1}},he=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=le(a,"embeddedToken"),c=le(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),x(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x(e[d],e);for(let a in e)e[a]=he(e[a],t,r,S.append(a,n),o,i);return e}return Array.isArray(e)?e.map(((e,a)=>he(e,t,r,S.append(a,n),o,i))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ae(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const i=ye(n),a="/"!==o[0]?we(i,o):o,s=Object.freeze({...i,pointer:a,value:S.get(a,i.schema)});return me(s)},me=e=>P(e.value)?be(A(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>P(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return me(n)},Se=t(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:be,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ie(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=$e;const{splitUrl:Pe}=f,Ae="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ce=t((({ast:e,schemaUri:t},r,o=Ae)=>{if(![Ae,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=n.subscribe("result",Ke(o,i));return Be(t,r,e,{}),n.unsubscribe(a),i[0]})),Ke=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:i}=o,a={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:i,errors:[]};r.push(a)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Ae&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Le={},Re=e=>Le[e],qe=e=>e in Le,_e={},De={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Le[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in De)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);De[t.id]=Ce({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),i=Pe(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[i].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Ae)=>Ce(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ce,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Ae,BASIC:Te,DETAILED:Ie,VERBOSE:ke,getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const i=Fe(e,r);return Re(i).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const i=Fe(e,r);return Re(i).collectEvaluatedItems(e,t,r,n,o)}};var Je={compile:e=>je.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[i,a,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,i,a])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(a,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:s,ast:a}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:i,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const i=r[e][2];return"boolean"==typeof i?!!i&&[]:i.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,i])=>{const a=e&&Ze.getKeyword(o).collectEvaluatedProperties(i,t,r,n);return!1!==a&&[...e,...a]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const i=r[e][2];return"boolean"==typeof i?!!i&&new Set:i.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,i])=>{const a=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(i,t,r,n);return!1!==a&&new Set([...e,...a])}),new Set)}},We={Core:Ze,Schema:je,Instance:_,Keywords:{metaData:Je,validate:Me}},Ge=We.Core,He=We.Schema,Qe=We.Instance,Xe=We.Keywords;e.Core=Ge,e.Instance=Qe,e.Keywords=Xe,e.Schema=He,e.default=We,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
*/function M(e){var t=String(e);if(B.test(t))return t;if(t.length>0&&!N.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(Z,"\\$1")+'"'}function W(e){this.parameters=Object.create(null),this.type=e}var G={format:function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!J.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],!B.test(o))throw new TypeError("invalid parameter name");n+="; "+o+"="+M(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(!J.test(n))throw new TypeError("invalid media type");var o=new W(n.toLowerCase());if(-1!==r){var i,a,s;for(D.lastIndex=r;a=D.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(F,"$1")),o.parameters[i]=s}if(r!==t.length)throw new TypeError("invalid parameter format")}return o}},H=async e=>Object.entries(await e),Q=t((async(e,t)=>(await t).map(e))),X=t((async(e,t,r)=>(await r).reduce((async(t,r)=>e(await t,r)),t))),Y=t((async(e,t,r={})=>X((async(t,r)=>await e(r)?t.concat([r]):t),[],t,r))),ee=t((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).some((e=>e))})),te=t((async(e,t)=>{const r=await Q(e,t);return(await Promise.all(r)).every((e=>e))})),re=t(((e,t)=>e.reduce((async(e,t)=>t(await e)),t))),ne={entries:H,map:Q,filter:Y,reduce:X,some:ee,every:te,pipeline:re,all:e=>Promise.all(e),allValues:e=>re([H,X((async(e,[t,r])=>(e[t]=await r,e)),{})],e)},oe=fetch;const{jsonTypeOf:ie,splitUrl:ae,safeResolveUrl:se}=f,ce={},ue={},le=(e,t)=>{const r=e in ue?ue[e]:e;if(r in ce)return ce[r][t]},fe={},de={},pe=(e,t="",r="")=>{e=JSON.parse(JSON.stringify(e));const n=ae(e.$schema||r)[0];if(!n)throw Error("Couldn't determine schema version");delete e.$schema;const o=le(n,"baseToken"),i=le(n,"anchorToken"),a=ae(t)[0];if(!a&&!ae(e[o]||"")[0])throw Error("Couldn't determine an identifier for the schema");const s=se(a,e[o]||""),[c,u]=ae(s);delete e[o],u&&o===i&&(e[i]=i!==o?encodeURI(u):"#"+encodeURI(u)),a&&(de[a]=c);const l={},f=le(n,"recursiveAnchorToken");let d;!0===e[f]&&(l[""]=c,e[i]="",delete e[f]);const p=le(n,"vocabularyToken");ie(e[p],"object")?(ue[c]=n,d=e[p],delete e[p]):(ue[c]=n,d={[n]:!0});const h={"":""};return fe[c]={id:c,schemaVersion:n,schema:he(e,c,n,S.nil,h,l),anchors:h,dynamicAnchors:l,vocabulary:d,validated:!1},fe[c]},he=(e,t,r,n,o,i)=>{if(ie(e,"object")){const a="string"==typeof e.$schema?ae(e.$schema)[0]:r,s=le(a,"embeddedToken"),c=le(a,"anchorToken");if("string"==typeof e[s]&&(s!==c||"#"!==e[s][0])){const n=se(t,e[s]);return e[s]=n,pe(e,n,r),x(e[s],e)}const u=le(r,"anchorToken"),l=le(r,"dynamicAnchorToken");"string"==typeof e[l]&&(i[e[l]]=t,e[u]=e[l],delete e[l]);const f=le(r,"embeddedToken");if("string"==typeof e[u]){const t=u!==f?e[u]:e[u].slice(1);o[t]=n,delete e[u]}const d=le(r,"jrefToken");if("string"==typeof e[d])return x(e[d],e);for(let a in e)e[a]=he(e[a],t,r,S.append(a,n),o,i);return e}return Array.isArray(e)?e.map(((e,a)=>he(e,t,r,S.append(a,n),o,i))):e},ye=e=>fe[de[e]]||fe[e],ve=Object.freeze({id:"",schemaVersion:void 0,vocabulary:{},pointer:S.nil,schema:void 0,value:void 0,anchors:{},dynamicAnchors:{},validated:!0}),be=async(e,t=ve)=>{const r=se(ge(t),e),[n,o]=ae(r);if(!(e=>e in fe||e in de)(n)){const e=await oe(n,{headers:{Accept:"application/schema+json"}});if(e.status>=400)throw await e.text(),Error("Failed to retrieve schema with id: "+n);if(e.headers.has("content-type")){const t=G.parse(e.headers.get("content-type")).type;if("application/schema+json"!==t)throw Error(`${n} is not a schema. Found a document with media type: ${t}`)}pe(await e.json(),n)}const i=ye(n),a="/"!==o[0]?we(i,o):o,s=Object.freeze({...i,pointer:a,value:S.get(a,i.schema)});return me(s)},me=e=>P(e.value)?be(A(e.value),e):e,we=(e,t)=>{if(!(t in e.anchors))throw Error(`No such anchor '${encodeURI(e.id)}#${encodeURI(t)}'`);return e.anchors[t]},ge=e=>`${e.id}#${encodeURI(e.pointer)}`,Oe=e=>P(e.value)?T(e.value):e.value,Ee=(e,t)=>{const r=ye(t.id),n=Object.freeze({...t,pointer:S.append(e,t.pointer),value:Oe(t)[e],validated:r.validated});return me(n)},Se=t(((e,t)=>ne.pipeline([Oe,ne.map((async(r,n)=>e(await Ee(n,t),n))),ne.all],t)));var je={setConfig:(e,t,r)=>{ce[e]||(ce[e]={}),ce[e][t]=r},getConfig:le,add:pe,get:be,markValidated:e=>{fe[e].validated=!0},uri:ge,value:Oe,getAnchorPointer:we,typeOf:(e,t)=>ie(Oe(e),t),has:(e,t)=>e in Oe(t),step:Ee,keys:e=>Object.keys(Oe(e)),entries:e=>ne.pipeline([Oe,Object.keys,ne.map((async t=>[t,await Ee(t,e)])),ne.all],e),map:Se,length:e=>Oe(e).length};class $e extends Error{constructor(e){super("Invalid Schema"),this.name=this.constructor.name,this.output=e}}var xe=$e;const{splitUrl:Pe}=f,Ae="FLAG",Te="BASIC",Ie="DETAILED",ke="VERBOSE";let Ve=Ie,Ue=!0;const ze=async e=>{const t={metaData:{}};return{ast:t,schemaUri:await Ne(e,t)}},Ce=t((({ast:e,schemaUri:t},r,o=Ae)=>{if(![Ae,Te,Ie,ke].includes(o))throw Error(`The '${o}' error format is not supported`);let i=[];const a=n.subscribe("result",Ke(o,i));return Be(t,r,e,{}),n.unsubscribe(a),i[0]})),Ke=(e,t)=>{const r=[];return(n,o)=>{if("result"===n){const{keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:i}=o,a={keyword:e,absoluteKeywordLocation:t,instanceLocation:n,valid:i,errors:[]};r.push(a)}else if("result.start"===n)r.push(n);else if("result.end"===n){const n=r.pop();for(;"result.start"!==r[r.length-1];){const t=r.pop(),o=[t];e===Te&&(o.push(...t.errors),delete t.errors),(e===ke||e!==Ae&&!t.valid)&&n.errors.unshift(...o)}r[r.length-1]=n,t[0]=n}}},Le={},Re=e=>Le[e],qe=e=>e in Le,_e={},De={},Ne=async(e,t)=>{if(!qe(e.schemaVersion+"#validate")){const t=await je.get(e.schemaVersion);(je.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 _e)Object.entries(_e[e]).forEach((([e,r])=>{((e,t)=>{Le[e]={collectEvaluatedItems:(e,r,n)=>t.interpret(e,r,n)&&new Set,collectEvaluatedProperties:(e,r,n)=>t.interpret(e,r,n)&&[],...t}})(`${t.id}#${e}`,r)}));else if(r)throw Error("Missing required vocabulary: "+e)}))}if(Ue&&!e.validated){if(je.markValidated(e.id),!(e.schemaVersion in De)){const t=await je.get(e.schemaVersion),r={metaData:{}},n=await Ne(t,r);De[t.id]=Ce({ast:r,schemaUri:n})}const t=_.cons(e.schema,e.id),r=De[e.schemaVersion](t,Ve);if(!r.valid)throw new xe(r)}return e.id in t.metaData||(t.metaData[e.id]={id:e.id,dynamicAnchors:e.dynamicAnchors,anchors:e.anchors}),await Re(e.schemaVersion+"#validate").compile(e,t),je.uri(e)},Be=(e,t,r,n)=>{const o=Fe(e,r),i=Pe(e)[0];return Re(o).interpret(e,t,r,{...r.metaData[i].dynamicAnchors,...n})},Fe=(e,t)=>{if(!(e in t))throw Error("No schema found at "+e);return t[e][0]};var Ze={validate:async(e,t,r)=>{const n=await ze(e),o=(e,t=Ae)=>Ce(n,_.cons(e),t);return void 0===t?o:o(t,r)},compile:ze,interpret:Ce,setMetaOutputFormat:e=>{Ve=e},setShouldMetaValidate:e=>{Ue=e},FLAG:Ae,BASIC:Te,DETAILED:Ie,VERBOSE:ke,add:(e,t="",r="")=>{const{id:n}=je.add(e,t,r);delete De[n]},getKeyword:Re,hasKeyword:qe,defineVocabulary:(e,t)=>{_e[e]=t},compileSchema:Ne,interpretSchema:Be,collectEvaluatedProperties:(e,t,r,n,o)=>{const i=Fe(e,r);return Re(i).collectEvaluatedProperties(e,t,r,n,o)},collectEvaluatedItems:(e,t,r,n,o)=>{const i=Fe(e,r);return Re(i).collectEvaluatedItems(e,t,r,n,o)}};var Je={compile:e=>je.value(e),interpret:()=>!0};var Me={compile:async(e,t)=>{const r=je.uri(e);if(!(r in t)){t[r]=!1;const n=je.value(e);t[r]=[e.schemaVersion+"#validate",je.uri(e),"boolean"==typeof n?n:await ne.pipeline([je.entries,ne.map((([t,r])=>[`${e.schemaVersion}#${t}`,r])),ne.filter((([t])=>Ze.hasKeyword(t)&&t!==e.schemaVersion+"#validate")),ne.map((async([r,n])=>{const o=await Ze.getKeyword(r).compile(n,t,e);return[r,je.uri(n),o]})),ne.all],e)]}return r},interpret:(e,t,r,o)=>{const[i,a,s]=r[e];n.publishSync("result.start");const c="boolean"==typeof s?s:s.every((([e,i,a])=>{n.publishSync("result.start");const s=Ze.getKeyword(e).interpret(a,t,r,o);return n.publishSync("result",{keyword:e,absoluteKeywordLocation:i,instanceLocation:_.uri(t),valid:s,ast:a}),n.publishSync("result.end"),s}));return n.publishSync("result",{keyword:i,absoluteKeywordLocation:a,instanceLocation:_.uri(t),valid:c,ast:e}),n.publishSync("result.end"),c},collectEvaluatedProperties:(e,t,r,n,o=!1)=>{const i=r[e][2];return"boolean"==typeof i?!!i&&[]:i.filter((([e])=>!o||!e.endsWith("#unevaluatedProperties"))).reduce(((e,[o,,i])=>{const a=e&&Ze.getKeyword(o).collectEvaluatedProperties(i,t,r,n);return!1!==a&&[...e,...a]}),[])},collectEvaluatedItems:(e,t,r,n,o=!1)=>{const i=r[e][2];return"boolean"==typeof i?!!i&&new Set:i.filter((([e])=>!o||!e.endsWith("#unevaluatedItems"))).reduce(((e,[o,,i])=>{const a=!1!==e&&Ze.getKeyword(o).collectEvaluatedItems(i,t,r,n);return!1!==a&&new Set([...e,...a])}),new Set)}},We={Core:Ze,Schema:je,Instance:_,Keywords:{metaData:Je,validate:Me}},Ge=We.Core,He=We.Schema,Qe=We.Instance,Xe=We.Keywords;e.Core=Ge,e.Instance=Qe,e.Keywords=Xe,e.Schema=He,e.default=We,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=json-schema-core-umd.min.js.map |
@@ -180,7 +180,12 @@ const curry = require("just-curry-it"); | ||
const add = (schema, url = "", defaultSchemaVersion = "") => { | ||
const { id } = Schema.add(schema, url, defaultSchemaVersion); | ||
delete metaValidators[id]; | ||
}; | ||
module.exports = { | ||
validate, compile, interpret, | ||
setMetaOutputFormat, setShouldMetaValidate, FLAG, BASIC, DETAILED, VERBOSE, | ||
getKeyword, hasKeyword, defineVocabulary, | ||
add, getKeyword, hasKeyword, defineVocabulary, | ||
compileSchema, interpretSchema, collectEvaluatedProperties, collectEvaluatedItems | ||
}; |
@@ -91,2 +91,4 @@ const contentTypeParser = require("content-type"); | ||
}; | ||
return schemaStore[id]; | ||
}; | ||
@@ -93,0 +95,0 @@ |
{ | ||
"name": "@hyperjump/json-schema-core", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "A framework for building JSON Schema tools", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1622003
9189