@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.cccdc9c7e033588e2df9d1887ceae49788344d84

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.
Files changed (43) hide show
  1. package/dist/noeldemartin-solid-utils.d.ts +10 -62
  2. package/dist/noeldemartin-solid-utils.js +590 -0
  3. package/dist/noeldemartin-solid-utils.js.map +1 -0
  4. package/package.json +54 -63
  5. package/src/helpers/auth.test.ts +221 -0
  6. package/src/helpers/auth.ts +28 -27
  7. package/src/helpers/identifiers.test.ts +76 -0
  8. package/src/helpers/identifiers.ts +1 -1
  9. package/src/helpers/index.ts +0 -1
  10. package/src/helpers/interop.ts +23 -16
  11. package/src/helpers/io.test.ts +228 -0
  12. package/src/helpers/io.ts +53 -73
  13. package/src/helpers/jsonld.ts +3 -3
  14. package/src/helpers/wac.test.ts +64 -0
  15. package/src/helpers/wac.ts +10 -6
  16. package/src/index.ts +3 -0
  17. package/src/models/SolidDocument.test.ts +77 -0
  18. package/src/models/SolidDocument.ts +14 -18
  19. package/src/models/SolidStore.ts +22 -12
  20. package/src/models/SolidThing.ts +5 -7
  21. package/src/models/index.ts +2 -0
  22. package/.github/workflows/ci.yml +0 -16
  23. package/.nvmrc +0 -1
  24. package/CHANGELOG.md +0 -70
  25. package/dist/noeldemartin-solid-utils.cjs.js +0 -2
  26. package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
  27. package/dist/noeldemartin-solid-utils.esm.js +0 -2
  28. package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
  29. package/dist/noeldemartin-solid-utils.umd.js +0 -90
  30. package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
  31. package/noeldemartin.config.js +0 -9
  32. package/src/helpers/testing.ts +0 -190
  33. package/src/main.ts +0 -5
  34. package/src/plugins/chai/assertions.ts +0 -40
  35. package/src/plugins/chai/index.ts +0 -5
  36. package/src/plugins/cypress/types.d.ts +0 -15
  37. package/src/plugins/index.ts +0 -2
  38. package/src/plugins/jest/index.ts +0 -5
  39. package/src/plugins/jest/matchers.ts +0 -65
  40. package/src/plugins/jest/types.d.ts +0 -14
  41. package/src/testing/ResponseStub.ts +0 -46
  42. package/src/testing/index.ts +0 -2
  43. package/src/testing/mocking.ts +0 -33
