@noeldemartin/solid-utils 0.1.1-next.8dbff68470e9068fdba6a336302f07e0df1dcd79 → 0.1.1-next.9e1ba757a71d124d509b14f4ed0de95a13e0c196
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/noeldemartin-solid-utils.cjs.js +1 -1
- package/dist/noeldemartin-solid-utils.cjs.js.map +1 -1
- package/dist/noeldemartin-solid-utils.d.ts +57 -17
- package/dist/noeldemartin-solid-utils.esm.js +1 -1
- package/dist/noeldemartin-solid-utils.esm.js.map +1 -1
- package/package.json +4 -7
- package/src/errors/MalformedSolidDocumentError.ts +2 -2
- package/src/errors/NetworkRequestError.ts +4 -4
- package/src/errors/NotFoundError.ts +2 -2
- package/src/errors/UnauthorizedError.ts +2 -2
- package/src/errors/UnsuccessfulNetworkRequestError.ts +23 -0
- package/src/errors/index.ts +1 -0
- package/src/helpers/auth.ts +82 -16
- package/src/helpers/interop.ts +63 -27
- package/src/helpers/io.ts +78 -47
- package/src/helpers/jsonld.ts +17 -0
- package/src/helpers/testing.ts +2 -2
- package/src/helpers/vocabs.ts +2 -1
- package/src/helpers/wac.ts +6 -2
- package/src/models/SolidDocument.ts +38 -37
- package/src/models/SolidStore.ts +61 -0
- package/src/models/index.ts +2 -1
- package/src/plugins/jest/matchers.ts +5 -7
- package/src/types/n3.d.ts +9 -0
|
@@ -11,14 +11,18 @@ declare global {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
}
|
|
14
|
-
import {
|
|
15
|
-
import type {
|
|
14
|
+
import { JSError } from '@noeldemartin/utils';
|
|
15
|
+
import type { JSErrorOptions } from '@noeldemartin/utils';
|
|
16
16
|
import type { Quad } from 'rdf-js';
|
|
17
17
|
|
|
18
18
|
export declare type AnyFetch = (input: any, options?: any) => Promise<Response>;
|
|
19
19
|
|
|
20
|
+
export declare function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGraph>;
|
|
21
|
+
|
|
20
22
|
export declare function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string>;
|
|
21
23
|
|
|
24
|
+
export declare function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string>;
|
|
25
|
+
|
|
22
26
|
export declare function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument>;
|
|
23
27
|
|
|
24
28
|
export declare function defineIRIPrefix(name: string, value: string): void;
|
|
@@ -51,7 +55,9 @@ export declare function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch)
|
|
|
51
55
|
|
|
52
56
|
export declare function fetchSolidDocumentIfFound(url: string, fetch?: Fetch): Promise<SolidDocument | null>;
|
|
53
57
|
|
|
54
|
-
export declare function
|
|
58
|
+
export declare function findContainerRegistrations(typeIndexUrl: string, type: string | string[], fetch?: Fetch): Promise<string[]>;
|
|
59
|
+
|
|
60
|
+
export declare function findInstanceRegistrations(typeIndexUrl: string, type: string | string[], fetch?: Fetch): Promise<string[]>;
|
|
55
61
|
|
|
56
62
|
export declare function installChaiPlugin(): void;
|
|
57
63
|
|
|
@@ -77,9 +83,9 @@ export declare type JsonLDResource = Omit<JsonLD, '@id'> & {
|
|
|
77
83
|
'@id': string;
|
|
78
84
|
};
|
|
79
85
|
|
|
80
|
-
export declare function jsonldToQuads(jsonld: JsonLD): Promise<Quad[]>;
|
|
86
|
+
export declare function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]>;
|
|
81
87
|
|
|
82
|
-
export declare class MalformedSolidDocumentError extends
|
|
88
|
+
export declare class MalformedSolidDocumentError extends JSError {
|
|
83
89
|
readonly documentUrl: string | null;
|
|
84
90
|
readonly documentFormat: SolidDocumentFormat;
|
|
85
91
|
readonly malformationDetails: string;
|
|
@@ -88,22 +94,24 @@ export declare class MalformedSolidDocumentError extends Error_2 {
|
|
|
88
94
|
|
|
89
95
|
export declare function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource;
|
|
90
96
|
|
|
91
|
-
export declare class NetworkRequestError extends
|
|
97
|
+
export declare class NetworkRequestError extends JSError {
|
|
92
98
|
readonly url: string;
|
|
93
|
-
constructor(url: string, options?:
|
|
99
|
+
constructor(url: string, options?: JSErrorOptions);
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
export declare function normalizeSparql(sparql: string): string;
|
|
97
103
|
|
|
98
|
-
export declare class NotFoundError extends
|
|
104
|
+
export declare class NotFoundError extends JSError {
|
|
99
105
|
readonly url: string;
|
|
100
106
|
constructor(url: string);
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
export declare function parseResourceSubject(subject: string): SubjectParts;
|
|
104
110
|
|
|
111
|
+
export declare function parseTurtle(turtle: string, options?: Partial<ParsingOptions>): Promise<RDFGraphData>;
|
|
112
|
+
|
|
105
113
|
export declare interface ParsingOptions {
|
|
106
|
-
|
|
114
|
+
baseIRI: string;
|
|
107
115
|
normalizeBlankNodes: boolean;
|
|
108
116
|
}
|
|
109
117
|
|
|
@@ -115,20 +123,24 @@ export declare function quadToTurtle(quad: Quad): string;
|
|
|
115
123
|
|
|
116
124
|
export declare type RDFContext = Record<string, string>;
|
|
117
125
|
|
|
118
|
-
export declare
|
|
126
|
+
export declare interface RDFGraphData {
|
|
127
|
+
quads: Quad[];
|
|
128
|
+
containsRelativeIRIs: boolean;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export declare class SolidDocument extends SolidStore {
|
|
119
132
|
readonly url: string;
|
|
120
133
|
readonly headers: Headers;
|
|
121
|
-
private quads;
|
|
122
134
|
constructor(url: string, quads: Quad[], headers: Headers);
|
|
123
|
-
isEmpty(): boolean;
|
|
124
135
|
isPersonalProfile(): boolean;
|
|
125
136
|
isStorage(): boolean;
|
|
137
|
+
isUserWritable(): boolean;
|
|
138
|
+
getUserPermissions(): SolidDocumentPermission[];
|
|
139
|
+
getPublicPermissions(): SolidDocumentPermission[];
|
|
126
140
|
getLastModified(): Date | null;
|
|
127
|
-
|
|
128
|
-
statement(subject?: string, predicate?: string, object?: string): Quad | null;
|
|
129
|
-
contains(subject: string, predicate?: string, object?: string): boolean;
|
|
130
|
-
getThing(subject: string): SolidThing;
|
|
141
|
+
protected expandIRI(iri: string): string;
|
|
131
142
|
private getLatestDocumentDate;
|
|
143
|
+
private getPermissionsFromWAC;
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
export declare function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean>;
|
|
@@ -137,6 +149,26 @@ export declare enum SolidDocumentFormat {
|
|
|
137
149
|
Turtle = "Turtle"
|
|
138
150
|
}
|
|
139
151
|
|
|
152
|
+
export declare enum SolidDocumentPermission {
|
|
153
|
+
Read = "read",
|
|
154
|
+
Write = "write",
|
|
155
|
+
Append = "append",
|
|
156
|
+
Control = "control"
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare class SolidStore {
|
|
160
|
+
private quads;
|
|
161
|
+
constructor(quads?: Quad[]);
|
|
162
|
+
isEmpty(): boolean;
|
|
163
|
+
getQuads(): Quad[];
|
|
164
|
+
addQuads(quads: Quad[]): void;
|
|
165
|
+
statements(subject?: string, predicate?: string, object?: string): Quad[];
|
|
166
|
+
statement(subject?: string, predicate?: string, object?: string): Quad | null;
|
|
167
|
+
contains(subject: string, predicate?: string, object?: string): boolean;
|
|
168
|
+
getThing(subject: string): SolidThing;
|
|
169
|
+
protected expandIRI(iri: string): string;
|
|
170
|
+
}
|
|
171
|
+
|
|
140
172
|
export declare class SolidThing {
|
|
141
173
|
readonly url: string;
|
|
142
174
|
private quads;
|
|
@@ -148,6 +180,8 @@ export declare class SolidThing {
|
|
|
148
180
|
export declare interface SolidUserProfile {
|
|
149
181
|
webId: string;
|
|
150
182
|
storageUrls: string[];
|
|
183
|
+
cloaked: boolean;
|
|
184
|
+
writableProfileUrl: string | null;
|
|
151
185
|
name?: string;
|
|
152
186
|
avatarUrl?: string;
|
|
153
187
|
oidcIssuerUrl?: string;
|
|
@@ -175,13 +209,19 @@ export declare function turtleToQuadsSync(turtle: string, options?: Partial<Pars
|
|
|
175
209
|
|
|
176
210
|
export declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;
|
|
177
211
|
|
|
178
|
-
export declare class UnauthorizedError extends
|
|
212
|
+
export declare class UnauthorizedError extends JSError {
|
|
179
213
|
readonly url: string;
|
|
180
214
|
readonly responseStatus?: number;
|
|
181
215
|
constructor(url: string, responseStatus?: number);
|
|
182
216
|
get forbidden(): boolean | undefined;
|
|
183
217
|
}
|
|
184
218
|
|
|
219
|
+
export declare class UnsuccessfulNetworkRequestError extends JSError {
|
|
220
|
+
response: Response;
|
|
221
|
+
constructor(response: Response);
|
|
222
|
+
constructor(message: string, response: Response);
|
|
223
|
+
}
|
|
224
|
+
|
|
185
225
|
export declare function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void>;
|
|
186
226
|
|
|
187
227
|
export { }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.to-string-tag.js";import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/assertThisInitialized";import r from"@babel/runtime/helpers/esm/inherits";import n from"@babel/runtime/helpers/esm/possibleConstructorReturn";import o from"@babel/runtime/helpers/esm/getPrototypeOf";import s from"@babel/runtime/helpers/esm/defineProperty";import"core-js/modules/es.array.concat.js";import{Error as u,parseDate as a,stringMatchAll as i,objectWithoutEmpty as c,arr as l,tap as f,arrayFilter as p,arrayReplace as d,urlRoot as m,silenced as v,urlParentDirectory as h,urlRoute as j,objectDeepClone as y,urlParse as x,uuid as w,isObject as b,isArray as g,pull as k,arrayRemove as E,requireUrlParentDirectory as T}from"@noeldemartin/utils";import R from"@babel/runtime/helpers/esm/createClass";import A from"@babel/runtime/helpers/esm/asyncToGenerator";import I from"@babel/runtime/regenerator";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.regexp.exec.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.regexp.test.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import P from"@babel/runtime/helpers/esm/toConsumableArray";import S from"@babel/runtime/helpers/esm/slicedToArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/esnext.async-iterator.filter.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.filter.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/esnext.async-iterator.flat-map.js";import"core-js/modules/esnext.iterator.flat-map.js";import"core-js/modules/esnext.async-iterator.for-each.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.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.object.entries.js";import"core-js/modules/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import U from"md5";import{Writer as q,Parser as D,BlankNode as N,Quad as C}from"n3";import{toRDF as B,fromRDF as O}from"jsonld";import"core-js/modules/es.string.match.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.string.starts-with.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.object.values.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.keys.js";function z(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,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 L;!function(e){e.Turtle="Turtle"}(L||(L={}));var M=function(n){r(MalformedSolidDocumentError,u);var o=z(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 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 Q=function(n){r(NetworkRequestError,u);var o=F(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 H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var $=function(n){r(NotFoundError,u);var o=H(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 J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,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 W=function(n){r(UnauthorizedError,u);var o=J(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 R(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(),_={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdfs:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function G(e,t){_[e]=t}function X(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=S(r,2),o=n[0],s=n[1];if(o&&s){var u,a,i,c=null!==(u=null!==(a=_[o])&&void 0!==a?a:null===(i=t.extraContext)||void 0===i?void 0:i[o])&&void 0!==u?u:null;if(!c)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return c+s}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+o}var K=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 R(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===X(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===X(e)})).map((function(e){return e.object.value}))}}]),t}(),V=function(){function t(r,n,o){e(this,t),s(this,"url",void 0),s(this,"headers",void 0),s(this,"quads",void 0),this.url=r,this.quads=n,this.headers=o}return R(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,X("rdfs:type"),X("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=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:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(o){return!(r&&o.object.value!==X(r,{defaultPrefix:n.url})||e&&o.subject.value!==X(e,{defaultPrefix:n.url})||t&&o.predicate.value!==X(t,{defaultPrefix:n.url}))}))}},{key:"statement",value:function(e,t,r){var n=this,o=this.quads.find((function(o){return!(r&&o.object.value!==X(r,{defaultPrefix:n.url})||e&&o.subject.value!==X(e,{defaultPrefix:n.url})||t&&o.predicate.value!==X(t,{defaultPrefix:n.url}))}));return null!=o?o:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new K(e,t)}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(P(this.statements(void 0,"purl:modified")),P(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}}]),t}();function Y(e){return"@graph"in e}function Z(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return ee(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ee(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw s}}}}function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function te(e,t){return re.apply(this,arguments)}function re(){return(re=A(I.mark((function e(t,r){var n,o,s;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(o=e.sent).status){e.next=7;break}throw new $(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new W(t,o.status);case 9:return e.next=11,o.text();case 11:return s=e.sent,e.abrupt("return",{body:s,headers:o.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof W)){e.next=19;break}throw e.t0;case 19:if(!(e.t0 instanceof $)){e.next=21;break}throw e.t0;case 21:throw new Q(t,{cause:e.t0});case 22:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function ne(e){var t,r=e.slice(0),n={},o=Z(l(e).flatMap((function(e,t){return f(p(["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=U(l(u).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===s})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),i=Z(u);try{for(i.s();!(o=i.n()).done;){for(var c=o.value,f=r[c],p={subject:f.subject,object:f.object},m=0,v=Object.entries(p);m<v.length;m++){var h=S(v[m],2),j=h[0],y=h[1];"BlankNode"===y.termType&&y.value===s&&(p[j]=new N(a))}d(r,f,new C(p.subject,f.predicate,p.object))}}catch(e){i.e(e)}finally{i.f()}};for(o.s();!(t=o.n()).done;)s()}catch(e){o.e(e)}finally{o.f()}return r}function oe(e,t,r){return se.apply(this,arguments)}function se(){return(se=A(I.mark((function e(t,r,n){var o,s;return I.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,ge(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 V(t,s,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ue(e,t){return ae.apply(this,arguments)}function ae(){return(ae=A(I.mark((function e(t,r){var n,o,s,u;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,te(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,s=n.headers,e.next=7,ge(o,{documentUrl:t});case 7:return u=e.sent,e.abrupt("return",new V(t,u,s));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ie(e,t){return ce.apply(this,arguments)}function ce(){return(ce=A(I.mark((function e(t,r){var n;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ue(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 $){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 le(e){return fe.apply(this,arguments)}function fe(){return(fe=A(I.mark((function e(t){var r;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Y(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map(le));case 3:return r=e.sent,e.abrupt("return",r.flat());case 5:return e.abrupt("return",B(t));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function pe(e){var t=be(e);return Object.entries(t).reduce((function(e,t){var r=S(t,2),n=r[0],o=r[1].map((function(e){return" "+he(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function de(e){return me.apply(this,arguments)}function me(){return(me=A(I.mark((function e(t){var r;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(e){return(new q).quadsToString(e)}function he(e){return(new q).quadsToString([e]).slice(0,-1)}function je(e,t){return ye.apply(this,arguments)}function ye(){return(ye=A(I.mark((function e(t,r){var n;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,ue(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 xe(e){return we.apply(this,arguments)}function we(){return we=A(I.mark((function e(t){var r,n,o,s=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=s.length>1&&void 0!==s[1]?s[1]:{},n=i(t,/(\w+) DATA {([^}]+)}/g),o={},e.next=5,Promise.all(P(n).map(function(){var e=A(I.mark((function e(t){var n,s;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),s=t[2],e.next=4,ge(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 be(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=i(e,/(\w+) DATA {([^}]+)}/g),o={},s=Z(n);try{for(s.s();!(t=s.n()).done;){var u=t.value,a=u[1].toLowerCase(),c=u[2];o[a]=Ee(c,r)}}catch(e){s.e(e)}finally{s.f()}return o}function ge(e){return ke.apply(this,arguments)}function ke(){return ke=A(I.mark((function e(t){var r,n,o,s,u=arguments;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=u.length>1&&void 0!==u[1]?u[1]:{},n=c({baseIRI:r.documentUrl}),o=new D(n),s=[],e.abrupt("return",new Promise((function(e,n){o.parse(t,(function(t,o){var u;t?n(new M(null!==(u=r.documentUrl)&&void 0!==u?u:null,L.Turtle,t.message)):o?s.push(o):r.normalizeBlankNodes?e(ne(s)):e(s)}))})));case 5:case"end":return e.stop()}}),e)}))),ke.apply(this,arguments)}function Ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=c({baseIRI:t.documentUrl}),n=new D(r);try{var o=n.parse(e);return t.normalizeBlankNodes?ne(o):o}catch(e){var s,u;throw new M(null!==(s=t.documentUrl)&&void 0!==s?s:null,L.Turtle,null!==(u=e.message)&&void 0!==u?u:"")}}function Te(e,t,r){return Re.apply(this,arguments)}function Re(){return(Re=A(I.mark((function e(t,r,n){var o;return I.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 Ae(e,t){return Ie.apply(this,arguments)}function Ie(){return(Ie=A(I.mark((function e(t,r){var n,o,s,u,a,i,l,f,p,d,m,y,x,w;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=j(t),e.next=3,ue(f,r);case 3:if((p=e.sent).isPersonalProfile()){e.next=6;break}throw new Error("Document at ".concat(f," is not a profile."));case 6:d=p.statements(t,"pim:storage").map((function(e){return e.object.value})),m=p.statement(t,"solid:publicTypeIndex"),y=p.statement(t,"solid:privateTypeIndex"),x=h(f);case 10:if(!x||0!==d.length){e.next=20;break}return e.next=13,v(ue(x,r));case 13:if(null==(w=e.sent)||!w.isStorage()){e.next=17;break}return d.push(x),e.abrupt("break",20);case 17:x=h(x),e.next=10;break;case 20:return e.abrupt("return",c({webId:t,storageUrls:d,name:null!==(n=null===(o=p.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(s=p.statement(t,"foaf:name"))||void 0===s?void 0:s.object.value,avatarUrl:null!==(u=null===(a=p.statement(t,"vcard:hasPhoto"))||void 0===a?void 0:a.object.value)&&void 0!==u?u:null===(i=p.statement(t,"foaf:img"))||void 0===i?void 0:i.object.value,oidcIssuerUrl:null===(l=p.statement(t,"solid:oidcIssuer"))||void 0===l?void 0:l.object.value,publicTypeIndexUrl:null==m?void 0:m.object.value,privateTypeIndexUrl:null==y?void 0:y.object.value}));case 21:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pe(e,t){return Se.apply(this,arguments)}function Se(){return(Se=A(I.mark((function e(t,r){var n,o,s;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=v((function(e){return Ae(e,r)})),e.next=3,s(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,s(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,s(m(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ue(e){var t=function(e){return e.path&&e.path.startsWith("/")?e.path.match(/^\/[^/]*$/)?"/":"/".concat(l(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 qe(e){var t;if("@type"in e&&!("@value"in e)){e["@id"]=null!==(t=e["@id"])&&void 0!==t?t:w();for(var r=0,n=Object.values(e);r<n.length;r++){var o=n[r];b(o)&&qe(o),g(o)&&o.forEach((function(e){return b(e)&&qe(e)}))}}}function De(e){return f(y(e),(function(e){return qe(e)}))}function Ne(e){var t=x(e);return t?c({containerUrl:Ue(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}}function Ce(e,t){return Be.apply(this,arguments)}function Be(){return(Be=A(I.mark((function e(t,r){var n,o,s;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(r),o=t.storageUrls[0],s="".concat(o,"settings/privateTypeIndex"),e.next=5,je(s,r);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/privateTypeIndex-").concat(w()),e.next=10;break;case 9:e.t0=s;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(e,t){return ze.apply(this,arguments)}function ze(){return(ze=A(I.mark((function e(t,r){var n,o,s;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(r),e.next=3,Ce(t,r);case 3:return o=e.sent,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",s="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#privateTypeIndex> <").concat(o,"> .\n }\n "),e.next=8,Promise.all([oe(o,"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",r),Te(t.webId,s,r)]);case 8:return e.abrupt("return",o);case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Le(e,t,r){return Me.apply(this,arguments)}function Me(){return(Me=A(I.mark((function e(t,r,n){var o,s,u;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ue(t,n);case 2:return s=e.sent,u=s.statements(void 0,"rdfs:type","solid:TypeRegistration").find((function(e){return s.contains(e.subject.value,"solid:forClass",r)&&s.contains(e.subject.value,"solid:instanceContainer")})),e.abrupt("return",u&&null!==(o=s.getThing(u.subject.value))&&void 0!==o?o:null);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Fe(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 Qe(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 Qe(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 Qe(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 He(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 $e={},Je={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},We=function(n){r(ExpectedQuadAssertionError,u);var o=He(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(r){var n;return e(this,ExpectedQuadAssertionError),n=o.call(this,"Couldn't find the following triple: ".concat(he(r))),s(t(n),"expectedQuad",void 0),n.expectedQuad=r,n}return ExpectedQuadAssertionError}();function _e(e,t){var r,n=Fe(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(!Ge(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 Xe(e.value,t.value)}((r=e).object,n.object)&&Xe(r.subject.value,n.subject.value)&&Xe(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new We(e);E(t,n)};for(n.s();!(r=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function Ge(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Xe(e,t){var r,n;return Ge(e)?(null!==(n=(r=$e)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],o=e,s=Fe(i(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 l,f=S(c[a],2),p=f[0],d=f[1];o=o.replace("%PATTERN".concat(p,"%"),null!==(l=Je[d])&&void 0!==l?l:d)}return new RegExp(o)}(e)).test(t):e===t}function Ke(){$e={}}function Ve(e,t){return Ye.apply(this,arguments)}function Ye(){return(Ye=A(I.mark((function e(t,r){var n,o,s,u,a;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Ke(),e.next=3,le(t);case 3:return n=e.sent,e.next=6,le(r);case 6:if(o=e.sent,s=ve(n),u=ve(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,_e(n,o),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof We){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 Ze(e,t){var r;Ke();for(var n=be(e,{normalizeBlankNodes:!0}),o=be(t,{normalizeBlankNodes:!0}),s=function(r,n){return{success:r,message:n,expected:e,actual:t}},u=0,a=Object.keys(n);u<a.length;u++){var i=a[u];if(!(i in o))return s(!1,"Couldn't find expected ".concat(i," operation."));var c=k(n,i),l=k(o,i);if(c.length!==l.length)return s(!1,"Expected ".concat(c.length," ").concat(i," triples, found ").concat(l.length,"."));try{_e(c,l)}catch(e){if(!(e instanceof We))throw e;return s(!1,"Couldn't find the following ".concat(i," triple: ").concat(he(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 et(e,t){Ke();var r=Ee(e,{normalizeBlankNodes:!0}),n=Ee(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{_e(r,n)}catch(e){if(!(e instanceof We))throw e;return o(!1,e.message)}return o(!0,"turtle matches")}function tt(e,t){return rt.apply(this,arguments)}function rt(){return(rt=A(I.mark((function e(t,r){var n,o,s,u,a,i,c;return I.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:return a=e.sent,i=null!==(o=a.headers.get("Link"))&&void 0!==o?o:"",c=null!==(s=null===(u=i.match(/<([^>]+)>;\s*rel="acl"/))||void 0===u?void 0:u[1])&&void 0!==s?s:null,e.abrupt("return",null!=c?c:fail("Could not find ACL Resource for '".concat(t,"'")));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function nt(e,t,r){return ot.apply(this,arguments)}function ot(){return(ot=A(I.mark((function e(t,r,n){var o,s,u;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(o=n)||void 0===o){e.next=4;break}e.t0=o,e.next=7;break;case 4:return e.next=6,tt(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,ie(null!==(u=n)&&void 0!==u?u:"",r);case 10:if(e.t2=s=e.sent,e.t1=null!==e.t2,!e.t1){e.next=14;break}e.t1=void 0!==s;case 14:if(!e.t1){e.next=18;break}e.t3=s,e.next=21;break;case 18:return e.next=20,nt(T(t),r);case 20:e.t3=e.sent;case 21:return e.abrupt("return",e.t3);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function st(e,t){return ut.apply(this,arguments)}function ut(){return(ut=A(I.mark((function e(t,r){var n,o;return I.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,tt(t,r);case 2:return n=e.sent,e.next=5,nt(t,r,n);case 5:return o=e.sent,e.abrupt("return",c({url:n,effectiveUrl:o.url,document:o}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var at={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=et(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=Ze(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function it(){chai.use((function(e){return Object.entries(at).forEach((function(t){var r=S(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function ct(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}:function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}}}var lt={toEqualJsonLD:function(e,t){var r=this;return A(I.mark((function n(){var o;return I.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Ve(t,e);case 2:return o=n.sent,n.abrupt("return",ct(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return ct(Ze(t,e),{context:this,hint:"toEqualSparql",expected:pe(t),received:pe(e)})}};function ft(){expect.extend(lt)}export{M as MalformedSolidDocumentError,Q as NetworkRequestError,$ as NotFoundError,V as SolidDocument,L as SolidDocumentFormat,K as SolidThing,W as UnauthorizedError,Oe as createPrivateTypeIndex,oe as createSolidDocument,G as defineIRIPrefix,X as expandIRI,Pe as fetchLoginUserProfile,ue as fetchSolidDocument,st as fetchSolidDocumentACL,ie as fetchSolidDocumentIfFound,Le as findContainerRegistration,it as installChaiPlugin,ft as installJestPlugin,Y as isJsonLDGraph,Ve as jsonldEquals,le as jsonldToQuads,De as mintJsonLDIdentifiers,pe as normalizeSparql,Ne as parseResourceSubject,he as quadToTurtle,de as quadsToJsonLD,ve as quadsToTurtle,je as solidDocumentExists,Ze as sparqlEquals,xe as sparqlToQuads,be as sparqlToQuadsSync,et as turtleEquals,ge as turtleToQuads,Ee as turtleToQuadsSync,Te as updateSolidDocument};
|
|
1
|
+
import"core-js/modules/es.object.to-string.js";import"core-js/modules/es.reflect.to-string-tag.js";import"core-js/modules/es.reflect.construct.js";import e from"@babel/runtime/helpers/esm/classCallCheck";import t from"@babel/runtime/helpers/esm/assertThisInitialized";import r from"@babel/runtime/helpers/esm/inherits";import n from"@babel/runtime/helpers/esm/possibleConstructorReturn";import o from"@babel/runtime/helpers/esm/getPrototypeOf";import s from"@babel/runtime/helpers/esm/defineProperty";import"core-js/modules/es.array.concat.js";import{JSError as u,parseDate as a,stringMatch as c,arrayFilter as i,objectWithoutEmpty as l,stringMatchAll as f,arr as p,tap as d,arrayReplace as m,urlRoot as v,silenced as h,urlParentDirectory as y,urlRoute as b,objectDeepClone as j,urlParse as w,uuid as x,isObject as g,isArray as k,pull as R,arrayRemove as I,urlResolve as E,requireUrlParentDirectory as P}from"@noeldemartin/utils";import T from"@babel/runtime/helpers/esm/createClass";import"core-js/modules/es.object.keys.js";import"core-js/modules/es.symbol.js";import"core-js/modules/es.array.filter.js";import"core-js/modules/esnext.async-iterator.filter.js";import"core-js/modules/esnext.iterator.filter.js";import"core-js/modules/es.object.get-own-property-descriptor.js";import"core-js/modules/es.object.get-own-property-descriptors.js";import A from"@babel/runtime/helpers/esm/slicedToArray";import O from"@babel/runtime/helpers/esm/asyncToGenerator";import q from"@babel/runtime/regenerator";import"core-js/modules/esnext.async-iterator.for-each.js";import"core-js/modules/esnext.iterator.constructor.js";import"core-js/modules/esnext.iterator.for-each.js";import"core-js/modules/web.dom-collections.for-each.js";import"core-js/modules/es.array.map.js";import"core-js/modules/esnext.async-iterator.map.js";import"core-js/modules/esnext.iterator.map.js";import"core-js/modules/es.object.entries.js";import"core-js/modules/esnext.async-iterator.some.js";import"core-js/modules/esnext.iterator.some.js";import"core-js/modules/es.object.values.js";import"core-js/modules/es.array.find.js";import"core-js/modules/esnext.async-iterator.find.js";import"core-js/modules/esnext.iterator.find.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.replace.js";import U from"@babel/runtime/helpers/esm/toConsumableArray";import"core-js/modules/es.array.slice.js";import"core-js/modules/es.string.starts-with.js";import"core-js/modules/es.string.split.js";import"core-js/modules/es.function.name.js";import"core-js/modules/es.array.from.js";import"core-js/modules/es.regexp.test.js";import"core-js/modules/es.symbol.description.js";import"core-js/modules/es.symbol.iterator.js";import"core-js/modules/es.array.flat-map.js";import"core-js/modules/es.array.unscopables.flat-map.js";import"core-js/modules/esnext.async-iterator.flat-map.js";import"core-js/modules/esnext.iterator.flat-map.js";import"core-js/modules/es.array.iterator.js";import"core-js/modules/es.set.js";import"core-js/modules/es.string.iterator.js";import"core-js/modules/esnext.set.add-all.js";import"core-js/modules/esnext.set.delete-all.js";import"core-js/modules/esnext.set.difference.js";import"core-js/modules/esnext.set.every.js";import"core-js/modules/esnext.set.filter.js";import"core-js/modules/esnext.set.find.js";import"core-js/modules/esnext.set.intersection.js";import"core-js/modules/esnext.set.is-disjoint-from.js";import"core-js/modules/esnext.set.is-subset-of.js";import"core-js/modules/esnext.set.is-superset-of.js";import"core-js/modules/esnext.set.join.js";import"core-js/modules/esnext.set.map.js";import"core-js/modules/esnext.set.reduce.js";import"core-js/modules/esnext.set.some.js";import"core-js/modules/esnext.set.symmetric-difference.js";import"core-js/modules/esnext.set.union.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.join.js";import"core-js/modules/esnext.async-iterator.reduce.js";import"core-js/modules/esnext.iterator.reduce.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.promise.js";import"core-js/modules/es.array.includes.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import S from"md5";import{compactJsonLD as C,jsonLDToRDF as D,TurtleParser as N,jsonLDFromRDF as B,TurtleWriter as z,createBlankNode as L,createQuad as M}from"@noeldemartin/solid-utils-external";import"core-js/modules/es.string.match.js";import"core-js/modules/es.string.includes.js";import"core-js/modules/es.regexp.constructor.js";import"core-js/modules/es.regexp.sticky.js";import"core-js/modules/es.regexp.to-string.js";function Q(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 W;!function(e){e.Turtle="Turtle"}(W||(W={}));var F=function(n){r(MalformedSolidDocumentError,u);var o=Q(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 H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=o(e);if(t){var u=o(this).constructor;r=Reflect.construct(s,arguments,u)}else r=s.apply(this,arguments);return n(this,r)}}var $=function(n){r(NetworkRequestError,u);var o=H(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 _(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(NotFoundError,u);var o=_(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 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(UnauthorizedError,u);var o=G(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 T(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}();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(UnsuccessfulRequestError,u);var o=K(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}(),Y={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function Z(e,t){Y[e]=t}function ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=A(r,2),o=n[0],s=n[1];if(o&&s){var u,a,c,i=null!==(u=null!==(a=Y[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 te,re=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 T(t,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===ee(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===ee(e)})).map((function(e){return e.object.value}))}}]),t}(),ne=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 T(t,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"getQuads",value:function(){return this.quads.slice(0)}},{key:"addQuads",value:function(e){var t;(t=this.quads).push.apply(t,U(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 re(e,t)}},{key:"expandIRI",value:function(e){return ee(e)}}]),t}();function oe(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"}(te||(te={}));var se=function(n){r(u,ne);var o=oe(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 T(u,[{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,ee("rdf:type"),ee("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(te.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 ee(e,{defaultPrefix:this.url})}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(U(this.statements(void 0,"purl:modified")),U(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")&&te.Read,s.includes("write")&&te.Write,s.includes("append")&&te.Append,s.includes("control")&&te.Control])}}]),u}();function ue(e){return ae.apply(this,arguments)}function ae(){return(ae=O(q.mark((function e(t){var r;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,C(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 ce(e){return"@graph"in e}function ie(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 le(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 le(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 le(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 fe(e,t){return pe.apply(this,arguments)}function pe(){return(pe=O(q.mark((function e(t,r){var n,o,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},e.prev=1,e.next=4,r(t,n);case 4:if(404!==(o=e.sent).status){e.next=7;break}throw new J(t);case 7:if(![401,403].includes(o.status)){e.next=9;break}throw new X(t,o.status);case 9:return e.next=11,o.text();case 11:return s=e.sent,e.abrupt("return",{body:s,headers:o.headers});case 15:if(e.prev=15,e.t0=e.catch(1),!(e.t0 instanceof X)){e.next=19;break}throw e.t0;case 19:if(!(e.t0 instanceof J)){e.next=21;break}throw e.t0;case 21:throw new $(t,{cause:e.t0});case 22:case"end":return e.stop()}}),e,null,[[1,15]])})))).apply(this,arguments)}function de(e){var t,r=e.slice(0),n={},o=ie(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=S(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=ie(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,v=Object.entries(f);d<v.length;d++){var h=A(v[d],2),y=h[0],b=h[1];"BlankNode"===b.termType&&b.value===s&&(f[y]=L(a))}m(r,l,M(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 me(e,t,r){return ve.apply(this,arguments)}function ve(){return(ve=O(q.mark((function e(t,r,n){var o,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),e.next=3,Se(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 se(t,s,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function he(e,t){return ye.apply(this,arguments)}function ye(){return(ye=O(q.mark((function e(t,r){var n,o,s,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fe(t,null!=r?r:window.fetch);case 2:return n=e.sent,o=n.body,s=n.headers,e.next=7,Se(o,{baseIRI:t});case 7:return u=e.sent,e.abrupt("return",new se(t,u,s));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function be(e,t){return je.apply(this,arguments)}function je(){return(je=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,he(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 J){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 we(e,t){return xe.apply(this,arguments)}function xe(){return(xe=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ce(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map((function(e){return we(e,r)})));case 3:return n=e.sent,e.abrupt("return",n.flat());case 5:return e.abrupt("return",D(t,{base:r}));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ge(e){var t=Ue(e);return Object.entries(t).reduce((function(e,t){var r=A(t,2),n=r[0],o=r[1].map((function(e){return" "+Pe(e)})).sort().join("\n");return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(o,"\n}"))}),[]).join(" ;\n")}function ke(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new N(r),o={quads:[],containsRelativeIRIs:!1};return new Promise((function(r,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 F(null!==(u=t.baseIRI)&&void 0!==u?u:null,W.Turtle,e.message)):n?o.quads.push(n):r(o)}))}))}function Re(e){return Ie.apply(this,arguments)}function Ie(){return(Ie=O(q.mark((function e(t){var r;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,B(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(e){return(new z).quadsToString(e)}function Pe(e){return(new z).quadsToString([e]).slice(0,-1)}function Te(e,t){return Ae.apply(this,arguments)}function Ae(){return(Ae=O(q.mark((function e(t,r){var n;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,he(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 Oe(e){return qe.apply(this,arguments)}function qe(){return qe=O(q.mark((function e(t){var r,n,o,s=arguments;return q.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(U(n).map(function(){var e=O(q.mark((function e(t){var n,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),s=t[2],e.next=4,Se(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)}))),qe.apply(this,arguments)}function Ue(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=f(e,/(\w+) DATA {([^}]+)}/g),o={},s=ie(n);try{for(s.s();!(t=s.n()).done;){var u=t.value,a=u[1].toLowerCase(),c=u[2];o[a]=De(c,r)}}catch(e){s.e(e)}finally{s.f()}return o}function Se(e){return Ce.apply(this,arguments)}function Ce(){return Ce=O(q.mark((function e(t){var r,n,o,s=arguments;return q.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,ke(t,r);case 3:return n=e.sent,o=n.quads,e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)}))),Ce.apply(this,arguments)}function De(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=l({baseIRI:t.baseIRI}),n=new N(r);try{var o=n.parse(e);return t.normalizeBlankNodes?de(o):o}catch(e){var s,u;throw new F(null!==(s=t.baseIRI)&&void 0!==s?s:null,W.Turtle,null!==(u=e.message)&&void 0!==u?u:"")}}function Ne(e,t,r){return Be.apply(this,arguments)}function Be(){return(Be=O(q.mark((function e(t,r,n){var o;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(window),e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ze(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 Le(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ze(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ze(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Me(e,t){return Qe.apply(this,arguments)}function Qe(){return Qe=O(q.mark((function e(t,r){var n,o,u,a,c,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:u=new ne(t.getQuads()),a=s({},t.url,t),c=function(e){return 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}))},i=function(){var e=O(q.mark((function e(){var t,n,o,s,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,n=Object.entries(a);case 1:if(!(t<n.length)){e.next=23;break}if(o=A(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,he(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 X)){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)}))),Qe.apply(this,arguments)}function We(e,t){return Fe.apply(this,arguments)}function Fe(){return(Fe=O(q.mark((function e(t,r){var n,o,s,u,a,c,i,f,p,d,m,v,j,w,x,g,k,R;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=b(t),e.next=3,he(f,r);case 3:if((p=e.sent).isPersonalProfile()||p.contains(t,"solid:oidcIssuer")){e.next=6;break}throw new Error("".concat(t," is not a valid webId."));case 6:return e.next=8,Me(p,r);case 8:d=e.sent,m=d.store,v=d.writableProfileUrl,j=d.cloaked,w=m.statements(t,"pim:storage").map((function(e){return e.object.value})),x=m.statement(t,"solid:publicTypeIndex"),g=m.statement(t,"solid:privateTypeIndex"),k=y(f);case 16:if(!k||0!==w.length){e.next=26;break}return e.next=19,h(he(k,r));case 19:if(null==(R=e.sent)||!R.isStorage()){e.next=23;break}return w.push(k),e.abrupt("break",26);case 23:k=y(k),e.next=16;break;case 26:return e.abrupt("return",Le({webId:t,storageUrls:w,cloaked:j,writableProfileUrl:v},l({name:null!==(n=null===(o=m.statement(t,"vcard:fn"))||void 0===o?void 0:o.object.value)&&void 0!==n?n:null===(s=m.statement(t,"foaf:name"))||void 0===s?void 0:s.object.value,avatarUrl:null!==(u=null===(a=m.statement(t,"vcard:hasPhoto"))||void 0===a?void 0:a.object.value)&&void 0!==u?u:null===(c=m.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(i=m.statement(t,"solid:oidcIssuer"))||void 0===i?void 0:i.object.value,publicTypeIndexUrl:null==x?void 0:x.object.value,privateTypeIndexUrl:null==g?void 0:g.object.value})));case 27:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function He(e,t){return $e.apply(this,arguments)}function $e(){return($e=O(q.mark((function e(t,r){var n,o,s;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=h((function(e){return We(e,r)})),e.next=3,s(t);case 3:if(e.t2=o=e.sent,e.t1=null!==e.t2,!e.t1){e.next=7;break}e.t1=void 0!==o;case 7:if(!e.t1){e.next=11;break}e.t3=o,e.next=14;break;case 11:return e.next=13,s(t.replace(/\/$/,"").concat("/profile/card#me"));case 13:e.t3=e.sent;case 14:if(e.t4=n=e.t3,e.t0=null!==e.t4,!e.t0){e.next=18;break}e.t0=void 0!==n;case 18:if(!e.t0){e.next=22;break}e.t5=n,e.next=25;break;case 22:return e.next=24,s(v(t).concat("/profile/card#me"));case 24:e.t5=e.sent;case 25:return e.abrupt("return",e.t5);case 26:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _e(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 Je(e){var t;if("@type"in e&&!("@value"in e)){e["@id"]=null!==(t=e["@id"])&&void 0!==t?t:x();for(var r=0,n=Object.values(e);r<n.length;r++){var o=n[r];g(o)&&Je(o),k(o)&&o.forEach((function(e){return g(e)&&Je(e)}))}}}function Ge(e){return d(j(e),(function(e){return Je(e)}))}function Xe(e){var t=w(e);return t?l({containerUrl:_e(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}}function Ke(e,t,r){return Ve.apply(this,arguments)}function Ve(){return(Ve=O(q.mark((function e(t,r,n){var o,s,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),s=t.storageUrls[0],u="".concat(s,"settings/").concat(r,"TypeIndex"),e.next=5,Te(u,n);case 5:if(!e.sent){e.next=9;break}e.t0="".concat(s,"settings/").concat(r,"TypeIndex-").concat(x()),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 Ye(e,t,r){return Ze.apply(this,arguments)}function Ze(){return(Ze=O(q.mark((function e(t,r,n){var o,s,u,a;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t.writableProfileUrl){e.next=2;break}throw new Error("Can't create type index without a writable profile document");case 2:return n=null!==(o=n)&&void 0!==o?o:window.fetch.bind(n),e.next=5,Ke(t,r,n);case 5:return s=e.sent,u="public"===r?"<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .":"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",a="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#").concat(r,"TypeIndex> <").concat(s,"> .\n }\n "),e.next=10,Promise.all([me(s,u,n),Ne(t.writableProfileUrl,a,n)]);case 10:return e.abrupt("return",s);case 12:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function et(e,t,r,n){return tt.apply(this,arguments)}function tt(){return(tt=O(q.mark((function e(t,r,n,o){var s,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,he(t,o);case 2:return s=e.sent,u=Array.isArray(r)?r:[r],e.abrupt("return",u.map((function(e){return s.statements(void 0,"rdf:type","solid:TypeRegistration").filter((function(t){return s.contains(t.subject.value,"solid:forClass",e)})).map((function(e){return s.statements(e.subject.value,n)})).flat().map((function(e){return e.object.value})).filter((function(e){return!!e}))})).flat());case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function rt(e,t){return nt.apply(this,arguments)}function nt(){return(nt=O(q.mark((function e(t,r){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ye(t,"public",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ot(e,t){return st.apply(this,arguments)}function st(){return(st=O(q.mark((function e(t,r){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ye(t,"private",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ut(e,t,r){return at.apply(this,arguments)}function at(){return(at=O(q.mark((function e(t,r,n){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",et(t,r,"solid:instanceContainer",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ct(e,t,r){return it.apply(this,arguments)}function it(){return(it=O(q.mark((function e(t,r,n){return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",et(t,r,"solid:instance",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function lt(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 ft(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 ft(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 ft(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 pt(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 dt={},mt={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},vt=function(n){r(ExpectedQuadAssertionError,u);var o=pt(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(r){var n;return e(this,ExpectedQuadAssertionError),n=o.call(this,"Couldn't find the following triple: ".concat(Pe(r))),s(t(n),"expectedQuad",void 0),n.expectedQuad=r,n}return ExpectedQuadAssertionError}();function ht(e,t){var r,n=lt(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(!yt(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 bt(e.value,t.value)}((r=e).object,n.object)&&bt(r.subject.value,n.subject.value)&&bt(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new vt(e);I(t,n)};for(n.s();!(r=n.n()).done;)o()}catch(e){n.e(e)}finally{n.f()}}function yt(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function bt(e,t){var r,n;return yt(e)?(null!==(n=(r=dt)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],o=e,s=lt(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=A(c[a],2),p=l[0],d=l[1];o=o.replace("%PATTERN".concat(p,"%"),null!==(i=mt[d])&&void 0!==i?i:d)}return new RegExp(o)}(e)).test(t):e===t}function jt(){dt={}}function wt(e,t){return xt.apply(this,arguments)}function xt(){return(xt=O(q.mark((function e(t,r){var n,o,s,u,a;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jt(),e.next=3,we(t);case 3:return n=e.sent,e.next=6,we(r);case 6:if(o=e.sent,s=Ee(n),u=Ee(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,ht(n,o),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof vt){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 gt(e,t){var r;jt();for(var n=Ue(e,{normalizeBlankNodes:!0}),o=Ue(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=R(n,c),l=R(o,c);if(i.length!==l.length)return s(!1,"Expected ".concat(i.length," ").concat(c," triples, found ").concat(l.length,"."));try{ht(i,l)}catch(e){if(!(e instanceof vt))throw e;return s(!1,"Couldn't find the following ".concat(c," triple: ").concat(Pe(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 kt(e,t){jt();var r=De(e,{normalizeBlankNodes:!0}),n=De(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{ht(r,n)}catch(e){if(!(e instanceof vt))throw e;return o(!1,e.message)}return o(!0,"turtle matches")}function Rt(e,t){return It.apply(this,arguments)}function It(){return(It=O(q.mark((function e(t,r){var n,o,s,u,a,c,i;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(window),e.next=3,r(t,{method:"HEAD"});case 3:if(a=e.sent,c=null!==(o=a.headers.get("Link"))&&void 0!==o?o:"",i=null!==(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",E(P(t),i));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Et(e,t,r){return Pt.apply(this,arguments)}function Pt(){return(Pt=O(q.mark((function e(t,r,n){var o,s,u;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(o=n)||void 0===o){e.next=4;break}e.t0=o,e.next=7;break;case 4:return e.next=6,Rt(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,be(null!==(u=n)&&void 0!==u?u:"",r);case 10:if(e.t2=s=e.sent,e.t1=null!==e.t2,!e.t1){e.next=14;break}e.t1=void 0!==s;case 14:if(!e.t1){e.next=18;break}e.t3=s,e.next=21;break;case 18:return e.next=20,Et(P(t),r);case 20:e.t3=e.sent;case 21:return e.abrupt("return",e.t3);case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Tt(e,t){return At.apply(this,arguments)}function At(){return(At=O(q.mark((function e(t,r){var n,o;return q.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Rt(t,r);case 2:return n=e.sent,e.next=5,Et(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 Ot={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=kt(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=gt(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function qt(){chai.use((function(e){return Object.entries(Ot).forEach((function(t){var r=A(t,2),n=r[0],o=r[1];return e.Assertion.addMethod(n,o)}))}))}function Ut(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 St={toEqualJsonLD:function(e,t){var r=this;return O(q.mark((function n(){var o;return q.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,wt(t,e);case 2:return o=n.sent,n.abrupt("return",Ut(o,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return Ut(gt(t,e),{context:this,hint:"toEqualSparql",expected:ge(t),received:ge(e)})}};function Ct(){expect.extend(St)}export{F as MalformedSolidDocumentError,$ as NetworkRequestError,J as NotFoundError,se as SolidDocument,W as SolidDocumentFormat,te as SolidDocumentPermission,ne as SolidStore,re as SolidThing,X as UnauthorizedError,V as UnsuccessfulNetworkRequestError,ue as compactJsonLDGraph,ot as createPrivateTypeIndex,rt as createPublicTypeIndex,me as createSolidDocument,Z as defineIRIPrefix,ee as expandIRI,He as fetchLoginUserProfile,he as fetchSolidDocument,Tt as fetchSolidDocumentACL,be as fetchSolidDocumentIfFound,ut as findContainerRegistrations,ct as findInstanceRegistrations,qt as installChaiPlugin,Ct as installJestPlugin,ce as isJsonLDGraph,wt as jsonldEquals,we as jsonldToQuads,Ge as mintJsonLDIdentifiers,ge as normalizeSparql,Xe as parseResourceSubject,ke as parseTurtle,Pe as quadToTurtle,Re as quadsToJsonLD,Ee as quadsToTurtle,Te as solidDocumentExists,gt as sparqlEquals,Oe as sparqlToQuads,Ue as sparqlToQuadsSync,kt as turtleEquals,Se as turtleToQuads,De as turtleToQuadsSync,Ne as updateSolidDocument};
|
|
2
2
|
//# sourceMappingURL=noeldemartin-solid-utils.esm.js.map
|