@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.70fba2db4562da63a3ae210c80936d148acfc0de
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.
- package/dist/io-CMHtz5bu.js +401 -0
- package/dist/io-CMHtz5bu.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +13 -65
- package/dist/noeldemartin-solid-utils.js +224 -0
- package/dist/noeldemartin-solid-utils.js.map +1 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +157 -0
- package/dist/testing.js.map +1 -0
- package/package.json +58 -63
- package/src/errors/UnauthorizedError.ts +1 -3
- package/src/errors/UnsuccessfulNetworkRequestError.ts +2 -2
- package/src/helpers/auth.test.ts +221 -0
- package/src/helpers/auth.ts +28 -27
- package/src/helpers/identifiers.test.ts +76 -0
- package/src/helpers/identifiers.ts +14 -17
- package/src/helpers/index.ts +0 -1
- package/src/helpers/interop.ts +23 -16
- package/src/helpers/io.test.ts +228 -0
- package/src/helpers/io.ts +57 -77
- package/src/helpers/jsonld.ts +6 -6
- package/src/helpers/vocabs.ts +3 -6
- package/src/helpers/wac.test.ts +64 -0
- package/src/helpers/wac.ts +10 -6
- package/src/index.ts +3 -0
- package/src/models/SolidDocument.test.ts +77 -0
- package/src/models/SolidDocument.ts +14 -18
- package/src/models/SolidStore.ts +22 -12
- package/src/models/SolidThing.ts +5 -7
- package/src/models/index.ts +2 -0
- package/src/{helpers/testing.ts → testing/helpers.ts} +24 -27
- package/src/testing/hepers.test.ts +329 -0
- package/src/testing/index.ts +2 -2
- package/src/testing/vitest/index.ts +15 -0
- package/src/testing/vitest/matchers.ts +68 -0
- package/src/types/n3.d.ts +0 -2
- package/.github/workflows/ci.yml +0 -16
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -70
- package/dist/noeldemartin-solid-utils.cjs.js +0 -2
- package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
- package/dist/noeldemartin-solid-utils.esm.js +0 -2
- package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
- package/dist/noeldemartin-solid-utils.umd.js +0 -90
- package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
- package/noeldemartin.config.js +0 -9
- package/src/main.ts +0 -5
- package/src/plugins/chai/assertions.ts +0 -40
- package/src/plugins/chai/index.ts +0 -5
- package/src/plugins/cypress/types.d.ts +0 -15
- package/src/plugins/index.ts +0 -2
- package/src/plugins/jest/index.ts +0 -5
- package/src/plugins/jest/matchers.ts +0 -65
- package/src/plugins/jest/types.d.ts +0 -14
- package/src/testing/ResponseStub.ts +0 -46
- package/src/testing/mocking.ts +0 -33
|
@@ -1,2 +0,0 @@
|
|
|
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 c,arrayFilter as i,objectWithoutEmpty as l,stringMatchAll as f,arr as p,tap as d,arrayReplace as m,urlRoot as h,silenced as v,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,fail as T}from"@noeldemartin/utils";import A 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 q from"@babel/runtime/helpers/esm/asyncToGenerator";import S 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/es.array.sort.js";import"core-js/modules/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.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 D from"md5";import{compactJsonLD as B,jsonLDToRDF as N,TurtleParser as z,jsonLDFromRDF as L,TurtleWriter as W,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";import"core-js/modules/es.object.assign.js";function F(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 H;!function(e){e.Turtle="Turtle"}(H||(H={}));var $=function(n){r(MalformedSolidDocumentError,u);var o=F(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 _(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 J=function(n){r(NetworkRequestError,u);var o=_(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 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(NotFoundError,u);var o=G(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 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(UnauthorizedError,u);var o=K(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 A(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}();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(UnsuccessfulRequestError,u);var o=Y(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 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(UnsupportedAuthorizationProtocolError,u);var o=ee(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}(),re={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",ldp:"http://www.w3.org/ns/ldp#",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 ne(e,t){re[e]=t}function oe(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],s=n[1];if(o&&s){var u,a,c,i=null!==(u=null!==(a=re[o])&&void 0!==a?a:null===(c=t.extraContext)||void 0===c?void 0:c[o])&&void 0!==u?u:null;if(!i)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return i+s}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+o}var se,ue=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 A(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===oe(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===oe(e)})).map((function(e){return e.object.value}))}}]),t}(),ae=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 A(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 oe(e)}}]),t}();function ce(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"}(se||(se={}));var ie=function(n){r(u,ae);var o=ce(u);function u(r,n,a){var c;return e(this,u),c=o.call(this,n),s(t(c),"url",void 0),s(t(c),"headers",void 0),c.url=r,c.headers=a,c}return A(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,oe("rdf:type"),oe("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(se.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 oe(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:"",s=null!==(r=null===(n=c(o,new RegExp("".concat(e,'="([^"]+)"'))))||void 0===n?void 0:n[1])&&void 0!==r?r:"";return i([s.includes("read")&&se.Read,s.includes("write")&&se.Write,s.includes("append")&&se.Append,s.includes("control")&&se.Control])}}]),u}();function le(e){return fe.apply(this,arguments)}function fe(){return(fe=q(S.mark((function e(t){var r;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B(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 pe(e){return"@graph"in e}function de(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 me(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 me(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 me(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var he="anonymous://".length;function ve(e,t){return ye.apply(this,arguments)}function ye(){return(ye=q(S.mark((function e(t,r){var n,o,s,u,a;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},null!=r&&r.cache&&(n.cache=r.cache),e.prev=2,s=null!==(o=null==r?void 0:r.fetch)&&void 0!==o?o:window.fetch,e.next=6,s(t,n);case 6:if(404!==(u=e.sent).status){e.next=9;break}throw new X(t);case 9:if(![401,403].includes(u.status)){e.next=11;break}throw new V(t,u.status);case 11:return e.next=13,u.text();case 13:return a=e.sent,e.abrupt("return",{body:a,headers:u.headers});case 17:if(e.prev=17,e.t0=e.catch(2),!(e.t0 instanceof V)){e.next=21;break}throw e.t0;case 21:if(!(e.t0 instanceof X)){e.next=23;break}throw e.t0;case 23:throw new J(t,{cause:e.t0});case 24:case"end":return e.stop()}}),e,null,[[2,17]])})))).apply(this,arguments)}function be(e){var t,r=e.slice(0),n={},o=de(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 s=function(){var o,s=t.value,u=n[s],a=D(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()),c=de(u);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,h=Object.entries(f);d<h.length;d++){var v=U(h[d],2),y=v[0],b=v[1];"BlankNode"===b.termType&&b.value===s&&(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;)s()}catch(e){o.e(e)}finally{o.f()}return r}function we(e){return e.map((function(e){return" "+Be(e)})).sort().join("\n")}function je(e){var t;null!==(t=e["@id"])&&void 0!==t&&t.startsWith("#")&&(e["@id"]="anonymous://"+e["@id"])}function xe(e){var t,r=de(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;n.subject.value.startsWith("anonymous://")&&(n.subject.value=n.subject.value.slice(he))}}catch(e){r.e(e)}finally{r.f()}}function ge(e,t,r){return ke.apply(this,arguments)}function ke(){return(ke=q(S.mark((function e(t,r,n){var o,s;return S.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,Qe(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 ie(t,s,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(e,t){return Ee.apply(this,arguments)}function Ee(){return(Ee=q(S.mark((function e(t,r){var n,o,s,u;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ve(t,r);case 2:return n=e.sent,o=n.body,s=n.headers,e.next=7,Qe(o,{baseIRI:t});case 7:return u=e.sent,e.abrupt("return",new ie(t,u,s));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ie(e,t){return Pe.apply(this,arguments)}function Pe(){return(Pe=q(S.mark((function e(t,r){var n;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Re(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 X){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 Oe(e,t){return Te.apply(this,arguments)}function Te(){return(Te=q(S.mark((function e(t,r){var n,o;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!pe(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map((function(e){return Oe(e,r)})));case 3:return n=e.sent,e.abrupt("return",n.flat());case 5:return je(t),e.next=8,N(t,{base:r});case 8:return xe(o=e.sent),e.abrupt("return",o);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ae(e){var t=Me(e);return Object.entries(t).reduce((function(e,t){var r=U(t,2),n=r[0],o=we(r[1]);return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function Ue(e){return we(He(e))}function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new z(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 $(null!==(u=t.baseIRI)&&void 0!==u?u:null,H.Turtle,e.message)):n?o.quads.push(n):r(o)}))}))}function Se(e){return Ce.apply(this,arguments)}function Ce(){return(Ce=q(S.mark((function e(t){var r;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,L(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function De(e){return(new W).quadsToString(e)}function Be(e){return(new W).quadsToString([e]).slice(0,-1)}function Ne(e,t){return ze.apply(this,arguments)}function ze(){return(ze=q(S.mark((function e(t,r){var n;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,Re(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 Le(e){return We.apply(this,arguments)}function We(){return We=q(S.mark((function e(t){var r,n,o,s=arguments;return S.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(C(n).map(function(){var e=q(S.mark((function e(t){var n,s;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),s=t[2],e.next=4,Qe(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)}))),We.apply(this,arguments)}function Me(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f(e,/(\w+) DATA {([^}]+)}/g),o={},s=de(n);try{for(s.s();!(t=s.n()).done;){var u=t.value,a=u[1].toLowerCase(),c=u[2];o[a]=He(c,r)}}catch(e){s.e(e)}finally{s.f()}return o}function Qe(e){return Fe.apply(this,arguments)}function Fe(){return Fe=q(S.mark((function e(t){var r,n,o,s=arguments;return S.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,qe(t,r);case 3:return n=e.sent,o=n.quads,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),Fe.apply(this,arguments)}function He(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new z(r);try{var o=n.parse(e);return t.normalizeBlankNodes?be(o):o}catch(e){var s,u;throw new $(null!==(s=t.baseIRI)&&void 0!==s?s:null,H.Turtle,null!==(u=e.message)&&void 0!==u?u:"")}}function $e(e,t,r){return _e.apply(this,arguments)}function _e(){return(_e=q(S.mark((function e(t,r,n){var o;return S.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 Je(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 Ge(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Je(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Je(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Xe(e,t){return Ke.apply(this,arguments)}function Ke(){return Ke=q(S.mark((function e(t,r){var n,o,u,a,c,i;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=new ae(t.getQuads()),a=s({},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=q(S.mark((function e(){var t,n,o,s,i;return S.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),s=o[0],null===o[1]){e.next=5;break}return e.abrupt("continue",20);case 5:return e.prev=5,e.next=8,Re(s,r);case 8:i=e.sent,a[s]=i,u.addQuads(i.getQuads()),c(i),e.next=20;break;case 14:if(e.prev=14,e.t0=e.catch(5),!(e.t0 instanceof V)){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)}}(),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: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)}))),Ke.apply(this,arguments)}function Ve(e){return Ye.apply(this,arguments)}function Ye(){return Ye=q(S.mark((function e(t){var r,n,o,s,u,a,c,i,f,p,d,m,h,j,x,g,k,R,E,I,P,O=arguments;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=O.length>1&&void 0!==O[1]?O[1]:{},p={fetch:f.fetch,cache:"no-store"},d=w(t),e.next=5,Re(d,p);case 5:if((m=e.sent).isPersonalProfile()||m.contains(t,"solid:oidcIssuer")){e.next=8;break}throw new Error("".concat(t," is not a valid webId."));case 8:return e.next=10,Xe(m,f);case 10:h=e.sent,j=h.store,x=h.writableProfileUrl,g=h.cloaked,k=j.statements(t,"pim:storage").map((function(e){return e.object.value})),R=j.statement(t,"solid:publicTypeIndex"),E=j.statement(t,"solid:privateTypeIndex"),I=b(d);case 18:if(!I||0!==k.length){e.next=28;break}return e.next=21,v(Re(I,p));case 21:if(null==(P=e.sent)||!P.isStorage()){e.next=25;break}return k.push(I),e.abrupt("break",28);case 25:I=b(I),e.next=18;break;case 28:if(0!==k.length){e.next=30;break}throw new Error("Could not find any storage for ".concat(t,"."));case 30:return e.next=32,null===(r=f.onLoaded)||void 0===r?void 0:r.call(f,new ae(j.statements(t)));case 32:return e.abrupt("return",Ge({webId:t,cloaked:g,writableProfileUrl:x,storageUrls:y(k)},l({name:null!==(n=null===(o=j.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(s=j.statement(t,"foaf:name"))||void 0===s?void 0:s.object.value,avatarUrl:null!==(u=null===(a=j.statement(t,"vcard:hasPhoto"))||void 0===a?void 0:a.object.value)&&void 0!==u?u:null===(c=j.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(i=j.statement(t,"solid:oidcIssuer"))||void 0===i?void 0:i.object.value,publicTypeIndexUrl:null==R?void 0:R.object.value,privateTypeIndexUrl:null==E?void 0:E.object.value})));case 33:case"end":return e.stop()}}),e)}))),Ye.apply(this,arguments)}function Ze(e){return et.apply(this,arguments)}function et(){return et=q(S.mark((function e(t){var r,n,o,s,u=arguments;return S.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",Ve(t,o));case 3:return s=v((function(e){return Ve(e,o)})),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(h(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)}))),et.apply(this,arguments)}function tt(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 rt(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)&&rt(o),R(o)&&o.forEach((function(e){return k(e)&&rt(e)}))}}}function nt(e){return d(j(e),(function(e){return rt(e)}))}function ot(e){var t=x(e);return t?l({containerUrl:tt(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}}function st(e,t,r){return ut.apply(this,arguments)}function ut(){return(ut=q(S.mark((function e(t,r,n){var o,s,u;return S.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,Ne(u,{fetch: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 at(e,t,r){return ct.apply(this,arguments)}function ct(){return(ct=q(S.mark((function e(t,r,n){var o,s,u,a;return S.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,st(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,ge(s,u,n);case 10:return e.next=12,$e(t.writableProfileUrl,a,n);case 12:return e.abrupt("return",s);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function it(e,t,r,n){return lt.apply(this,arguments)}function lt(){return(lt=q(S.mark((function e(t,r,n,o){var s,u;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Re(t,{fetch: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 ft(e,t){return pt.apply(this,arguments)}function pt(){return(pt=q(S.mark((function e(t,r){return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",at(t,"public",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function dt(e,t){return mt.apply(this,arguments)}function mt(){return(mt=q(S.mark((function e(t,r){return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",at(t,"private",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ht(e,t,r){return vt.apply(this,arguments)}function vt(){return(vt=q(S.mark((function e(t,r,n){return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",it(t,r,"solid:instanceContainer",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yt(e,t,r){return bt.apply(this,arguments)}function bt(){return(bt=q(S.mark((function e(t,r,n){return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",it(t,r,"solid:instance",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wt(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 jt(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 jt(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 jt(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 xt(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 gt={},kt={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},Rt=function(n){r(ExpectedQuadAssertionError,u);var o=xt(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(r){var n;return e(this,ExpectedQuadAssertionError),n=o.call(this,"Couldn't find the following triple: ".concat(Be(r))),s(t(n),"expectedQuad",void 0),n.expectedQuad=r,n}return ExpectedQuadAssertionError}();function Et(e,t){var r,n=wt(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(!It(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 Pt(e.value,t.value)}((r=e).object,n.object)&&Pt(r.subject.value,n.subject.value)&&Pt(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new Rt(e);I(t,n)};for(n.s();!(r=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function It(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Pt(e,t){var r,n;return It(e)?(null!==(n=(r=gt)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],o=e,s=wt(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,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=kt[d])&&void 0!==i?i:d)}return new RegExp(o)}(e)).test(t):e===t}function Ot(){gt={}}function Tt(e,t){return At.apply(this,arguments)}function At(){return(At=q(S.mark((function e(t,r){var n,o,s,u,a;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ot(),e.next=3,Oe(t);case 3:return n=e.sent,e.next=6,Oe(r);case 6:if(o=e.sent,s=De(n),u=De(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,Et(n,o),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof Rt){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 Ut(e,t){var r;Ot();for(var n=Me(e,{normalizeBlankNodes:!0}),o=Me(t,{normalizeBlankNodes:!0}),s=function(r,n){return{success:r,message:n,expected:e,actual:t}},u=0,a=Object.keys(n);u<a.length;u++){var c=a[u];if(!(c in o))return s(!1,"Couldn't find expected ".concat(c," operation."));var i=E(n,c),l=E(o,c);if(i.length!==l.length)return s(!1,"Expected ".concat(i.length," ").concat(c," triples, found ").concat(l.length,"."));try{Et(i,l)}catch(e){if(!(e instanceof Rt))throw e;return s(!1,"Couldn't find the following ".concat(c," triple: ").concat(Be(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 qt(e,t){Ot();var r=He(e,{normalizeBlankNodes:!0}),n=He(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{Et(r,n)}catch(e){if(!(e instanceof Rt))throw e;return o(!1,e.message)}return o(!0,"turtle matches")}function St(e,t){return Ct.apply(this,arguments)}function Ct(){return(Ct=q(S.mark((function e(t,r){var n,o,s,u,a,c,i;return S.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!==(s=null===(u=c.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),i));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Dt(e,t,r){return Bt.apply(this,arguments)}function Bt(){return(Bt=q(S.mark((function e(t,r,n){var o,s,u;return S.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,St(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,Ie(null!==(s=n)&&void 0!==s?s:"",{fetch:r});case 10:if(u=e.sent){e.next=13;break}return e.abrupt("return",Dt(O(t),r));case 13:if(!u.isACPResource()){e.next=15;break}throw new te(t,"ACP");case 15:return e.abrupt("return",u);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Nt(e,t){return zt.apply(this,arguments)}function zt(){return(zt=q(S.mark((function e(t,r){var n,o;return S.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,St(t,r);case 2:return n=e.sent,e.next=5,Dt(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 Lt={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=qt(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=Ut(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function Wt(){chai.use((function(e){return Object.entries(Lt).forEach((function(t){var r=U(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function Mt(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 Qt={toEqualJsonLD:function(e,t){var r=this;return q(S.mark((function n(){var o;return S.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Tt(t,e);case 2:return o=n.sent,n.abrupt("return",Mt(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Mt(Ut(t,e),{context:this,hint:"toEqualSparql",expected:Ae(t),received:Ae(e)})},toEqualTurtle:function(e,t){return Mt(qt(t,e),{context:this,hint:"toEqualTurtle",expected:Ue(t),received:Ue(e)})}};function Ft(){expect.extend(Qt)}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 A(t,[{key:"arrayBuffer",value:(a=q(S.mark((function e(){return S.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=q(S.mark((function e(){return S.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=q(S.mark((function e(){return S.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=q(S.mark((function e(){return S.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=q(S.mark((function e(){return S.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(q(S.mark((function t(){var r;return S.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{$ as MalformedSolidDocumentError,J as NetworkRequestError,X as NotFoundError,$t as ResponseStub,ie as SolidDocument,H as SolidDocumentFormat,se as SolidDocumentPermission,ae as SolidStore,ue as SolidThing,V as UnauthorizedError,Z as UnsuccessfulNetworkRequestError,te as UnsupportedAuthorizationProtocolError,le as compactJsonLDGraph,dt as createPrivateTypeIndex,ft as createPublicTypeIndex,ge as createSolidDocument,ne as defineIRIPrefix,oe as expandIRI,Ze as fetchLoginUserProfile,Re as fetchSolidDocument,Nt as fetchSolidDocumentACL,Ie as fetchSolidDocumentIfFound,ht as findContainerRegistrations,yt as findInstanceRegistrations,Wt as installChaiPlugin,Ft as installJestPlugin,pe as isJsonLDGraph,Tt as jsonldEquals,Oe as jsonldToQuads,nt as mintJsonLDIdentifiers,_t as mockFetch,Ae as normalizeSparql,Ue as normalizeTurtle,ot as parseResourceSubject,qe as parseTurtle,Be as quadToTurtle,Se as quadsToJsonLD,De as quadsToTurtle,Ne as solidDocumentExists,Ut as sparqlEquals,Le as sparqlToQuads,Me as sparqlToQuadsSync,qt as turtleEquals,Qe as turtleToQuads,He as turtleToQuadsSync,$e as updateSolidDocument};
|
|
2
|
-
//# sourceMappingURL=noeldemartin-solid-utils.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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/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 ldp: 'http://www.w3.org/ns/ldp#',\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\nconst ANONYMOUS_PREFIX = 'anonymous://';\nconst ANONYMOUS_PREFIX_LENGTH = ANONYMOUS_PREFIX.length;\n\nasync function fetchRawSolidDocument(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<{ body: string; headers: Headers }> {\n const requestOptions: RequestInit = {\n headers: { Accept: 'text/turtle' },\n };\n\n if (options?.cache) {\n requestOptions.cache = options.cache;\n }\n\n try {\n const fetch = options?.fetch ?? window.fetch;\n const response = await fetch(url, requestOptions);\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\nfunction normalizeQuads(quads: Quad[]): string {\n return quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n}\n\nfunction preprocessSubjects(jsonld: JsonLD): void {\n if (!jsonld['@id']?.startsWith('#')) {\n return;\n }\n\n jsonld['@id'] = ANONYMOUS_PREFIX + jsonld['@id'];\n}\n\nfunction postprocessSubjects(quads: Quad[]): void {\n for (const quad of quads) {\n if (!quad.subject.value.startsWith(ANONYMOUS_PREFIX)) {\n continue;\n }\n\n quad.subject.value = quad.subject.value.slice(ANONYMOUS_PREFIX_LENGTH);\n }\n}\n\nexport interface FetchSolidDocumentOptions {\n fetch?: Fetch;\n cache?: RequestCache;\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, options?: FetchSolidDocumentOptions): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, options);\n const statements = await turtleToQuads(data, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, options);\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 preprocessSubjects(jsonld);\n\n const quads = await (jsonLDToRDF(jsonld as JsonLdDocument, { base: baseIRI }) as Promise<Quad[]>);\n\n postprocessSubjects(quads);\n\n return quads;\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 = normalizeQuads(quads);\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function normalizeTurtle(sparql: string): string {\n const quads = turtleToQuadsSync(sparql);\n\n return normalizeQuads(quads);\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, options?: FetchSolidDocumentOptions): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, options);\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, FetchSolidDocumentOptions } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...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, options?: FetchSolidDocumentOptions): 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, options);\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, options: FetchUserProfileOptions = {}): Promise<SolidUserProfile> {\n const requestOptions: FetchSolidDocumentOptions = {\n fetch: options.fetch,\n\n // Needed for CSS v7.1.3.\n // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972\n cache: 'no-store',\n };\n\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, requestOptions);\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, options);\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, requestOptions));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n await options.onLoaded?.(new SolidStore(store.statements(webId)));\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\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 FetchUserProfileOptions {\n fetch?: Fetch;\n onLoaded?(store: SolidStore): Promise<unknown> | unknown;\n}\n\nexport interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {\n required?: boolean;\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);\n }\n\n const fetchProfile = silenced(url => fetchUserProfile(url, options));\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 createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n await updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\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\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\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\n/**\n * @deprecated Use soukai-solid instead\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, normalizeTurtle } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals, turtleEquals } 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 toEqualTurtle(received, expected) {\n const result = turtleEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualTurtle',\n expected: normalizeTurtle(expected),\n received: normalizeTurtle(received),\n });\n },\n};\n\nexport default matchers;\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\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 } 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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mockFetch<T = any>(): T {\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 unknown as T;\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","ldp","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","ANONYMOUS_PREFIX_LENGTH","fetchRawSolidDocument","requestOptions","Accept","cache","fetch","window","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","normalizeQuads","quadToTurtle","sort","preprocessSubjects","_jsonld$Id","postprocessSubjects","createSolidDocument","bind","turtleToQuads","method","Headers","fetchSolidDocument","data","baseIRI","fetchSolidDocumentIfFound","document","_context4","jsonldToQuads","Promise","all","resource","graphQuads","flat","jsonLDToRDF","base","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","concat","toUpperCase","normalizeTurtle","turtleToQuadsSync","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","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","onLoaded","_options$onLoaded","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","toEqualTurtle","installJestPlugin","expect","extend","ResponseStub","rawBody","JSON","mockFetch","responses","methods","mockResponse","mockNotFoundResponse","fetchMock","jest","fn","shift","fail","assign"],"mappings":"ohKAYYA,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,IAAxBC,KAAKD,eACW,MAAxBC,KAAKD,oBACLE,scCbOC,yCAAiCb,uEAMtCc,EAAsCC,+DAdtD,SAAyBD,EAAsCC,gBAC3DA,YAAWA,iBAAYD,EAEa,iBAAtBA,YACLA,wBAA+BC,EAASC,6CAC7BD,EAAST,yBAAgBS,EAASC,uBAU5CC,CAAgBH,EAAmBC,gCAEpCA,SAAWA,MAAAA,EAAAA,EAAYD,mdChBfI,uDAA8ClB,kGAKnDM,EAAaa,EAAkBZ,sGACdD,8DAAuDa,OAAaZ,oDAExFD,IAAMA,IACNa,SAAWA,oDCLlBC,GAA4B,CAC9BC,IAAK,iCACLC,KAAM,6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