@noeldemartin/solid-utils 0.1.1-next.0138d472d679413be54bc014f8cf21f03a1e1c3c → 0.1.1-next.8c064afc67573f7cf20fa4cbeecfad10a949a9ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("core-js/modules/es.reflect.construct.js");var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/inherits"),r=require("@babel/runtime/helpers/possibleConstructorReturn"),n=require("@babel/runtime/helpers/getPrototypeOf");require("core-js/modules/es.array.concat.js");var u=require("@noeldemartin/utils"),o=require("@babel/runtime/helpers/createClass"),a=require("@babel/runtime/helpers/asyncToGenerator"),s=require("@babel/runtime/regenerator");require("core-js/modules/es.array.map.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js");var i=require("@babel/runtime/helpers/toConsumableArray"),c=require("@babel/runtime/helpers/slicedToArray");require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.array.flat-map.js"),require("core-js/modules/es.array.unscopables.flat-map.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/esnext.set.add-all.js"),require("core-js/modules/esnext.set.delete-all.js"),require("core-js/modules/esnext.set.difference.js"),require("core-js/modules/esnext.set.every.js"),require("core-js/modules/esnext.set.filter.js"),require("core-js/modules/esnext.set.find.js"),require("core-js/modules/esnext.set.intersection.js"),require("core-js/modules/esnext.set.is-disjoint-from.js"),require("core-js/modules/esnext.set.is-subset-of.js"),require("core-js/modules/esnext.set.is-superset-of.js"),require("core-js/modules/esnext.set.join.js"),require("core-js/modules/esnext.set.map.js"),require("core-js/modules/esnext.set.reduce.js"),require("core-js/modules/esnext.set.some.js"),require("core-js/modules/esnext.set.symmetric-difference.js"),require("core-js/modules/esnext.set.union.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/es.string.match-all.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.flat.js");var l=require("n3"),f=require("jsonld"),d=require("md5");require("core-js/modules/es.string.match.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.string.starts-with.js"),require("core-js/modules/es.string.split.js");var p=require("@babel/runtime/helpers/typeof");require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.string.includes.js");var v=require("jest-diff");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=m(e),y=m(t),x=m(r),j=m(n),b=m(o),w=m(a),g=m(s),q=m(i),k=m(c),E=m(d),T=m(p),R=m(v);function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=j.default(e);if(t){var u=j.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}exports.SolidDocumentFormat=void 0,(exports.SolidDocumentFormat||(exports.SolidDocumentFormat={})).Turtle="Turtle";var S=function(e){y.default(MalformedSolidDocumentError,e);var t=D(MalformedSolidDocumentError);function MalformedSolidDocumentError(e,r,n){var u;return h.default(this,MalformedSolidDocumentError),(u=t.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(e,r,n))).documentUrl=e,u.documentFormat=r,u.malformationDetails=n,u}return MalformedSolidDocumentError}(u.Error);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=j.default(e);if(t){var u=j.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var I=function(e){y.default(NetworkRequestError,e);var t=P(NetworkRequestError);function NetworkRequestError(e){var r;return h.default(this,NetworkRequestError),(r=t.call(this,"Request failed trying to fetch ".concat(e))).url=e,r}return NetworkRequestError}(u.Error);function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=j.default(e);if(t){var u=j.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var N=function(e){y.default(NotFoundError,e);var t=A(NotFoundError);function NotFoundError(e){var r;return h.default(this,NotFoundError),(r=t.call(this,"Document with '".concat(e,"' url not found"))).url=e,r}return NotFoundError}(u.Error);function U(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=j.default(e);if(t){var u=j.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var C=function(e){y.default(UnauthorizedError,e);var t=U(UnauthorizedError);function UnauthorizedError(e,r){var n;return h.default(this,UnauthorizedError),(n=t.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(e,r))).url=e,n.responseStatus=r,n}return b.default(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(u.Error),B={foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdfs:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function O(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=k.default(r,2),u=n[0],o=n[1];if(o){var a,s,i,c=null!==(a=null!==(s=B[u])&&void 0!==s?s:null===(i=t.extraContext)||void 0===i?void 0:i[u])&&void 0!==a?a:null;if(!c)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return c+o}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+u}var z=function(){function e(t,r){h.default(this,e),this.url=t,this.quads=r}return b.default(e,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===O(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===O(e)})).map((function(e){return e.object.value}))}}]),e}(),F=function(){function e(t,r,n){h.default(this,e),this.url=t,this.quads=r,this.headers=n}return b.default(e,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,O("rdfs:type"),O("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=u.parseDate(this.headers.get("last-modified")))&&void 0!==r?r:u.parseDate(null===(n=this.statement(this.url,"purl:modified"))||void 0===n?void 0:n.object.value))&&void 0!==t?t:this.getLatestDocumentDate())&&void 0!==e?e:null}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(u){return!(r&&u.object.value!==O(r,{defaultPrefix:n.url})||e&&u.subject.value!==O(e,{defaultPrefix:n.url})||t&&u.predicate.value!==O(t,{defaultPrefix:n.url}))}))}},{key:"statement",value:function(e,t,r){var n=this,u=this.quads.find((function(u){return!(r&&u.object.value!==O(r,{defaultPrefix:n.url})||e&&u.subject.value!==O(e,{defaultPrefix:n.url})||t&&u.predicate.value!==O(t,{defaultPrefix:n.url}))}));return null!=u?u:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new z(e,t)}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(q.default(this.statements(void 0,"purl:modified")),q.default(this.statements(void 0,"purl:created"))).map((function(e){return u.parseDate(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}}]),e}();function M(e){return"@graph"in e}function L(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Q(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function W(e,t){return $.apply(this,arguments)}function $(){return($=w.default(g.default.mark((function e(t,r){var n,u,o;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(u=e.sent).status){e.next=7;break}throw new N(t);case 7:if(![401,403].includes(u.status)){e.next=9;break}throw new C(t,u.status);case 9:return e.next=11,u.text();case 11:return o=e.sent,e.abrupt("return",{body:o,headers:u.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof C)){e.next=19;break}throw e.t0;case 19:throw new I(t);case 20:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function H(e){var t,r=e.slice(0),n={},o=u.arr(e).flatMap((function(e,t){var r,o=u.arrayFilter(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),a=L(o);try{for(a.s();!(r=a.n()).done;){var s,i=r.value;n[i]=null!==(s=n[i])&&void 0!==s?s:new Set,n[i].add(t)}}catch(e){a.e(e)}finally{a.f()}return o})).filter().unique(),a=L(o);try{var s=function(){var o,a=t.value,s=E.default(u.arr(n[a]).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===a})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),i=L(n[a]);try{for(i.s();!(o=i.n()).done;){for(var c=o.value,f=r[c],d={subject:f.subject,object:f.object},p=0,v=Object.entries(d);p<v.length;p++){var m=k.default(v[p],2),h=m[0],y=m[1];"BlankNode"===y.termType&&y.value===a&&(d[h]=new l.BlankNode(s))}u.arrayReplace(r,f,new l.Quad(d.subject,f.predicate,d.object))}}catch(e){i.e(e)}finally{i.f()}};for(a.s();!(t=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return r}function J(e,t,r){return _.apply(this,arguments)}function _(){return(_=w.default(g.default.mark((function e(t,r,n){var u,o;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch,e.next=3,oe(r);case 3:return o=e.sent,e.next=6,n(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:r});case 6:return e.abrupt("return",new F(t,o,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function G(e,t){return X.apply(this,arguments)}function X(){return(X=w.default(g.default.mark((function e(t,r){var n,u,o,a;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,W(t,null!=r?r:window.fetch);case 2:return n=e.sent,u=n.body,o=n.headers,e.next=7,oe(u,{documentUrl:t});case 7:return a=e.sent,e.abrupt("return",new F(t,a,o));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(e){return V.apply(this,arguments)}function V(){return(V=w.default(g.default.mark((function e(t){var r;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!M(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map(K));case 3:return r=e.sent,e.abrupt("return",r.flat());case 5:return e.abrupt("return",f.toRDF(t));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(e){var t=ue(e);return Object.entries(t).reduce((function(e,t){var r=k.default(t,2),n=r[0],u=r[1].map((function(e){return" "+ee(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(u,"\n}"))}),[]).join(" ;\n")}function Z(e){return(new l.Writer).quadsToString(e)}function ee(e){return(new l.Writer).quadsToString([e]).slice(0,-1)}function te(e,t){return re.apply(this,arguments)}function re(){return(re=w.default(g.default.mark((function e(t,r){var n;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,G(t,r);case 3:return n=e.sent,e.abrupt("return",!n.isEmpty());case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ne(){return(ne=w.default(g.default.mark((function e(t){var r,n,u,o=arguments;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},n=t.matchAll(/(\w+) DATA {([^}]+)}/g),u={},e.next=5,Promise.all(q.default(n).map(function(){var e=w.default(g.default.mark((function e(t){var n,o;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),o=t[2],e.next=4,oe(o,r);case 4:u[n]=e.sent;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.abrupt("return",u);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ue(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.matchAll(/(\w+) DATA {([^}]+)}/g),u={},o=L(n);try{for(o.s();!(t=o.n()).done;){var a=t.value,s=a[1].toLowerCase(),i=a[2];u[s]=se(i,r)}}catch(e){o.e(e)}finally{o.f()}return u}function oe(e){return ae.apply(this,arguments)}function ae(){return(ae=w.default(g.default.mark((function e(t){var r,n,o,a,s=arguments;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},n=u.objectWithoutEmpty({baseIRI:r.documentUrl}),o=new l.Parser(n),a=[],e.abrupt("return",new Promise((function(e,n){o.parse(t,(function(t,u){var o;t?n(new S(null!==(o=r.documentUrl)&&void 0!==o?o:null,exports.SolidDocumentFormat.Turtle,t.message)):u?a.push(u):r.normalizeBlankNodes?e(H(a)):e(a)}))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=u.objectWithoutEmpty({baseIRI:t.documentUrl}),n=new l.Parser(r);try{var o=n.parse(e);return t.normalizeBlankNodes?H(o):o}catch(e){var a;throw new S(null!==(a=t.documentUrl)&&void 0!==a?a:null,exports.SolidDocumentFormat.Turtle,e.message)}}function ie(e,t,r){return ce.apply(this,arguments)}function ce(){return(ce=w.default(g.default.mark((function e(t,r,n){var u;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch,e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e,t){return fe.apply(this,arguments)}function fe(){return(fe=w.default(g.default.mark((function e(t,r){var n,o,a,s,i,c,l,f,d,p,v,m,h,y;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=u.urlRoute(t),e.next=3,G(f,r);case 3:if((d=e.sent).isPersonalProfile()){e.next=6;break}throw new Error("Document at ".concat(f," is not a profile."));case 6:p=d.statements(t,"pim:storage").map((function(e){return e.object.value})),v=d.statement(t,"solid:publicTypeIndex"),m=d.statement(t,"solid:privateTypeIndex"),h=u.urlParentDirectory(f);case 10:if(!h||0!==p.length){e.next=20;break}return e.next=13,u.silenced(G(h,r));case 13:if(null==(y=e.sent)||!y.isStorage()){e.next=17;break}return p.push(h),e.abrupt("break",20);case 17:h=u.urlParentDirectory(h),e.next=10;break;case 20:return e.abrupt("return",u.objectWithoutEmpty({webId:t,storageUrls:p,name:null!==(n=null===(o=d.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(a=d.statement(t,"foaf:name"))||void 0===a?void 0:a.object.value,avatarUrl:null!==(s=null===(i=d.statement(t,"vcard:hasPhoto"))||void 0===i?void 0:i.object.value)&&void 0!==s?s:null===(c=d.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(l=d.statement(t,"solid:oidcIssuer"))||void 0===l?void 0:l.object.value,publicTypeIndexUrl:null==v?void 0:v.object.value,privateTypeIndexUrl:null==m?void 0:m.object.value}));case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function de(){return(de=w.default(g.default.mark((function e(t,r){var n,o,a;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=u.silenced((function(e){return le(e,r)})),e.next=3,a(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,a(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,a(u.urlRoot(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(e,t){return ve.apply(this,arguments)}function ve(){return(ve=w.default(g.default.mark((function e(t,r){var n,o,a;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,o=t.storageUrls[0],a="".concat(o,"settings/privateTypeIndex"),e.next=5,te(a,r);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/privateTypeIndex-").concat(u.uuid()),e.next=10;break;case 9:e.t0=a;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(){return(me=w.default(g.default.mark((function e(t,r){var n,u,o;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,e.next=3,pe(t,r);case 3:return u=e.sent,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",o="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <").concat(u,"> .\n }\n "),J(u,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",r),ie(t.webId,o,r),e.abrupt("return",u);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(){return(he=w.default(g.default.mark((function e(t,r,n){var u,o,a;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,G(t,n);case 2:return o=e.sent,a=o.statements(void 0,"rdfs:type","solid:TypeRegistration").find((function(e){return o.contains(e.subject.value,"solid:forClass",r)&&o.contains(e.subject.value,"solid:instanceContainer")})),e.abrupt("return",a&&null!==(u=o.getThing(a.subject.value))&&void 0!==u?u:null);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return xe(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xe(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function xe(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var je={};function be(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function we(e,t){if(!be(e))return e===t;var r=[];if(!(e in je)){var n,u=e.matchAll(/\[\[((.*)\]\[)?([^\]]+)\]\]/g),o=[],a=e,s=ye(u);try{for(s.s();!(n=s.n()).done;){var i=n.value;i[2]&&r.push(i[2]),o.push(i[3]),a=a.replace(i[0],"%PATTERN".concat(o.length-1,"%"))}}catch(e){s.e(e)}finally{s.f()}a=a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var c=0,l=Object.entries(o);c<l.length;c++){var f=k.default(l[c],2),d=f[0],p=f[1];a=a.replace("%PATTERN".concat(d,"%"),p)}je[e]=new RegExp(a)}return je[e].test(t)}function ge(e,t){return function(e,t){if(e.termType!==t.termType)return!1;if("Literal"===e.termType&&"Literal"===t.termType){if(e.datatype.value!==t.datatype.value)return!1;if(!be(e.value))return"http://www.w3.org/2001/XMLSchema#dateTime"===e.datatype.value?new Date(e.value).getTime()===new Date(t.value).getTime():e.value===t.value}return we(e.value,t.value)}(e.object,t.object)&&we(e.subject.value,t.subject.value)&&we(e.predicate.value,t.predicate.value)}function qe(){je={}}function ke(e,t){return Ee.apply(this,arguments)}function Ee(){return(Ee=w.default(g.default.mark((function e(t,r){var n,u,o,a,s,i,c,l,f;return g.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qe(),e.next=3,K(t);case 3:return n=e.sent,e.next=6,K(r);case 6:if(u=e.sent,o=Z(n),a=Z(u),s=function(e,t){return{success:e,message:t,expected:o,actual:a}},n.length===u.length){e.next=12;break}return e.abrupt("return",s(!1,"Expected ".concat(n.length," triples, found ").concat(u.length,".")));case 12:i=ye(n),e.prev=13,l=function(){var e=c.value;if(!u.some((function(t){return ge(e,t)})))return{v:s(!1,"Couldn't find the following triple: ".concat(ee(e)))}},i.s();case 16:if((c=i.n()).done){e.next=22;break}if(f=l(),"object"!==T.default(f)){e.next=20;break}return e.abrupt("return",f.v);case 20:e.next=16;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(13),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:return e.abrupt("return",s(!0,"jsonld matches"));case 31:case"end":return e.stop()}}),e,null,[[13,24,27,30]])})))).apply(this,arguments)}function Te(e,t){var r;qe();for(var n=ue(e,{normalizeBlankNodes:!0}),o=ue(t,{normalizeBlankNodes:!0}),a=function(r,n){return{success:r,message:n,expected:e,actual:t}},s=0,i=Object.keys(n);s<i.length;s++){var c=i[s];if(!(c in o))return a(!1,"Couldn't find expected ".concat(c," operation."));var l=u.pull(n,c),f=u.pull(o,c);if(l.length!==f.length)return a(!1,"Expected ".concat(l.length," ").concat(c," triples, found ").concat(f.length,"."));var d,p=ye(l);try{var v=function(){var e=d.value;if(!f.some((function(t){return ge(e,t)})))return{v:a(!1,"Couldn't find the following ".concat(c," triple: ").concat(ee(e)))}};for(p.s();!(d=p.n()).done;){var m=v();if("object"===T.default(m))return m.v}}catch(e){p.e(e)}finally{p.f()}}var h=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return h?a(!1,"Did not expect to find ".concat(h," triples.")):a(!0,"sparql matches")}function Re(e,t){qe();var r=se(e,{normalizeBlankNodes:!0}),n=se(t,{normalizeBlankNodes:!0}),u=function(r,n){return{success:r,message:n,expected:e,actual:t}};if(r.length!==n.length)return u(!1,"Expected ".concat(r.length," triples, found ").concat(n.length,"."));var o,a=ye(r);try{var s=function(){var e=o.value;if(!n.some((function(t){return ge(e,t)})))return{v:u(!1,"Couldn't find the following triple: ".concat(ee(e)))}};for(a.s();!(o=a.n()).done;){var i=s();if("object"===T.default(i))return i.v}}catch(e){a.e(e)}finally{a.f()}return u(!0,"turtle matches")}var De={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=Re(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=Te(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Se(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}:function(){var r=R.default(t.expected,t.received,{expand:t.context.expand});return[e.message,n.matcherHint(t.hint),r&&r.includes("- Expect")?"Difference:\n\n".concat(r):["Expected: ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}}}var Pe={toEqualJsonLD:function(e,t){var r=this;return w.default(g.default.mark((function n(){var u;return g.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,ke(t,e);case 2:return u=n.sent,n.abrupt("return",Se(u,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Se(Te(t,e),{context:this,hint:"toEqualSparql",expected:Y(t),received:Y(e)})}};exports.MalformedSolidDocumentError=S,exports.NetworkRequestError=I,exports.NotFoundError=N,exports.SolidDocument=F,exports.SolidThing=z,exports.UnauthorizedError=C,exports.createPrivateTypeIndex=function(e,t){return me.apply(this,arguments)},exports.createSolidDocument=J,exports.defineIRIPrefix=function(e,t){B[e]=t},exports.expandIRI=O,exports.fetchLoginUserProfile=function(e,t){return de.apply(this,arguments)},exports.fetchSolidDocument=G,exports.findContainerRegistration=function(e,t,r){return he.apply(this,arguments)},exports.installChaiPlugin=function(){chai.use((function(e){return Object.entries(De).forEach((function(t){var r=k.default(t,2),n=r[0],u=r[1];return e.Assertion.addMethod(n,u)}))}))},exports.installJestPlugin=function(){expect.extend(Pe)},exports.isJsonLDGraph=M,exports.jsonldEquals=ke,exports.jsonldToQuads=K,exports.normalizeSparql=Y,exports.quadToTurtle=ee,exports.quadsToTurtle=Z,exports.solidDocumentExists=te,exports.sparqlEquals=Te,exports.sparqlToQuads=function(e){return ne.apply(this,arguments)},exports.sparqlToQuadsSync=ue,exports.turtleEquals=Re,exports.turtleToQuads=oe,exports.turtleToQuadsSync=se,exports.updateSolidDocument=ie;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("core-js/modules/es.reflect.construct.js");var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/inherits"),r=require("@babel/runtime/helpers/possibleConstructorReturn"),n=require("@babel/runtime/helpers/getPrototypeOf");require("core-js/modules/es.array.concat.js");var u=require("@noeldemartin/utils"),o=require("@babel/runtime/helpers/createClass"),a=require("@babel/runtime/helpers/asyncToGenerator"),s=require("@babel/runtime/regenerator");require("core-js/modules/es.array.map.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js");var i=require("@babel/runtime/helpers/toConsumableArray"),c=require("@babel/runtime/helpers/slicedToArray");require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/es.array.flat-map.js"),require("core-js/modules/es.array.unscopables.flat-map.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/esnext.set.add-all.js"),require("core-js/modules/esnext.set.delete-all.js"),require("core-js/modules/esnext.set.difference.js"),require("core-js/modules/esnext.set.every.js"),require("core-js/modules/esnext.set.filter.js"),require("core-js/modules/esnext.set.find.js"),require("core-js/modules/esnext.set.intersection.js"),require("core-js/modules/esnext.set.is-disjoint-from.js"),require("core-js/modules/esnext.set.is-subset-of.js"),require("core-js/modules/esnext.set.is-superset-of.js"),require("core-js/modules/esnext.set.join.js"),require("core-js/modules/esnext.set.map.js"),require("core-js/modules/esnext.set.reduce.js"),require("core-js/modules/esnext.set.some.js"),require("core-js/modules/esnext.set.symmetric-difference.js"),require("core-js/modules/esnext.set.union.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/es.string.match-all.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.flat.js");var l=require("n3"),f=require("jsonld"),d=require("md5");require("core-js/modules/es.string.match.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/es.string.starts-with.js"),require("core-js/modules/es.string.split.js");var p=require("@babel/runtime/helpers/typeof");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.object.keys.js"),require("core-js/modules/web.dom-collections.for-each.js");var m=v(e),h=v(t),y=v(r),x=v(n),j=v(o),b=v(a),w=v(s),g=v(i),q=v(c),k=v(d),T=v(p);function E(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var u=x.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return y.default(this,r)}}exports.SolidDocumentFormat=void 0,(exports.SolidDocumentFormat||(exports.SolidDocumentFormat={})).Turtle="Turtle";var R=function(e){h.default(MalformedSolidDocumentError,e);var t=E(MalformedSolidDocumentError);function MalformedSolidDocumentError(e,r,n){var u;return m.default(this,MalformedSolidDocumentError),(u=t.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(e,r,n))).documentUrl=e,u.documentFormat=r,u.malformationDetails=n,u}return MalformedSolidDocumentError}(u.Error);function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var u=x.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return y.default(this,r)}}var S=function(e){h.default(NetworkRequestError,e);var t=D(NetworkRequestError);function NetworkRequestError(e){var r;return m.default(this,NetworkRequestError),(r=t.call(this,"Request failed trying to fetch ".concat(e))).url=e,r}return NetworkRequestError}(u.Error);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var u=x.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return y.default(this,r)}}var I=function(e){h.default(NotFoundError,e);var t=P(NotFoundError);function NotFoundError(e){var r;return m.default(this,NotFoundError),(r=t.call(this,"Document with '".concat(e,"' url not found"))).url=e,r}return NotFoundError}(u.Error);function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=x.default(e);if(t){var u=x.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return y.default(this,r)}}var N=function(e){h.default(UnauthorizedError,e);var t=A(UnauthorizedError);function UnauthorizedError(e,r){var n;return m.default(this,UnauthorizedError),(n=t.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(e,r))).url=e,n.responseStatus=r,n}return j.default(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(u.Error),U={foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdfs:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function C(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=q.default(r,2),u=n[0],o=n[1];if(o){var a,s,i,c=null!==(a=null!==(s=U[u])&&void 0!==s?s:null===(i=t.extraContext)||void 0===i?void 0:i[u])&&void 0!==a?a:null;if(!c)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return c+o}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+u}var B=function(){function e(t,r){m.default(this,e),this.url=t,this.quads=r}return j.default(e,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===C(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===C(e)})).map((function(e){return e.object.value}))}}]),e}(),O=function(){function e(t,r,n){m.default(this,e),this.url=t,this.quads=r,this.headers=n}return j.default(e,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,C("rdfs:type"),C("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=u.parseDate(this.headers.get("last-modified")))&&void 0!==r?r:u.parseDate(null===(n=this.statement(this.url,"purl:modified"))||void 0===n?void 0:n.object.value))&&void 0!==t?t:this.getLatestDocumentDate())&&void 0!==e?e:null}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(u){return!(r&&u.object.value!==C(r,{defaultPrefix:n.url})||e&&u.subject.value!==C(e,{defaultPrefix:n.url})||t&&u.predicate.value!==C(t,{defaultPrefix:n.url}))}))}},{key:"statement",value:function(e,t,r){var n=this,u=this.quads.find((function(u){return!(r&&u.object.value!==C(r,{defaultPrefix:n.url})||e&&u.subject.value!==C(e,{defaultPrefix:n.url})||t&&u.predicate.value!==C(t,{defaultPrefix:n.url}))}));return null!=u?u:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new B(e,t)}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(g.default(this.statements(void 0,"purl:modified")),g.default(this.statements(void 0,"purl:created"))).map((function(e){return u.parseDate(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}}]),e}();function z(e){return"@graph"in e}function F(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(e,t){return Q.apply(this,arguments)}function Q(){return(Q=b.default(w.default.mark((function e(t,r){var n,u,o;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(u=e.sent).status){e.next=7;break}throw new I(t);case 7:if(![401,403].includes(u.status)){e.next=9;break}throw new N(t,u.status);case 9:return e.next=11,u.text();case 11:return o=e.sent,e.abrupt("return",{body:o,headers:u.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof N)){e.next=19;break}throw e.t0;case 19:throw new S(t);case 20:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function W(e){var t,r=e.slice(0),n={},o=u.arr(e).flatMap((function(e,t){var r,o=u.arrayFilter(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),a=F(o);try{for(a.s();!(r=a.n()).done;){var s,i=r.value;n[i]=null!==(s=n[i])&&void 0!==s?s:new Set,n[i].add(t)}}catch(e){a.e(e)}finally{a.f()}return o})).filter().unique(),a=F(o);try{var s=function(){var o,a=t.value,s=k.default(u.arr(n[a]).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===a})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),i=F(n[a]);try{for(i.s();!(o=i.n()).done;){for(var c=o.value,f=r[c],d={subject:f.subject,object:f.object},p=0,v=Object.entries(d);p<v.length;p++){var m=q.default(v[p],2),h=m[0],y=m[1];"BlankNode"===y.termType&&y.value===a&&(d[h]=new l.BlankNode(s))}u.arrayReplace(r,f,new l.Quad(d.subject,f.predicate,d.object))}}catch(e){i.e(e)}finally{i.f()}};for(a.s();!(t=a.n()).done;)s()}catch(e){a.e(e)}finally{a.f()}return r}function $(e,t,r){return H.apply(this,arguments)}function H(){return(H=b.default(w.default.mark((function e(t,r,n){var u,o;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch,e.next=3,ne(r);case 3:return o=e.sent,e.next=6,n(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:r});case 6:return e.abrupt("return",new O(t,o,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e,t){return _.apply(this,arguments)}function _(){return(_=b.default(w.default.mark((function e(t,r){var n,u,o,a;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L(t,null!=r?r:window.fetch);case 2:return n=e.sent,u=n.body,o=n.headers,e.next=7,ne(u,{documentUrl:t});case 7:return a=e.sent,e.abrupt("return",new O(t,a,o));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function G(e){return X.apply(this,arguments)}function X(){return(X=b.default(w.default.mark((function e(t){var r;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!z(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map(G));case 3:return r=e.sent,e.abrupt("return",r.flat());case 5:return e.abrupt("return",f.toRDF(t));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(e){var t=re(e);return Object.entries(t).reduce((function(e,t){var r=q.default(t,2),n=r[0],u=r[1].map((function(e){return" "+Y(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(u,"\n}"))}),[]).join(" ;\n")}function V(e){return(new l.Writer).quadsToString(e)}function Y(e){return(new l.Writer).quadsToString([e]).slice(0,-1)}function Z(e,t){return ee.apply(this,arguments)}function ee(){return(ee=b.default(w.default.mark((function e(t,r){var n;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,J(t,r);case 3:return n=e.sent,e.abrupt("return",!n.isEmpty());case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function te(){return(te=b.default(w.default.mark((function e(t){var r,n,u,o=arguments;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},n=t.matchAll(/(\w+) DATA {([^}]+)}/g),u={},e.next=5,Promise.all(g.default(n).map(function(){var e=b.default(w.default.mark((function e(t){var n,o;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),o=t[2],e.next=4,ne(o,r);case 4:u[n]=e.sent;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.abrupt("return",u);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function re(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.matchAll(/(\w+) DATA {([^}]+)}/g),u={},o=F(n);try{for(o.s();!(t=o.n()).done;){var a=t.value,s=a[1].toLowerCase(),i=a[2];u[s]=oe(i,r)}}catch(e){o.e(e)}finally{o.f()}return u}function ne(e){return ue.apply(this,arguments)}function ue(){return(ue=b.default(w.default.mark((function e(t){var r,n,o,a,s=arguments;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},n=u.objectWithoutEmpty({baseIRI:r.documentUrl}),o=new l.Parser(n),a=[],e.abrupt("return",new Promise((function(e,n){o.parse(t,(function(t,u){var o;t?n(new R(null!==(o=r.documentUrl)&&void 0!==o?o:null,exports.SolidDocumentFormat.Turtle,t.message)):u?a.push(u):r.normalizeBlankNodes?e(W(a)):e(a)}))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=u.objectWithoutEmpty({baseIRI:t.documentUrl}),n=new l.Parser(r);try{var o=n.parse(e);return t.normalizeBlankNodes?W(o):o}catch(e){var a;throw new R(null!==(a=t.documentUrl)&&void 0!==a?a:null,exports.SolidDocumentFormat.Turtle,e.message)}}function ae(e,t,r){return se.apply(this,arguments)}function se(){return(se=b.default(w.default.mark((function e(t,r,n){var u;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch,e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(e,t){return ce.apply(this,arguments)}function ce(){return(ce=b.default(w.default.mark((function e(t,r){var n,o,a,s,i,c,l,f,d,p,v,m,h,y;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=u.urlRoute(t),e.next=3,J(f,r);case 3:if((d=e.sent).isPersonalProfile()){e.next=6;break}throw new Error("Document at ".concat(f," is not a profile."));case 6:p=d.statements(t,"pim:storage").map((function(e){return e.object.value})),v=d.statement(t,"solid:publicTypeIndex"),m=d.statement(t,"solid:privateTypeIndex"),h=u.urlParentDirectory(f);case 10:if(!h||0!==p.length){e.next=20;break}return e.next=13,u.silenced(J(h,r));case 13:if(null==(y=e.sent)||!y.isStorage()){e.next=17;break}return p.push(h),e.abrupt("break",20);case 17:h=u.urlParentDirectory(h),e.next=10;break;case 20:return e.abrupt("return",u.objectWithoutEmpty({webId:t,storageUrls:p,name:null!==(n=null===(o=d.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(a=d.statement(t,"foaf:name"))||void 0===a?void 0:a.object.value,avatarUrl:null!==(s=null===(i=d.statement(t,"vcard:hasPhoto"))||void 0===i?void 0:i.object.value)&&void 0!==s?s:null===(c=d.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(l=d.statement(t,"solid:oidcIssuer"))||void 0===l?void 0:l.object.value,publicTypeIndexUrl:null==v?void 0:v.object.value,privateTypeIndexUrl:null==m?void 0:m.object.value}));case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(){return(le=b.default(w.default.mark((function e(t,r){var n,o,a;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=u.silenced((function(e){return ie(e,r)})),e.next=3,a(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,a(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,a(u.urlRoot(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e,t){return de.apply(this,arguments)}function de(){return(de=b.default(w.default.mark((function e(t,r){var n,o,a;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,o=t.storageUrls[0],a="".concat(o,"settings/privateTypeIndex"),e.next=5,Z(a,r);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/privateTypeIndex-").concat(u.uuid()),e.next=10;break;case 9:e.t0=a;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(){return(pe=b.default(w.default.mark((function e(t,r){var n,u,o;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,e.next=3,fe(t,r);case 3:return u=e.sent,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",o="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <").concat(u,"> .\n }\n "),$(u,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",r),ae(t.webId,o,r),e.abrupt("return",u);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(){return(ve=b.default(w.default.mark((function e(t,r,n){var u,o,a;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,J(t,n);case 2:return o=e.sent,a=o.statements(void 0,"rdfs:type","solid:TypeRegistration").find((function(e){return o.contains(e.subject.value,"solid:forClass",r)&&o.contains(e.subject.value,"solid:instanceContainer")})),e.abrupt("return",a&&null!==(u=o.getThing(a.subject.value))&&void 0!==u?u:null);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return he(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return he(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function he(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var ye={};function xe(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function je(e,t){if(!xe(e))return e===t;var r=[];if(!(e in ye)){var n,u=e.matchAll(/\[\[((.*)\]\[)?([^\]]+)\]\]/g),o=[],a=e,s=me(u);try{for(s.s();!(n=s.n()).done;){var i=n.value;i[2]&&r.push(i[2]),o.push(i[3]),a=a.replace(i[0],"%PATTERN".concat(o.length-1,"%"))}}catch(e){s.e(e)}finally{s.f()}a=a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var c=0,l=Object.entries(o);c<l.length;c++){var f=q.default(l[c],2),d=f[0],p=f[1];a=a.replace("%PATTERN".concat(d,"%"),p)}ye[e]=new RegExp(a)}return ye[e].test(t)}function be(e,t){return function(e,t){if(e.termType!==t.termType)return!1;if("Literal"===e.termType&&"Literal"===t.termType){if(e.datatype.value!==t.datatype.value)return!1;if(!xe(e.value))return"http://www.w3.org/2001/XMLSchema#dateTime"===e.datatype.value?new Date(e.value).getTime()===new Date(t.value).getTime():e.value===t.value}return je(e.value,t.value)}(e.object,t.object)&&je(e.subject.value,t.subject.value)&&je(e.predicate.value,t.predicate.value)}function we(){ye={}}function ge(e,t){return qe.apply(this,arguments)}function qe(){return(qe=b.default(w.default.mark((function e(t,r){var n,u,o,a,s,i,c,l,f;return w.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return we(),e.next=3,G(t);case 3:return n=e.sent,e.next=6,G(r);case 6:if(u=e.sent,o=V(n),a=V(u),s=function(e,t){return{success:e,message:t,expected:o,actual:a}},n.length===u.length){e.next=12;break}return e.abrupt("return",s(!1,"Expected ".concat(n.length," triples, found ").concat(u.length,".")));case 12:i=me(n),e.prev=13,l=function(){var e=c.value;if(!u.some((function(t){return be(e,t)})))return{v:s(!1,"Couldn't find the following triple: ".concat(Y(e)))}},i.s();case 16:if((c=i.n()).done){e.next=22;break}if(f=l(),"object"!==T.default(f)){e.next=20;break}return e.abrupt("return",f.v);case 20:e.next=16;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(13),i.e(e.t0);case 27:return e.prev=27,i.f(),e.finish(27);case 30:return e.abrupt("return",s(!0,"jsonld matches"));case 31:case"end":return e.stop()}}),e,null,[[13,24,27,30]])})))).apply(this,arguments)}function ke(e,t){var r;we();for(var n=re(e,{normalizeBlankNodes:!0}),o=re(t,{normalizeBlankNodes:!0}),a=function(r,n){return{success:r,message:n,expected:e,actual:t}},s=0,i=Object.keys(n);s<i.length;s++){var c=i[s];if(!(c in o))return a(!1,"Couldn't find expected ".concat(c," operation."));var l=u.pull(n,c),f=u.pull(o,c);if(l.length!==f.length)return a(!1,"Expected ".concat(l.length," ").concat(c," triples, found ").concat(f.length,"."));var d,p=me(l);try{var v=function(){var e=d.value;if(!f.some((function(t){return be(e,t)})))return{v:a(!1,"Couldn't find the following ".concat(c," triple: ").concat(Y(e)))}};for(p.s();!(d=p.n()).done;){var m=v();if("object"===T.default(m))return m.v}}catch(e){p.e(e)}finally{p.f()}}var h=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return h?a(!1,"Did not expect to find ".concat(h," triples.")):a(!0,"sparql matches")}function Te(e,t){we();var r=oe(e,{normalizeBlankNodes:!0}),n=oe(t,{normalizeBlankNodes:!0}),u=function(r,n){return{success:r,message:n,expected:e,actual:t}};if(r.length!==n.length)return u(!1,"Expected ".concat(r.length," triples, found ").concat(n.length,"."));var o,a=me(r);try{var s=function(){var e=o.value;if(!n.some((function(t){return be(e,t)})))return{v:u(!1,"Couldn't find the following triple: ".concat(Y(e)))}};for(a.s();!(o=a.n()).done;){var i=s();if("object"===T.default(i))return i.v}}catch(e){a.e(e)}finally{a.f()}return u(!0,"turtle matches")}var Ee={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=Te(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=ke(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Re(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}:function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}}}var De={toEqualJsonLD:function(e,t){var r=this;return b.default(w.default.mark((function n(){var u;return w.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,ge(t,e);case 2:return u=n.sent,n.abrupt("return",Re(u,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Re(ke(t,e),{context:this,hint:"toEqualSparql",expected:K(t),received:K(e)})}};exports.MalformedSolidDocumentError=R,exports.NetworkRequestError=S,exports.NotFoundError=I,exports.SolidDocument=O,exports.SolidThing=B,exports.UnauthorizedError=N,exports.createPrivateTypeIndex=function(e,t){return pe.apply(this,arguments)},exports.createSolidDocument=$,exports.defineIRIPrefix=function(e,t){U[e]=t},exports.expandIRI=C,exports.fetchLoginUserProfile=function(e,t){return le.apply(this,arguments)},exports.fetchSolidDocument=J,exports.findContainerRegistration=function(e,t,r){return ve.apply(this,arguments)},exports.installChaiPlugin=function(){chai.use((function(e){return Object.entries(Ee).forEach((function(t){var r=q.default(t,2),n=r[0],u=r[1];return e.Assertion.addMethod(n,u)}))}))},exports.installJestPlugin=function(){expect.extend(De)},exports.isJsonLDGraph=z,exports.jsonldEquals=ge,exports.jsonldToQuads=G,exports.normalizeSparql=K,exports.quadToTurtle=Y,exports.quadsToTurtle=V,exports.solidDocumentExists=Z,exports.sparqlEquals=ke,exports.sparqlToQuads=function(e){return te.apply(this,arguments)},exports.sparqlToQuadsSync=re,exports.turtleEquals=Te,exports.turtleToQuads=ne,exports.turtleToQuadsSync=oe,exports.updateSolidDocument=ae;
2
2
  //# sourceMappingURL=noeldemartin-solid-utils.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"noeldemartin-solid-utils.cjs.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/plugins/chai/assertions.ts","../src/plugins/jest/matchers.ts","../src/plugins/chai/index.ts","../src/plugins/jest/index.ts"],"sourcesContent":["import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends Error {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Request failed trying to fetch ${url}`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends Error {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n foaf: 'http://xmlns.com/foaf/0.1/',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdfs: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http'))\n return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter(quad => quad.predicate.value === expandIRI(property))\n .map(quad => quad.object.value);\n }\n\n}\n","import { parseDate } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidDocument {\n\n public readonly url: string;\n public readonly headers: Headers;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n this.url = url;\n this.quads = quads;\n this.headers = headers;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdfs:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public getLastModified(): Date | null {\n return parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\n .map(statement => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => a > b ? a : b) : null;\n }\n\n}\n","export type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = { '@graph': JsonLDResource[] };\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import { arr, arrayFilter, arrayReplace,objectWithoutEmpty } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser as TurtleParser, Writer as TurtleWriter } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport { toRDF } from 'jsonld';\nimport md5 from 'md5';\nimport type { Quad } from 'rdf-js';\nimport type { Term as N3Term } from 'n3';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<any>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nasync function fetchRawSolidDocument(url: string, fetch: Fetch): Promise<{ body: string; headers: Headers }> {\n const options = {\n headers: { Accept: 'text/turtle' },\n };\n\n try {\n const response = await fetch(url, options);\n\n if (response.status === 404)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError)\n throw error;\n\n throw new NetworkRequestError(url);\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) => {\n const ids = arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]);\n\n for (const id of ids) {\n quadsIndexes[id] = quadsIndexes[id] ?? new Set();\n quadsIndexes[id].add(index);\n }\n\n return ids;\n })\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const normalizedId = md5(\n arr(quadsIndexes[originalId])\n .map(index => quads[index])\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\n .sorted()\n .join(),\n );\n\n for (const index of quadsIndexes[originalId]) {\n const quad = normalizedQuads[index];\n const terms: Record<string, N3Term> = { subject: quad.subject as N3Term, object: quad.object as N3Term };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = new N3BlankNode(normalizedId);\n }\n\n arrayReplace(normalizedQuads, quad, new N3Quad(terms.subject, quad.predicate as N3Term, terms.object));\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n documentUrl: string;\n normalizeBlankNodes: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch;\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, fetch?: Fetch): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, fetch ?? window.fetch);\n const statements = await turtleToQuads(data, { documentUrl: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(jsonldToQuads));\n\n return graphQuads.flat();\n }\n\n return toRDF(jsonld as JsonLdDocument) as Promise<Quad[]>;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object\n .entries(quads)\n .reduce((normalizedOperations, [operation, quads]) => {\n const normalizedQuads = quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all([...operations].map(async operation => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }));\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n const quads: Quad[] = [];\n\n return new Promise((resolve, reject) => {\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.documentUrl ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n return;\n }\n\n if (!quad) {\n options.normalizeBlankNodes\n ? resolve(normalizeBlankNodes(quads))\n : resolve(quads);\n\n return;\n }\n\n quads.push(quad);\n });\n });\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(options.documentUrl ?? null, SolidDocumentFormat.Turtle, error.message);\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch;\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUserProfile> {\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, fetch);\n\n if (!document.isPersonalProfile())\n throw new Error(`Document at ${documentUrl} is not a profile.`);\n\n const storageUrls = document.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = document.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = document.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, fetch));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n return objectWithoutEmpty({\n webId,\n storageUrls,\n name:\n document.statement(webId, 'vcard:fn')?.object.value ??\n document.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n document.statement(webId, 'vcard:hasPhoto')?.object.value ??\n document.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: document.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n });\n}\n\nexport async function fetchLoginUserProfile(loginUrl: string, fetch?: Fetch): Promise<SolidUserProfile | null> {\n const fetchProfile = silenced(url => fetchUserProfile(url, fetch));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type SolidThing from '@/models/SolidThing';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\nasync function mintPrivateTypeIndexUrl(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/privateTypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/privateTypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const typeIndexUrl = await mintPrivateTypeIndexUrl(user, fetch);\n const typeIndexBody = `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n updateSolidDocument(user.webId, profileUpdateBody, fetch);\n\n return typeIndexUrl;\n}\n\nexport async function findContainerRegistration(\n typeIndexUrl: string,\n childrenType: string,\n fetch?: Fetch,\n): Promise<SolidThing | null> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const containerQuad = typeIndex\n .statements(undefined, 'rdfs:type', 'solid:TypeRegistration')\n .find(\n statement =>\n typeIndex.contains(statement.subject.value, 'solid:forClass', childrenType) &&\n typeIndex.contains(statement.subject.value, 'solid:instanceContainer'),\n );\n\n return containerQuad\n ? typeIndex.getThing(containerQuad.subject.value) ?? null\n : null;\n}\n","import type { JsonLD } from '@/helpers/jsonld';\nimport { pull } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n if (!containsPatterns(expected))\n return expected === actual;\n\n const patternAliases = [];\n\n if (!(expected in patternsRegExpsIndex)) {\n const patternMatches = expected.matchAll(/\\[\\[((.*)\\]\\[)?([^\\]]+)\\]\\]/g);\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n if (patternMatch[2]) {\n patternAliases.push(patternMatch[2]);\n }\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, pattern);\n }\n\n patternsRegExpsIndex[expected] = new RegExp(expectedRegExp);\n }\n\n return patternsRegExpsIndex[expected].test(actual);\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following ${operation} triple: ${quadToTurtle(expectedQuad)}`);\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'turtle matches');\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import diff from 'jest-diff';\n\nimport { normalizeSparql } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n')\n : () => {\n const diffString = diff(options.expected, options.received, {\n expand: options.context.expand,\n });\n\n return [\n result.message,\n utils.matcherHint(options.hint),\n diffString && diffString.includes('- Expect')\n ? `Difference:\\n\\n${diffString}`\n : [\n `Expected: ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n');\n };\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n};\n\nexport default matchers;\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","documentUrl","documentFormat","malformationDetails","errorMessage","Error","NetworkRequestError","url","NotFoundError","UnauthorizedError","responseStatus","this","undefined","knownPrefixes","foaf","pim","purl","rdfs","schema","solid","vcard","expandIRI","iri","options","startsWith","split","prefix","name","expandedPrefix","extraContext","_options$extraContext","defaultPrefix","SolidThing","quads","property","find","quad","predicate","value","_this$quads$find","object","filter","map","SolidDocument","headers","statements","length","statement","get","_this$headers$get","match","parseDate","_this$statement","getLatestDocumentDate","subject","_this","_this2","dates","date","reduce","a","b","isJsonLDGraph","jsonld","fetchRawSolidDocument","fetch","Accept","response","status","includes","text","body","_context","normalizeBlankNodes","normalizedQuads","slice","quadsIndexes","blankNodeIds","arr","flatMap","index","ids","arrayFilter","termType","id","Set","add","unique","originalId","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","N3BlankNode","arrayReplace","N3Quad","createSolidDocument","window","turtleToQuads","method","Headers","fetchSolidDocument","data","jsonldToQuads","Promise","all","graphQuads","flat","toRDF","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","document","isEmpty","operations","matchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","turtle","parserOptions","objectWithoutEmpty","baseIRI","parser","TurtleParser","resolve","reject","parse","error","Turtle","message","push","updateSolidDocument","fetchUserProfile","webId","urlRoute","isPersonalProfile","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","_document$statement","_document$statement2","avatarUrl","_document$statement3","_document$statement4","oidcIssuerUrl","_document$statement5","publicTypeIndexUrl","privateTypeIndexUrl","loginUrl","fetchProfile","replace","urlRoot","mintPrivateTypeIndexUrl","user","storageUrl","typeIndexUrl","uuid","profileUpdateBody","childrenType","typeIndex","containerQuad","contains","getThing","patternsRegExpsIndex","containsPatterns","test","quadValueEquals","expected","actual","patternAliases","patternMatches","patterns","expectedRegExp","patternMatch","patternIndex","pattern","RegExp","quadEquals","datatype","Date","getTime","quadObjectEquals","resetPatterns","jsonldEquals","expectedQuads","actualQuads","expectedTurtle","actualTurtle","result","success","expectedQuad","some","actualQuad","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","assertions","graph","_obj","assert","bind","query","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","diffString","diff","expand","matchers","toEqualJsonLD","toEqualSparql","chai","use","_chai","forEach","Assertion","addMethod","expect","extend"],"mappings":"4pHAYYA,oCAAAA,8BAAAA,qDAISC,iIAMLC,EAA4BC,EAAqCC,2EApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,KAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,wCAXsBE,4cCdpCC,yGAILC,4GACgCA,KAEnCA,IAAMA,gCAP8BF,4cCA5BG,uFAILD,sFACgBA,uBAEnBA,IAAMA,0BAPwBF,4cCMtBI,mGAKLF,EAAaG,iEAX7B,SAAsBH,EAAaG,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBH,GASzBH,CAAaG,EAAKG,KAEnBH,IAAMA,IACNG,eAAiBA,6DAG1B,uBAC0C,IAAxBC,KAAKD,eACW,MAAxBC,KAAKD,oBACLE,yBAfiCP,SCDzCQ,EAA4B,CAC9BC,KAAM,6BACNC,IAAK,kCACLC,KAAM,4BACNC,KAAM,8CACNC,OAAQ,sBACRC,MAAO,oCACPC,MAAO,6CAOKC,EAAUC,OAAaC,yDAAqC,MACpED,EAAIE,WAAW,QACf,OAAOF,QAEYA,EAAIG,MAAM,sBAA1BC,OAAQC,UAEXA,EAAM,WACAC,sBAAiBf,EAAca,4BAAWH,EAAQM,iCAARC,EAAuBJ,kBAAW,SAE7EE,EACD,MAAM,IAAIvB,uDAAgDiB,eAEvDM,EAAiBD,MAGvBJ,EAAQQ,cACT,MAAM,IAAI1B,4DAAqDiB,eAE5DC,EAAQQ,cAAgBL,MCnCdM,w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ClJ,KAAK,OACbA,KAAK,UAMnB,IAAMsJ,GAAiC,CAC7BC,uBAAcL,EAAU/C,yJACLgB,GAAahB,EAAU+C,iBAAtC1B,2BAECkB,GAAalB,EAAQ,CACxBqB,QAASlL,EACToL,KAAM,gBACN5C,SAAAA,EACA+C,SAAAA,mDAGRM,uBAAcN,EAAU/C,UAGbuC,GAFQb,GAAa1B,EAAU+C,GAEV,CACxBL,QAAS9N,KACTgO,KAAM,gBACN5C,SAAU7E,EAAgB6E,GAC1B+C,SAAU5H,EAAgB4H,yTT9CNnN,EAAcW,GAC1CzB,EAAcc,GAAQW,yPUftB+M,KAAKC,KAAI,SAAAC,UAASzJ,OAAOC,QAAQiI,IAAYwB,SAAQ,iCAAE7N,OAAM6E,cAAY+I,EAAME,UAAUC,UAAU/N,EAAM6E,+CCAzGmJ,OAAOC,OAAOV"}
1
+ {"version":3,"file":"noeldemartin-solid-utils.cjs.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/plugins/chai/assertions.ts","../src/plugins/jest/matchers.ts","../src/plugins/chai/index.ts","../src/plugins/jest/index.ts"],"sourcesContent":["import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends Error {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Request failed trying to fetch ${url}`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends Error {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n foaf: 'http://xmlns.com/foaf/0.1/',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdfs: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http'))\n return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter(quad => quad.predicate.value === expandIRI(property))\n .map(quad => quad.object.value);\n }\n\n}\n","import { parseDate } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidDocument {\n\n public readonly url: string;\n public readonly headers: Headers;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n this.url = url;\n this.quads = quads;\n this.headers = headers;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdfs:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public getLastModified(): Date | null {\n return parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\n .map(statement => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => a > b ? a : b) : null;\n }\n\n}\n","export type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = { '@graph': JsonLDResource[] };\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import { arr, arrayFilter, arrayReplace,objectWithoutEmpty } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser as TurtleParser, Writer as TurtleWriter } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport { toRDF } from 'jsonld';\nimport md5 from 'md5';\nimport type { Quad } from 'rdf-js';\nimport type { Term as N3Term } from 'n3';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<any>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nasync function fetchRawSolidDocument(url: string, fetch: Fetch): Promise<{ body: string; headers: Headers }> {\n const options = {\n headers: { Accept: 'text/turtle' },\n };\n\n try {\n const response = await fetch(url, options);\n\n if (response.status === 404)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError)\n throw error;\n\n throw new NetworkRequestError(url);\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) => {\n const ids = arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]);\n\n for (const id of ids) {\n quadsIndexes[id] = quadsIndexes[id] ?? new Set();\n quadsIndexes[id].add(index);\n }\n\n return ids;\n })\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const normalizedId = md5(\n arr(quadsIndexes[originalId])\n .map(index => quads[index])\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\n .sorted()\n .join(),\n );\n\n for (const index of quadsIndexes[originalId]) {\n const quad = normalizedQuads[index];\n const terms: Record<string, N3Term> = { subject: quad.subject as N3Term, object: quad.object as N3Term };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = new N3BlankNode(normalizedId);\n }\n\n arrayReplace(normalizedQuads, quad, new N3Quad(terms.subject, quad.predicate as N3Term, terms.object));\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n documentUrl: string;\n normalizeBlankNodes: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch;\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, fetch?: Fetch): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, fetch ?? window.fetch);\n const statements = await turtleToQuads(data, { documentUrl: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(jsonldToQuads));\n\n return graphQuads.flat();\n }\n\n return toRDF(jsonld as JsonLdDocument) as Promise<Quad[]>;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object\n .entries(quads)\n .reduce((normalizedOperations, [operation, quads]) => {\n const normalizedQuads = quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all([...operations].map(async operation => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }));\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n const quads: Quad[] = [];\n\n return new Promise((resolve, reject) => {\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.documentUrl ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n return;\n }\n\n if (!quad) {\n options.normalizeBlankNodes\n ? resolve(normalizeBlankNodes(quads))\n : resolve(quads);\n\n return;\n }\n\n quads.push(quad);\n });\n });\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(options.documentUrl ?? null, SolidDocumentFormat.Turtle, error.message);\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch;\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUserProfile> {\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, fetch);\n\n if (!document.isPersonalProfile())\n throw new Error(`Document at ${documentUrl} is not a profile.`);\n\n const storageUrls = document.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = document.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = document.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, fetch));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n return objectWithoutEmpty({\n webId,\n storageUrls,\n name:\n document.statement(webId, 'vcard:fn')?.object.value ??\n document.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n document.statement(webId, 'vcard:hasPhoto')?.object.value ??\n document.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: document.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n });\n}\n\nexport async function fetchLoginUserProfile(loginUrl: string, fetch?: Fetch): Promise<SolidUserProfile | null> {\n const fetchProfile = silenced(url => fetchUserProfile(url, fetch));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type SolidThing from '@/models/SolidThing';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\nasync function mintPrivateTypeIndexUrl(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/privateTypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/privateTypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const typeIndexUrl = await mintPrivateTypeIndexUrl(user, fetch);\n const typeIndexBody = `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n updateSolidDocument(user.webId, profileUpdateBody, fetch);\n\n return typeIndexUrl;\n}\n\nexport async function findContainerRegistration(\n typeIndexUrl: string,\n childrenType: string,\n fetch?: Fetch,\n): Promise<SolidThing | null> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const containerQuad = typeIndex\n .statements(undefined, 'rdfs:type', 'solid:TypeRegistration')\n .find(\n statement =>\n typeIndex.contains(statement.subject.value, 'solid:forClass', childrenType) &&\n typeIndex.contains(statement.subject.value, 'solid:instanceContainer'),\n );\n\n return containerQuad\n ? typeIndex.getThing(containerQuad.subject.value) ?? null\n : null;\n}\n","import type { JsonLD } from '@/helpers/jsonld';\nimport { pull } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n if (!containsPatterns(expected))\n return expected === actual;\n\n const patternAliases = [];\n\n if (!(expected in patternsRegExpsIndex)) {\n const patternMatches = expected.matchAll(/\\[\\[((.*)\\]\\[)?([^\\]]+)\\]\\]/g);\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n if (patternMatch[2]) {\n patternAliases.push(patternMatch[2]);\n }\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, pattern);\n }\n\n patternsRegExpsIndex[expected] = new RegExp(expectedRegExp);\n }\n\n return patternsRegExpsIndex[expected].test(actual);\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following ${operation} triple: ${quadToTurtle(expectedQuad)}`);\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'turtle matches');\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import { normalizeSparql } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n')\n : () => {\n return [\n result.message,\n utils.matcherHint(options.hint),\n ].join('\\n\\n');\n };\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n};\n\nexport default matchers;\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","documentUrl","documentFormat","malformationDetails","errorMessage","Error","NetworkRequestError","url","NotFoundError","UnauthorizedError","responseStatus","this","undefined","knownPrefixes","foaf","pim","purl","rdfs","schema","solid","vcard","expandIRI","iri","options","startsWith","split","prefix","name","expandedPrefix","extraContext","_options$extraContext","defaultPrefix","SolidThing","quads","property","find","quad","predicate","value","_this$quads$find","object","filter","map","SolidDocument","headers","statements","length","statement","get","_this$headers$get","match","parseDate","_this$statement","getLatestDocumentDate","subject","_this","_this2","dates","date","reduce","a","b","isJsonLDGraph","jsonld","fetchRawSolidDocument","fetch","Accept","response","status","includes","text","body","_context","normalizeBlankNodes","normalizedQuads","slice","quadsIndexes","blankNodeIds","arr","flatMap","index","ids","arrayFilter","termType","id","Set","add","unique","originalId","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","N3BlankNode","arrayReplace","N3Quad","createSolidDocument","window","turtleToQuads","method","Headers","fetchSolidDocument","data","jsonldToQuads","Promise","all","graphQuads","flat","toRDF","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","document","isEmpty","operations","matchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","turtle","parserOptions","objectWithoutEmpty","baseIRI","parser","TurtleParser","resolve","reject","parse","error","Turtle","message","push","updateSolidDocument","fetchUserProfile","webId","urlRoute","isPersonalProfile","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","_document$statement","_document$statement2","avatarUrl","_document$statement3","_document$statement4","oidcIssuerUrl","_document$statement5","publicTypeIndexUrl","privateTypeIndexUrl","loginUrl","fetchProfile","replace","urlRoot","mintPrivateTypeIndexUrl","user","storageUrl","typeIndexUrl","uuid","profileUpdateBody","childrenType","typeIndex","containerQuad","contains","getThing","patternsRegExpsIndex","containsPatterns","test","quadValueEquals","expected","actual","patternAliases","patternMatches","patterns","expectedRegExp","patternMatch","patternIndex","pattern","RegExp","quadEquals","datatype","Date","getTime","quadObjectEquals","resetPatterns","jsonldEquals","expectedQuads","actualQuads","expectedTurtle","actualTurtle","result","success","expectedQuad","some","actualQuad","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","assertions","graph","_obj","assert","bind","query","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","chai","use","_chai","forEach","Assertion","addMethod","expect","extend"],"mappings":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,UAAU5N,EAAM6E,+CCAzGgJ,OAAOC,OAAOV"}
@@ -1,2 +1,2 @@
1
- import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/inherits";import r from"@babel/runtime/helpers/esm/possibleConstructorReturn";import n from"@babel/runtime/helpers/esm/getPrototypeOf";import"core-js/modules/es.array.concat.js";import{Error as o,parseDate as s,objectWithoutEmpty as u,arr as a,arrayFilter as c,arrayReplace as i,silenced as l,urlParentDirectory as f,urlRoute as p,urlRoot as d,uuid as m,pull as v}from"@noeldemartin/utils";import h from"@babel/runtime/helpers/esm/createClass";import y from"@babel/runtime/helpers/esm/asyncToGenerator";import j from"@babel/runtime/regenerator";import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import b from"@babel/runtime/helpers/esm/toConsumableArray";import w from"@babel/runtime/helpers/esm/slicedToArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/esnext.set.add-all.js";import"core-js/modules/esnext.set.delete-all.js";import"core-js/modules/esnext.set.difference.js";import"core-js/modules/esnext.set.every.js";import"core-js/modules/esnext.set.filter.js";import"core-js/modules/esnext.set.find.js";import"core-js/modules/esnext.set.intersection.js";import"core-js/modules/esnext.set.is-disjoint-from.js";import"core-js/modules/esnext.set.is-subset-of.js";import"core-js/modules/esnext.set.is-superset-of.js";import"core-js/modules/esnext.set.join.js";import"core-js/modules/esnext.set.map.js";import"core-js/modules/esnext.set.reduce.js";import"core-js/modules/esnext.set.some.js";import"core-js/modules/esnext.set.symmetric-difference.js";import"core-js/modules/esnext.set.union.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.object.entries.js";import"core-js/modules/es.string.match-all.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.flat.js";import{Writer as x,Parser as g,BlankNode as k,Quad as T}from"n3";import{toRDF as E}from"jsonld";import R from"md5";import"core-js/modules/es.string.match.js";import"core-js/modules/es.array.find.js";import"core-js/modules/es.string.starts-with.js";import"core-js/modules/es.string.split.js";import A from"@babel/runtime/helpers/esm/typeof";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.string.includes.js";import I from"jest-diff";function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,s=n(e);if(t){var u=n(this).constructor;o=Reflect.construct(s,arguments,u)}else o=s.apply(this,arguments);return r(this,o)}}var P;!function(e){e.Turtle="Turtle"}(P||(P={}));var D=function(r){t(MalformedSolidDocumentError,o);var n=S(MalformedSolidDocumentError);function MalformedSolidDocumentError(t,r,o){var s;return e(this,MalformedSolidDocumentError),(s=n.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(t,r,o))).documentUrl=t,s.documentFormat=r,s.malformationDetails=o,s}return MalformedSolidDocumentError}();function U(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,s=n(e);if(t){var u=n(this).constructor;o=Reflect.construct(s,arguments,u)}else o=s.apply(this,arguments);return r(this,o)}}var q=function(r){t(NetworkRequestError,o);var n=U(NetworkRequestError);function NetworkRequestError(t){var r;return e(this,NetworkRequestError),(r=n.call(this,"Request failed trying to fetch ".concat(t))).url=t,r}return NetworkRequestError}();function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,s=n(e);if(t){var u=n(this).constructor;o=Reflect.construct(s,arguments,u)}else o=s.apply(this,arguments);return r(this,o)}}var C=function(r){t(NotFoundError,o);var n=N(NotFoundError);function NotFoundError(t){var r;return e(this,NotFoundError),(r=n.call(this,"Document with '".concat(t,"' url not found"))).url=t,r}return NotFoundError}();function B(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,s=n(e);if(t){var u=n(this).constructor;o=Reflect.construct(s,arguments,u)}else o=s.apply(this,arguments);return r(this,o)}}var O=function(r){t(UnauthorizedError,o);var n=B(UnauthorizedError);function UnauthorizedError(t,r){var o;return e(this,UnauthorizedError),(o=n.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(t,r))).url=t,o.responseStatus=r,o}return h(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(),z={foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdfs:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function M(e,t){z[e]=t}function L(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=w(r,2),o=n[0],s=n[1];if(s){var u,a,c,i=null!==(u=null!==(a=z[o])&&void 0!==a?a:null===(c=t.extraContext)||void 0===c?void 0:c[o])&&void 0!==u?u:null;if(!i)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return i+s}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+o}var F=function(){function t(r,n){e(this,t),this.url=r,this.quads=n}return h(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===L(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===L(e)})).map((function(e){return e.object.value}))}}]),t}(),$=function(){function t(r,n,o){e(this,t),this.url=r,this.quads=n,this.headers=o}return h(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,L("rdfs:type"),L("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=s(this.headers.get("last-modified")))&&void 0!==r?r:s(null===(n=this.statement(this.url,"purl:modified"))||void 0===n?void 0:n.object.value))&&void 0!==t?t:this.getLatestDocumentDate())&&void 0!==e?e:null}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(o){return!(r&&o.object.value!==L(r,{defaultPrefix:n.url})||e&&o.subject.value!==L(e,{defaultPrefix:n.url})||t&&o.predicate.value!==L(t,{defaultPrefix:n.url}))}))}},{key:"statement",value:function(e,t,r){var n=this,o=this.quads.find((function(o){return!(r&&o.object.value!==L(r,{defaultPrefix:n.url})||e&&o.subject.value!==L(e,{defaultPrefix:n.url})||t&&o.predicate.value!==L(t,{defaultPrefix:n.url}))}));return null!=o?o:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new F(e,t)}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(b(this.statements(void 0,"purl:modified")),b(this.statements(void 0,"purl:created"))).map((function(e){return s(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}}]),t}();function H(e){return"@graph"in e}function J(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return _(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw s}}}}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function G(e,t){return W.apply(this,arguments)}function W(){return(W=y(j.mark((function e(t,r){var n,o,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(o=e.sent).status){e.next=7;break}throw new C(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new O(t,o.status);case 9:return e.next=11,o.text();case 11:return s=e.sent,e.abrupt("return",{body:s,headers:o.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof O)){e.next=19;break}throw e.t0;case 19:throw new q(t);case 20:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function X(e){var t,r=e.slice(0),n={},o=a(e).flatMap((function(e,t){var r,o=c(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),s=J(o);try{for(s.s();!(r=s.n()).done;){var u,a=r.value;n[a]=null!==(u=n[a])&&void 0!==u?u:new Set,n[a].add(t)}}catch(e){s.e(e)}finally{s.f()}return o})).filter().unique(),s=J(o);try{var u=function(){var o,s=t.value,u=R(a(n[s]).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===s})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),c=J(n[s]);try{for(c.s();!(o=c.n()).done;){for(var l=o.value,f=r[l],p={subject:f.subject,object:f.object},d=0,m=Object.entries(p);d<m.length;d++){var v=w(m[d],2),h=v[0],y=v[1];"BlankNode"===y.termType&&y.value===s&&(p[h]=new k(u))}i(r,f,new T(p.subject,f.predicate,p.object))}}catch(e){c.e(e)}finally{c.f()}};for(s.s();!(t=s.n()).done;)u()}catch(e){s.e(e)}finally{s.f()}return r}function K(e,t,r){return Q.apply(this,arguments)}function Q(){return(Q=y(j.mark((function e(t,r,n){var o,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch,e.next=3,ie(r);case 3:return s=e.sent,e.next=6,n(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:r});case 6:return e.abrupt("return",new $(t,s,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function V(e,t){return Y.apply(this,arguments)}function Y(){return(Y=y(j.mark((function e(t,r){var n,o,s,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,G(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,s=n.headers,e.next=7,ie(o,{documentUrl:t});case 7:return u=e.sent,e.abrupt("return",new $(t,u,s));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Z(e){return ee.apply(this,arguments)}function ee(){return(ee=y(j.mark((function e(t){var r;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!H(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map(Z));case 3:return r=e.sent,e.abrupt("return",r.flat());case 5:return e.abrupt("return",E(t));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function te(e){var t=ce(e);return Object.entries(t).reduce((function(e,t){var r=w(t,2),n=r[0],o=r[1].map((function(e){return" "+ne(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function re(e){return(new x).quadsToString(e)}function ne(e){return(new x).quadsToString([e]).slice(0,-1)}function oe(e,t){return se.apply(this,arguments)}function se(){return(se=y(j.mark((function e(t,r){var n;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,V(t,r);case 3:return n=e.sent,e.abrupt("return",!n.isEmpty());case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ue(e){return ae.apply(this,arguments)}function ae(){return(ae=y(j.mark((function e(t){var r,n,o,s=arguments;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},n=t.matchAll(/(\w+) DATA {([^}]+)}/g),o={},e.next=5,Promise.all(b(n).map(function(){var e=y(j.mark((function e(t){var n,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),s=t[2],e.next=4,ie(s,r);case 4:o[n]=e.sent;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ce(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.matchAll(/(\w+) DATA {([^}]+)}/g),o={},s=J(n);try{for(s.s();!(t=s.n()).done;){var u=t.value,a=u[1].toLowerCase(),c=u[2];o[a]=fe(c,r)}}catch(e){s.e(e)}finally{s.f()}return o}function ie(e){return le.apply(this,arguments)}function le(){return(le=y(j.mark((function e(t){var r,n,o,s,a=arguments;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},n=u({baseIRI:r.documentUrl}),o=new g(n),s=[],e.abrupt("return",new Promise((function(e,n){o.parse(t,(function(t,o){var u;t?n(new D(null!==(u=r.documentUrl)&&void 0!==u?u:null,P.Turtle,t.message)):o?s.push(o):r.normalizeBlankNodes?e(X(s)):e(s)}))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=u({baseIRI:t.documentUrl}),n=new g(r);try{var o=n.parse(e);return t.normalizeBlankNodes?X(o):o}catch(e){var s;throw new D(null!==(s=t.documentUrl)&&void 0!==s?s:null,P.Turtle,e.message)}}function pe(e,t,r){return de.apply(this,arguments)}function de(){return(de=y(j.mark((function e(t,r,n){var o;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch,e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e,t){return ve.apply(this,arguments)}function ve(){return(ve=y(j.mark((function e(t,r){var n,o,s,a,c,i,d,m,v,h,y,b,w,x;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m=p(t),e.next=3,V(m,r);case 3:if((v=e.sent).isPersonalProfile()){e.next=6;break}throw new Error("Document at ".concat(m," is not a profile."));case 6:h=v.statements(t,"pim:storage").map((function(e){return e.object.value})),y=v.statement(t,"solid:publicTypeIndex"),b=v.statement(t,"solid:privateTypeIndex"),w=f(m);case 10:if(!w||0!==h.length){e.next=20;break}return e.next=13,l(V(w,r));case 13:if(null==(x=e.sent)||!x.isStorage()){e.next=17;break}return h.push(w),e.abrupt("break",20);case 17:w=f(w),e.next=10;break;case 20:return e.abrupt("return",u({webId:t,storageUrls:h,name:null!==(n=null===(o=v.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(s=v.statement(t,"foaf:name"))||void 0===s?void 0:s.object.value,avatarUrl:null!==(a=null===(c=v.statement(t,"vcard:hasPhoto"))||void 0===c?void 0:c.object.value)&&void 0!==a?a:null===(i=v.statement(t,"foaf:img"))||void 0===i?void 0:i.object.value,oidcIssuerUrl:null===(d=v.statement(t,"solid:oidcIssuer"))||void 0===d?void 0:d.object.value,publicTypeIndexUrl:null==y?void 0:y.object.value,privateTypeIndexUrl:null==b?void 0:b.object.value}));case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e,t){return ye.apply(this,arguments)}function ye(){return(ye=y(j.mark((function e(t,r){var n,o,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=l((function(e){return me(e,r)})),e.next=3,s(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,s(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,s(d(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(e,t){return be.apply(this,arguments)}function be(){return(be=y(j.mark((function e(t,r){var n,o,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,o=t.storageUrls[0],s="".concat(o,"settings/privateTypeIndex"),e.next=5,oe(s,r);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/privateTypeIndex-").concat(m()),e.next=10;break;case 9:e.t0=s;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(e,t){return xe.apply(this,arguments)}function xe(){return(xe=y(j.mark((function e(t,r){var n,o,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,e.next=3,je(t,r);case 3:return o=e.sent,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",s="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <").concat(o,"> .\n }\n "),K(o,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",r),pe(t.webId,s,r),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t,r){return ke.apply(this,arguments)}function ke(){return(ke=y(j.mark((function e(t,r,n){var o,s,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,V(t,n);case 2:return s=e.sent,u=s.statements(void 0,"rdfs:type","solid:TypeRegistration").find((function(e){return s.contains(e.subject.value,"solid:forClass",r)&&s.contains(e.subject.value,"solid:instanceContainer")})),e.abrupt("return",u&&null!==(o=s.getThing(u.subject.value))&&void 0!==o?o:null);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Ee(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ee(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw s}}}}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Re={};function Ae(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Ie(e,t){if(!Ae(e))return e===t;var r=[];if(!(e in Re)){var n,o=e.matchAll(/\[\[((.*)\]\[)?([^\]]+)\]\]/g),s=[],u=e,a=Te(o);try{for(a.s();!(n=a.n()).done;){var c=n.value;c[2]&&r.push(c[2]),s.push(c[3]),u=u.replace(c[0],"%PATTERN".concat(s.length-1,"%"))}}catch(e){a.e(e)}finally{a.f()}u=u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var i=0,l=Object.entries(s);i<l.length;i++){var f=w(l[i],2),p=f[0],d=f[1];u=u.replace("%PATTERN".concat(p,"%"),d)}Re[e]=new RegExp(u)}return Re[e].test(t)}function Se(e,t){return function(e,t){if(e.termType!==t.termType)return!1;if("Literal"===e.termType&&"Literal"===t.termType){if(e.datatype.value!==t.datatype.value)return!1;if(!Ae(e.value))return"http://www.w3.org/2001/XMLSchema#dateTime"===e.datatype.value?new Date(e.value).getTime()===new Date(t.value).getTime():e.value===t.value}return Ie(e.value,t.value)}(e.object,t.object)&&Ie(e.subject.value,t.subject.value)&&Ie(e.predicate.value,t.predicate.value)}function Pe(){Re={}}function De(e,t){return Ue.apply(this,arguments)}function Ue(){return(Ue=y(j.mark((function e(t,r){var n,o,s,u,a,c,i,l,f;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Pe(),e.next=3,Z(t);case 3:return n=e.sent,e.next=6,Z(r);case 6:if(o=e.sent,s=re(n),u=re(o),a=function(e,t){return{success:e,message:t,expected:s,actual:u}},n.length===o.length){e.next=12;break}return e.abrupt("return",a(!1,"Expected ".concat(n.length," triples, found ").concat(o.length,".")));case 12:c=Te(n),e.prev=13,l=function(){var e=i.value;if(!o.some((function(t){return Se(e,t)})))return{v:a(!1,"Couldn't find the following triple: ".concat(ne(e)))}},c.s();case 16:if((i=c.n()).done){e.next=22;break}if(f=l(),"object"!==A(f)){e.next=20;break}return e.abrupt("return",f.v);case 20:e.next=16;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(13),c.e(e.t0);case 27:return e.prev=27,c.f(),e.finish(27);case 30:return e.abrupt("return",a(!0,"jsonld matches"));case 31:case"end":return e.stop()}}),e,null,[[13,24,27,30]])})))).apply(this,arguments)}function qe(e,t){var r;Pe();for(var n=ce(e,{normalizeBlankNodes:!0}),o=ce(t,{normalizeBlankNodes:!0}),s=function(r,n){return{success:r,message:n,expected:e,actual:t}},u=0,a=Object.keys(n);u<a.length;u++){var c=a[u];if(!(c in o))return s(!1,"Couldn't find expected ".concat(c," operation."));var i=v(n,c),l=v(o,c);if(i.length!==l.length)return s(!1,"Expected ".concat(i.length," ").concat(c," triples, found ").concat(l.length,"."));var f,p=Te(i);try{var d=function(){var e=f.value;if(!l.some((function(t){return Se(e,t)})))return{v:s(!1,"Couldn't find the following ".concat(c," triple: ").concat(ne(e)))}};for(p.s();!(f=p.n()).done;){var m=d();if("object"===A(m))return m.v}}catch(e){p.e(e)}finally{p.f()}}var h=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return h?s(!1,"Did not expect to find ".concat(h," triples.")):s(!0,"sparql matches")}function Ne(e,t){Pe();var r=fe(e,{normalizeBlankNodes:!0}),n=fe(t,{normalizeBlankNodes:!0}),o=function(r,n){return{success:r,message:n,expected:e,actual:t}};if(r.length!==n.length)return o(!1,"Expected ".concat(r.length," triples, found ").concat(n.length,"."));var s,u=Te(r);try{var a=function(){var e=s.value;if(!n.some((function(t){return Se(e,t)})))return{v:o(!1,"Couldn't find the following triple: ".concat(ne(e)))}};for(u.s();!(s=u.n()).done;){var c=a();if("object"===A(c))return c.v}}catch(e){u.e(e)}finally{u.f()}return o(!0,"turtle matches")}var Ce={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=Ne(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=qe(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Be(){chai.use((function(e){return Object.entries(Ce).forEach((function(t){var r=w(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function Oe(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}:function(){var r=I(t.expected,t.received,{expand:t.context.expand});return[e.message,n.matcherHint(t.hint),r&&r.includes("- Expect")?"Difference:\n\n".concat(r):["Expected: ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}}}var ze={toEqualJsonLD:function(e,t){var r=this;return y(j.mark((function n(){var o;return j.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,De(t,e);case 2:return o=n.sent,n.abrupt("return",Oe(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Oe(qe(t,e),{context:this,hint:"toEqualSparql",expected:te(t),received:te(e)})}};function Me(){expect.extend(ze)}export{D as MalformedSolidDocumentError,q as NetworkRequestError,C as NotFoundError,$ as SolidDocument,P as SolidDocumentFormat,F as SolidThing,O as UnauthorizedError,we as createPrivateTypeIndex,K as createSolidDocument,M as defineIRIPrefix,L as expandIRI,he as fetchLoginUserProfile,V as fetchSolidDocument,ge as findContainerRegistration,Be as installChaiPlugin,Me as installJestPlugin,H as isJsonLDGraph,De as jsonldEquals,Z as jsonldToQuads,te as normalizeSparql,ne as quadToTurtle,re as quadsToTurtle,oe as solidDocumentExists,qe as sparqlEquals,ue as sparqlToQuads,ce as sparqlToQuadsSync,Ne as turtleEquals,ie as turtleToQuads,fe as turtleToQuadsSync,pe as updateSolidDocument};
1
+ import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/inherits";import r from"@babel/runtime/helpers/esm/possibleConstructorReturn";import n from"@babel/runtime/helpers/esm/getPrototypeOf";import"core-js/modules/es.array.concat.js";import{Error as o,parseDate as u,objectWithoutEmpty as s,arr as a,arrayFilter as c,arrayReplace as i,silenced as l,urlParentDirectory as f,urlRoute as p,urlRoot as d,uuid as m,pull as v}from"@noeldemartin/utils";import h from"@babel/runtime/helpers/esm/createClass";import y from"@babel/runtime/helpers/esm/asyncToGenerator";import j from"@babel/runtime/regenerator";import"core-js/modules/es.array.map.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import b from"@babel/runtime/helpers/esm/toConsumableArray";import w from"@babel/runtime/helpers/esm/slicedToArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/esnext.set.add-all.js";import"core-js/modules/esnext.set.delete-all.js";import"core-js/modules/esnext.set.difference.js";import"core-js/modules/esnext.set.every.js";import"core-js/modules/esnext.set.filter.js";import"core-js/modules/esnext.set.find.js";import"core-js/modules/esnext.set.intersection.js";import"core-js/modules/esnext.set.is-disjoint-from.js";import"core-js/modules/esnext.set.is-subset-of.js";import"core-js/modules/esnext.set.is-superset-of.js";import"core-js/modules/esnext.set.join.js";import"core-js/modules/esnext.set.map.js";import"core-js/modules/esnext.set.reduce.js";import"core-js/modules/esnext.set.some.js";import"core-js/modules/esnext.set.symmetric-difference.js";import"core-js/modules/esnext.set.union.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.join.js";import"core-js/modules/es.object.entries.js";import"core-js/modules/es.string.match-all.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.flat.js";import{Writer as x,Parser as g,BlankNode as k,Quad as T}from"n3";import{toRDF as E}from"jsonld";import R from"md5";import"core-js/modules/es.string.match.js";import"core-js/modules/es.array.find.js";import"core-js/modules/es.string.starts-with.js";import"core-js/modules/es.string.split.js";import A from"@babel/runtime/helpers/esm/typeof";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.object.keys.js";import"core-js/modules/web.dom-collections.for-each.js";function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,u=n(e);if(t){var s=n(this).constructor;o=Reflect.construct(u,arguments,s)}else o=u.apply(this,arguments);return r(this,o)}}var S;!function(e){e.Turtle="Turtle"}(S||(S={}));var P=function(r){t(MalformedSolidDocumentError,o);var n=I(MalformedSolidDocumentError);function MalformedSolidDocumentError(t,r,o){var u;return e(this,MalformedSolidDocumentError),(u=n.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(t,r,o))).documentUrl=t,u.documentFormat=r,u.malformationDetails=o,u}return MalformedSolidDocumentError}();function U(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,u=n(e);if(t){var s=n(this).constructor;o=Reflect.construct(u,arguments,s)}else o=u.apply(this,arguments);return r(this,o)}}var q=function(r){t(NetworkRequestError,o);var n=U(NetworkRequestError);function NetworkRequestError(t){var r;return e(this,NetworkRequestError),(r=n.call(this,"Request failed trying to fetch ".concat(t))).url=t,r}return NetworkRequestError}();function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,u=n(e);if(t){var s=n(this).constructor;o=Reflect.construct(u,arguments,s)}else o=u.apply(this,arguments);return r(this,o)}}var N=function(r){t(NotFoundError,o);var n=D(NotFoundError);function NotFoundError(t){var r;return e(this,NotFoundError),(r=n.call(this,"Document with '".concat(t,"' url not found"))).url=t,r}return NotFoundError}();function C(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,u=n(e);if(t){var s=n(this).constructor;o=Reflect.construct(u,arguments,s)}else o=u.apply(this,arguments);return r(this,o)}}var B=function(r){t(UnauthorizedError,o);var n=C(UnauthorizedError);function UnauthorizedError(t,r){var o;return e(this,UnauthorizedError),(o=n.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(t,r))).url=t,o.responseStatus=r,o}return h(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(),O={foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdfs:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function z(e,t){O[e]=t}function M(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=w(r,2),o=n[0],u=n[1];if(u){var s,a,c,i=null!==(s=null!==(a=O[o])&&void 0!==a?a:null===(c=t.extraContext)||void 0===c?void 0:c[o])&&void 0!==s?s:null;if(!i)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return i+u}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+o}var L=function(){function t(r,n){e(this,t),this.url=r,this.quads=n}return h(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===M(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===M(e)})).map((function(e){return e.object.value}))}}]),t}(),F=function(){function t(r,n,o){e(this,t),this.url=r,this.quads=n,this.headers=o}return h(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,M("rdfs:type"),M("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=u(this.headers.get("last-modified")))&&void 0!==r?r:u(null===(n=this.statement(this.url,"purl:modified"))||void 0===n?void 0:n.object.value))&&void 0!==t?t:this.getLatestDocumentDate())&&void 0!==e?e:null}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(o){return!(r&&o.object.value!==M(r,{defaultPrefix:n.url})||e&&o.subject.value!==M(e,{defaultPrefix:n.url})||t&&o.predicate.value!==M(t,{defaultPrefix:n.url}))}))}},{key:"statement",value:function(e,t,r){var n=this,o=this.quads.find((function(o){return!(r&&o.object.value!==M(r,{defaultPrefix:n.url})||e&&o.subject.value!==M(e,{defaultPrefix:n.url})||t&&o.predicate.value!==M(t,{defaultPrefix:n.url}))}));return null!=o?o:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new L(e,t)}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(b(this.statements(void 0,"purl:modified")),b(this.statements(void 0,"purl:created"))).map((function(e){return u(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}}]),t}();function $(e){return"@graph"in e}function H(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return J(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return J(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,u=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw u}}}}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _(e,t){return G.apply(this,arguments)}function G(){return(G=y(j.mark((function e(t,r){var n,o,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(o=e.sent).status){e.next=7;break}throw new N(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new B(t,o.status);case 9:return e.next=11,o.text();case 11:return u=e.sent,e.abrupt("return",{body:u,headers:o.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof B)){e.next=19;break}throw e.t0;case 19:throw new q(t);case 20:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function W(e){var t,r=e.slice(0),n={},o=a(e).flatMap((function(e,t){var r,o=c(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),u=H(o);try{for(u.s();!(r=u.n()).done;){var s,a=r.value;n[a]=null!==(s=n[a])&&void 0!==s?s:new Set,n[a].add(t)}}catch(e){u.e(e)}finally{u.f()}return o})).filter().unique(),u=H(o);try{var s=function(){var o,u=t.value,s=R(a(n[u]).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===u})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),c=H(n[u]);try{for(c.s();!(o=c.n()).done;){for(var l=o.value,f=r[l],p={subject:f.subject,object:f.object},d=0,m=Object.entries(p);d<m.length;d++){var v=w(m[d],2),h=v[0],y=v[1];"BlankNode"===y.termType&&y.value===u&&(p[h]=new k(s))}i(r,f,new T(p.subject,f.predicate,p.object))}}catch(e){c.e(e)}finally{c.f()}};for(u.s();!(t=u.n()).done;)s()}catch(e){u.e(e)}finally{u.f()}return r}function X(e,t,r){return K.apply(this,arguments)}function K(){return(K=y(j.mark((function e(t,r,n){var o,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch,e.next=3,ce(r);case 3:return u=e.sent,e.next=6,n(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:r});case 6:return e.abrupt("return",new F(t,u,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Q(e,t){return V.apply(this,arguments)}function V(){return(V=y(j.mark((function e(t,r){var n,o,u,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,_(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,u=n.headers,e.next=7,ce(o,{documentUrl:t});case 7:return s=e.sent,e.abrupt("return",new F(t,s,u));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Y(e){return Z.apply(this,arguments)}function Z(){return(Z=y(j.mark((function e(t){var r;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map(Y));case 3:return r=e.sent,e.abrupt("return",r.flat());case 5:return e.abrupt("return",E(t));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ee(e){var t=ae(e);return Object.entries(t).reduce((function(e,t){var r=w(t,2),n=r[0],o=r[1].map((function(e){return" "+re(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function te(e){return(new x).quadsToString(e)}function re(e){return(new x).quadsToString([e]).slice(0,-1)}function ne(e,t){return oe.apply(this,arguments)}function oe(){return(oe=y(j.mark((function e(t,r){var n;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Q(t,r);case 3:return n=e.sent,e.abrupt("return",!n.isEmpty());case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ue(e){return se.apply(this,arguments)}function se(){return(se=y(j.mark((function e(t){var r,n,o,u=arguments;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=t.matchAll(/(\w+) DATA {([^}]+)}/g),o={},e.next=5,Promise.all(b(n).map(function(){var e=y(j.mark((function e(t){var n,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),u=t[2],e.next=4,ce(u,r);case 4:o[n]=e.sent;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ae(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.matchAll(/(\w+) DATA {([^}]+)}/g),o={},u=H(n);try{for(u.s();!(t=u.n()).done;){var s=t.value,a=s[1].toLowerCase(),c=s[2];o[a]=le(c,r)}}catch(e){u.e(e)}finally{u.f()}return o}function ce(e){return ie.apply(this,arguments)}function ie(){return(ie=y(j.mark((function e(t){var r,n,o,u,a=arguments;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]?a[1]:{},n=s({baseIRI:r.documentUrl}),o=new g(n),u=[],e.abrupt("return",new Promise((function(e,n){o.parse(t,(function(t,o){var s;t?n(new P(null!==(s=r.documentUrl)&&void 0!==s?s:null,S.Turtle,t.message)):o?u.push(o):r.normalizeBlankNodes?e(W(u)):e(u)}))})));case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function le(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=s({baseIRI:t.documentUrl}),n=new g(r);try{var o=n.parse(e);return t.normalizeBlankNodes?W(o):o}catch(e){var u;throw new P(null!==(u=t.documentUrl)&&void 0!==u?u:null,S.Turtle,e.message)}}function fe(e,t,r){return pe.apply(this,arguments)}function pe(){return(pe=y(j.mark((function e(t,r,n){var o;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch,e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function de(e,t){return me.apply(this,arguments)}function me(){return(me=y(j.mark((function e(t,r){var n,o,u,a,c,i,d,m,v,h,y,b,w,x;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m=p(t),e.next=3,Q(m,r);case 3:if((v=e.sent).isPersonalProfile()){e.next=6;break}throw new Error("Document at ".concat(m," is not a profile."));case 6:h=v.statements(t,"pim:storage").map((function(e){return e.object.value})),y=v.statement(t,"solid:publicTypeIndex"),b=v.statement(t,"solid:privateTypeIndex"),w=f(m);case 10:if(!w||0!==h.length){e.next=20;break}return e.next=13,l(Q(w,r));case 13:if(null==(x=e.sent)||!x.isStorage()){e.next=17;break}return h.push(w),e.abrupt("break",20);case 17:w=f(w),e.next=10;break;case 20:return e.abrupt("return",s({webId:t,storageUrls:h,name:null!==(n=null===(o=v.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(u=v.statement(t,"foaf:name"))||void 0===u?void 0:u.object.value,avatarUrl:null!==(a=null===(c=v.statement(t,"vcard:hasPhoto"))||void 0===c?void 0:c.object.value)&&void 0!==a?a:null===(i=v.statement(t,"foaf:img"))||void 0===i?void 0:i.object.value,oidcIssuerUrl:null===(d=v.statement(t,"solid:oidcIssuer"))||void 0===d?void 0:d.object.value,publicTypeIndexUrl:null==y?void 0:y.object.value,privateTypeIndexUrl:null==b?void 0:b.object.value}));case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(e,t){return he.apply(this,arguments)}function he(){return(he=y(j.mark((function e(t,r){var n,o,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=l((function(e){return de(e,r)})),e.next=3,u(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,u(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,u(d(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ye(e,t){return je.apply(this,arguments)}function je(){return(je=y(j.mark((function e(t,r){var n,o,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,o=t.storageUrls[0],u="".concat(o,"settings/privateTypeIndex"),e.next=5,ne(u,r);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/privateTypeIndex-").concat(m()),e.next=10;break;case 9:e.t0=u;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function be(e,t){return we.apply(this,arguments)}function we(){return(we=y(j.mark((function e(t,r){var n,o,u;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch,e.next=3,ye(t,r);case 3:return o=e.sent,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",u="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <").concat(o,"> .\n }\n "),X(o,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",r),fe(t.webId,u,r),e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(e,t,r){return ge.apply(this,arguments)}function ge(){return(ge=y(j.mark((function e(t,r,n){var o,u,s;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Q(t,n);case 2:return u=e.sent,s=u.statements(void 0,"rdfs:type","solid:TypeRegistration").find((function(e){return u.contains(e.subject.value,"solid:forClass",r)&&u.contains(e.subject.value,"solid:instanceContainer")})),e.abrupt("return",s&&null!==(o=u.getThing(s.subject.value))&&void 0!==o?o:null);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ke(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return Te(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Te(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,s=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){a=!0,u=e},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw u}}}}function Te(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Ee={};function Re(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Ae(e,t){if(!Re(e))return e===t;var r=[];if(!(e in Ee)){var n,o=e.matchAll(/\[\[((.*)\]\[)?([^\]]+)\]\]/g),u=[],s=e,a=ke(o);try{for(a.s();!(n=a.n()).done;){var c=n.value;c[2]&&r.push(c[2]),u.push(c[3]),s=s.replace(c[0],"%PATTERN".concat(u.length-1,"%"))}}catch(e){a.e(e)}finally{a.f()}s=s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var i=0,l=Object.entries(u);i<l.length;i++){var f=w(l[i],2),p=f[0],d=f[1];s=s.replace("%PATTERN".concat(p,"%"),d)}Ee[e]=new RegExp(s)}return Ee[e].test(t)}function Ie(e,t){return function(e,t){if(e.termType!==t.termType)return!1;if("Literal"===e.termType&&"Literal"===t.termType){if(e.datatype.value!==t.datatype.value)return!1;if(!Re(e.value))return"http://www.w3.org/2001/XMLSchema#dateTime"===e.datatype.value?new Date(e.value).getTime()===new Date(t.value).getTime():e.value===t.value}return Ae(e.value,t.value)}(e.object,t.object)&&Ae(e.subject.value,t.subject.value)&&Ae(e.predicate.value,t.predicate.value)}function Se(){Ee={}}function Pe(e,t){return Ue.apply(this,arguments)}function Ue(){return(Ue=y(j.mark((function e(t,r){var n,o,u,s,a,c,i,l,f;return j.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Se(),e.next=3,Y(t);case 3:return n=e.sent,e.next=6,Y(r);case 6:if(o=e.sent,u=te(n),s=te(o),a=function(e,t){return{success:e,message:t,expected:u,actual:s}},n.length===o.length){e.next=12;break}return e.abrupt("return",a(!1,"Expected ".concat(n.length," triples, found ").concat(o.length,".")));case 12:c=ke(n),e.prev=13,l=function(){var e=i.value;if(!o.some((function(t){return Ie(e,t)})))return{v:a(!1,"Couldn't find the following triple: ".concat(re(e)))}},c.s();case 16:if((i=c.n()).done){e.next=22;break}if(f=l(),"object"!==A(f)){e.next=20;break}return e.abrupt("return",f.v);case 20:e.next=16;break;case 22:e.next=27;break;case 24:e.prev=24,e.t0=e.catch(13),c.e(e.t0);case 27:return e.prev=27,c.f(),e.finish(27);case 30:return e.abrupt("return",a(!0,"jsonld matches"));case 31:case"end":return e.stop()}}),e,null,[[13,24,27,30]])})))).apply(this,arguments)}function qe(e,t){var r;Se();for(var n=ae(e,{normalizeBlankNodes:!0}),o=ae(t,{normalizeBlankNodes:!0}),u=function(r,n){return{success:r,message:n,expected:e,actual:t}},s=0,a=Object.keys(n);s<a.length;s++){var c=a[s];if(!(c in o))return u(!1,"Couldn't find expected ".concat(c," operation."));var i=v(n,c),l=v(o,c);if(i.length!==l.length)return u(!1,"Expected ".concat(i.length," ").concat(c," triples, found ").concat(l.length,"."));var f,p=ke(i);try{var d=function(){var e=f.value;if(!l.some((function(t){return Ie(e,t)})))return{v:u(!1,"Couldn't find the following ".concat(c," triple: ").concat(re(e)))}};for(p.s();!(f=p.n()).done;){var m=d();if("object"===A(m))return m.v}}catch(e){p.e(e)}finally{p.f()}}var h=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return h?u(!1,"Did not expect to find ".concat(h," triples.")):u(!0,"sparql matches")}function De(e,t){Se();var r=le(e,{normalizeBlankNodes:!0}),n=le(t,{normalizeBlankNodes:!0}),o=function(r,n){return{success:r,message:n,expected:e,actual:t}};if(r.length!==n.length)return o(!1,"Expected ".concat(r.length," triples, found ").concat(n.length,"."));var u,s=ke(r);try{var a=function(){var e=u.value;if(!n.some((function(t){return Ie(e,t)})))return{v:o(!1,"Couldn't find the following triple: ".concat(re(e)))}};for(s.s();!(u=s.n()).done;){var c=a();if("object"===A(c))return c.v}}catch(e){s.e(e)}finally{s.f()}return o(!0,"turtle matches")}var Ne={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=De(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=qe(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Ce(){chai.use((function(e){return Object.entries(Ne).forEach((function(t){var r=w(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function Be(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}:function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}}}var Oe={toEqualJsonLD:function(e,t){var r=this;return y(j.mark((function n(){var o;return j.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Pe(t,e);case 2:return o=n.sent,n.abrupt("return",Be(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Be(qe(t,e),{context:this,hint:"toEqualSparql",expected:ee(t),received:ee(e)})}};function ze(){expect.extend(Oe)}export{P as MalformedSolidDocumentError,q as NetworkRequestError,N as NotFoundError,F as SolidDocument,S as SolidDocumentFormat,L as SolidThing,B as UnauthorizedError,be as createPrivateTypeIndex,X as createSolidDocument,z as defineIRIPrefix,M as expandIRI,ve as fetchLoginUserProfile,Q as fetchSolidDocument,xe as findContainerRegistration,Ce as installChaiPlugin,ze as installJestPlugin,$ as isJsonLDGraph,Pe as jsonldEquals,Y as jsonldToQuads,ee as normalizeSparql,re as quadToTurtle,te as quadsToTurtle,ne as solidDocumentExists,qe as sparqlEquals,ue as sparqlToQuads,ae as sparqlToQuadsSync,De as turtleEquals,ce as turtleToQuads,le as turtleToQuadsSync,fe as updateSolidDocument};
2
2
  //# sourceMappingURL=noeldemartin-solid-utils.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"noeldemartin-solid-utils.esm.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/plugins/chai/assertions.ts","../src/plugins/chai/index.ts","../src/plugins/jest/matchers.ts","../src/plugins/jest/index.ts"],"sourcesContent":["import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends Error {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Request failed trying to fetch ${url}`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends Error {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n foaf: 'http://xmlns.com/foaf/0.1/',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdfs: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http'))\n return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter(quad => quad.predicate.value === expandIRI(property))\n .map(quad => quad.object.value);\n }\n\n}\n","import { parseDate } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidDocument {\n\n public readonly url: string;\n public readonly headers: Headers;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n this.url = url;\n this.quads = quads;\n this.headers = headers;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdfs:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public getLastModified(): Date | null {\n return parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\n .map(statement => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => a > b ? a : b) : null;\n }\n\n}\n","export type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = { '@graph': JsonLDResource[] };\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import { arr, arrayFilter, arrayReplace,objectWithoutEmpty } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser as TurtleParser, Writer as TurtleWriter } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport { toRDF } from 'jsonld';\nimport md5 from 'md5';\nimport type { Quad } from 'rdf-js';\nimport type { Term as N3Term } from 'n3';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<any>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nasync function fetchRawSolidDocument(url: string, fetch: Fetch): Promise<{ body: string; headers: Headers }> {\n const options = {\n headers: { Accept: 'text/turtle' },\n };\n\n try {\n const response = await fetch(url, options);\n\n if (response.status === 404)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError)\n throw error;\n\n throw new NetworkRequestError(url);\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) => {\n const ids = arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]);\n\n for (const id of ids) {\n quadsIndexes[id] = quadsIndexes[id] ?? new Set();\n quadsIndexes[id].add(index);\n }\n\n return ids;\n })\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const normalizedId = md5(\n arr(quadsIndexes[originalId])\n .map(index => quads[index])\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\n .sorted()\n .join(),\n );\n\n for (const index of quadsIndexes[originalId]) {\n const quad = normalizedQuads[index];\n const terms: Record<string, N3Term> = { subject: quad.subject as N3Term, object: quad.object as N3Term };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = new N3BlankNode(normalizedId);\n }\n\n arrayReplace(normalizedQuads, quad, new N3Quad(terms.subject, quad.predicate as N3Term, terms.object));\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n documentUrl: string;\n normalizeBlankNodes: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch;\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, fetch?: Fetch): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, fetch ?? window.fetch);\n const statements = await turtleToQuads(data, { documentUrl: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(jsonldToQuads));\n\n return graphQuads.flat();\n }\n\n return toRDF(jsonld as JsonLdDocument) as Promise<Quad[]>;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object\n .entries(quads)\n .reduce((normalizedOperations, [operation, quads]) => {\n const normalizedQuads = quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all([...operations].map(async operation => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }));\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n const quads: Quad[] = [];\n\n return new Promise((resolve, reject) => {\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.documentUrl ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n return;\n }\n\n if (!quad) {\n options.normalizeBlankNodes\n ? resolve(normalizeBlankNodes(quads))\n : resolve(quads);\n\n return;\n }\n\n quads.push(quad);\n });\n });\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(options.documentUrl ?? null, SolidDocumentFormat.Turtle, error.message);\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch;\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUserProfile> {\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, fetch);\n\n if (!document.isPersonalProfile())\n throw new Error(`Document at ${documentUrl} is not a profile.`);\n\n const storageUrls = document.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = document.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = document.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, fetch));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n return objectWithoutEmpty({\n webId,\n storageUrls,\n name:\n document.statement(webId, 'vcard:fn')?.object.value ??\n document.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n document.statement(webId, 'vcard:hasPhoto')?.object.value ??\n document.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: document.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n });\n}\n\nexport async function fetchLoginUserProfile(loginUrl: string, fetch?: Fetch): Promise<SolidUserProfile | null> {\n const fetchProfile = silenced(url => fetchUserProfile(url, fetch));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type SolidThing from '@/models/SolidThing';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\nasync function mintPrivateTypeIndexUrl(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/privateTypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/privateTypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const typeIndexUrl = await mintPrivateTypeIndexUrl(user, fetch);\n const typeIndexBody = `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n updateSolidDocument(user.webId, profileUpdateBody, fetch);\n\n return typeIndexUrl;\n}\n\nexport async function findContainerRegistration(\n typeIndexUrl: string,\n childrenType: string,\n fetch?: Fetch,\n): Promise<SolidThing | null> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const containerQuad = typeIndex\n .statements(undefined, 'rdfs:type', 'solid:TypeRegistration')\n .find(\n statement =>\n typeIndex.contains(statement.subject.value, 'solid:forClass', childrenType) &&\n typeIndex.contains(statement.subject.value, 'solid:instanceContainer'),\n );\n\n return containerQuad\n ? typeIndex.getThing(containerQuad.subject.value) ?? null\n : null;\n}\n","import type { JsonLD } from '@/helpers/jsonld';\nimport { pull } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n if (!containsPatterns(expected))\n return expected === actual;\n\n const patternAliases = [];\n\n if (!(expected in patternsRegExpsIndex)) {\n const patternMatches = expected.matchAll(/\\[\\[((.*)\\]\\[)?([^\\]]+)\\]\\]/g);\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n if (patternMatch[2]) {\n patternAliases.push(patternMatch[2]);\n }\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, pattern);\n }\n\n patternsRegExpsIndex[expected] = new RegExp(expectedRegExp);\n }\n\n return patternsRegExpsIndex[expected].test(actual);\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following ${operation} triple: ${quadToTurtle(expectedQuad)}`);\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'turtle matches');\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import diff from 'jest-diff';\n\nimport { normalizeSparql } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n')\n : () => {\n const diffString = diff(options.expected, options.received, {\n expand: options.context.expand,\n });\n\n return [\n result.message,\n utils.matcherHint(options.hint),\n diffString && diffString.includes('- Expect')\n ? `Difference:\\n\\n${diffString}`\n : [\n `Expected: ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n');\n };\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n};\n\nexport default matchers;\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","Error","documentUrl","documentFormat","malformationDetails","errorMessage","NetworkRequestError","url","NotFoundError","UnauthorizedError","responseStatus","this","undefined","knownPrefixes","foaf","pim","purl","rdfs","schema","solid","vcard","defineIRIPrefix","name","value","expandIRI","iri","options","startsWith","split","prefix","expandedPrefix","extraContext","_options$extraContext","defaultPrefix","SolidThing","quads","property","find","quad","predicate","_this$quads$find","object","filter","map","SolidDocument","headers","statements","length","statement","get","_this$headers$get","match","parseDate","_this$statement","getLatestDocumentDate","subject","_this","_this2","dates","date","reduce","a","b","isJsonLDGraph","jsonld","fetchRawSolidDocument","fetch","Accept","response","status","includes","text","body","_context","normalizeBlankNodes","normalizedQuads","slice","quadsIndexes","blankNodeIds","arr","flatMap","index","ids","arrayFilter","termType","id","Set","add","unique","originalId","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","N3BlankNode","arrayReplace","N3Quad","createSolidDocument","window","turtleToQuads","method","Headers","fetchSolidDocument","data","jsonldToQuads","Promise","all","graphQuads","flat","toRDF","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","document","isEmpty","sparqlToQuads","operations","matchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","turtle","parserOptions","objectWithoutEmpty","baseIRI","parser","TurtleParser","resolve","reject","parse","error","Turtle","message","push","updateSolidDocument","fetchUserProfile","webId","urlRoute","isPersonalProfile","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","_document$statement","_document$statement2","avatarUrl","_document$statement3","_document$statement4","oidcIssuerUrl","_document$statement5","publicTypeIndexUrl","privateTypeIndexUrl","fetchLoginUserProfile","loginUrl","fetchProfile","replace","urlRoot","mintPrivateTypeIndexUrl","user","storageUrl","typeIndexUrl","uuid","createPrivateTypeIndex","profileUpdateBody","findContainerRegistration","childrenType","typeIndex","containerQuad","contains","getThing","patternsRegExpsIndex","containsPatterns","test","quadValueEquals","expected","actual","patternAliases","patternMatches","patterns","expectedRegExp","patternMatch","patternIndex","pattern","RegExp","quadEquals","datatype","Date","getTime","quadObjectEquals","resetPatterns","jsonldEquals","expectedQuads","actualQuads","expectedTurtle","actualTurtle","result","success","expectedQuad","some","actualQuad","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","assertions","graph","_obj","assert","bind","query","installChaiPlugin","chai","use","_chai","forEach","Assertion","addMethod","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","diffString","diff","expand","matchers","toEqualJsonLD","toEqualSparql","installJestPlugin","expect","extend"],"mappings":"iiHAYYA,GAAZ,SAAYA,GACRA,kBADJ,CAAYA,IAAAA,WAISC,4CAAoCC,6EAMzCC,EAA4BC,EAAqCC,mEApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,KAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,qdCzBdE,oCAA4BL,6DAIjCM,oGACgCA,KAEnCA,IAAMA,6cCPEC,8BAAsBP,iDAI3BM,8EACgBA,uBAEnBA,IAAMA,ucCDEE,kCAA0BR,yDAK/BM,EAAaG,yDAX7B,SAAsBH,EAAaG,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBH,GASzBF,CAAaE,EAAKG,KAEnBH,IAAMA,IACNG,eAAiBA,qDAG1B,uBAC0C,IAAxBC,KAAKD,eACW,MAAxBC,KAAKD,oBACLE,2BChBRC,EAA4B,CAC9BC,KAAM,6BACNC,IAAK,kCACLC,KAAM,4BACNC,KAAM,8CACNC,OAAQ,sBACRC,MAAO,oCACPC,MAAO,6CAGKC,EAAgBC,EAAcC,GAC1CV,EAAcS,GAAQC,WAGVC,EAAUC,OAAaC,yDAAqC,MACpED,EAAIE,WAAW,QACf,OAAOF,QAEYA,EAAIG,MAAM,cAA1BC,OAAQP,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ME,YAAY5N,EAAQ6N,MAC1B,yBACqBH,EAAMI,cAAc9N,EAAQ0K,+BAChCgD,EAAMK,cAAc/N,EAAQgO,YAC3C7J,KAAK,OACTA,KAAK,SACL,eACQ8J,EAAaC,EAAKlO,EAAQ0K,SAAU1K,EAAQgO,SAAU,CACxDG,OAAQnO,EAAQ2N,QAAQQ,eAGrB,CACHpC,EAAOpE,QACP+F,EAAME,YAAY5N,EAAQ6N,MAC1BI,GAAcA,EAAWrL,SAAS,qCACVqL,GAClB,qBACeP,EAAMI,cAAc9N,EAAQ0K,+BAC5BgD,EAAMK,cAAc/N,EAAQgO,YAC3C7J,KAAK,OACbA,KAAK,UAMnB,IAAMiK,GAAiC,CAC7BC,uBAAcL,EAAUtD,iIACLgB,GAAahB,EAAUsD,iBAAtCjC,2BAECyB,GAAazB,EAAQ,CACxB4B,QAAS7L,EACT+L,KAAM,gBACNnD,SAAAA,EACAsD,SAAAA,mDAGRM,uBAAcN,EAAUtD,UAGb8C,GAFQpB,GAAa1B,EAAUsD,GAEV,CACxBL,QAAS1O,KACT4O,KAAM,gBACNnD,SAAUjF,GAAgBiF,GAC1BsD,SAAUvI,GAAgBuI,gBC7DtBO,KACZC,OAAOC,OAAOL"}
1
+ {"version":3,"file":"noeldemartin-solid-utils.esm.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/plugins/chai/assertions.ts","../src/plugins/chai/index.ts","../src/plugins/jest/matchers.ts","../src/plugins/jest/index.ts"],"sourcesContent":["import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends Error {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Request failed trying to fetch ${url}`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends Error {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { Error } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends Error {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n foaf: 'http://xmlns.com/foaf/0.1/',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdfs: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http'))\n return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter(quad => quad.predicate.value === expandIRI(property))\n .map(quad => quad.object.value);\n }\n\n}\n","import { parseDate } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidDocument {\n\n public readonly url: string;\n public readonly headers: Headers;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n this.url = url;\n this.quads = quads;\n this.headers = headers;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdfs:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public getLastModified(): Date | null {\n return parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === expandIRI(object, { defaultPrefix: this.url })) &&\n (!subject || statement.subject.value === expandIRI(subject, { defaultPrefix: this.url })) &&\n (!predicate || statement.predicate.value === expandIRI(predicate, { defaultPrefix: this.url })),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\n .map(statement => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => a > b ? a : b) : null;\n }\n\n}\n","export type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = { '@graph': JsonLDResource[] };\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import { arr, arrayFilter, arrayReplace,objectWithoutEmpty } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser as TurtleParser, Writer as TurtleWriter } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport { toRDF } from 'jsonld';\nimport md5 from 'md5';\nimport type { Quad } from 'rdf-js';\nimport type { Term as N3Term } from 'n3';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<any>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nasync function fetchRawSolidDocument(url: string, fetch: Fetch): Promise<{ body: string; headers: Headers }> {\n const options = {\n headers: { Accept: 'text/turtle' },\n };\n\n try {\n const response = await fetch(url, options);\n\n if (response.status === 404)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError)\n throw error;\n\n throw new NetworkRequestError(url);\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) => {\n const ids = arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]);\n\n for (const id of ids) {\n quadsIndexes[id] = quadsIndexes[id] ?? new Set();\n quadsIndexes[id].add(index);\n }\n\n return ids;\n })\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const normalizedId = md5(\n arr(quadsIndexes[originalId])\n .map(index => quads[index])\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\n .sorted()\n .join(),\n );\n\n for (const index of quadsIndexes[originalId]) {\n const quad = normalizedQuads[index];\n const terms: Record<string, N3Term> = { subject: quad.subject as N3Term, object: quad.object as N3Term };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = new N3BlankNode(normalizedId);\n }\n\n arrayReplace(normalizedQuads, quad, new N3Quad(terms.subject, quad.predicate as N3Term, terms.object));\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n documentUrl: string;\n normalizeBlankNodes: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch;\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, fetch?: Fetch): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, fetch ?? window.fetch);\n const statements = await turtleToQuads(data, { documentUrl: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(jsonldToQuads));\n\n return graphQuads.flat();\n }\n\n return toRDF(jsonld as JsonLdDocument) as Promise<Quad[]>;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object\n .entries(quads)\n .reduce((normalizedOperations, [operation, quads]) => {\n const normalizedQuads = quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all([...operations].map(async operation => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }));\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = sparql.matchAll(/(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n const quads: Quad[] = [];\n\n return new Promise((resolve, reject) => {\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.documentUrl ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n return;\n }\n\n if (!quad) {\n options.normalizeBlankNodes\n ? resolve(normalizeBlankNodes(quads))\n : resolve(quads);\n\n return;\n }\n\n quads.push(quad);\n });\n });\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.documentUrl });\n const parser = new TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(options.documentUrl ?? null, SolidDocumentFormat.Turtle, error.message);\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch;\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUserProfile> {\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, fetch);\n\n if (!document.isPersonalProfile())\n throw new Error(`Document at ${documentUrl} is not a profile.`);\n\n const storageUrls = document.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = document.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = document.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, fetch));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n return objectWithoutEmpty({\n webId,\n storageUrls,\n name:\n document.statement(webId, 'vcard:fn')?.object.value ??\n document.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n document.statement(webId, 'vcard:hasPhoto')?.object.value ??\n document.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: document.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n });\n}\n\nexport async function fetchLoginUserProfile(loginUrl: string, fetch?: Fetch): Promise<SolidUserProfile | null> {\n const fetchProfile = silenced(url => fetchUserProfile(url, fetch));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type SolidThing from '@/models/SolidThing';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\nasync function mintPrivateTypeIndexUrl(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/privateTypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/privateTypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch;\n\n const typeIndexUrl = await mintPrivateTypeIndexUrl(user, fetch);\n const typeIndexBody = `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n updateSolidDocument(user.webId, profileUpdateBody, fetch);\n\n return typeIndexUrl;\n}\n\nexport async function findContainerRegistration(\n typeIndexUrl: string,\n childrenType: string,\n fetch?: Fetch,\n): Promise<SolidThing | null> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const containerQuad = typeIndex\n .statements(undefined, 'rdfs:type', 'solid:TypeRegistration')\n .find(\n statement =>\n typeIndex.contains(statement.subject.value, 'solid:forClass', childrenType) &&\n typeIndex.contains(statement.subject.value, 'solid:instanceContainer'),\n );\n\n return containerQuad\n ? typeIndex.getThing(containerQuad.subject.value) ?? null\n : null;\n}\n","import type { JsonLD } from '@/helpers/jsonld';\nimport { pull } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n if (!containsPatterns(expected))\n return expected === actual;\n\n const patternAliases = [];\n\n if (!(expected in patternsRegExpsIndex)) {\n const patternMatches = expected.matchAll(/\\[\\[((.*)\\]\\[)?([^\\]]+)\\]\\]/g);\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n if (patternMatch[2]) {\n patternAliases.push(patternMatch[2]);\n }\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, pattern);\n }\n\n patternsRegExpsIndex[expected] = new RegExp(expectedRegExp);\n }\n\n return patternsRegExpsIndex[expected].test(actual);\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following ${operation} triple: ${quadToTurtle(expectedQuad)}`);\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n for (const expectedQuad of expectedQuads) {\n if (!actualQuads.some(actualQuad => quadEquals(expectedQuad, actualQuad)))\n return result(false, `Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n return result(true, 'turtle matches');\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import { normalizeSparql } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n')\n : () => {\n return [\n result.message,\n utils.matcherHint(options.hint),\n ].join('\\n\\n');\n };\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n};\n\nexport default matchers;\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","Error","documentUrl","documentFormat","malformationDetails","errorMessage","NetworkRequestError","url","NotFoundError","UnauthorizedError","responseStatus","this","undefined","knownPrefixes","foaf","pim","purl","rdfs","schema","solid","vcard","defineIRIPrefix","name","value","expandIRI","iri","options","startsWith","split","prefix","expandedPrefix","extraContext","_options$extraContext","defaultPrefix","SolidThing","quads","property","find","quad","predicate","_this$quads$find","object","filter","map","SolidDocument","headers","statements","length","statement","get","_this$headers$get","match","parseDate","_this$statement","getLatestDocumentDate","subject","_this","_this2","dates","date","reduce","a","b","isJsonLDGraph","jsonld","fetchRawSolidDocument","fetch","Accept","response","status","includes","text","body","_context","normalizeBlankNodes","normalizedQuads","slice","quadsIndexes","blankNodeIds","arr","flatMap","index","ids","arrayFilter","termType","id","Set","add","unique","originalId","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","N3BlankNode","arrayReplace","N3Quad","createSolidDocument","window","turtleToQuads","method","Headers","fetchSolidDocument","data","jsonldToQuads","Promise","all","graphQuads","flat","toRDF","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","document","isEmpty","sparqlToQuads","operations","matchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","turtle","parserOptions","objectWithoutEmpty","baseIRI","parser","TurtleParser","resolve","reject","parse","error","Turtle","message","push","updateSolidDocument","fetchUserProfile","webId","urlRoute","isPersonalProfile","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","_document$statement","_document$statement2","avatarUrl","_document$statement3","_document$statement4","oidcIssuerUrl","_document$statement5","publicTypeIndexUrl","privateTypeIndexUrl","fetchLoginUserProfile","loginUrl","fetchProfile","replace","urlRoot","mintPrivateTypeIndexUrl","user","storageUrl","typeIndexUrl","uuid","createPrivateTypeIndex","profileUpdateBody","findContainerRegistration","childrenType","typeIndex","containerQuad","contains","getThing","patternsRegExpsIndex","containsPatterns","test","quadValueEquals","expected","actual","patternAliases","patternMatches","patterns","expectedRegExp","patternMatch","patternIndex","pattern","RegExp","quadEquals","datatype","Date","getTime","quadObjectEquals","resetPatterns","jsonldEquals","expectedQuads","actualQuads","expectedTurtle","actualTurtle","result","success","expectedQuad","some","actualQuad","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","assertions","graph","_obj","assert","bind","query","installChaiPlugin","chai","use","_chai","forEach","Assertion","addMethod","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","installJestPlugin","expect","extend"],"mappings":"09GAYYA,GAAZ,SAAYA,GACRA,kBADJ,CAAYA,IAAAA,WAISC,4CAAoCC,6EAMzCC,EAA4BC,EAAqCC,mEApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,KAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,qdCzBdE,oCAA4BL,6DAIjCM,oGACgCA,KAEnCA,IAAMA,6cCPEC,8BAAsBP,iDAI3BM,8EACgBA,uBAEnBA,IAAMA,ucCDEE,kCAA0BR,yDAK/BM,EAAaG,yDAX7B,SAAsBH,EAAaG,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBH,GASzBF,CAAaE,EAAKG,KAEnBH,IAAMA,IACNG,eAAiBA,qDAG1B,uBAC0C,IAAxBC,KAAKD,eACW,MAAxBC,KAAKD,oBACLE,2BChBRC,EAA4B,CAC9BC,KAAM,6BACNC,IAAK,kCACLC,KAAM,4BACNC,KAAM,8CACNC,OAAQ,sBACRC,MAAO,oCACPC,MAAO,6CAGKC,EAAgBC,EAAcC,GAC1CV,EAAcS,GAAQC,WAGVC,EAAUC,OAAaC,yDAAqC,MACpED,EAAIE,WAAW,QACf,OAAOF,QAEYA,EAAIG,MAAM,cAA1BC,OAAQP,UAEXA,EAAM,WACAQ,sBAAiBjB,EAAcgB,4BAAWH,EAAQK,iCAARC,EAAuBH,kBAAW,SAE7EC,EACD,MAAM,IAAI7B,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KAAK,OACTA,KAAK,SACL,iBACS,CACH4H,EAAOpE,QACP+F,EAAME,YAAY5N,EAAQ6N,OAC5B1J,KAAK,UAMnB,IAAM8J,GAAiC,CAC7BC,uBAAcF,EAAUtD,iIACLgB,GAAahB,EAAUsD,iBAAtCjC,2BAECyB,GAAazB,EAAQ,CACxB4B,QAAS7L,EACT+L,KAAM,gBACNnD,SAAAA,EACAsD,SAAAA,mDAGRG,uBAAcH,EAAUtD,UAGb8C,GAFQpB,GAAa1B,EAAUsD,GAEV,CACxBL,QAAS1O,KACT4O,KAAM,gBACNnD,SAAUjF,GAAgBiF,GAC1BsD,SAAUvI,GAAgBuI,gBCjDtBI,KACZC,OAAOC,OAAOL"}
@@ -1,7 +1,9 @@
1
- module.exports = {
1
+ const { defineConfig } = require('@noeldemartin/scripts');
2
+
3
+ module.exports = defineConfig({
2
4
  name: 'NoelDeMartinSolidUtils',
3
5
  declarations: [
4
6
  // 'src/plugins/cypress/types.d.ts',
5
7
  'src/plugins/jest/types.d.ts',
6
8
  ],
7
- };
9
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noeldemartin/solid-utils",
3
- "version": "0.1.1-next.0138d472d679413be54bc014f8cf21f03a1e1c3c",
3
+ "version": "0.1.1-next.8c064afc67573f7cf20fa4cbeecfad10a949a9ef",
4
4
  "description": "My JavaScript utilities for Solid",
5
5
  "main": "dist/noeldemartin-solid-utils.cjs.js",
6
6
  "module": "dist/noeldemartin-solid-utils.esm.js",
@@ -29,7 +29,7 @@
29
29
  "homepage": "https://github.com/noeldemartin/solid-utils",
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.14.0",
32
- "@noeldemartin/utils": "^0.2.1-next.f9c86762b10628346fab4d9d8f543b7f9e3c997f",
32
+ "@noeldemartin/utils": "^0.2.1-next.c3e1bb57127c6f5eab27c6fbb99463760b5aa02c",
33
33
  "@types/rdf-js": "^4.0.1",
34
34
  "core-js": "^3.12.1",
35
35
  "jest-diff": "^26.6.2",
@@ -1,5 +1,3 @@
1
- import diff from 'jest-diff';
2
-
3
1
  import { normalizeSparql } from '@/helpers/io';
4
2
  import { jsonldEquals, sparqlEquals } from '@/helpers/testing';
5
3
  import type { EqualityResult } from '@/helpers/testing';
@@ -24,19 +22,9 @@ function formatResult(result: EqualityResult, options: FormatResultOptions) {
24
22
  ].join('\n'),
25
23
  ].join('\n\n')
26
24
  : () => {
27
- const diffString = diff(options.expected, options.received, {
28
- expand: options.context.expand,
29
- });
30
-
31
25
  return [
32
26
  result.message,
33
27
  utils.matcherHint(options.hint),
34
- diffString && diffString.includes('- Expect')
35
- ? `Difference:\n\n${diffString}`
36
- : [
37
- `Expected: ${utils.printExpected(options.expected)}`,
38
- `Received: ${utils.printReceived(options.received)}`,
39
- ].join('\n'),
40
28
  ].join('\n\n');
41
29
  };
42
30