@noeldemartin/solid-utils 0.6.0-next.8a6a0b585adc7a1c329fb0fed5c420bb72cdccda → 0.6.0-next.93662083f605ab1c82251296bba0307c629df50a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/io-Bxx0x6OA.js +404 -0
- package/dist/io-Bxx0x6OA.js.map +1 -0
- package/dist/noeldemartin-solid-utils.js +165 -531
- package/dist/noeldemartin-solid-utils.js.map +1 -1
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +157 -0
- package/dist/testing.js.map +1 -0
- package/package.json +9 -3
- package/src/helpers/io.ts +1 -1
- package/src/helpers/jsonld.ts +1 -1
- package/src/testing/helpers.ts +187 -0
- package/src/testing/hepers.test.ts +329 -0
- package/src/testing/index.ts +2 -0
- package/src/testing/vitest/index.ts +13 -0
- package/src/testing/vitest/matchers.ts +68 -0
|
@@ -1,590 +1,224 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
class b extends p {
|
|
29
|
-
constructor(r) {
|
|
30
|
-
super(`Document with '${r}' url not found`);
|
|
31
|
-
l(this, "url");
|
|
32
|
-
this.url = r;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function mt(e, t) {
|
|
36
|
-
return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${e}`;
|
|
37
|
-
}
|
|
38
|
-
class I extends p {
|
|
39
|
-
constructor(r, n) {
|
|
40
|
-
super(mt(r, n));
|
|
41
|
-
l(this, "url");
|
|
42
|
-
l(this, "responseStatus");
|
|
43
|
-
this.url = r, this.responseStatus = n;
|
|
44
|
-
}
|
|
45
|
-
get forbidden() {
|
|
46
|
-
return typeof this.responseStatus < "u" ? this.responseStatus === 403 : void 0;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function yt(e, t) {
|
|
50
|
-
return t = t ?? e, typeof e == "string" ? `${e} (returned ${t.status} status code)` : `Request to ${t.url} returned ${t.status} status code`;
|
|
51
|
-
}
|
|
52
|
-
class Bt extends p {
|
|
53
|
-
constructor(r, n) {
|
|
54
|
-
super(yt(r, n));
|
|
55
|
-
l(this, "response");
|
|
56
|
-
this.response = n ?? r;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
class gt extends p {
|
|
60
|
-
constructor(r, n, s) {
|
|
61
|
-
super(`The resource at ${r} is using an unsupported authorization protocol (${n})`, s);
|
|
62
|
-
l(this, "url");
|
|
63
|
-
l(this, "protocol");
|
|
64
|
-
this.url = r, this.protocol = n;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const H = {
|
|
68
|
-
acl: "http://www.w3.org/ns/auth/acl#",
|
|
69
|
-
foaf: "http://xmlns.com/foaf/0.1/",
|
|
70
|
-
ldp: "http://www.w3.org/ns/ldp#",
|
|
71
|
-
pim: "http://www.w3.org/ns/pim/space#",
|
|
72
|
-
purl: "http://purl.org/dc/terms/",
|
|
73
|
-
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
74
|
-
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
|
|
75
|
-
schema: "https://schema.org/",
|
|
76
|
-
solid: "http://www.w3.org/ns/solid/terms#",
|
|
77
|
-
vcard: "http://www.w3.org/2006/vcard/ns#"
|
|
78
|
-
};
|
|
79
|
-
function Ft(e, t) {
|
|
80
|
-
H[e] = t;
|
|
81
|
-
}
|
|
82
|
-
function f(e, t = {}) {
|
|
83
|
-
var s;
|
|
84
|
-
if (e.startsWith("http"))
|
|
85
|
-
return e;
|
|
86
|
-
const [r, n] = e.split(":");
|
|
87
|
-
if (r && n) {
|
|
88
|
-
const a = H[r] ?? ((s = t.extraContext) == null ? void 0 : s[r]) ?? null;
|
|
89
|
-
if (!a)
|
|
90
|
-
throw new Error(`Can't expand IRI with unknown prefix: '${e}'`);
|
|
91
|
-
return a + n;
|
|
92
|
-
}
|
|
93
|
-
if (!t.defaultPrefix)
|
|
94
|
-
throw new Error(`Can't expand IRI without a default prefix: '${e}'`);
|
|
95
|
-
return t.defaultPrefix + r;
|
|
96
|
-
}
|
|
97
|
-
class vt {
|
|
98
|
-
constructor(t, r) {
|
|
99
|
-
l(this, "url");
|
|
100
|
-
l(this, "quads");
|
|
101
|
-
this.url = t, this.quads = r;
|
|
102
|
-
}
|
|
103
|
-
value(t) {
|
|
104
|
-
var r;
|
|
105
|
-
return (r = this.quads.find((n) => n.predicate.value === f(t))) == null ? void 0 : r.object.value;
|
|
106
|
-
}
|
|
107
|
-
values(t) {
|
|
108
|
-
return this.quads.filter((r) => r.predicate.value === f(t)).map((r) => r.object.value);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
class _ {
|
|
112
|
-
constructor(t = []) {
|
|
113
|
-
l(this, "quads");
|
|
114
|
-
this.quads = t;
|
|
115
|
-
}
|
|
116
|
-
isEmpty() {
|
|
117
|
-
return this.statements.length === 0;
|
|
118
|
-
}
|
|
119
|
-
getQuads() {
|
|
120
|
-
return this.quads.slice(0);
|
|
121
|
-
}
|
|
122
|
-
addQuads(t) {
|
|
123
|
-
this.quads.push(...t);
|
|
124
|
-
}
|
|
125
|
-
statements(t, r, n) {
|
|
126
|
-
return this.quads.filter(
|
|
127
|
-
(s) => (!n || this.termMatches(s.object, n)) && (!t || this.termMatches(s.subject, t)) && (!r || this.termMatches(s.predicate, r))
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
statement(t, r, n) {
|
|
131
|
-
return this.quads.find(
|
|
132
|
-
(a) => (!n || this.termMatches(a.object, n)) && (!t || this.termMatches(a.subject, t)) && (!r || this.termMatches(a.predicate, r))
|
|
133
|
-
) ?? null;
|
|
134
|
-
}
|
|
135
|
-
contains(t, r, n) {
|
|
136
|
-
return this.statement(t, r, n) !== null;
|
|
137
|
-
}
|
|
138
|
-
getThing(t) {
|
|
139
|
-
const r = this.statements(t);
|
|
140
|
-
return new vt(t, r);
|
|
141
|
-
}
|
|
142
|
-
expandIRI(t) {
|
|
143
|
-
return f(t);
|
|
144
|
-
}
|
|
145
|
-
termMatches(t, r) {
|
|
146
|
-
return typeof r == "string" ? this.expandIRI(r) === t.value : t.termType === t.termType && t.value === r.value;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
var bt = /* @__PURE__ */ ((e) => (e.Read = "read", e.Write = "write", e.Append = "append", e.Control = "control", e))(bt || {});
|
|
150
|
-
class J extends _ {
|
|
151
|
-
constructor(r, n, s) {
|
|
152
|
-
super(n);
|
|
153
|
-
l(this, "url");
|
|
154
|
-
l(this, "headers");
|
|
155
|
-
this.url = r, this.headers = s;
|
|
156
|
-
}
|
|
157
|
-
isACPResource() {
|
|
158
|
-
var r;
|
|
159
|
-
return !!((r = this.headers.get("Link")) != null && r.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/));
|
|
160
|
-
}
|
|
161
|
-
isPersonalProfile() {
|
|
162
|
-
return !!this.statement(this.url, f("rdf:type"), f("foaf:PersonalProfileDocument"));
|
|
163
|
-
}
|
|
164
|
-
isStorage() {
|
|
165
|
-
var r;
|
|
166
|
-
return !!((r = this.headers.get("Link")) != null && r.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/));
|
|
167
|
-
}
|
|
168
|
-
isUserWritable() {
|
|
169
|
-
return this.getUserPermissions().includes(
|
|
170
|
-
"write"
|
|
171
|
-
/* Write */
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
|
-
getUserPermissions() {
|
|
175
|
-
return this.getPermissionsFromWAC("user");
|
|
176
|
-
}
|
|
177
|
-
getPublicPermissions() {
|
|
178
|
-
return this.getPermissionsFromWAC("public");
|
|
179
|
-
}
|
|
180
|
-
getLastModified() {
|
|
181
|
-
var r;
|
|
182
|
-
return g(this.headers.get("last-modified")) ?? g((r = this.statement(this.url, "purl:modified")) == null ? void 0 : r.object.value) ?? this.getLatestDocumentDate() ?? null;
|
|
183
|
-
}
|
|
184
|
-
expandIRI(r) {
|
|
185
|
-
return f(r, { defaultPrefix: this.url });
|
|
186
|
-
}
|
|
187
|
-
getLatestDocumentDate() {
|
|
188
|
-
const r = [...this.statements(void 0, "purl:modified"), ...this.statements(void 0, "purl:created")].map((n) => g(n.object.value)).filter((n) => n !== null);
|
|
189
|
-
return r.length > 0 ? r.reduce((n, s) => n > s ? n : s) : null;
|
|
190
|
-
}
|
|
191
|
-
getPermissionsFromWAC(r) {
|
|
192
|
-
var a;
|
|
193
|
-
const n = this.headers.get("WAC-Allow") ?? "", s = ((a = rt(n, new RegExp(`${r}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
|
|
194
|
-
return k([
|
|
195
|
-
s.includes("read") && "read",
|
|
196
|
-
s.includes("write") && "write",
|
|
197
|
-
s.includes("append") && "append",
|
|
198
|
-
s.includes("control") && "control"
|
|
199
|
-
/* Control */
|
|
200
|
-
]);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
async function Ht(e) {
|
|
204
|
-
const t = await T.compact(e, {});
|
|
205
|
-
return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
|
|
206
|
-
}
|
|
207
|
-
function It(e) {
|
|
208
|
-
return "@graph" in e;
|
|
209
|
-
}
|
|
210
|
-
const P = "anonymous://", xt = P.length;
|
|
211
|
-
async function Tt(e, t) {
|
|
212
|
-
const r = {
|
|
213
|
-
headers: { Accept: "text/turtle" }
|
|
214
|
-
};
|
|
215
|
-
t != null && t.cache && (r.cache = t.cache);
|
|
216
|
-
try {
|
|
217
|
-
const s = await ((t == null ? void 0 : t.fetch) ?? window.fetch)(e, r);
|
|
218
|
-
if (s.status === 404) throw new b(e);
|
|
219
|
-
if ([401, 403].includes(s.status)) throw new I(e, s.status);
|
|
220
|
-
return {
|
|
221
|
-
body: await s.text(),
|
|
222
|
-
headers: s.headers
|
|
223
|
-
};
|
|
224
|
-
} catch (n) {
|
|
225
|
-
throw n instanceof I || n instanceof b ? n : new wt(e, { cause: n });
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
function Rt(e) {
|
|
229
|
-
const t = e.slice(0), r = {}, n = v(e).flatMap((s, a) => M(
|
|
230
|
-
k([
|
|
231
|
-
s.object.termType === "BlankNode" ? s.object.value : null,
|
|
232
|
-
s.subject.termType === "BlankNode" ? s.subject.value : null
|
|
233
|
-
]),
|
|
234
|
-
(u) => u.forEach((o) => (r[o] ?? (r[o] = /* @__PURE__ */ new Set())).add(a))
|
|
235
|
-
)).filter().unique();
|
|
236
|
-
for (const s of n) {
|
|
237
|
-
const a = r[s], u = dt(
|
|
238
|
-
v(a).map((o) => e[o]).filter(({ subject: { termType: o, value: i } }) => o === "BlankNode" && i === s).map(({ predicate: o, object: i }) => i.termType === "BlankNode" ? o.value : o.value + i.value).sorted().join()
|
|
239
|
-
);
|
|
240
|
-
for (const o of a) {
|
|
241
|
-
const i = t[o], c = {
|
|
242
|
-
subject: i.subject,
|
|
243
|
-
object: i.object
|
|
244
|
-
};
|
|
245
|
-
for (const [w, d] of Object.entries(c))
|
|
246
|
-
d.termType !== "BlankNode" || d.value !== s || (c[w] = new ft(u));
|
|
247
|
-
nt(
|
|
248
|
-
t,
|
|
249
|
-
i,
|
|
250
|
-
new ht(c.subject, i.predicate, c.object)
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return t;
|
|
255
|
-
}
|
|
256
|
-
function G(e) {
|
|
257
|
-
return e.map((t) => " " + Et(t)).sort().join(`
|
|
258
|
-
`);
|
|
259
|
-
}
|
|
260
|
-
function Pt(e) {
|
|
261
|
-
var t;
|
|
262
|
-
(t = e["@id"]) != null && t.startsWith("#") && (e["@id"] = P + e["@id"]);
|
|
263
|
-
}
|
|
264
|
-
function jt(e) {
|
|
265
|
-
for (const t of e)
|
|
266
|
-
t.subject.value.startsWith(P) && (t.subject.value = t.subject.value.slice(xt));
|
|
267
|
-
}
|
|
268
|
-
async function $t(e, t, r) {
|
|
269
|
-
r = r ?? window.fetch.bind(window);
|
|
270
|
-
const n = await j(t);
|
|
271
|
-
return await r(e, {
|
|
272
|
-
method: "PUT",
|
|
273
|
-
headers: { "Content-Type": "text/turtle" },
|
|
274
|
-
body: t
|
|
275
|
-
}), new J(e, n, new Headers({}));
|
|
276
|
-
}
|
|
277
|
-
async function h(e, t) {
|
|
278
|
-
const { body: r, headers: n } = await Tt(e, t), s = await j(r, { baseIRI: e });
|
|
279
|
-
return new J(e, s, n);
|
|
280
|
-
}
|
|
281
|
-
async function qt(e, t) {
|
|
282
|
-
try {
|
|
283
|
-
return await h(e, t);
|
|
284
|
-
} catch (r) {
|
|
285
|
-
if (!(r instanceof b)) throw r;
|
|
286
|
-
return null;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
async function At(e, t) {
|
|
290
|
-
if (It(e))
|
|
291
|
-
return (await Promise.all(e["@graph"].map((s) => At(s, t)))).flat();
|
|
292
|
-
Pt(e);
|
|
293
|
-
const r = await T.toRDF(e, { base: t });
|
|
294
|
-
return jt(r), r;
|
|
295
|
-
}
|
|
296
|
-
function _t(e) {
|
|
297
|
-
const t = St(e);
|
|
298
|
-
return Object.entries(t).reduce((r, [n, s]) => {
|
|
299
|
-
const a = G(s);
|
|
300
|
-
return r.concat(`${n.toUpperCase()} DATA {
|
|
301
|
-
${a}
|
|
302
|
-
}`);
|
|
303
|
-
}, []).join(` ;
|
|
304
|
-
`);
|
|
305
|
-
}
|
|
306
|
-
function Jt(e) {
|
|
307
|
-
const t = V(e);
|
|
308
|
-
return G(t);
|
|
309
|
-
}
|
|
310
|
-
function Ct(e, t = {}) {
|
|
311
|
-
const r = y({ baseIRI: t.baseIRI }), n = new z(r), s = {
|
|
312
|
-
quads: [],
|
|
313
|
-
containsRelativeIRIs: !1
|
|
314
|
-
};
|
|
315
|
-
return new Promise((a, u) => {
|
|
316
|
-
const o = n._resolveRelativeIRI;
|
|
317
|
-
n._resolveRelativeIRI = (...i) => (s.containsRelativeIRIs = !0, n._resolveRelativeIRI = o, n._resolveRelativeIRI(...i)), n.parse(e, (i, c) => {
|
|
318
|
-
if (i) {
|
|
319
|
-
u(
|
|
320
|
-
new F(t.baseIRI ?? null, R.Turtle, i.message)
|
|
321
|
-
);
|
|
322
|
-
return;
|
|
323
|
-
}
|
|
324
|
-
if (!c) {
|
|
325
|
-
a(s);
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
s.quads.push(c);
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
async function Gt(e) {
|
|
333
|
-
return {
|
|
334
|
-
"@graph": await T.fromRDF(e)
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
function Vt(e) {
|
|
338
|
-
return new B().quadsToString(e);
|
|
339
|
-
}
|
|
340
|
-
function Et(e) {
|
|
341
|
-
return new B().quadsToString([e]).slice(0, -1);
|
|
342
|
-
}
|
|
343
|
-
async function Ut(e, t) {
|
|
344
|
-
try {
|
|
345
|
-
return !(await h(e, t)).isEmpty();
|
|
346
|
-
} catch {
|
|
347
|
-
return !1;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
async function Xt(e, t = {}) {
|
|
351
|
-
const r = L(e, /(\w+) DATA {([^}]+)}/g), n = {};
|
|
352
|
-
return await Promise.all(
|
|
353
|
-
[...r].map(async (s) => {
|
|
354
|
-
const a = s[1].toLowerCase(), u = s[2];
|
|
355
|
-
n[a] = await j(u, t);
|
|
356
|
-
})
|
|
357
|
-
), n;
|
|
358
|
-
}
|
|
359
|
-
function St(e, t = {}) {
|
|
360
|
-
const r = L(e, /(\w+) DATA {([^}]+)}/g), n = {};
|
|
361
|
-
for (const s of r) {
|
|
362
|
-
const a = s[1].toLowerCase(), u = s[2];
|
|
363
|
-
n[a] = V(u, t);
|
|
364
|
-
}
|
|
365
|
-
return n;
|
|
366
|
-
}
|
|
367
|
-
async function j(e, t = {}) {
|
|
368
|
-
const { quads: r } = await Ct(e, t);
|
|
369
|
-
return r;
|
|
370
|
-
}
|
|
371
|
-
function V(e, t = {}) {
|
|
372
|
-
const r = y({ baseIRI: t.baseIRI }), n = new z(r);
|
|
373
|
-
try {
|
|
374
|
-
const s = n.parse(e);
|
|
375
|
-
return t.normalizeBlankNodes ? Rt(s) : s;
|
|
376
|
-
} catch (s) {
|
|
377
|
-
throw new F(
|
|
378
|
-
t.baseIRI ?? null,
|
|
379
|
-
R.Turtle,
|
|
380
|
-
s.message ?? ""
|
|
381
|
-
);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
async function Dt(e, t, r) {
|
|
385
|
-
r = r ?? window.fetch.bind(window), await r(e, {
|
|
386
|
-
method: "PATCH",
|
|
387
|
-
headers: { "Content-Type": "application/sparql-update" },
|
|
388
|
-
body: t
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
async function Nt(e, t) {
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var L = (t, e, r) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var f = (t, e, r) => L(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { f as m, S as k, U as Q, c as H, u as J, s as N, a as z } from "./io-Bxx0x6OA.js";
|
|
5
|
+
import { M as yt, N as vt, d as Tt, w as gt, b as xt, x as Pt, y as Ut, m as bt, r as $t, v as Et, o as jt, j as St, n as Dt, e as qt, p as Ct, h as Rt, q as At, g as It, i as Lt, k as kt, t as Qt, l as Ht } from "./io-Bxx0x6OA.js";
|
|
6
|
+
import { JSError as E, silenced as j, urlRoot as O, urlRoute as W, urlParentDirectory as U, objectWithoutEmpty as h, arrayUnique as F, tap as M, objectDeepClone as _, urlParse as B, uuid as S, isObject as b, isArray as G, arr as V, urlResolve as K, requireUrlParentDirectory as D } from "@noeldemartin/utils";
|
|
7
|
+
function X(t, e) {
|
|
8
|
+
return e = e ?? t, typeof t == "string" ? `${t} (returned ${e.status} status code)` : `Request to ${e.url} returned ${e.status} status code`;
|
|
9
|
+
}
|
|
10
|
+
class st extends E {
|
|
11
|
+
constructor(r, a) {
|
|
12
|
+
super(X(r, a));
|
|
13
|
+
f(this, "response");
|
|
14
|
+
this.response = a ?? r;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class Y extends E {
|
|
18
|
+
constructor(r, a, o) {
|
|
19
|
+
super(`The resource at ${r} is using an unsupported authorization protocol (${a})`, o);
|
|
20
|
+
f(this, "url");
|
|
21
|
+
f(this, "protocol");
|
|
22
|
+
this.url = r, this.protocol = a;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function Z(t, e) {
|
|
392
26
|
var u;
|
|
393
|
-
const r = new
|
|
394
|
-
|
|
395
|
-
},
|
|
396
|
-
for (const [
|
|
27
|
+
const r = new k(t.getQuads()), a = { [t.url]: t }, o = (n) => {
|
|
28
|
+
n.statements(void 0, "foaf:isPrimaryTopicOf").map((i) => i.object.value).forEach((i) => a[i] = a[i] ?? null), n.statements(void 0, "foaf:primaryTopic").map((i) => i.subject.value).forEach((i) => a[i] = a[i] ?? null);
|
|
29
|
+
}, s = async () => {
|
|
30
|
+
for (const [n, i] of Object.entries(a))
|
|
397
31
|
if (i === null)
|
|
398
32
|
try {
|
|
399
|
-
const c = await
|
|
400
|
-
n
|
|
33
|
+
const c = await m(n, e);
|
|
34
|
+
a[n] = c, r.addQuads(c.getQuads()), o(c);
|
|
401
35
|
} catch (c) {
|
|
402
|
-
if (c instanceof
|
|
403
|
-
n
|
|
36
|
+
if (c instanceof Q) {
|
|
37
|
+
a[n] = !1;
|
|
404
38
|
continue;
|
|
405
39
|
}
|
|
406
40
|
throw c;
|
|
407
41
|
}
|
|
408
42
|
};
|
|
409
|
-
|
|
43
|
+
o(t);
|
|
410
44
|
do
|
|
411
|
-
await
|
|
412
|
-
while (Object.values(
|
|
45
|
+
await s();
|
|
46
|
+
while (Object.values(a).some((n) => n === null));
|
|
413
47
|
return {
|
|
414
48
|
store: r,
|
|
415
|
-
cloaked: Object.values(
|
|
416
|
-
writableProfileUrl:
|
|
417
|
-
(
|
|
49
|
+
cloaked: Object.values(a).some((n) => n === !1),
|
|
50
|
+
writableProfileUrl: t.isUserWritable() ? t.url : ((u = Object.values(a).find(
|
|
51
|
+
(n) => !!n && n.isUserWritable()
|
|
418
52
|
)) == null ? void 0 : u.url) ?? null
|
|
419
53
|
};
|
|
420
54
|
}
|
|
421
|
-
async function
|
|
422
|
-
var
|
|
55
|
+
async function $(t, e = {}) {
|
|
56
|
+
var y, v, T, g, x, P;
|
|
423
57
|
const r = {
|
|
424
|
-
fetch:
|
|
58
|
+
fetch: e.fetch,
|
|
425
59
|
// Needed for CSS v7.1.3.
|
|
426
60
|
// See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972
|
|
427
61
|
cache: "no-store"
|
|
428
|
-
},
|
|
429
|
-
if (!
|
|
430
|
-
throw new Error(`${
|
|
431
|
-
const { store:
|
|
432
|
-
let
|
|
433
|
-
for (;
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
i.push(
|
|
62
|
+
}, a = W(t), o = await m(a, r);
|
|
63
|
+
if (!o.isPersonalProfile() && !o.contains(t, "solid:oidcIssuer"))
|
|
64
|
+
throw new Error(`${t} is not a valid webId.`);
|
|
65
|
+
const { store: s, writableProfileUrl: u, cloaked: n } = await Z(o, e), i = s.statements(t, "pim:storage").map((d) => d.object.value), c = s.statement(t, "solid:publicTypeIndex"), p = s.statement(t, "solid:privateTypeIndex");
|
|
66
|
+
let l = U(a);
|
|
67
|
+
for (; l && i.length === 0; ) {
|
|
68
|
+
const d = await j(m(l, r));
|
|
69
|
+
if (d != null && d.isStorage()) {
|
|
70
|
+
i.push(l);
|
|
437
71
|
break;
|
|
438
72
|
}
|
|
439
|
-
|
|
73
|
+
l = U(l);
|
|
440
74
|
}
|
|
441
75
|
if (i.length === 0)
|
|
442
|
-
throw new Error(`Could not find any storage for ${
|
|
443
|
-
return await ((
|
|
444
|
-
webId:
|
|
445
|
-
cloaked:
|
|
76
|
+
throw new Error(`Could not find any storage for ${t}.`);
|
|
77
|
+
return await ((y = e.onLoaded) == null ? void 0 : y.call(e, s)), {
|
|
78
|
+
webId: t,
|
|
79
|
+
cloaked: n,
|
|
446
80
|
writableProfileUrl: u,
|
|
447
|
-
storageUrls:
|
|
448
|
-
...
|
|
449
|
-
name: ((
|
|
450
|
-
avatarUrl: ((
|
|
451
|
-
oidcIssuerUrl: (
|
|
81
|
+
storageUrls: F(i),
|
|
82
|
+
...h({
|
|
83
|
+
name: ((v = s.statement(t, "vcard:fn")) == null ? void 0 : v.object.value) ?? ((T = s.statement(t, "foaf:name")) == null ? void 0 : T.object.value),
|
|
84
|
+
avatarUrl: ((g = s.statement(t, "vcard:hasPhoto")) == null ? void 0 : g.object.value) ?? ((x = s.statement(t, "foaf:img")) == null ? void 0 : x.object.value),
|
|
85
|
+
oidcIssuerUrl: (P = s.statement(t, "solid:oidcIssuer")) == null ? void 0 : P.object.value,
|
|
452
86
|
publicTypeIndexUrl: c == null ? void 0 : c.object.value,
|
|
453
|
-
privateTypeIndexUrl:
|
|
87
|
+
privateTypeIndexUrl: p == null ? void 0 : p.object.value
|
|
454
88
|
})
|
|
455
89
|
};
|
|
456
90
|
}
|
|
457
|
-
async function
|
|
458
|
-
if (
|
|
459
|
-
return
|
|
460
|
-
const r =
|
|
461
|
-
return await r(
|
|
91
|
+
async function it(t, e = {}) {
|
|
92
|
+
if (e.required)
|
|
93
|
+
return $(t, e);
|
|
94
|
+
const r = j((a) => $(a, e));
|
|
95
|
+
return await r(t) ?? await r(t.replace(/\/$/, "").concat("/profile/card#me")) ?? await r(O(t).concat("/profile/card#me"));
|
|
462
96
|
}
|
|
463
|
-
function
|
|
464
|
-
return !
|
|
97
|
+
function tt(t) {
|
|
98
|
+
return !t.path || !t.path.startsWith("/") ? null : t.path.match(/^\/[^/]*$/) ? "/" : `/${V(t.path.split("/")).filter().slice(0, -1).join("/")}/`.replace("//", "/");
|
|
465
99
|
}
|
|
466
|
-
function
|
|
467
|
-
const
|
|
468
|
-
return
|
|
100
|
+
function et(t) {
|
|
101
|
+
const e = tt(t);
|
|
102
|
+
return t.protocol && t.domain ? `${t.protocol}://${t.domain}${e ?? "/"}` : e;
|
|
469
103
|
}
|
|
470
|
-
function
|
|
471
|
-
if (!(!("@type" in
|
|
472
|
-
|
|
473
|
-
for (const
|
|
474
|
-
|
|
104
|
+
function w(t) {
|
|
105
|
+
if (!(!("@type" in t) || "@value" in t)) {
|
|
106
|
+
t["@id"] = t["@id"] ?? S();
|
|
107
|
+
for (const e of Object.values(t))
|
|
108
|
+
b(e) && w(e), G(e) && e.forEach((r) => b(r) && w(r));
|
|
475
109
|
}
|
|
476
110
|
}
|
|
477
|
-
function
|
|
478
|
-
return M(
|
|
111
|
+
function ct(t) {
|
|
112
|
+
return M(_(t), (e) => w(e));
|
|
479
113
|
}
|
|
480
|
-
function
|
|
481
|
-
const
|
|
482
|
-
return
|
|
483
|
-
containerUrl:
|
|
484
|
-
documentName:
|
|
485
|
-
resourceHash:
|
|
114
|
+
function ut(t) {
|
|
115
|
+
const e = B(t);
|
|
116
|
+
return e ? h({
|
|
117
|
+
containerUrl: et(e),
|
|
118
|
+
documentName: e.path ? e.path.split("/").pop() : null,
|
|
119
|
+
resourceHash: e.fragment
|
|
486
120
|
}) : {};
|
|
487
121
|
}
|
|
488
|
-
async function
|
|
122
|
+
async function rt(t, e, r) {
|
|
489
123
|
r = r ?? window.fetch.bind(r);
|
|
490
|
-
const
|
|
491
|
-
return await
|
|
124
|
+
const a = t.storageUrls[0], o = `${a}settings/${e}TypeIndex`;
|
|
125
|
+
return await N(o, { fetch: r }) ? `${a}settings/${e}TypeIndex-${S()}` : o;
|
|
492
126
|
}
|
|
493
|
-
async function
|
|
494
|
-
if (
|
|
127
|
+
async function q(t, e, r) {
|
|
128
|
+
if (t.writableProfileUrl === null)
|
|
495
129
|
throw new Error("Can't create type index without a writable profile document");
|
|
496
130
|
r = r ?? window.fetch.bind(r);
|
|
497
|
-
const
|
|
131
|
+
const a = await rt(t, e, r), o = e === "public" ? "<> a <http://www.w3.org/ns/solid/terms#TypeIndex> ." : `
|
|
498
132
|
<> a
|
|
499
133
|
<http://www.w3.org/ns/solid/terms#TypeIndex>,
|
|
500
134
|
<http://www.w3.org/ns/solid/terms#UnlistedDocument> .
|
|
501
|
-
`,
|
|
135
|
+
`, s = `
|
|
502
136
|
INSERT DATA {
|
|
503
|
-
<${
|
|
137
|
+
<${t.webId}> <http://www.w3.org/ns/solid/terms#${e}TypeIndex> <${a}> .
|
|
504
138
|
}
|
|
505
139
|
`;
|
|
506
|
-
return await
|
|
507
|
-
}
|
|
508
|
-
async function Y(e, t, r, n) {
|
|
509
|
-
const s = await h(e, { fetch: n });
|
|
510
|
-
return (Array.isArray(t) ? t : [t]).map((u) => s.statements(void 0, "rdf:type", "solid:TypeRegistration").filter((o) => s.contains(o.subject.value, "solid:forClass", u)).map((o) => s.statements(o.subject.value, r)).flat().map((o) => o.object.value).filter((o) => !!o)).flat();
|
|
140
|
+
return await H(a, o, r), await J(t.writableProfileUrl, s, r), a;
|
|
511
141
|
}
|
|
512
|
-
async function
|
|
513
|
-
|
|
142
|
+
async function C(t, e, r, a) {
|
|
143
|
+
const o = await m(t, { fetch: a });
|
|
144
|
+
return (Array.isArray(e) ? e : [e]).map((u) => o.statements(void 0, "rdf:type", "solid:TypeRegistration").filter((n) => o.contains(n.subject.value, "solid:forClass", u)).map((n) => o.statements(n.subject.value, r)).flat().map((n) => n.object.value).filter((n) => !!n)).flat();
|
|
514
145
|
}
|
|
515
|
-
async function
|
|
516
|
-
return
|
|
146
|
+
async function lt(t, e) {
|
|
147
|
+
return q(t, "public", e);
|
|
517
148
|
}
|
|
518
|
-
async function
|
|
519
|
-
return
|
|
149
|
+
async function dt(t, e) {
|
|
150
|
+
return q(t, "private", e);
|
|
520
151
|
}
|
|
521
|
-
async function
|
|
522
|
-
return
|
|
152
|
+
async function ft(t, e, r) {
|
|
153
|
+
return C(t, e, "solid:instanceContainer", r);
|
|
523
154
|
}
|
|
524
|
-
async function
|
|
525
|
-
|
|
526
|
-
t = t ?? window.fetch.bind(window);
|
|
527
|
-
const s = ((a = ((await t(e, { method: "HEAD" })).headers.get("Link") ?? "").match(/<([^>]+)>;\s*rel="acl"/)) == null ? void 0 : a[1]) ?? null;
|
|
528
|
-
if (!s)
|
|
529
|
-
throw new Error(`Could not find ACL Resource for '${e}'`);
|
|
530
|
-
return lt(W(e), s);
|
|
155
|
+
async function mt(t, e, r) {
|
|
156
|
+
return C(t, e, "solid:instance", r);
|
|
531
157
|
}
|
|
532
|
-
async function
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
const
|
|
543
|
-
|
|
158
|
+
async function R(t, e) {
|
|
159
|
+
var s;
|
|
160
|
+
e = e ?? window.fetch.bind(window);
|
|
161
|
+
const o = ((s = ((await e(t, { method: "HEAD" })).headers.get("Link") ?? "").match(/<([^>]+)>;\s*rel="acl"/)) == null ? void 0 : s[1]) ?? null;
|
|
162
|
+
if (!o)
|
|
163
|
+
throw new Error(`Could not find ACL Resource for '${t}'`);
|
|
164
|
+
return K(D(t), o);
|
|
165
|
+
}
|
|
166
|
+
async function A(t, e, r) {
|
|
167
|
+
r = r ?? await R(t, e);
|
|
168
|
+
const a = await z(r ?? "", { fetch: e });
|
|
169
|
+
if (!a)
|
|
170
|
+
return A(D(t), e);
|
|
171
|
+
if (a.isACPResource())
|
|
172
|
+
throw new Y(t, "ACP");
|
|
173
|
+
return a;
|
|
174
|
+
}
|
|
175
|
+
async function pt(t, e) {
|
|
176
|
+
const r = await R(t, e), a = await A(t, e, r);
|
|
177
|
+
return h({
|
|
544
178
|
url: r,
|
|
545
|
-
effectiveUrl:
|
|
546
|
-
document:
|
|
179
|
+
effectiveUrl: a.url,
|
|
180
|
+
document: a
|
|
547
181
|
});
|
|
548
182
|
}
|
|
549
183
|
export {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
184
|
+
yt as MalformedSolidDocumentError,
|
|
185
|
+
vt as NetworkRequestError,
|
|
186
|
+
Tt as NotFoundError,
|
|
187
|
+
gt as SolidDocument,
|
|
188
|
+
xt as SolidDocumentFormat,
|
|
189
|
+
Pt as SolidDocumentPermission,
|
|
190
|
+
k as SolidStore,
|
|
191
|
+
Ut as SolidThing,
|
|
192
|
+
Q as UnauthorizedError,
|
|
193
|
+
st as UnsuccessfulNetworkRequestError,
|
|
194
|
+
Y as UnsupportedAuthorizationProtocolError,
|
|
195
|
+
bt as compactJsonLDGraph,
|
|
196
|
+
dt as createPrivateTypeIndex,
|
|
197
|
+
lt as createPublicTypeIndex,
|
|
198
|
+
H as createSolidDocument,
|
|
199
|
+
$t as defineIRIPrefix,
|
|
200
|
+
Et as expandIRI,
|
|
201
|
+
it as fetchLoginUserProfile,
|
|
202
|
+
m as fetchSolidDocument,
|
|
203
|
+
pt as fetchSolidDocumentACL,
|
|
204
|
+
z as fetchSolidDocumentIfFound,
|
|
205
|
+
ft as findContainerRegistrations,
|
|
206
|
+
mt as findInstanceRegistrations,
|
|
207
|
+
jt as isJsonLDGraph,
|
|
208
|
+
St as jsonldToQuads,
|
|
209
|
+
ct as mintJsonLDIdentifiers,
|
|
210
|
+
Dt as normalizeSparql,
|
|
211
|
+
qt as normalizeTurtle,
|
|
212
|
+
ut as parseResourceSubject,
|
|
579
213
|
Ct as parseTurtle,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
214
|
+
Rt as quadToTurtle,
|
|
215
|
+
At as quadsToJsonLD,
|
|
216
|
+
It as quadsToTurtle,
|
|
217
|
+
N as solidDocumentExists,
|
|
218
|
+
Lt as sparqlToQuads,
|
|
219
|
+
kt as sparqlToQuadsSync,
|
|
220
|
+
Qt as turtleToQuads,
|
|
221
|
+
Ht as turtleToQuadsSync,
|
|
222
|
+
J as updateSolidDocument
|
|
589
223
|
};
|
|
590
224
|
//# sourceMappingURL=noeldemartin-solid-utils.js.map
|