@noeldemartin/solid-utils 0.2.0 → 0.3.0

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
- import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.to-string-tag.js";import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/assertThisInitialized";import r from"@babel/runtime/helpers/esm/inherits";import n from"@babel/runtime/helpers/esm/possibleConstructorReturn";import o from"@babel/runtime/helpers/esm/getPrototypeOf";import u from"@babel/runtime/helpers/esm/defineProperty";import"core-js/modules/es.array.concat.js";import{JSError as s,parseDate as a,stringMatch as c,arrayFilter as i,objectWithoutEmpty as l,stringMatchAll as f,arr as p,tap as d,arrayReplace as m,urlRoot as v,silenced as h,arrayUnique as y,urlParentDirectory as b,urlRoute as j,objectDeepClone as w,urlParse as x,uuid as g,isObject as k,isArray as R,pull as E,arrayRemove as I,urlResolve as P,requireUrlParentDirectory as A}from"@noeldemartin/utils";import T from"@babel/runtime/helpers/esm/createClass";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/esnext.async-iterator.filter.js";import"core-js/modules/esnext.iterator.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import U from"@babel/runtime/helpers/esm/slicedToArray";import O from"@babel/runtime/helpers/esm/asyncToGenerator";import q from"@babel/runtime/regenerator";import"core-js/modules/esnext.async-iterator.for-each.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.for-each.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.array.map.js";import"core-js/modules/esnext.async-iterator.map.js";import"core-js/modules/esnext.iterator.map.js";import"core-js/modules/es.object.entries.js";import"core-js/modules/esnext.async-iterator.some.js";import"core-js/modules/esnext.iterator.some.js";import"core-js/modules/es.object.values.js";import"core-js/modules/es.array.find.js";import"core-js/modules/esnext.async-iterator.find.js";import"core-js/modules/esnext.iterator.find.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import C from"@babel/runtime/helpers/esm/toConsumableArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.string.starts-with.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.regexp.test.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/esnext.async-iterator.flat-map.js";import"core-js/modules/esnext.iterator.flat-map.js";import"core-js/modules/es.array.iterator.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/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import S from"md5";import{compactJsonLD as D,jsonLDToRDF as B,TurtleParser as N,jsonLDFromRDF as z,TurtleWriter as L,createBlankNode as M,createQuad as Q}from"@noeldemartin/solid-utils-external";import"core-js/modules/es.string.match.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.sticky.js";import"core-js/modules/es.regexp.to-string.js";function W(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var F;!function(e){e.Turtle="Turtle"}(F||(F={}));var H=function(n){r(MalformedSolidDocumentError,s);var o=W(MalformedSolidDocumentError);function MalformedSolidDocumentError(r,n,s){var a;return e(this,MalformedSolidDocumentError),a=o.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(r,n,s)),u(t(a),"documentUrl",void 0),u(t(a),"documentFormat",void 0),u(t(a),"malformationDetails",void 0),a.documentUrl=r,a.documentFormat=n,a.malformationDetails=s,a}return MalformedSolidDocumentError}();function $(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var _=function(n){r(NetworkRequestError,s);var o=$(NetworkRequestError);function NetworkRequestError(r,n){var s;return e(this,NetworkRequestError),s=o.call(this,"Request failed trying to fetch ".concat(r),n),u(t(s),"url",void 0),s.url=r,s}return NetworkRequestError}();function J(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var G=function(n){r(NotFoundError,s);var o=J(NotFoundError);function NotFoundError(r){var n;return e(this,NotFoundError),n=o.call(this,"Document with '".concat(r,"' url not found")),u(t(n),"url",void 0),n.url=r,n}return NotFoundError}();function X(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var K=function(n){r(UnauthorizedError,s);var o=X(UnauthorizedError);function UnauthorizedError(r,n){var s;return e(this,UnauthorizedError),s=o.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(r,n)),u(t(s),"url",void 0),u(t(s),"responseStatus",void 0),s.url=r,s.responseStatus=n,s}return T(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}();function V(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var Y=function(n){r(UnsuccessfulRequestError,s);var o=V(UnsuccessfulRequestError);function UnsuccessfulRequestError(r,n){var s;return e(this,UnsuccessfulRequestError),s=o.call(this,function(e,t){var r;return t=null!==(r=t)&&void 0!==r?r:e,"string"==typeof e?"".concat(e," (returned ").concat(t.status," status code)"):"Request to ".concat(t.url," returned ").concat(t.status," status code")}(r,n)),u(t(s),"response",void 0),s.response=null!=n?n:r,s}return UnsuccessfulRequestError}();function Z(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var ee=function(n){r(UnsupportedAuthorizationProtocolError,s);var o=Z(UnsupportedAuthorizationProtocolError);function UnsupportedAuthorizationProtocolError(r,n,s){var a;return e(this,UnsupportedAuthorizationProtocolError),a=o.call(this,"The resource at ".concat(r," is using an unsupported authorization protocol (").concat(n,")"),s),u(t(a),"url",void 0),u(t(a),"protocol",void 0),a.url=r,a.protocol=n,a}return UnsupportedAuthorizationProtocolError}(),te={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function re(e,t){te[e]=t}function ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=U(r,2),o=n[0],u=n[1];if(o&&u){var s,a,c,i=null!==(s=null!==(a=te[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 oe,ue=function(){function t(r,n){e(this,t),u(this,"url",void 0),u(this,"quads",void 0),this.url=r,this.quads=n}return T(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===ne(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===ne(e)})).map((function(e){return e.object.value}))}}]),t}(),se=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e(this,t),u(this,"quads",void 0),this.quads=r}return T(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"getQuads",value:function(){return this.quads.slice(0)}},{key:"addQuads",value:function(e){var t;(t=this.quads).push.apply(t,C(e))}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(o){return!(r&&o.object.value!==n.expandIRI(r)||e&&o.subject.value!==n.expandIRI(e)||t&&o.predicate.value!==n.expandIRI(t))}))}},{key:"statement",value:function(e,t,r){var n=this,o=this.quads.find((function(o){return!(r&&o.object.value!==n.expandIRI(r)||e&&o.subject.value!==n.expandIRI(e)||t&&o.predicate.value!==n.expandIRI(t))}));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 ue(e,t)}},{key:"expandIRI",value:function(e){return ne(e)}}]),t}();function ae(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}!function(e){e.Read="read",e.Write="write",e.Append="append",e.Control="control"}(oe||(oe={}));var ce=function(n){r(s,se);var o=ae(s);function s(r,n,a){var c;return e(this,s),c=o.call(this,n),u(t(c),"url",void 0),u(t(c),"headers",void 0),c.url=r,c.headers=a,c}return T(s,[{key:"isACPResource",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/))}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,ne("rdf:type"),ne("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:"isUserWritable",value:function(){return this.getUserPermissions().includes(oe.Write)}},{key:"getUserPermissions",value:function(){return this.getPermissionsFromWAC("user")}},{key:"getPublicPermissions",value:function(){return this.getPermissionsFromWAC("public")}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=a(this.headers.get("last-modified")))&&void 0!==r?r:a(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:"expandIRI",value:function(e){return ne(e,{defaultPrefix:this.url})}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(C(this.statements(void 0,"purl:modified")),C(this.statements(void 0,"purl:created"))).map((function(e){return a(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}},{key:"getPermissionsFromWAC",value:function(e){var t,r,n,o=null!==(t=this.headers.get("WAC-Allow"))&&void 0!==t?t:"",u=null!==(r=null===(n=c(o,new RegExp("".concat(e,'="([^"]+)"'))))||void 0===n?void 0:n[1])&&void 0!==r?r:"";return i([u.includes("read")&&oe.Read,u.includes("write")&&oe.Write,u.includes("append")&&oe.Append,u.includes("control")&&oe.Control])}}]),s}();function ie(e){return le.apply(this,arguments)}function le(){return(le=O(q.mark((function e(t){var r;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,D(t,{});case 2:if(!("@graph"in(r=e.sent))){e.next=5;break}return e.abrupt("return",r);case 5:if(!("@id"in r)){e.next=7;break}return e.abrupt("return",{"@graph":[r]});case 7:return e.abrupt("return",{"@graph":[]});case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e){return"@graph"in e}function pe(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 de(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 de(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 de(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 me(e,t){return ve.apply(this,arguments)}function ve(){return(ve=O(q.mark((function e(t,r){var n,o,u;return q.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 G(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new K(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 K)){e.next=19;break}throw e.t0;case 19:if(!(e.t0 instanceof G)){e.next=21;break}throw e.t0;case 21:throw new _(t,{cause:e.t0});case 22:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function he(e){var t,r=e.slice(0),n={},o=pe(p(e).flatMap((function(e,t){return d(i(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),(function(e){return e.forEach((function(e){var r;return(null!==(r=n[e])&&void 0!==r?r:n[e]=new Set).add(t)}))}))})).filter().unique());try{var u=function(){var o,u=t.value,s=n[u],a=S(p(s).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=pe(s);try{for(c.s();!(o=c.n()).done;){for(var i=o.value,l=r[i],f={subject:l.subject,object:l.object},d=0,v=Object.entries(f);d<v.length;d++){var h=U(v[d],2),y=h[0],b=h[1];"BlankNode"===b.termType&&b.value===u&&(f[y]=M(a))}m(r,l,Q(f.subject,l.predicate,f.object))}}catch(e){c.e(e)}finally{c.f()}};for(o.s();!(t=o.n()).done;)u()}catch(e){o.e(e)}finally{o.f()}return r}function ye(e,t,r){return be.apply(this,arguments)}function be(){return(be=O(q.mark((function e(t,r,n){var o,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),e.next=3,Be(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 ce(t,u,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function je(e,t){return we.apply(this,arguments)}function we(){return(we=O(q.mark((function e(t,r){var n,o,u,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,me(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,u=n.headers,e.next=7,Be(o,{baseIRI:t});case 7:return s=e.sent,e.abrupt("return",new ce(t,s,u));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(e,t){return ge.apply(this,arguments)}function ge(){return(ge=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,je(t,r);case 3:return n=e.sent,e.abrupt("return",n);case 7:if(e.prev=7,e.t0=e.catch(0),e.t0 instanceof G){e.next=11;break}throw e.t0;case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ke(e,t){return Re.apply(this,arguments)}function Re(){return(Re=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!fe(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map((function(e){return ke(e,r)})));case 3:return n=e.sent,e.abrupt("return",n.flat());case 5:return e.abrupt("return",B(t,{base:r}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(e){var t=De(e);return Object.entries(t).reduce((function(e,t){var r=U(t,2),n=r[0],o=r[1].map((function(e){return" "+Ue(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function Ie(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new N(r),o={quads:[],containsRelativeIRIs:!1};return new Promise((function(r,u){var s=n._resolveRelativeIRI;n._resolveRelativeIRI=function(){return o.containsRelativeIRIs=!0,n._resolveRelativeIRI=s,n._resolveRelativeIRI.apply(n,arguments)},n.parse(e,(function(e,n){var s;e?u(new H(null!==(s=t.baseIRI)&&void 0!==s?s:null,F.Turtle,e.message)):n?o.quads.push(n):r(o)}))}))}function Pe(e){return Ae.apply(this,arguments)}function Ae(){return(Ae=O(q.mark((function e(t){var r;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Te(e){return(new L).quadsToString(e)}function Ue(e){return(new L).quadsToString([e]).slice(0,-1)}function Oe(e,t){return qe.apply(this,arguments)}function qe(){return(qe=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,je(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 Ce(e){return Se.apply(this,arguments)}function Se(){return Se=O(q.mark((function e(t){var r,n,o,u=arguments;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=f(t,/(\w+) DATA {([^}]+)}/g),o={},e.next=5,Promise.all(C(n).map(function(){var e=O(q.mark((function e(t){var n,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),u=t[2],e.next=4,Be(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)}))),Se.apply(this,arguments)}function De(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f(e,/(\w+) DATA {([^}]+)}/g),o={},u=pe(n);try{for(u.s();!(t=u.n()).done;){var s=t.value,a=s[1].toLowerCase(),c=s[2];o[a]=ze(c,r)}}catch(e){u.e(e)}finally{u.f()}return o}function Be(e){return Ne.apply(this,arguments)}function Ne(){return Ne=O(q.mark((function e(t){var r,n,o,u=arguments;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},e.next=3,Ie(t,r);case 3:return n=e.sent,o=n.quads,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),Ne.apply(this,arguments)}function ze(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new N(r);try{var o=n.parse(e);return t.normalizeBlankNodes?he(o):o}catch(e){var u,s;throw new H(null!==(u=t.baseIRI)&&void 0!==u?u:null,F.Turtle,null!==(s=e.message)&&void 0!==s?s:"")}}function Le(e,t,r){return Me.apply(this,arguments)}function Me(){return(Me=O(q.mark((function e(t,r,n){var o;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),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 Qe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function We(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Fe(e,t){return He.apply(this,arguments)}function He(){return He=O(q.mark((function e(t,r){var n,o,s,a,c,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=new se(t.getQuads()),a=u({},t.url,t),c=function(e){e.statements(void 0,"foaf:isPrimaryTopicOf").map((function(e){return e.object.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null})),e.statements(void 0,"foaf:primaryTopic").map((function(e){return e.subject.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null}))},i=function(){var e=O(q.mark((function e(){var t,n,o,u,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,n=Object.entries(a);case 1:if(!(t<n.length)){e.next=23;break}if(o=U(n[t],2),u=o[0],null===o[1]){e.next=5;break}return e.abrupt("continue",20);case 5:return e.prev=5,e.next=8,je(u,r);case 8:i=e.sent,a[u]=i,s.addQuads(i.getQuads()),c(i),e.next=20;break;case 14:if(e.prev=14,e.t0=e.catch(5),!(e.t0 instanceof K)){e.next=19;break}return a[u]=!1,e.abrupt("continue",20);case 19:throw e.t0;case 20:t++,e.next=1;break;case 23:case"end":return e.stop()}}),e,null,[[5,14]])})));return function(){return e.apply(this,arguments)}}(),c(t);case 5:return e.next=7,i();case 7:if(Object.values(a).some((function(e){return null===e}))){e.next=5;break}case 8:return e.abrupt("return",{store:s,cloaked:Object.values(a).some((function(e){return!1===e})),writableProfileUrl:t.isUserWritable()?t.url:null!==(n=null===(o=Object.values(a).find((function(e){return!!e&&e.isUserWritable()})))||void 0===o?void 0:o.url)&&void 0!==n?n:null});case 9:case"end":return e.stop()}}),e)}))),He.apply(this,arguments)}function $e(e,t){return _e.apply(this,arguments)}function _e(){return(_e=O(q.mark((function e(t,r){var n,o,u,s,a,c,i,f,p,d,m,v,w,x,g,k,R,E;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=j(t),e.next=3,je(f,r);case 3:if((p=e.sent).isPersonalProfile()||p.contains(t,"solid:oidcIssuer")){e.next=6;break}throw new Error("".concat(t," is not a valid webId."));case 6:return e.next=8,Fe(p,r);case 8:d=e.sent,m=d.store,v=d.writableProfileUrl,w=d.cloaked,x=m.statements(t,"pim:storage").map((function(e){return e.object.value})),g=m.statement(t,"solid:publicTypeIndex"),k=m.statement(t,"solid:privateTypeIndex"),R=b(f);case 16:if(!R||0!==x.length){e.next=26;break}return e.next=19,h(je(R,r));case 19:if(null==(E=e.sent)||!E.isStorage()){e.next=23;break}return x.push(R),e.abrupt("break",26);case 23:R=b(R),e.next=16;break;case 26:return e.abrupt("return",We({webId:t,cloaked:w,writableProfileUrl:v,storageUrls:y(x)},l({name:null!==(n=null===(o=m.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(u=m.statement(t,"foaf:name"))||void 0===u?void 0:u.object.value,avatarUrl:null!==(s=null===(a=m.statement(t,"vcard:hasPhoto"))||void 0===a?void 0:a.object.value)&&void 0!==s?s:null===(c=m.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(i=m.statement(t,"solid:oidcIssuer"))||void 0===i?void 0:i.object.value,publicTypeIndexUrl:null==g?void 0:g.object.value,privateTypeIndexUrl:null==k?void 0:k.object.value})));case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Je(e,t){return Ge.apply(this,arguments)}function Ge(){return(Ge=O(q.mark((function e(t,r){var n,o,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=h((function(e){return $e(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(v(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 Xe(e){var t=function(e){return e.path&&e.path.startsWith("/")?e.path.match(/^\/[^/]*$/)?"/":"/".concat(p(e.path.split("/")).filter().slice(0,-1).join("/"),"/").replace("//","/"):null}(e);return e.protocol&&e.domain?"".concat(e.protocol,"://").concat(e.domain).concat(null!=t?t:"/"):t}function Ke(e){var t;if("@type"in e&&!("@value"in e)){e["@id"]=null!==(t=e["@id"])&&void 0!==t?t:g();for(var r=0,n=Object.values(e);r<n.length;r++){var o=n[r];k(o)&&Ke(o),R(o)&&o.forEach((function(e){return k(e)&&Ke(e)}))}}}function Ve(e){return d(w(e),(function(e){return Ke(e)}))}function Ye(e){var t=x(e);return t?l({containerUrl:Xe(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}}function Ze(e,t,r){return et.apply(this,arguments)}function et(){return(et=O(q.mark((function e(t,r,n){var o,u,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),u=t.storageUrls[0],s="".concat(u,"settings/").concat(r,"TypeIndex"),e.next=5,Oe(s,n);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(u,"settings/").concat(r,"TypeIndex-").concat(g()),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 tt(e,t,r){return rt.apply(this,arguments)}function rt(){return(rt=O(q.mark((function e(t,r,n){var o,u,s,a;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t.writableProfileUrl){e.next=2;break}throw new Error("Can't create type index without a writable profile document");case 2:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),e.next=5,Ze(t,r,n);case 5:return u=e.sent,s="public"===r?"<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .":"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",a="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#").concat(r,"TypeIndex> <").concat(u,"> .\n }\n "),e.next=10,Promise.all([ye(u,s,n),Le(t.writableProfileUrl,a,n)]);case 10:return e.abrupt("return",u);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nt(e,t,r,n){return ot.apply(this,arguments)}function ot(){return(ot=O(q.mark((function e(t,r,n,o){var u,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,je(t,o);case 2:return u=e.sent,s=Array.isArray(r)?r:[r],e.abrupt("return",s.map((function(e){return u.statements(void 0,"rdf:type","solid:TypeRegistration").filter((function(t){return u.contains(t.subject.value,"solid:forClass",e)})).map((function(e){return u.statements(e.subject.value,n)})).flat().map((function(e){return e.object.value})).filter((function(e){return!!e}))})).flat());case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ut(e,t){return st.apply(this,arguments)}function st(){return(st=O(q.mark((function e(t,r){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tt(t,"public",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function at(e,t){return ct.apply(this,arguments)}function ct(){return(ct=O(q.mark((function e(t,r){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",tt(t,"private",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function it(e,t,r){return lt.apply(this,arguments)}function lt(){return(lt=O(q.mark((function e(t,r,n){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nt(t,r,"solid:instanceContainer",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ft(e,t,r){return pt.apply(this,arguments)}function pt(){return(pt=O(q.mark((function e(t,r,n){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",nt(t,r,"solid:instance",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dt(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 mt(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 mt(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 mt(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 vt(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,u=o(e);if(t){var s=o(this).constructor;r=Reflect.construct(u,arguments,s)}else r=u.apply(this,arguments);return n(this,r)}}var ht={},yt={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},bt=function(n){r(ExpectedQuadAssertionError,s);var o=vt(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(r){var n;return e(this,ExpectedQuadAssertionError),n=o.call(this,"Couldn't find the following triple: ".concat(Ue(r))),u(t(n),"expectedQuad",void 0),n.expectedQuad=r,n}return ExpectedQuadAssertionError}();function jt(e,t){var r,n=dt(e);try{var o=function(){var e=r.value,n=t.find((function(t){return n=t,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(!wt(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 xt(e.value,t.value)}((r=e).object,n.object)&&xt(r.subject.value,n.subject.value)&&xt(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new bt(e);I(t,n)};for(n.s();!(r=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function wt(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function xt(e,t){var r,n;return wt(e)?(null!==(n=(r=ht)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],o=e,u=dt(f(e,/\[\[((.*?)\]\[)?([^\]]+)\]\]/g));try{for(u.s();!(t=u.n()).done;){var s=t.value;s[2]&&r.push(s[2]),n.push(s[3]),o=o.replace(s[0],"%PATTERN".concat(n.length-1,"%"))}}catch(e){u.e(e)}finally{u.f()}o=o.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var a=0,c=Object.entries(n);a<c.length;a++){var i,l=U(c[a],2),p=l[0],d=l[1];o=o.replace("%PATTERN".concat(p,"%"),null!==(i=yt[d])&&void 0!==i?i:d)}return new RegExp(o)}(e)).test(t):e===t}function gt(){ht={}}function kt(e,t){return Rt.apply(this,arguments)}function Rt(){return(Rt=O(q.mark((function e(t,r){var n,o,u,s,a;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gt(),e.next=3,ke(t);case 3:return n=e.sent,e.next=6,ke(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:e.prev=12,jt(n,o),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof bt){e.next=20;break}throw e.t0;case 20:return e.abrupt("return",a(!1,e.t0.message));case 21:return e.abrupt("return",a(!0,"jsonld matches"));case 22:case"end":return e.stop()}}),e,null,[[12,16]])})))).apply(this,arguments)}function Et(e,t){var r;gt();for(var n=De(e,{normalizeBlankNodes:!0}),o=De(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=E(n,c),l=E(o,c);if(i.length!==l.length)return u(!1,"Expected ".concat(i.length," ").concat(c," triples, found ").concat(l.length,"."));try{jt(i,l)}catch(e){if(!(e instanceof bt))throw e;return u(!1,"Couldn't find the following ".concat(c," triple: ").concat(Ue(e.expectedQuad)))}}var f=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return f?u(!1,"Did not expect to find ".concat(f," triples.")):u(!0,"sparql matches")}function It(e,t){gt();var r=ze(e,{normalizeBlankNodes:!0}),n=ze(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,"."));try{jt(r,n)}catch(e){if(!(e instanceof bt))throw e;return o(!1,e.message)}return o(!0,"turtle matches")}function Pt(e,t){return At.apply(this,arguments)}function At(){return(At=O(q.mark((function e(t,r){var n,o,u,s,a,c,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(window),e.next=3,r(t,{method:"HEAD"});case 3:if(a=e.sent,c=null!==(o=a.headers.get("Link"))&&void 0!==o?o:"",i=null!==(u=null===(s=c.match(/<([^>]+)>;\s*rel="acl"/))||void 0===s?void 0:s[1])&&void 0!==u?u:null){e.next=8;break}throw new Error("Could not find ACL Resource for '".concat(t,"'"));case 8:return e.abrupt("return",P(A(t),i));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Tt(e,t,r){return Ut.apply(this,arguments)}function Ut(){return(Ut=O(q.mark((function e(t,r,n){var o,u,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(o=n)||void 0===o){e.next=4;break}e.t0=o,e.next=7;break;case 4:return e.next=6,Pt(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,xe(null!==(u=n)&&void 0!==u?u:"",r);case 10:if(s=e.sent){e.next=13;break}return e.abrupt("return",Tt(A(t),r));case 13:if(!s.isACPResource()){e.next=15;break}throw new ee(t,"ACP");case 15:return e.abrupt("return",s);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ot(e,t){return qt.apply(this,arguments)}function qt(){return(qt=O(q.mark((function e(t,r){var n,o;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Pt(t,r);case 2:return n=e.sent,e.next=5,Tt(t,r,n);case 5:return o=e.sent,e.abrupt("return",l({url:n,effectiveUrl:o.url,document:o}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ct={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=It(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=Et(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function St(){chai.use((function(e){return Object.entries(Ct).forEach((function(t){var r=U(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function Dt(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}: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")}}}var Bt={toEqualJsonLD:function(e,t){var r=this;return O(q.mark((function n(){var o;return q.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,kt(t,e);case 2:return o=n.sent,n.abrupt("return",Dt(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Dt(Et(t,e),{context:this,hint:"toEqualSparql",expected:Ee(t),received:Ee(e)})}};function Nt(){expect.extend(Bt)}export{H as MalformedSolidDocumentError,_ as NetworkRequestError,G as NotFoundError,ce as SolidDocument,F as SolidDocumentFormat,oe as SolidDocumentPermission,se as SolidStore,ue as SolidThing,K as UnauthorizedError,Y as UnsuccessfulNetworkRequestError,ee as UnsupportedAuthorizationProtocolError,ie as compactJsonLDGraph,at as createPrivateTypeIndex,ut as createPublicTypeIndex,ye as createSolidDocument,re as defineIRIPrefix,ne as expandIRI,Je as fetchLoginUserProfile,je as fetchSolidDocument,Ot as fetchSolidDocumentACL,xe as fetchSolidDocumentIfFound,it as findContainerRegistrations,ft as findInstanceRegistrations,St as installChaiPlugin,Nt as installJestPlugin,fe as isJsonLDGraph,kt as jsonldEquals,ke as jsonldToQuads,Ve as mintJsonLDIdentifiers,Ee as normalizeSparql,Ye as parseResourceSubject,Ie as parseTurtle,Ue as quadToTurtle,Pe as quadsToJsonLD,Te as quadsToTurtle,Oe as solidDocumentExists,Et as sparqlEquals,Ce as sparqlToQuads,De as sparqlToQuadsSync,It as turtleEquals,Be as turtleToQuads,ze as turtleToQuadsSync,Le as updateSolidDocument};
1
+ import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.to-string-tag.js";import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/assertThisInitialized";import r from"@babel/runtime/helpers/esm/inherits";import n from"@babel/runtime/helpers/esm/possibleConstructorReturn";import o from"@babel/runtime/helpers/esm/getPrototypeOf";import s from"@babel/runtime/helpers/esm/defineProperty";import"core-js/modules/es.array.concat.js";import{JSError as u,parseDate as a,stringMatch as i,arrayFilter as c,objectWithoutEmpty as l,stringMatchAll as f,arr as p,tap as d,arrayReplace as m,urlRoot as v,silenced as h,arrayUnique as y,urlParentDirectory as b,urlRoute as w,objectDeepClone as j,urlParse as x,uuid as g,isObject as k,isArray as R,pull as E,arrayRemove as I,urlResolve as P,requireUrlParentDirectory as O,stringToSlug as A,fail as T}from"@noeldemartin/utils";import U from"@babel/runtime/helpers/esm/createClass";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/esnext.async-iterator.filter.js";import"core-js/modules/esnext.iterator.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import q from"@babel/runtime/helpers/esm/slicedToArray";import S from"@babel/runtime/helpers/esm/asyncToGenerator";import C from"@babel/runtime/regenerator";import"core-js/modules/esnext.async-iterator.for-each.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.for-each.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.array.map.js";import"core-js/modules/esnext.async-iterator.map.js";import"core-js/modules/esnext.iterator.map.js";import"core-js/modules/es.object.entries.js";import"core-js/modules/esnext.async-iterator.some.js";import"core-js/modules/esnext.iterator.some.js";import"core-js/modules/es.object.values.js";import"core-js/modules/es.array.find.js";import"core-js/modules/esnext.async-iterator.find.js";import"core-js/modules/esnext.iterator.find.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import D from"@babel/runtime/helpers/esm/toConsumableArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.string.starts-with.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.regexp.test.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/esnext.async-iterator.flat-map.js";import"core-js/modules/esnext.iterator.flat-map.js";import"core-js/modules/es.array.iterator.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/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import B from"md5";import{compactJsonLD as N,jsonLDToRDF as z,TurtleParser as L,jsonLDFromRDF as M,TurtleWriter as Q,createBlankNode as W,createQuad as F}from"@noeldemartin/solid-utils-external";import"core-js/modules/es.string.match.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.sticky.js";import"core-js/modules/es.regexp.to-string.js";import"core-js/modules/es.string.ends-with.js";import{faker as H}from"@noeldemartin/faker";import"core-js/modules/es.object.assign.js";function $(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var _;!function(e){e.Turtle="Turtle"}(_||(_={}));var J=function(n){r(MalformedSolidDocumentError,u);var o=$(MalformedSolidDocumentError);function MalformedSolidDocumentError(r,n,u){var a;return e(this,MalformedSolidDocumentError),a=o.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(r,n,u)),s(t(a),"documentUrl",void 0),s(t(a),"documentFormat",void 0),s(t(a),"malformationDetails",void 0),a.documentUrl=r,a.documentFormat=n,a.malformationDetails=u,a}return MalformedSolidDocumentError}();function G(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var X=function(n){r(NetworkRequestError,u);var o=G(NetworkRequestError);function NetworkRequestError(r,n){var u;return e(this,NetworkRequestError),u=o.call(this,"Request failed trying to fetch ".concat(r),n),s(t(u),"url",void 0),u.url=r,u}return NetworkRequestError}();function K(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var V=function(n){r(NotFoundError,u);var o=K(NotFoundError);function NotFoundError(r){var n;return e(this,NotFoundError),n=o.call(this,"Document with '".concat(r,"' url not found")),s(t(n),"url",void 0),n.url=r,n}return NotFoundError}();function Y(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var Z=function(n){r(UnauthorizedError,u);var o=Y(UnauthorizedError);function UnauthorizedError(r,n){var u;return e(this,UnauthorizedError),u=o.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(r,n)),s(t(u),"url",void 0),s(t(u),"responseStatus",void 0),u.url=r,u.responseStatus=n,u}return U(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}();function ee(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var te=function(n){r(UnsuccessfulRequestError,u);var o=ee(UnsuccessfulRequestError);function UnsuccessfulRequestError(r,n){var u;return e(this,UnsuccessfulRequestError),u=o.call(this,function(e,t){var r;return t=null!==(r=t)&&void 0!==r?r:e,"string"==typeof e?"".concat(e," (returned ").concat(t.status," status code)"):"Request to ".concat(t.url," returned ").concat(t.status," status code")}(r,n)),s(t(u),"response",void 0),u.response=null!=n?n:r,u}return UnsuccessfulRequestError}();function re(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var ne=function(n){r(UnsupportedAuthorizationProtocolError,u);var o=re(UnsupportedAuthorizationProtocolError);function UnsupportedAuthorizationProtocolError(r,n,u){var a;return e(this,UnsupportedAuthorizationProtocolError),a=o.call(this,"The resource at ".concat(r," is using an unsupported authorization protocol (").concat(n,")"),u),s(t(a),"url",void 0),s(t(a),"protocol",void 0),a.url=r,a.protocol=n,a}return UnsupportedAuthorizationProtocolError}(),oe={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function se(e,t){oe[e]=t}function ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=q(r,2),o=n[0],s=n[1];if(o&&s){var u,a,i,c=null!==(u=null!==(a=oe[o])&&void 0!==a?a:null===(i=t.extraContext)||void 0===i?void 0:i[o])&&void 0!==u?u:null;if(!c)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return c+s}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+o}var ae,ie=function(){function t(r,n){e(this,t),s(this,"url",void 0),s(this,"quads",void 0),this.url=r,this.quads=n}return U(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===ue(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===ue(e)})).map((function(e){return e.object.value}))}}]),t}(),ce=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e(this,t),s(this,"quads",void 0),this.quads=r}return U(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"getQuads",value:function(){return this.quads.slice(0)}},{key:"addQuads",value:function(e){var t;(t=this.quads).push.apply(t,D(e))}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(o){return!(r&&o.object.value!==n.expandIRI(r)||e&&o.subject.value!==n.expandIRI(e)||t&&o.predicate.value!==n.expandIRI(t))}))}},{key:"statement",value:function(e,t,r){var n=this,o=this.quads.find((function(o){return!(r&&o.object.value!==n.expandIRI(r)||e&&o.subject.value!==n.expandIRI(e)||t&&o.predicate.value!==n.expandIRI(t))}));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 ie(e,t)}},{key:"expandIRI",value:function(e){return ue(e)}}]),t}();function le(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}!function(e){e.Read="read",e.Write="write",e.Append="append",e.Control="control"}(ae||(ae={}));var fe=function(n){r(u,ce);var o=le(u);function u(r,n,a){var i;return e(this,u),i=o.call(this,n),s(t(i),"url",void 0),s(t(i),"headers",void 0),i.url=r,i.headers=a,i}return U(u,[{key:"isACPResource",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/))}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,ue("rdf:type"),ue("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:"isUserWritable",value:function(){return this.getUserPermissions().includes(ae.Write)}},{key:"getUserPermissions",value:function(){return this.getPermissionsFromWAC("user")}},{key:"getPublicPermissions",value:function(){return this.getPermissionsFromWAC("public")}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=a(this.headers.get("last-modified")))&&void 0!==r?r:a(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:"expandIRI",value:function(e){return ue(e,{defaultPrefix:this.url})}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(D(this.statements(void 0,"purl:modified")),D(this.statements(void 0,"purl:created"))).map((function(e){return a(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}},{key:"getPermissionsFromWAC",value:function(e){var t,r,n,o=null!==(t=this.headers.get("WAC-Allow"))&&void 0!==t?t:"",s=null!==(r=null===(n=i(o,new RegExp("".concat(e,'="([^"]+)"'))))||void 0===n?void 0:n[1])&&void 0!==r?r:"";return c([s.includes("read")&&ae.Read,s.includes("write")&&ae.Write,s.includes("append")&&ae.Append,s.includes("control")&&ae.Control])}}]),u}();function pe(e){return de.apply(this,arguments)}function de(){return(de=S(C.mark((function e(t){var r;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,N(t,{});case 2:if(!("@graph"in(r=e.sent))){e.next=5;break}return e.abrupt("return",r);case 5:if(!("@id"in r)){e.next=7;break}return e.abrupt("return",{"@graph":[r]});case 7:return e.abrupt("return",{"@graph":[]});case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function me(e){return"@graph"in e}function ve(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,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 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}function ye(e,t){return be.apply(this,arguments)}function be(){return(be=S(C.mark((function e(t,r){var n,o,s;return C.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 V(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new Z(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 Z)){e.next=19;break}throw e.t0;case 19:if(!(e.t0 instanceof V)){e.next=21;break}throw e.t0;case 21:throw new X(t,{cause:e.t0});case 22:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function we(e){var t,r=e.slice(0),n={},o=ve(p(e).flatMap((function(e,t){return d(c(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),(function(e){return e.forEach((function(e){var r;return(null!==(r=n[e])&&void 0!==r?r:n[e]=new Set).add(t)}))}))})).filter().unique());try{var s=function(){var o,s=t.value,u=n[s],a=B(p(u).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()),i=ve(u);try{for(i.s();!(o=i.n()).done;){for(var c=o.value,l=r[c],f={subject:l.subject,object:l.object},d=0,v=Object.entries(f);d<v.length;d++){var h=q(v[d],2),y=h[0],b=h[1];"BlankNode"===b.termType&&b.value===s&&(f[y]=W(a))}m(r,l,F(f.subject,l.predicate,f.object))}}catch(e){i.e(e)}finally{i.f()}};for(o.s();!(t=o.n()).done;)s()}catch(e){o.e(e)}finally{o.f()}return r}function je(e,t,r){return xe.apply(this,arguments)}function xe(){return(xe=S(C.mark((function e(t,r,n){var o,s;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),e.next=3,Le(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 fe(t,s,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e,t){return ke.apply(this,arguments)}function ke(){return(ke=S(C.mark((function e(t,r){var n,o,s,u;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ye(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,s=n.headers,e.next=7,Le(o,{baseIRI:t});case 7:return u=e.sent,e.abrupt("return",new fe(t,u,s));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(e,t){return Ee.apply(this,arguments)}function Ee(){return(Ee=S(C.mark((function e(t,r){var n;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ge(t,r);case 3:return n=e.sent,e.abrupt("return",n);case 7:if(e.prev=7,e.t0=e.catch(0),e.t0 instanceof V){e.next=11;break}throw e.t0;case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function Ie(e,t){return Pe.apply(this,arguments)}function Pe(){return(Pe=S(C.mark((function e(t,r){var n;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!me(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map((function(e){return Ie(e,r)})));case 3:return n=e.sent,e.abrupt("return",n.flat());case 5:return e.abrupt("return",z(t,{base:r}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(e){var t=ze(e);return Object.entries(t).reduce((function(e,t){var r=q(t,2),n=r[0],o=r[1].map((function(e){return" "+Se(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function Ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new L(r),o={quads:[],containsRelativeIRIs:!1};return new Promise((function(r,s){var u=n._resolveRelativeIRI;n._resolveRelativeIRI=function(){return o.containsRelativeIRIs=!0,n._resolveRelativeIRI=u,n._resolveRelativeIRI.apply(n,arguments)},n.parse(e,(function(e,n){var u;e?s(new J(null!==(u=t.baseIRI)&&void 0!==u?u:null,_.Turtle,e.message)):n?o.quads.push(n):r(o)}))}))}function Te(e){return Ue.apply(this,arguments)}function Ue(){return(Ue=S(C.mark((function e(t){var r;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,M(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qe(e){return(new Q).quadsToString(e)}function Se(e){return(new Q).quadsToString([e]).slice(0,-1)}function Ce(e,t){return De.apply(this,arguments)}function De(){return(De=S(C.mark((function e(t,r){var n;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ge(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 Be(e){return Ne.apply(this,arguments)}function Ne(){return Ne=S(C.mark((function e(t){var r,n,o,s=arguments;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},n=f(t,/(\w+) DATA {([^}]+)}/g),o={},e.next=5,Promise.all(D(n).map(function(){var e=S(C.mark((function e(t){var n,s;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),s=t[2],e.next=4,Le(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)}))),Ne.apply(this,arguments)}function ze(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f(e,/(\w+) DATA {([^}]+)}/g),o={},s=ve(n);try{for(s.s();!(t=s.n()).done;){var u=t.value,a=u[1].toLowerCase(),i=u[2];o[a]=Qe(i,r)}}catch(e){s.e(e)}finally{s.f()}return o}function Le(e){return Me.apply(this,arguments)}function Me(){return Me=S(C.mark((function e(t){var r,n,o,s=arguments;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},e.next=3,Ae(t,r);case 3:return n=e.sent,o=n.quads,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),Me.apply(this,arguments)}function Qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new L(r);try{var o=n.parse(e);return t.normalizeBlankNodes?we(o):o}catch(e){var s,u;throw new J(null!==(s=t.baseIRI)&&void 0!==s?s:null,_.Turtle,null!==(u=e.message)&&void 0!==u?u:"")}}function We(e,t,r){return Fe.apply(this,arguments)}function Fe(){return(Fe=S(C.mark((function e(t,r,n){var o;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),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 He(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function $e(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?He(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):He(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(e,t){return Je.apply(this,arguments)}function Je(){return Je=S(C.mark((function e(t,r){var n,o,u,a,i,c;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=new ce(t.getQuads()),a=s({},t.url,t),i=function(e){e.statements(void 0,"foaf:isPrimaryTopicOf").map((function(e){return e.object.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null})),e.statements(void 0,"foaf:primaryTopic").map((function(e){return e.subject.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null}))},c=function(){var e=S(C.mark((function e(){var t,n,o,s,c;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,n=Object.entries(a);case 1:if(!(t<n.length)){e.next=23;break}if(o=q(n[t],2),s=o[0],null===o[1]){e.next=5;break}return e.abrupt("continue",20);case 5:return e.prev=5,e.next=8,ge(s,r);case 8:c=e.sent,a[s]=c,u.addQuads(c.getQuads()),i(c),e.next=20;break;case 14:if(e.prev=14,e.t0=e.catch(5),!(e.t0 instanceof Z)){e.next=19;break}return a[s]=!1,e.abrupt("continue",20);case 19:throw e.t0;case 20:t++,e.next=1;break;case 23:case"end":return e.stop()}}),e,null,[[5,14]])})));return function(){return e.apply(this,arguments)}}(),i(t);case 5:return e.next=7,c();case 7:if(Object.values(a).some((function(e){return null===e}))){e.next=5;break}case 8:return e.abrupt("return",{store:u,cloaked:Object.values(a).some((function(e){return!1===e})),writableProfileUrl:t.isUserWritable()?t.url:null!==(n=null===(o=Object.values(a).find((function(e){return!!e&&e.isUserWritable()})))||void 0===o?void 0:o.url)&&void 0!==n?n:null});case 9:case"end":return e.stop()}}),e)}))),Je.apply(this,arguments)}function Ge(e,t){return Xe.apply(this,arguments)}function Xe(){return(Xe=S(C.mark((function e(t,r){var n,o,s,u,a,i,c,f,p,d,m,v,j,x,g,k,R,E;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=w(t),e.next=3,ge(f,r);case 3:if((p=e.sent).isPersonalProfile()||p.contains(t,"solid:oidcIssuer")){e.next=6;break}throw new Error("".concat(t," is not a valid webId."));case 6:return e.next=8,_e(p,r);case 8:d=e.sent,m=d.store,v=d.writableProfileUrl,j=d.cloaked,x=m.statements(t,"pim:storage").map((function(e){return e.object.value})),g=m.statement(t,"solid:publicTypeIndex"),k=m.statement(t,"solid:privateTypeIndex"),R=b(f);case 16:if(!R||0!==x.length){e.next=26;break}return e.next=19,h(ge(R,r));case 19:if(null==(E=e.sent)||!E.isStorage()){e.next=23;break}return x.push(R),e.abrupt("break",26);case 23:R=b(R),e.next=16;break;case 26:return e.abrupt("return",$e({webId:t,cloaked:j,writableProfileUrl:v,storageUrls:y(x)},l({name:null!==(n=null===(o=m.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(s=m.statement(t,"foaf:name"))||void 0===s?void 0:s.object.value,avatarUrl:null!==(u=null===(a=m.statement(t,"vcard:hasPhoto"))||void 0===a?void 0:a.object.value)&&void 0!==u?u:null===(i=m.statement(t,"foaf:img"))||void 0===i?void 0:i.object.value,oidcIssuerUrl:null===(c=m.statement(t,"solid:oidcIssuer"))||void 0===c?void 0:c.object.value,publicTypeIndexUrl:null==g?void 0:g.object.value,privateTypeIndexUrl:null==k?void 0:k.object.value})));case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ke(e){return Ve.apply(this,arguments)}function Ve(){return Ve=S(C.mark((function e(t){var r,n,o,s,u=arguments;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o=u.length>1&&void 0!==u[1]?u[1]:{}).required){e.next=3;break}return e.abrupt("return",Ge(t,o.fetch));case 3:return s=h((function(e){return Ge(e,o.fetch)})),e.next=6,s(t);case 6:if(e.t2=n=e.sent,e.t1=null!==e.t2,!e.t1){e.next=10;break}e.t1=void 0!==n;case 10:if(!e.t1){e.next=14;break}e.t3=n,e.next=17;break;case 14:return e.next=16,s(t.replace(/\/$/,"").concat("/profile/card#me"));case 16:e.t3=e.sent;case 17:if(e.t4=r=e.t3,e.t0=null!==e.t4,!e.t0){e.next=21;break}e.t0=void 0!==r;case 21:if(!e.t0){e.next=25;break}e.t5=r,e.next=28;break;case 25:return e.next=27,s(v(t).concat("/profile/card#me"));case 27:e.t5=e.sent;case 28:return e.abrupt("return",e.t5);case 29:case"end":return e.stop()}}),e)}))),Ve.apply(this,arguments)}function Ye(e){var t=function(e){return e.path&&e.path.startsWith("/")?e.path.match(/^\/[^/]*$/)?"/":"/".concat(p(e.path.split("/")).filter().slice(0,-1).join("/"),"/").replace("//","/"):null}(e);return e.protocol&&e.domain?"".concat(e.protocol,"://").concat(e.domain).concat(null!=t?t:"/"):t}function Ze(e){var t;if("@type"in e&&!("@value"in e)){e["@id"]=null!==(t=e["@id"])&&void 0!==t?t:g();for(var r=0,n=Object.values(e);r<n.length;r++){var o=n[r];k(o)&&Ze(o),R(o)&&o.forEach((function(e){return k(e)&&Ze(e)}))}}}function et(e){return d(j(e),(function(e){return Ze(e)}))}function tt(e){var t=x(e);return t?l({containerUrl:Ye(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}}function rt(e,t,r){return nt.apply(this,arguments)}function nt(){return(nt=S(C.mark((function e(t,r,n){var o,s,u;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),s=t.storageUrls[0],u="".concat(s,"settings/").concat(r,"TypeIndex"),e.next=5,Ce(u,n);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(s,"settings/").concat(r,"TypeIndex-").concat(g()),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 ot(e,t,r){return st.apply(this,arguments)}function st(){return(st=S(C.mark((function e(t,r,n){var o,s,u,a;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t.writableProfileUrl){e.next=2;break}throw new Error("Can't create type index without a writable profile document");case 2:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),e.next=5,rt(t,r,n);case 5:return s=e.sent,u="public"===r?"<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .":"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",a="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#").concat(r,"TypeIndex> <").concat(s,"> .\n }\n "),e.next=10,Promise.all([je(s,u,n),We(t.writableProfileUrl,a,n)]);case 10:return e.abrupt("return",s);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ut(e,t,r,n){return at.apply(this,arguments)}function at(){return(at=S(C.mark((function e(t,r,n,o){var s,u;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ge(t,o);case 2:return s=e.sent,u=Array.isArray(r)?r:[r],e.abrupt("return",u.map((function(e){return s.statements(void 0,"rdf:type","solid:TypeRegistration").filter((function(t){return s.contains(t.subject.value,"solid:forClass",e)})).map((function(e){return s.statements(e.subject.value,n)})).flat().map((function(e){return e.object.value})).filter((function(e){return!!e}))})).flat());case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function it(e,t){return ct.apply(this,arguments)}function ct(){return(ct=S(C.mark((function e(t,r){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ot(t,"public",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lt(e,t){return ft.apply(this,arguments)}function ft(){return(ft=S(C.mark((function e(t,r){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ot(t,"private",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pt(e,t,r){return dt.apply(this,arguments)}function dt(){return(dt=S(C.mark((function e(t,r,n){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ut(t,r,"solid:instanceContainer",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function mt(e,t,r){return vt.apply(this,arguments)}function vt(){return(vt=S(C.mark((function e(t,r,n){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ut(t,r,"solid:instance",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ht(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 yt(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 yt(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 yt(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 bt(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,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var wt={},jt={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},xt=function(n){r(ExpectedQuadAssertionError,u);var o=bt(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(r){var n;return e(this,ExpectedQuadAssertionError),n=o.call(this,"Couldn't find the following triple: ".concat(Se(r))),s(t(n),"expectedQuad",void 0),n.expectedQuad=r,n}return ExpectedQuadAssertionError}();function gt(e,t){var r,n=ht(e);try{var o=function(){var e=r.value,n=t.find((function(t){return n=t,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(!kt(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 Rt(e.value,t.value)}((r=e).object,n.object)&&Rt(r.subject.value,n.subject.value)&&Rt(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new xt(e);I(t,n)};for(n.s();!(r=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function kt(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Rt(e,t){var r,n;return kt(e)?(null!==(n=(r=wt)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],o=e,s=ht(f(e,/\[\[((.*?)\]\[)?([^\]]+)\]\]/g));try{for(s.s();!(t=s.n()).done;){var u=t.value;u[2]&&r.push(u[2]),n.push(u[3]),o=o.replace(u[0],"%PATTERN".concat(n.length-1,"%"))}}catch(e){s.e(e)}finally{s.f()}o=o.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var a=0,i=Object.entries(n);a<i.length;a++){var c,l=q(i[a],2),p=l[0],d=l[1];o=o.replace("%PATTERN".concat(p,"%"),null!==(c=jt[d])&&void 0!==c?c:d)}return new RegExp(o)}(e)).test(t):e===t}function Et(){wt={}}function It(e,t){return Pt.apply(this,arguments)}function Pt(){return(Pt=S(C.mark((function e(t,r){var n,o,s,u,a;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Et(),e.next=3,Ie(t);case 3:return n=e.sent,e.next=6,Ie(r);case 6:if(o=e.sent,s=qe(n),u=qe(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:e.prev=12,gt(n,o),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof xt){e.next=20;break}throw e.t0;case 20:return e.abrupt("return",a(!1,e.t0.message));case 21:return e.abrupt("return",a(!0,"jsonld matches"));case 22:case"end":return e.stop()}}),e,null,[[12,16]])})))).apply(this,arguments)}function Ot(e,t){var r;Et();for(var n=ze(e,{normalizeBlankNodes:!0}),o=ze(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 i=a[u];if(!(i in o))return s(!1,"Couldn't find expected ".concat(i," operation."));var c=E(n,i),l=E(o,i);if(c.length!==l.length)return s(!1,"Expected ".concat(c.length," ").concat(i," triples, found ").concat(l.length,"."));try{gt(c,l)}catch(e){if(!(e instanceof xt))throw e;return s(!1,"Couldn't find the following ".concat(i," triple: ").concat(Se(e.expectedQuad)))}}var f=null!==(r=Object.keys(o)[0])&&void 0!==r?r:null;return f?s(!1,"Did not expect to find ".concat(f," triples.")):s(!0,"sparql matches")}function At(e,t){Et();var r=Qe(e,{normalizeBlankNodes:!0}),n=Qe(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,"."));try{gt(r,n)}catch(e){if(!(e instanceof xt))throw e;return o(!1,e.message)}return o(!0,"turtle matches")}function Tt(e,t){return Ut.apply(this,arguments)}function Ut(){return(Ut=S(C.mark((function e(t,r){var n,o,s,u,a,i,c;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(window),e.next=3,r(t,{method:"HEAD"});case 3:if(a=e.sent,i=null!==(o=a.headers.get("Link"))&&void 0!==o?o:"",c=null!==(s=null===(u=i.match(/<([^>]+)>;\s*rel="acl"/))||void 0===u?void 0:u[1])&&void 0!==s?s:null){e.next=8;break}throw new Error("Could not find ACL Resource for '".concat(t,"'"));case 8:return e.abrupt("return",P(O(t),c));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function qt(e,t,r){return St.apply(this,arguments)}function St(){return(St=S(C.mark((function e(t,r,n){var o,s,u;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(o=n)||void 0===o){e.next=4;break}e.t0=o,e.next=7;break;case 4:return e.next=6,Tt(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,Re(null!==(s=n)&&void 0!==s?s:"",r);case 10:if(u=e.sent){e.next=13;break}return e.abrupt("return",qt(O(t),r));case 13:if(!u.isACPResource()){e.next=15;break}throw new ne(t,"ACP");case 15:return e.abrupt("return",u);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ct(e,t){return Dt.apply(this,arguments)}function Dt(){return(Dt=S(C.mark((function e(t,r){var n,o;return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Tt(t,r);case 2:return n=e.sent,e.next=5,qt(t,r,n);case 5:return o=e.sent,e.abrupt("return",l({url:n,effectiveUrl:o.url,document:o}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Bt={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=At(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=Ot(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Nt(){chai.use((function(e){return Object.entries(Bt).forEach((function(t){var r=q(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function zt(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}: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")}}}var Lt={toEqualJsonLD:function(e,t){var r=this;return S(C.mark((function n(){var o;return C.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,It(t,e);case 2:return o=n.sent,n.abrupt("return",zt(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return zt(Ot(t,e),{context:this,hint:"toEqualSparql",expected:Oe(t),received:Oe(e)})}};function Mt(){expect.extend(Lt)}function Qt(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=null!==(e=t.baseUrl)&&void 0!==e?e:H.internet.url();return r.endsWith("/")?r:r+"/"}function Wt(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(e=r.containerUrl)&&void 0!==e?e:Qt(r),o=null!==(t=r.name)&&void 0!==t?t:H.random.word();return n+A(o)}function Ft(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=null!==(e=r.documentUrl)&&void 0!==e?e:Wt(r),o=null!==(t=r.hash)&&void 0!==t?t:"it";return n+"#"+o}function Ht(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var $t=function(){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;e(this,t),s(this,"rawBody",void 0),s(this,"body",void 0),s(this,"bodyUsed",void 0),s(this,"headers",void 0),s(this,"ok",void 0),s(this,"redirected",void 0),s(this,"status",void 0),s(this,"statusText",void 0),s(this,"trailer",void 0),s(this,"type",void 0),s(this,"url",void 0),this.rawBody=r,this.headers=new Headers(n),this.status=o}var r,n,o,u,a;return U(t,[{key:"arrayBuffer",value:(a=S(C.mark((function e(){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.arrayBuffer is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return a.apply(this,arguments)})},{key:"blob",value:(u=S(C.mark((function e(){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.blob is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return u.apply(this,arguments)})},{key:"formData",value:(o=S(C.mark((function e(){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.formData is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"json",value:(n=S(C.mark((function e(){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",JSON.parse(this.rawBody));case 1:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"text",value:(r=S(C.mark((function e(){return C.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rawBody);case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"clone",value:function(){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ht(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ht(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},this)}}]),t}();function _t(){var e=[],t={mockResponse:function(t,r,n){e.push(new $t(t,r,n))},mockNotFoundResponse:function(){e.push(new $t("",{},404))}},r=jest.fn(S(C.mark((function t(){var r;return C.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(r=e.shift())&&void 0!==r?r:T("fetch mock called without response"));case 1:case"end":return t.stop()}}),t)}))));return Object.assign(r,t),r}export{J as MalformedSolidDocumentError,X as NetworkRequestError,V as NotFoundError,$t as ResponseStub,fe as SolidDocument,_ as SolidDocumentFormat,ae as SolidDocumentPermission,ce as SolidStore,ie as SolidThing,Z as UnauthorizedError,te as UnsuccessfulNetworkRequestError,ne as UnsupportedAuthorizationProtocolError,pe as compactJsonLDGraph,lt as createPrivateTypeIndex,it as createPublicTypeIndex,je as createSolidDocument,se as defineIRIPrefix,ue as expandIRI,Qt as fakeContainerUrl,Wt as fakeDocumentUrl,Ft as fakeResourceUrl,Ke as fetchLoginUserProfile,ge as fetchSolidDocument,Ct as fetchSolidDocumentACL,Re as fetchSolidDocumentIfFound,pt as findContainerRegistrations,mt as findInstanceRegistrations,Nt as installChaiPlugin,Mt as installJestPlugin,me as isJsonLDGraph,It as jsonldEquals,Ie as jsonldToQuads,et as mintJsonLDIdentifiers,_t as mockFetch,Oe as normalizeSparql,tt as parseResourceSubject,Ae as parseTurtle,Se as quadToTurtle,Te as quadsToJsonLD,qe as quadsToTurtle,Ce as solidDocumentExists,Ot as sparqlEquals,Be as sparqlToQuads,ze as sparqlToQuadsSync,At as turtleEquals,Le as turtleToQuads,Qe as turtleToQuadsSync,We 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/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/vocabs.ts","../src/models/SolidDocument.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/helpers/wac.ts","../src/plugins/chai/assertions.ts","../src/plugins/chai/index.ts","../src/plugins/jest/matchers.ts","../src/plugins/jest/index.ts"],"sourcesContent":["import { JSError } 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 JSError {\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 { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string, options?: JSErrorOptions) {\n super(`Request failed trying to fetch ${url}`, options);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends JSError {\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 { JSError } 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 JSError {\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","import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? messageOrResponse as Response;\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? messageOrResponse as Response;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\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 acl: 'http://www.w3.org/ns/auth/acl#',\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 rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\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 (prefix && 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 { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidStore from './SolidStore';\n\nexport enum SolidDocumentPermission {\n Read = 'read',\n Write = 'write',\n Append = 'append',\n Control = 'control',\n}\n\nexport default class SolidDocument extends SolidStore {\n\n public readonly url: string;\n public readonly headers: Headers;\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n super(quads);\n\n this.url = url;\n this.headers = headers;\n }\n\n public isACPResource(): boolean {\n return !!this.headers.get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdf: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 isUserWritable(): boolean {\n return this.getUserPermissions().includes(SolidDocumentPermission.Write);\n }\n\n public getUserPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('user');\n }\n\n public getPublicPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('public');\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 protected expandIRI(iri: string): string {\n return expandIRI(iri, { defaultPrefix: this.url });\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 private getPermissionsFromWAC(type: string): SolidDocumentPermission[] {\n const wacAllow = this.headers.get('WAC-Allow') ?? '';\n const publicModes = stringMatch<2>(wacAllow, new RegExp(`${type}=\"([^\"]+)\"`))?.[1] ?? '';\n\n return arrayFilter([\n publicModes.includes('read') && SolidDocumentPermission.Read,\n publicModes.includes('write') && SolidDocumentPermission.Write,\n publicModes.includes('append') && SolidDocumentPermission.Append,\n publicModes.includes('control') && SolidDocumentPermission.Control,\n ]);\n }\n\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 type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidStore {\n\n private quads: Quad[];\n\n public constructor(quads: Quad[] = []) {\n this.quads = quads;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public getQuads(): Quad[] {\n return this.quads.slice(0);\n }\n\n public addQuads(quads: Quad[]): void {\n this.quads.push(...quads);\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\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 === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\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 protected expandIRI(iri: string): string {\n return expandIRI(iri);\n }\n\n}\n","import { compactJsonLD } from '@noeldemartin/solid-utils-external';\nimport type { JsonLdDocument } from '@noeldemartin/solid-utils-external';\n\nexport 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 = {\n '@context'?: Record<string, unknown>;\n '@graph': JsonLDResource[];\n};\n\nexport async function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await compactJsonLD(jsonld as JsonLdDocument, {});\n\n if ('@graph' in compactedJsonLD) {\n return compactedJsonLD as JsonLDGraph;\n }\n\n if ('@id' in compactedJsonLD) {\n return { '@graph': [compactedJsonLD] } as JsonLDGraph;\n }\n\n return { '@graph': [] };\n}\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import md5 from 'md5';\nimport {\n TurtleParser,\n TurtleWriter,\n createBlankNode,\n createQuad,\n jsonLDFromRDF,\n jsonLDToRDF,\n} from '@noeldemartin/solid-utils-external';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\nimport type { JsonLdDocument, Term } from '@noeldemartin/solid-utils-external';\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, JsonLDGraph, JsonLDResource } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<Response>;\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 if (error instanceof NotFoundError)\n throw error;\n\n throw new NetworkRequestError(url, { cause: error });\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(\n (quad, index) => tap(\n arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]),\n ids => ids.forEach(id => (quadsIndexes[id] ??= new Set()).add(index)),\n ),\n )\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const quadIndexes = quadsIndexes[originalId] as Set<number>;\n const normalizedId = md5(\n arr(quadIndexes)\n .map(index => quads[index] as Quad)\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 quadIndexes) {\n const quad = normalizedQuads[index] as Quad;\n const terms: Record<string, Term> = {\n subject: quad.subject as Term,\n object: quad.object as Term,\n };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = createBlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n createQuad(\n terms.subject as Term,\n quad.predicate as Term,\n terms.object as Term,\n ),\n );\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n baseIRI: string;\n normalizeBlankNodes: boolean;\n}\n\nexport interface RDFGraphData {\n quads: Quad[];\n containsRelativeIRIs: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch.bind(window);\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, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(url: string, fetch?: Fetch): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return document;\n } catch (error) {\n if (!(error instanceof NotFoundError))\n throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(resource => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n return jsonLDToRDF(jsonld as JsonLdDocument, { base: baseIRI }) 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 parseTurtle(turtle: string, options: Partial<ParsingOptions> = {}): Promise<RDFGraphData> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new TurtleParser(parserOptions);\n const data: RDFGraphData = {\n quads: [],\n containsRelativeIRIs: false,\n };\n\n return new Promise((resolve, reject) => {\n const resolveRelativeIRI = parser._resolveRelativeIRI;\n\n parser._resolveRelativeIRI = (...args) => {\n data.containsRelativeIRIs = true;\n parser._resolveRelativeIRI = resolveRelativeIRI;\n\n return parser._resolveRelativeIRI(...args);\n };\n\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n\n return;\n }\n\n if (!quad) {\n // data.quads = options.normalizeBlankNodes\n // ? normalizeBlankNodes(data.quads)\n // : data.quads;\n\n resolve(data);\n\n return;\n }\n\n data.quads.push(quad);\n });\n });\n}\n\nexport async function quadsToJsonLD(quads: Quad[]): Promise<JsonLDGraph> {\n const graph = await jsonLDFromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\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 = stringMatchAll<3>(sparql, /(\\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 = stringMatchAll<3>(sparql, /(\\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 { quads } = await parseTurtle(turtle, options);\n\n return quads;\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\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(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n (error as Error).message ?? '',\n );\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch.bind(window);\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(webIdDocument: SolidDocument, fetch?: Fetch): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map(quad => quad.object.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map(quad => quad.subject.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n documents[url] = document;\n store.addQuads(document.getQuads());\n\n addReferencedDocumentUrls(document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some(document => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some(document => document === false),\n writableProfileUrl:\n webIdDocument.isUserWritable()\n ? webIdDocument.url\n : Object\n .values(documents)\n .find((document): document is SolidDocument => !!document && document.isUserWritable())\n ?.url ?? null,\n };\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() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, fetch);\n const storageUrls = store.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.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 {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls),\n ...objectWithoutEmpty({\n name:\n store.statement(webId, 'vcard:fn')?.object.value ??\n store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\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 { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/'))\n return null;\n\n if (parts.path.match(/^\\/[^/]*$/))\n return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld)\n return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue))\n __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue))\n propertyValue.forEach(value => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, clone => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts ? {} : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody = type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\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#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await Promise.all([\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch),\n updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch),\n ]);\n\n if (type === 'public') {\n // TODO Implement updating ACLs for the listing itself to public\n }\n\n return typeIndexUrl;\n}\n\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const types = Array.isArray(type) ? type : [type];\n\n return types.map(\n type => typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter(statement => typeIndex.contains(statement.subject.value, 'solid:forClass', type))\n .map(statement => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map(statement => statement.object.value)\n .filter(url => !!url),\n ).flat();\n}\n\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { JsonLD } from '@/helpers/jsonld';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\nconst builtInPatterns: Record<string, string> = {\n '%uuid%': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n};\n\nclass ExpectedQuadAssertionError extends JSError {\n\n constructor(public readonly expectedQuad: Quad) {\n super(`Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n}\n\nfunction assertExpectedQuadsExist(expectedQuads: Quad[], actualQuads: Quad[]): void {\n for (const expectedQuad of expectedQuads) {\n const matchingQuad = actualQuads.find(actualQuad => quadEquals(expectedQuad, actualQuad));\n\n if (!matchingQuad)\n throw new ExpectedQuadAssertionError(expectedQuad);\n\n arrayRemove(actualQuads, matchingQuad);\n }\n}\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction createPatternRegexp(expected: string): RegExp {\n const patternAliases = [];\n const patternMatches = stringMatchAll<4, 1 | 2>(\n expected,\n /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g,\n );\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n patternMatch[2] && patternAliases.push(patternMatch[2]);\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}%`, builtInPatterns[pattern] ?? pattern);\n }\n\n return new RegExp(expectedRegExp);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n return containsPatterns(expected)\n ? (patternsRegExpsIndex[expected] ??= createPatternRegexp(expected)).test(actual)\n : expected === 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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(\n false,\n `Couldn't find the following ${operation} triple: ${quadToTurtle(error.expectedQuad)}`,\n );\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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\nimport UnsupportedAuthorizationProtocolError from '@/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@/helpers/io';\nimport type SolidDocument from '@/models/SolidDocument';\nimport type { Fetch } from '@/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? await fetchACLResourceUrl(resourceUrl, fetch);\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', fetch);\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\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 ].join('\\n\\n')\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 { 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","JSError","documentUrl","documentFormat","malformationDetails","errorMessage","NetworkRequestError","url","options","NotFoundError","UnauthorizedError","responseStatus","this","undefined","UnsuccessfulRequestError","messageOrResponse","response","status","getErrorMessage","UnsupportedAuthorizationProtocolError","protocol","knownPrefixes","acl","foaf","pim","purl","rdf","rdfs","schema","solid","vcard","defineIRIPrefix","name","value","expandIRI","iri","startsWith","split","prefix","expandedPrefix","extraContext","_options$extraContext","Error","defaultPrefix","SolidDocumentPermission","SolidThing","quads","property","find","quad","predicate","_this$quads$find","object","filter","map","SolidStore","statements","length","slice","push","subject","statement","_this","_this2","SolidDocument","headers","get","_this$headers$get","match","_this$headers$get2","getUserPermissions","includes","Write","getPermissionsFromWAC","parseDate","_this$statement","getLatestDocumentDate","dates","date","reduce","a","b","type","wacAllow","publicModes","stringMatch","RegExp","_stringMatch","arrayFilter","Read","Append","Control","compactJsonLDGraph","jsonld","compactJsonLD","compactedJsonLD","isJsonLDGraph","fetchRawSolidDocument","fetch","Accept","text","body","_context","cause","normalizeBlankNodes","normalizedQuads","quadsIndexes","arr","flatMap","index","tap","termType","ids","forEach","id","Set","add","unique","originalId","quadIndexes","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","createBlankNode","arrayReplace","createQuad","createSolidDocument","window","bind","turtleToQuads","method","Headers","fetchSolidDocument","data","baseIRI","fetchSolidDocumentIfFound","document","_context4","jsonldToQuads","Promise","all","resource","graphQuads","flat","jsonLDToRDF","base","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","TurtleParser","containsRelativeIRIs","resolve","reject","resolveRelativeIRI","_resolveRelativeIRI","parse","error","Turtle","message","quadsToJsonLD","jsonLDFromRDF","graph","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","isEmpty","sparqlToQuads","operations","stringMatchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","updateSolidDocument","fetchExtendedUserProfile","webIdDocument","store","getQuads","documents","addReferencedDocumentUrls","profileDocumentUrl","loadProfileDocuments","addQuads","values","some","cloaked","writableProfileUrl","isUserWritable","_Object$values$find","fetchUserProfile","webId","urlRoute","isPersonalProfile","contains","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","arrayUnique","_store$statement","_store$statement2","avatarUrl","_store$statement3","_store$statement4","oidcIssuerUrl","_store$statement5","publicTypeIndexUrl","privateTypeIndexUrl","fetchLoginUserProfile","loginUrl","fetchProfile","replace","urlRoot","getContainerUrl","parts","containerPath","path","getContainerPath","domain","__mintJsonLDIdentifiers","uuid","propertyValue","isObject","isArray","mintJsonLDIdentifiers","objectDeepClone","clone","parseResourceSubject","urlParse","containerUrl","documentName","pop","resourceHash","fragment","mintTypeIndexUrl","user","storageUrl","typeIndexUrl","createTypeIndex","typeIndexBody","profileUpdateBody","findRegistrations","typeIndex","types","Array","createPublicTypeIndex","createPrivateTypeIndex","findContainerRegistrations","findInstanceRegistrations","patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","expectedQuad","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","actual","expected","datatype","containsPatterns","Date","getTime","quadValueEquals","quadObjectEquals","arrayRemove","test","_patternsRegExpsIndex","patternAliases","patterns","expectedRegExp","patternMatch","patternIndex","pattern","createPatternRegexp","resetPatterns","jsonldEquals","expectedTurtle","actualTurtle","result","success","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","fetchACLResourceUrl","resourceUrl","resourceHead","linkHeader","_linkHeader$match","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","isACPResource","fetchSolidDocumentACL","effectiveUrl","assertions","_obj","assert","query","installChaiPlugin","chai","use","_chai","Assertion","addMethod","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","installJestPlugin","expect","extend"],"mappings":"89JAYYA,GAAZ,SAAYA,GACRA,kBADJ,CAAYA,IAAAA,WAISC,4CAAoCC,6EAMzCC,EAA4BC,EAAqCC,kEApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,wGAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,qdCxBdE,oCAA4BL,6DAIjCM,EAAaC,mGACmBD,GAAOC,0BAE1CD,IAAMA,6cCREE,8BAAsBR,iDAI3BM,6EACgBA,6CAEnBA,IAAMA,ucCDEG,kCAA0BT,yDAK/BM,EAAaI,wDAX7B,SAAsBJ,EAAaI,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBJ,GASzBF,CAAaE,EAAKI,2DAEnBJ,IAAMA,IACNI,eAAiBA,qDAG1B,uBAC0C,IAAxB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IiI,EAAOrB,SAAUqB,EAAOtB,SAEvEjI,gBAAOgL,OAEG/C,EADO9Q,KACO2T,KACdC,EAFO5T,KAEO4T,OAAOlM,KAAK1H,MAE1BoS,EAASE,GADEuB,EACqB/C,GAEtC8C,EAAOxB,EAAOC,QAASD,EAAOjI,QAAS,GAAIiI,EAAOrB,SAAUqB,EAAOtB,mBCjC3DgD,KACZC,KAAKC,KAAI,SAAAC,UAAShN,OAAOC,QAAQwM,IAAYrN,SAAQ,yBAAEjF,OAAMwG,cAAYqM,EAAMC,UAAUC,UAAU/S,EAAMwG,SCQ7G,SAASwM,GAAahC,EAAwBxS,OACpCyU,EAAOjC,EAAOC,QACdiC,EAAQ1U,EAAQ2U,QAAQD,YAevB,CAAED,KAAAA,EAAMlK,QAdCkK,EACV,iBAAM,CACJjC,EAAOjI,QACPmK,EAAME,YAAY5U,EAAQ6U,OAC5B1N,KAAK,SACL,iBAAM,CACJqL,EAAOjI,QACPmK,EAAME,YAAY5U,EAAQ6U,MAC1B,yBACqBH,EAAMI,cAAc9U,EAAQmR,+BAChCuD,EAAMK,cAAc/U,EAAQgV,YAC3C7N,KAAK,OACTA,KAAK,UAKf,IAAM8N,GAAiC,CAC7BC,uBAAcF,EAAU7D,iIACLkB,GAAalB,EAAU6D,iBAAtCxC,2BAECgC,GAAahC,EAAQ,CACxBmC,QAASrR,EACTuR,KAAM,gBACN1D,SAAAA,EACA6D,SAAAA,mDAGRG,uBAAcH,EAAU7D,UAGbqD,GAFQ9B,GAAavB,EAAU6D,GAEV,CACxBL,QAASvU,KACTyU,KAAM,gBACN1D,SAAUnI,GAAgBmI,GAC1B6D,SAAUhM,GAAgBgM,gBC/CtBI,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/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/vocabs.ts","../src/models/SolidDocument.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/helpers/wac.ts","../src/plugins/chai/assertions.ts","../src/plugins/chai/index.ts","../src/plugins/jest/matchers.ts","../src/plugins/jest/index.ts","../src/testing/faking.ts","../src/testing/ResponseStub.ts","../src/testing/mocking.ts"],"sourcesContent":["import { JSError } 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 JSError {\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 { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string, options?: JSErrorOptions) {\n super(`Request failed trying to fetch ${url}`, options);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends JSError {\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 { JSError } 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 JSError {\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","import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? messageOrResponse as Response;\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? messageOrResponse as Response;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\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 acl: 'http://www.w3.org/ns/auth/acl#',\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 rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\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 (prefix && 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 { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidStore from './SolidStore';\n\nexport enum SolidDocumentPermission {\n Read = 'read',\n Write = 'write',\n Append = 'append',\n Control = 'control',\n}\n\nexport default class SolidDocument extends SolidStore {\n\n public readonly url: string;\n public readonly headers: Headers;\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n super(quads);\n\n this.url = url;\n this.headers = headers;\n }\n\n public isACPResource(): boolean {\n return !!this.headers.get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdf: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 isUserWritable(): boolean {\n return this.getUserPermissions().includes(SolidDocumentPermission.Write);\n }\n\n public getUserPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('user');\n }\n\n public getPublicPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('public');\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 protected expandIRI(iri: string): string {\n return expandIRI(iri, { defaultPrefix: this.url });\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 private getPermissionsFromWAC(type: string): SolidDocumentPermission[] {\n const wacAllow = this.headers.get('WAC-Allow') ?? '';\n const publicModes = stringMatch<2>(wacAllow, new RegExp(`${type}=\"([^\"]+)\"`))?.[1] ?? '';\n\n return arrayFilter([\n publicModes.includes('read') && SolidDocumentPermission.Read,\n publicModes.includes('write') && SolidDocumentPermission.Write,\n publicModes.includes('append') && SolidDocumentPermission.Append,\n publicModes.includes('control') && SolidDocumentPermission.Control,\n ]);\n }\n\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 type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport default class SolidStore {\n\n private quads: Quad[];\n\n public constructor(quads: Quad[] = []) {\n this.quads = quads;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public getQuads(): Quad[] {\n return this.quads.slice(0);\n }\n\n public addQuads(quads: Quad[]): void {\n this.quads.push(...quads);\n }\n\n public statements(subject?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\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 === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\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 protected expandIRI(iri: string): string {\n return expandIRI(iri);\n }\n\n}\n","import { compactJsonLD } from '@noeldemartin/solid-utils-external';\nimport type { JsonLdDocument } from '@noeldemartin/solid-utils-external';\n\nexport 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 = {\n '@context'?: Record<string, unknown>;\n '@graph': JsonLDResource[];\n};\n\nexport async function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await compactJsonLD(jsonld as JsonLdDocument, {});\n\n if ('@graph' in compactedJsonLD) {\n return compactedJsonLD as JsonLDGraph;\n }\n\n if ('@id' in compactedJsonLD) {\n return { '@graph': [compactedJsonLD] } as JsonLDGraph;\n }\n\n return { '@graph': [] };\n}\n\nexport function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import md5 from 'md5';\nimport {\n TurtleParser,\n TurtleWriter,\n createBlankNode,\n createQuad,\n jsonLDFromRDF,\n jsonLDToRDF,\n} from '@noeldemartin/solid-utils-external';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\nimport type { JsonLdDocument, Term } from '@noeldemartin/solid-utils-external';\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, JsonLDGraph, JsonLDResource } from '@/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<Response>;\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 if (error instanceof NotFoundError)\n throw error;\n\n throw new NetworkRequestError(url, { cause: error });\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(\n (quad, index) => tap(\n arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]),\n ids => ids.forEach(id => (quadsIndexes[id] ??= new Set()).add(index)),\n ),\n )\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const quadIndexes = quadsIndexes[originalId] as Set<number>;\n const normalizedId = md5(\n arr(quadIndexes)\n .map(index => quads[index] as Quad)\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 quadIndexes) {\n const quad = normalizedQuads[index] as Quad;\n const terms: Record<string, Term> = {\n subject: quad.subject as Term,\n object: quad.object as Term,\n };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId)\n continue;\n\n terms[termName] = createBlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n createQuad(\n terms.subject as Term,\n quad.predicate as Term,\n terms.object as Term,\n ),\n );\n }\n }\n\n return normalizedQuads;\n}\n\nexport interface ParsingOptions {\n baseIRI: string;\n normalizeBlankNodes: boolean;\n}\n\nexport interface RDFGraphData {\n quads: Quad[];\n containsRelativeIRIs: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch.bind(window);\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, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(url: string, fetch?: Fetch): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return document;\n } catch (error) {\n if (!(error instanceof NotFoundError))\n throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(resource => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n return jsonLDToRDF(jsonld as JsonLdDocument, { base: baseIRI }) 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 parseTurtle(turtle: string, options: Partial<ParsingOptions> = {}): Promise<RDFGraphData> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new TurtleParser(parserOptions);\n const data: RDFGraphData = {\n quads: [],\n containsRelativeIRIs: false,\n };\n\n return new Promise((resolve, reject) => {\n const resolveRelativeIRI = parser._resolveRelativeIRI;\n\n parser._resolveRelativeIRI = (...args) => {\n data.containsRelativeIRIs = true;\n parser._resolveRelativeIRI = resolveRelativeIRI;\n\n return parser._resolveRelativeIRI(...args);\n };\n\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\n );\n\n return;\n }\n\n if (!quad) {\n // data.quads = options.normalizeBlankNodes\n // ? normalizeBlankNodes(data.quads)\n // : data.quads;\n\n resolve(data);\n\n return;\n }\n\n data.quads.push(quad);\n });\n });\n}\n\nexport async function quadsToJsonLD(quads: Quad[]): Promise<JsonLDGraph> {\n const graph = await jsonLDFromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\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 = stringMatchAll<3>(sparql, /(\\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 = stringMatchAll<3>(sparql, /(\\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 { quads } = await parseTurtle(turtle, options);\n\n return quads;\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\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(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n (error as Error).message ?? '',\n );\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch.bind(window);\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: string[];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(webIdDocument: SolidDocument, fetch?: Fetch): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map(quad => quad.object.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map(quad => quad.subject.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n documents[url] = document;\n store.addQuads(document.getQuads());\n\n addReferencedDocumentUrls(document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some(document => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some(document => document === false),\n writableProfileUrl:\n webIdDocument.isUserWritable()\n ? webIdDocument.url\n : Object\n .values(documents)\n .find((document): document is SolidDocument => !!document && document.isUserWritable())\n ?.url ?? null,\n };\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() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, fetch);\n const storageUrls = store.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.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 {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls),\n ...objectWithoutEmpty({\n name:\n store.statement(webId, 'vcard:fn')?.object.value ??\n store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchLoginUserProfileOptions {\n required?: boolean;\n fetch?: Fetch;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options.fetch);\n }\n\n const fetchProfile = silenced(url => fetchUserProfile(url, options.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 { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/'))\n return null;\n\n if (parts.path.match(/^\\/[^/]*$/))\n return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld)\n return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue))\n __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue))\n propertyValue.forEach(value => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, clone => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts ? {} : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody = type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\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#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await Promise.all([\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch),\n updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch),\n ]);\n\n if (type === 'public') {\n // TODO Implement updating ACLs for the listing itself to public\n }\n\n return typeIndexUrl;\n}\n\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const types = Array.isArray(type) ? type : [type];\n\n return types.map(\n type => typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter(statement => typeIndex.contains(statement.subject.value, 'solid:forClass', type))\n .map(statement => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map(statement => statement.object.value)\n .filter(url => !!url),\n ).flat();\n}\n\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { JsonLD } from '@/helpers/jsonld';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\nconst builtInPatterns: Record<string, string> = {\n '%uuid%': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n};\n\nclass ExpectedQuadAssertionError extends JSError {\n\n constructor(public readonly expectedQuad: Quad) {\n super(`Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n}\n\nfunction assertExpectedQuadsExist(expectedQuads: Quad[], actualQuads: Quad[]): void {\n for (const expectedQuad of expectedQuads) {\n const matchingQuad = actualQuads.find(actualQuad => quadEquals(expectedQuad, actualQuad));\n\n if (!matchingQuad)\n throw new ExpectedQuadAssertionError(expectedQuad);\n\n arrayRemove(actualQuads, matchingQuad);\n }\n}\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction createPatternRegexp(expected: string): RegExp {\n const patternAliases = [];\n const patternMatches = stringMatchAll<4, 1 | 2>(\n expected,\n /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g,\n );\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n patternMatch[2] && patternAliases.push(patternMatch[2]);\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}%`, builtInPatterns[pattern] ?? pattern);\n }\n\n return new RegExp(expectedRegExp);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n return containsPatterns(expected)\n ? (patternsRegExpsIndex[expected] ??= createPatternRegexp(expected)).test(actual)\n : expected === 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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(\n false,\n `Couldn't find the following ${operation} triple: ${quadToTurtle(error.expectedQuad)}`,\n );\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 try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\nimport UnsupportedAuthorizationProtocolError from '@/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@/helpers/io';\nimport type SolidDocument from '@/models/SolidDocument';\nimport type { Fetch } from '@/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? await fetchACLResourceUrl(resourceUrl, fetch);\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', fetch);\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\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 ].join('\\n\\n')\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 { 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","import { faker } from '@noeldemartin/faker';\nimport { stringToSlug } from '@noeldemartin/utils';\n\nexport interface ContainerOptions {\n baseUrl: string;\n}\n\nexport interface DocumentOptions extends ContainerOptions {\n containerUrl: string;\n name: string;\n}\n\nexport interface ResourceOptions extends DocumentOptions {\n documentUrl: string;\n hash: string;\n}\n\nexport function fakeContainerUrl(options: Partial<ContainerOptions> = {}): string {\n const baseUrl = options.baseUrl ?? faker.internet.url();\n\n return baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';\n}\n\nexport function fakeDocumentUrl(options: Partial<DocumentOptions> = {}): string {\n const containerUrl = options.containerUrl ?? fakeContainerUrl(options);\n const name = options.name ?? faker.random.word();\n\n return containerUrl + stringToSlug(name);\n}\n\nexport function fakeResourceUrl(options: Partial<ResourceOptions> = {}): string {\n const documentUrl = options.documentUrl ?? fakeDocumentUrl(options);\n const hash = options.hash ?? 'it';\n\n return documentUrl + '#' + hash;\n}\n","export default class ResponseStub implements Response {\n\n private rawBody: string;\n\n public readonly body!: ReadableStream<Uint8Array> | null;\n public readonly bodyUsed!: boolean;\n public readonly headers: Headers;\n public readonly ok!: boolean;\n public readonly redirected!: boolean;\n public readonly status: number;\n public readonly statusText!: string;\n public readonly trailer!: Promise<Headers>;\n public readonly type!: ResponseType;\n public readonly url!: string;\n\n public constructor(rawBody: string = '', headers: Record<string, string> = {}, status: number = 200) {\n this.rawBody = rawBody;\n this.headers = new Headers(headers);\n this.status = status;\n }\n\n public async arrayBuffer(): Promise<ArrayBuffer> {\n throw new Error('ResponseStub.arrayBuffer is not implemented');\n }\n\n public async blob(): Promise<Blob> {\n throw new Error('ResponseStub.blob is not implemented');\n }\n\n public async formData(): Promise<FormData> {\n throw new Error('ResponseStub.formData is not implemented');\n }\n\n public async json(): Promise<unknown> {\n return JSON.parse(this.rawBody);\n }\n\n public async text(): Promise<string> {\n return this.rawBody;\n }\n\n public clone(): Response {\n return { ...this };\n }\n\n}\n","import { fail } from '@noeldemartin/utils';\nimport type { GetClosureArgs, GetClosureResult } from '@noeldemartin/utils';\n\nimport type { Fetch } from '@/helpers/io';\n\nimport ResponseStub from './ResponseStub';\n\nexport interface FetchMockMethods {\n mockResponse(body?: string, headers?: Record<string, string>, status?: number): void;\n mockNotFoundResponse(): void;\n}\n\nexport type FetchMock = jest.Mock<GetClosureResult<Fetch>, GetClosureArgs<Fetch>> & Fetch & FetchMockMethods;\n\nexport function mockFetch(): FetchMock {\n const responses: ResponseStub[] = [];\n const methods: FetchMockMethods = {\n mockResponse(body, headers, status) {\n responses.push(new ResponseStub(body, headers, status));\n },\n mockNotFoundResponse() {\n responses.push(new ResponseStub('', {}, 404));\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const fetchMock = jest.fn(async (...args: GetClosureArgs<Fetch>) => {\n return responses.shift() ?? fail<Response>('fetch mock called without response');\n });\n\n Object.assign(fetchMock, methods);\n\n return fetchMock as FetchMock;\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","JSError","documentUrl","documentFormat","malformationDetails","errorMessage","NetworkRequestError","url","options","NotFoundError","UnauthorizedError","responseStatus","this","undefined","UnsuccessfulRequestError","messageOrResponse","response","status","getErrorMessage","UnsupportedAuthorizationProtocolError","protocol","knownPrefixes","acl","foaf","pim","purl","rdf","rdfs","schema","solid","vcard","defineIRIPrefix","name","value","expandIRI","iri","startsWith","split","prefix","expandedPrefix","extraContext","_options$extraContext","Error","defaultPrefix","SolidDocumentPermission","SolidThing","quads","property","find","quad","predicate","_this$quads$find","object","filter","map","SolidStore","statements","length","slice","push","subject","statement","_this","_this2","SolidDocument","headers","get","_this$headers$get","match","_this$headers$get2","getUserPermissions","includes","Write","getPermissionsFromWAC","parseDate","_this$statement","getLatestDocumentDate","dates","date","reduce","a","b","type","wacAllow","publicModes","stringMatch","RegExp","_stringMatch","arrayFilter","Read","Append","Control","compactJsonLDGraph","jsonld","compactJsonLD","compactedJsonLD","isJsonLDGraph","fetchRawSolidDocument","fetch","Accept","text","body","_context","cause","normalizeBlankNodes","normalizedQuads","quadsIndexes","arr","flatMap","index","tap","termType","ids","forEach","id","Set","add","unique","originalId","quadIndexes","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","createBlankNode","arrayReplace","createQuad","createSolidDocument","window","bind","turtleToQuads","method","Headers","fetchSolidDocument","data","baseIRI","fetchSolidDocumentIfFound","document","_context4","jsonldToQuads","Promise","all","resource","graphQuads","flat","jsonLDToRDF","base","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","TurtleParser","containsRelativeIRIs","resolve","reject","resolveRelativeIRI","_resolveRelativeIRI","parse","error","Turtle","message","quadsToJsonLD","jsonLDFromRDF","graph","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","isEmpty","sparqlToQuads","operations","stringMatchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","updateSolidDocument","fetchExtendedUserProfile","webIdDocument","store","getQuads","documents","addReferencedDocumentUrls","profileDocumentUrl","loadProfileDocuments","addQuads","values","some","cloaked","writableProfileUrl","isUserWritable","_Object$values$find","fetchUserProfile","webId","urlRoute","isPersonalProfile","contains","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","arrayUnique","_store$statement","_store$statement2","avatarUrl","_store$statement3","_store$statement4","oidcIssuerUrl","_store$statement5","publicTypeIndexUrl","privateTypeIndexUrl","fetchLoginUserProfile","loginUrl","required","fetchProfile","replace","urlRoot","getContainerUrl","parts","containerPath","path","getContainerPath","domain","__mintJsonLDIdentifiers","uuid","propertyValue","isObject","isArray","mintJsonLDIdentifiers","objectDeepClone","clone","parseResourceSubject","urlParse","containerUrl","documentName","pop","resourceHash","fragment","mintTypeIndexUrl","user","storageUrl","typeIndexUrl","createTypeIndex","typeIndexBody","profileUpdateBody","findRegistrations","typeIndex","types","Array","createPublicTypeIndex","createPrivateTypeIndex","findContainerRegistrations","findInstanceRegistrations","patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","expectedQuad","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","actual","expected","datatype","containsPatterns","Date","getTime","quadValueEquals","quadObjectEquals","arrayRemove","test","_patternsRegExpsIndex","patternAliases","patterns","expectedRegExp","patternMatch","patternIndex","pattern","createPatternRegexp","resetPatterns","jsonldEquals","expectedTurtle","actualTurtle","result","success","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","fetchACLResourceUrl","resourceUrl","resourceHead","linkHeader","_linkHeader$match","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","isACPResource","fetchSolidDocumentACL","effectiveUrl","assertions","_obj","assert","query","installChaiPlugin","chai","use","_chai","Assertion","addMethod","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","installJestPlugin","expect","extend","fakeContainerUrl","baseUrl","faker","internet","endsWith","fakeDocumentUrl","random","word","stringToSlug","fakeResourceUrl","hash","ResponseStub","rawBody","JSON","mockFetch","responses","methods","mockResponse","mockNotFoundResponse","fetchMock","jest","fn","shift","fail","assign"],"mappings":"ioKAYYA,GAAZ,SAAYA,GACRA,kBADJ,CAAYA,IAAAA,WAISC,4CAAoCC,6EAMzCC,EAA4BC,EAAqCC,kEApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE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