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