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