@@ -0,0 +1,590 @@
1
+ var Z = Object.defineProperty;
2
+ var tt = (e, t, r) => t in e ? Z(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var l = (e, t, r) => tt(e, typeof t != "symbol" ? t + "" : t, r);
4
+ import { JSError as p, parseDate as g, stringMatch as et, arrayFilter as N, objectWithoutEmpty as y, stringMatchAll as k, arr as v, tap as L, arrayReplace as rt, silenced as M, urlRoot as nt, urlRoute as st, urlParentDirectory as U, arrayUnique as at, objectDeepClone as ot, urlParse as it, uuid as Q, isObject as S, isArray as ct, urlResolve as ut, requireUrlParentDirectory as O } from "@noeldemartin/utils";
5
+ import lt from "md5";
6
+ import { Parser as W, Writer as z, BlankNode as dt, Quad as ft } from "n3";
7
+ import { compact as ht, toRDF as pt, fromRDF as wt } from "jsonld";
8
+ function mt(e, t, r) {
9
+ return e ? `Malformed ${t} document found at ${e} - ${r}` : `Malformed ${t} document - ${r}`;
10
+ }
11
+ var T = /* @__PURE__ */ ((e) => (e.Turtle = "Turtle", e))(T || {});
12
+ class B extends p {
13
+ constructor(r, n, s) {
14
+ super(mt(r, n, s));
15
+ l(this, "documentUrl");
16
+ l(this, "documentFormat");
17
+ l(this, "malformationDetails");
18
+ this.documentUrl = r, this.documentFormat = n, this.malformationDetails = s;
19
+ }
20
+ }
21
+ class yt extends p {
22
+ constructor(r, n) {
23
+ super(`Request failed trying to fetch ${r}`, n);
24
+ l(this, "url");
25
+ this.url = r;
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 gt(e, t) {
36
+ return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${e}`;
37
+ }
38
+ class I extends p {
39
+ constructor(r, n) {
40
+ super(gt(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 vt(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 _t extends p {
53
+ constructor(r, n) {
54
+ super(vt(r, n));
55
+ l(this, "response");
56
+ this.response = n ?? r;
57
+ }
58
+ }
59
+ class bt 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 F = {
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 Jt(e, t) {
80
+ F[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 = F[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 It {
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 H {
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 It(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 xt = /* @__PURE__ */ ((e) => (e.Read = "read", e.Write = "write", e.Append = "append", e.Control = "control", e))(xt || {});
150
+ class _ extends H {
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 = et(n, new RegExp(`${r}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
194
+ return N([
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 Gt(e) {
204
+ const t = await ht(e, {});
205
+ return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
206
+ }
207
+ function Tt(e) {
208
+ return "@graph" in e;
209
+ }
210
+ const R = "anonymous://", Rt = R.length;
211
+ async function Pt(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 yt(e, { cause: n });
226
+ }
227
+ }
228
+ function jt(e) {
229
+ const t = e.slice(0), r = {}, n = v(e).flatMap((s, a) => L(
230
+ N([
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 = lt(
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 dt(u));
247
+ rt(
248
+ t,
249
+ i,
250
+ new ft(c.subject, i.predicate, c.object)
251
+ );
252
+ }
253
+ }
254
+ return t;
255
+ }
256
+ function J(e) {
257
+ return e.map((t) => " " + St(t)).sort().join(`
258
+ `);
259
+ }
260
+ function $t(e) {
261
+ var t;
262
+ (t = e["@id"]) != null && t.startsWith("#") && (e["@id"] = R + e["@id"]);
263
+ }
264
+ function qt(e) {
265
+ for (const t of e)
266
+ t.subject.value.startsWith(R) && (t.subject.value = t.subject.value.slice(Rt));
267
+ }
268
+ async function At(e, t, r) {
269
+ r = r ?? window.fetch.bind(window);
270
+ const n = await P(t);
271
+ return await r(e, {
272
+ method: "PUT",
273
+ headers: { "Content-Type": "text/turtle" },
274
+ body: t
275
+ }), new _(e, n, new Headers({}));
276
+ }
277
+ async function h(e, t) {
278
+ const { body: r, headers: n } = await Pt(e, t), s = await P(r, { baseIRI: e });
279
+ return new _(e, s, n);
280
+ }
281
+ async function Ct(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 Et(e, t) {
290
+ if (Tt(e))
291
+ return (await Promise.all(e["@graph"].map((s) => Et(s, t)))).flat();
292
+ $t(e);
293
+ const r = await pt(e, { base: t });
294
+ return qt(r), r;
295
+ }
296
+ function Vt(e) {
297
+ const t = Nt(e);
298
+ return Object.entries(t).reduce((r, [n, s]) => {
299
+ const a = J(s);
300
+ return r.concat(`${n.toUpperCase()} DATA {
301
+ ${a}
302
+ }`);
303
+ }, []).join(` ;
304
+ `);
305
+ }
306
+ function Xt(e) {
307
+ const t = G(e);
308
+ return J(t);
309
+ }
310
+ function Ut(e, t = {}) {
311
+ const r = y({ baseIRI: t.baseIRI }), n = new W(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 B(t.baseIRI ?? null, T.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 Yt(e) {
333
+ return {
334
+ "@graph": await wt(e)
335
+ };
336
+ }
337
+ function Kt(e) {
338
+ return new z().quadsToString(e);
339
+ }
340
+ function St(e) {
341
+ return new z().quadsToString([e]).slice(0, -1);
342
+ }
343
+ async function Dt(e, t) {
344
+ try {
345
+ return !(await h(e, t)).isEmpty();
346
+ } catch {
347
+ return !1;
348
+ }
349
+ }
350
+ async function Zt(e, t = {}) {
351
+ const r = k(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 P(u, t);
356
+ })
357
+ ), n;
358
+ }
359
+ function Nt(e, t = {}) {
360
+ const r = k(e, /(\w+) DATA {([^}]+)}/g), n = {};
361
+ for (const s of r) {
362
+ const a = s[1].toLowerCase(), u = s[2];
363
+ n[a] = G(u, t);
364
+ }
365
+ return n;
366
+ }
367
+ async function P(e, t = {}) {
368
+ const { quads: r } = await Ut(e, t);
369
+ return r;
370
+ }
371
+ function G(e, t = {}) {
372
+ const r = y({ baseIRI: t.baseIRI }), n = new W(r);
373
+ try {
374
+ const s = n.parse(e);
375
+ return t.normalizeBlankNodes ? jt(s) : s;
376
+ } catch (s) {
377
+ throw new B(
378
+ t.baseIRI ?? null,
379
+ T.Turtle,
380
+ s.message ?? ""
381
+ );
382
+ }
383
+ }
384
+ async function kt(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 Lt(e, t) {
392
+ var u;
393
+ const r = new H(e.getQuads()), n = { [e.url]: e }, s = (o) => {
394
+ o.statements(void 0, "foaf:isPrimaryTopicOf").map((i) => i.object.value).forEach((i) => n[i] = n[i] ?? null), o.statements(void 0, "foaf:primaryTopic").map((i) => i.subject.value).forEach((i) => n[i] = n[i] ?? null);
395
+ }, a = async () => {
396
+ for (const [o, i] of Object.entries(n))
397
+ if (i === null)
398
+ try {
399
+ const c = await h(o, t);
400
+ n[o] = c, r.addQuads(c.getQuads()), s(c);
401
+ } catch (c) {
402
+ if (c instanceof I) {
403
+ n[o] = !1;
404
+ continue;
405
+ }
406
+ throw c;
407
+ }
408
+ };
409
+ s(e);
410
+ do
411
+ await a();
412
+ while (Object.values(n).some((o) => o === null));
413
+ return {
414
+ store: r,
415
+ cloaked: Object.values(n).some((o) => o === !1),
416
+ writableProfileUrl: e.isUserWritable() ? e.url : ((u = Object.values(n).find(
417
+ (o) => !!o && o.isUserWritable()
418
+ )) == null ? void 0 : u.url) ?? null
419
+ };
420
+ }
421
+ async function D(e, t = {}) {
422
+ var j, $, q, A, C, E;
423
+ const r = {
424
+ fetch: t.fetch,
425
+ // Needed for CSS v7.1.3.
426
+ // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972
427
+ cache: "no-store"
428
+ }, n = st(e), s = await h(n, r);
429
+ if (!s.isPersonalProfile() && !s.contains(e, "solid:oidcIssuer"))
430
+ throw new Error(`${e} is not a valid webId.`);
431
+ const { store: a, writableProfileUrl: u, cloaked: o } = await Lt(s, t), i = a.statements(e, "pim:storage").map((m) => m.object.value), c = a.statement(e, "solid:publicTypeIndex"), w = a.statement(e, "solid:privateTypeIndex");
432
+ let d = U(n);
433
+ for (; d && i.length === 0; ) {
434
+ const m = await M(h(d, r));
435
+ if (m != null && m.isStorage()) {
436
+ i.push(d);
437
+ break;
438
+ }
439
+ d = U(d);
440
+ }
441
+ if (i.length === 0)
442
+ throw new Error(`Could not find any storage for ${e}.`);
443
+ return await ((j = t.onLoaded) == null ? void 0 : j.call(t, a)), {
444
+ webId: e,
445
+ cloaked: o,
446
+ writableProfileUrl: u,
447
+ storageUrls: at(i),
448
+ ...y({
449
+ name: (($ = a.statement(e, "vcard:fn")) == null ? void 0 : $.object.value) ?? ((q = a.statement(e, "foaf:name")) == null ? void 0 : q.object.value),
450
+ avatarUrl: ((A = a.statement(e, "vcard:hasPhoto")) == null ? void 0 : A.object.value) ?? ((C = a.statement(e, "foaf:img")) == null ? void 0 : C.object.value),
451
+ oidcIssuerUrl: (E = a.statement(e, "solid:oidcIssuer")) == null ? void 0 : E.object.value,
452
+ publicTypeIndexUrl: c == null ? void 0 : c.object.value,
453
+ privateTypeIndexUrl: w == null ? void 0 : w.object.value
454
+ })
455
+ };
456
+ }
457
+ async function te(e, t = {}) {
458
+ if (t.required)
459
+ return D(e, t);
460
+ const r = M((n) => D(n, t));
461
+ return await r(e) ?? await r(e.replace(/\/$/, "").concat("/profile/card#me")) ?? await r(nt(e).concat("/profile/card#me"));
462
+ }
463
+ function Mt(e) {
464
+ return !e.path || !e.path.startsWith("/") ? null : e.path.match(/^\/[^/]*$/) ? "/" : `/${v(e.path.split("/")).filter().slice(0, -1).join("/")}/`.replace("//", "/");
465
+ }
466
+ function Qt(e) {
467
+ const t = Mt(e);
468
+ return e.protocol && e.domain ? `${e.protocol}://${e.domain}${t ?? "/"}` : t;
469
+ }
470
+ function x(e) {
471
+ if (!(!("@type" in e) || "@value" in e)) {
472
+ e["@id"] = e["@id"] ?? Q();
473
+ for (const t of Object.values(e))
474
+ S(t) && x(t), ct(t) && t.forEach((r) => S(r) && x(r));
475
+ }
476
+ }
477
+ function ee(e) {
478
+ return L(ot(e), (t) => x(t));
479
+ }
480
+ function re(e) {
481
+ const t = it(e);
482
+ return t ? y({
483
+ containerUrl: Qt(t),
484
+ documentName: t.path ? t.path.split("/").pop() : null,
485
+ resourceHash: t.fragment
486
+ }) : {};
487
+ }
488
+ async function Ot(e, t, r) {
489
+ r = r ?? window.fetch.bind(r);
490
+ const n = e.storageUrls[0], s = `${n}settings/${t}TypeIndex`;
491
+ return await Dt(s, { fetch: r }) ? `${n}settings/${t}TypeIndex-${Q()}` : s;
492
+ }
493
+ async function V(e, t, r) {
494
+ if (e.writableProfileUrl === null)
495
+ throw new Error("Can't create type index without a writable profile document");
496
+ r = r ?? window.fetch.bind(r);
497
+ const n = await Ot(e, t, r), s = t === "public" ? "<> a <http://www.w3.org/ns/solid/terms#TypeIndex> ." : `
498
+ <> a
499
+ <http://www.w3.org/ns/solid/terms#TypeIndex>,
500
+ <http://www.w3.org/ns/solid/terms#UnlistedDocument> .
501
+ `, a = `
502
+ INSERT DATA {
503
+ <${e.webId}> <http://www.w3.org/ns/solid/terms#${t}TypeIndex> <${n}> .
504
+ }
505
+ `;
506
+ return await At(n, s, r), await kt(e.writableProfileUrl, a, r), n;
507
+ }
508
+ async function X(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();
511
+ }
512
+ async function ne(e, t) {
513
+ return V(e, "public", t);
514
+ }
515
+ async function se(e, t) {
516
+ return V(e, "private", t);
517
+ }
518
+ async function ae(e, t, r) {
519
+ return X(e, t, "solid:instanceContainer", r);
520
+ }
521
+ async function oe(e, t, r) {
522
+ return X(e, t, "solid:instance", r);
523
+ }
524
+ async function Y(e, t) {
525
+ var a;
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 ut(O(e), s);
531
+ }
532
+ async function K(e, t, r) {
533
+ r = r ?? await Y(e, t);
534
+ const n = await Ct(r ?? "", { fetch: t });
535
+ if (!n)
536
+ return K(O(e), t);
537
+ if (n.isACPResource())
538
+ throw new bt(e, "ACP");
539
+ return n;
540
+ }
541
+ async function ie(e, t) {
542
+ const r = await Y(e, t), n = await K(e, t, r);
543
+ return y({
544
+ url: r,
545
+ effectiveUrl: n.url,
546
+ document: n
547
+ });
548
+ }
549
+ export {
550
+ B as MalformedSolidDocumentError,
551
+ yt as NetworkRequestError,
552
+ b as NotFoundError,
553
+ _ as SolidDocument,
554
+ T as SolidDocumentFormat,
555
+ xt as SolidDocumentPermission,
556
+ H as SolidStore,
557
+ It as SolidThing,
558
+ I as UnauthorizedError,
559
+ _t as UnsuccessfulNetworkRequestError,
560
+ bt as UnsupportedAuthorizationProtocolError,
561
+ Gt as compactJsonLDGraph,
562
+ se as createPrivateTypeIndex,
563
+ ne as createPublicTypeIndex,
564
+ At as createSolidDocument,
565
+ Jt as defineIRIPrefix,
566
+ f as expandIRI,
567
+ te as fetchLoginUserProfile,
568
+ h as fetchSolidDocument,
569
+ ie as fetchSolidDocumentACL,
570
+ Ct as fetchSolidDocumentIfFound,
571
+ ae as findContainerRegistrations,
572
+ oe as findInstanceRegistrations,
573
+ Tt as isJsonLDGraph,
574
+ Et as jsonldToQuads,
575
+ ee as mintJsonLDIdentifiers,
576
+ Vt as normalizeSparql,
577
+ Xt as normalizeTurtle,
578
+ re as parseResourceSubject,
579
+ Ut as parseTurtle,
580
+ St as quadToTurtle,
581
+ Yt as quadsToJsonLD,
582
+ Kt as quadsToTurtle,
583
+ Dt as solidDocumentExists,
584
+ Zt as sparqlToQuads,
585
+ Nt as sparqlToQuadsSync,
586
+ P as turtleToQuads,
587
+ G as turtleToQuadsSync,
588
+ kt as updateSolidDocument
589
+ };
590
+ //# sourceMappingURL=noeldemartin-solid-utils.js.map