@noeldemartin/solid-utils 0.6.0 → 0.6.1-next.bf3a764266964fbc17b114eddb9cdb074e1dbef6

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.
@@ -1,224 +1,275 @@
1
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, d as N, e as z } from "./io-wCcrq4b9.js";
5
- import { M as yt, N as vt, h as Tt, w as gt, g as xt, x as Pt, y as Ut, m as bt, r as $t, v as Et, o as jt, j as St, b as Dt, n as qt, p as Ct, a as Rt, i as At, q as It, k as Lt, s as kt, l as Qt, t as Ht } from "./io-wCcrq4b9.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;
2
+ var N = (e, t, a) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
+ var o = (e, t, a) => N(e, typeof t != "symbol" ? t + "" : t, a);
4
+ import { f as p, S as Q, U as k, c as z, u as F, d as J, e as H, g as G } from "./io-DqYt65s_.js";
5
+ import { M as Pt, N as jt, i as Dt, x as Ut, h as qt, y as Et, z as $t, r as St, w as Rt, v as At, j as Ct, k as Lt, b as It, n as Nt, p as Qt, a as kt, l as zt, q as Ft, m as Jt, s as Ht, o as Gt, t as Ot } from "./io-DqYt65s_.js";
6
+ import { JSError as q, silenced as E, urlRoot as O, urlRoute as W, urlParentDirectory as j, objectWithoutEmpty as h, arrayUnique as _, tap as M, objectDeepClone as B, urlParse as V, uuid as $, isObject as D, isArray as Y, arr as K, urlResolve as X, requireUrlParentDirectory as S } from "@noeldemartin/utils";
7
+ function Z(e, t) {
8
+ return t = t ?? e, typeof e == "string" ? `${e} (returned ${t.status} status code)` : `Request to ${t.url} returned ${t.status} status code`;
9
+ }
10
+ class dt extends q {
11
+ constructor(a, r) {
12
+ super(Z(a, r));
13
+ o(this, "response");
14
+ this.response = r ?? a;
15
15
  }
16
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;
17
+ class tt extends q {
18
+ constructor(a, r, s) {
19
+ super(`The resource at ${a} is using an unsupported authorization protocol (${r})`, s);
20
+ o(this, "url");
21
+ o(this, "protocol");
22
+ this.url = a, this.protocol = r;
23
23
  }
24
24
  }
25
- async function Z(t, e) {
26
- var u;
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))
31
- if (i === null)
25
+ async function et(e, t) {
26
+ var l;
27
+ const a = new Q(e.getQuads()), r = { [e.url]: e }, s = (n) => {
28
+ n.statements(void 0, "foaf:isPrimaryTopicOf").map((u) => u.object.value).forEach((u) => r[u] = r[u] ?? null), n.statements(void 0, "foaf:primaryTopic").map((u) => u.subject.value).forEach((u) => r[u] = r[u] ?? null);
29
+ }, i = async () => {
30
+ for (const [n, u] of Object.entries(r))
31
+ if (u === null)
32
32
  try {
33
- const c = await m(n, e);
34
- a[n] = c, r.addQuads(c.getQuads()), o(c);
33
+ const c = await p(n, t);
34
+ r[n] = c, a.addQuads(c.getQuads()), s(c);
35
35
  } catch (c) {
36
- if (c instanceof Q) {
37
- a[n] = !1;
36
+ if (c instanceof k) {
37
+ r[n] = !1;
38
38
  continue;
39
39
  }
40
40
  throw c;
41
41
  }
42
42
  };
43
- o(t);
43
+ s(e);
44
44
  do
45
- await s();
46
- while (Object.values(a).some((n) => n === null));
45
+ await i();
46
+ while (Object.values(r).some((n) => n === null));
47
47
  return {
48
- store: r,
49
- cloaked: Object.values(a).some((n) => n === !1),
50
- writableProfileUrl: t.isUserWritable() ? t.url : ((u = Object.values(a).find(
48
+ store: a,
49
+ cloaked: Object.values(r).some((n) => n === !1),
50
+ writableProfileUrl: e.isUserWritable() ? e.url : ((l = Object.values(r).find(
51
51
  (n) => !!n && n.isUserWritable()
52
- )) == null ? void 0 : u.url) ?? null
52
+ )) == null ? void 0 : l.url) ?? null
53
53
  };
54
54
  }
55
- async function $(t, e = {}) {
56
- var y, v, T, g, x, P;
57
- const r = {
58
- fetch: e.fetch,
55
+ async function U(e, t = {}) {
56
+ var T, v, g, b, x, P;
57
+ const a = {
58
+ fetch: t.fetch,
59
59
  // Needed for CSS v7.1.3.
60
60
  // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972
61
61
  cache: "no-store"
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);
62
+ }, r = W(e), s = await p(r, a);
63
+ if (!s.isPersonalProfile() && !s.contains(e, "solid:oidcIssuer"))
64
+ throw new Error(`${e} is not a valid webId.`);
65
+ const { store: i, writableProfileUrl: l, cloaked: n } = await et(s, t), u = i.statements(e, "pim:storage").map((f) => f.object.value), c = i.statement(e, "solid:publicTypeIndex"), m = i.statement(e, "solid:privateTypeIndex");
66
+ let d = j(r);
67
+ for (; d && u.length === 0; ) {
68
+ const f = await E(p(d, a));
69
+ if (f != null && f.isStorage()) {
70
+ u.push(d);
71
71
  break;
72
72
  }
73
- l = U(l);
73
+ d = j(d);
74
74
  }
75
- if (i.length === 0)
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,
75
+ if (u.length === 0)
76
+ throw new Error(`Could not find any storage for ${e}.`);
77
+ return await ((T = t.onLoaded) == null ? void 0 : T.call(t, i)), {
78
+ webId: e,
79
79
  cloaked: n,
80
- writableProfileUrl: u,
81
- storageUrls: F(i),
80
+ writableProfileUrl: l,
81
+ storageUrls: _(u),
82
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,
83
+ name: ((v = i.statement(e, "vcard:fn")) == null ? void 0 : v.object.value) ?? ((g = i.statement(e, "foaf:name")) == null ? void 0 : g.object.value),
84
+ avatarUrl: ((b = i.statement(e, "vcard:hasPhoto")) == null ? void 0 : b.object.value) ?? ((x = i.statement(e, "foaf:img")) == null ? void 0 : x.object.value),
85
+ oidcIssuerUrl: (P = i.statement(e, "solid:oidcIssuer")) == null ? void 0 : P.object.value,
86
86
  publicTypeIndexUrl: c == null ? void 0 : c.object.value,
87
- privateTypeIndexUrl: p == null ? void 0 : p.object.value
87
+ privateTypeIndexUrl: m == null ? void 0 : m.object.value
88
88
  })
89
89
  };
90
90
  }
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"));
91
+ async function ft(e, t = {}) {
92
+ if (t.required)
93
+ return U(e, t);
94
+ const a = E((r) => U(r, t));
95
+ return await a(e) ?? await a(e.replace(/\/$/, "").concat("/profile/card#me")) ?? await a(O(e).concat("/profile/card#me"));
96
96
  }
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("//", "/");
97
+ function at(e) {
98
+ return !e.path || !e.path.startsWith("/") ? null : e.path.match(/^\/[^/]*$/) ? "/" : `/${K(e.path.split("/")).filter().slice(0, -1).join("/")}/`.replace("//", "/");
99
99
  }
100
- function et(t) {
101
- const e = tt(t);
102
- return t.protocol && t.domain ? `${t.protocol}://${t.domain}${e ?? "/"}` : e;
100
+ function rt(e) {
101
+ const t = at(e);
102
+ return e.protocol && e.domain ? `${e.protocol}://${e.domain}${t ?? "/"}` : t;
103
103
  }
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));
104
+ function y(e) {
105
+ if (!(!("@type" in e) || "@value" in e)) {
106
+ e["@id"] = e["@id"] ?? $();
107
+ for (const t of Object.values(e))
108
+ D(t) && y(t), Y(t) && t.forEach((a) => D(a) && y(a));
109
109
  }
110
110
  }
111
- function ct(t) {
112
- return M(_(t), (e) => w(e));
111
+ function pt(e) {
112
+ return M(B(e), (t) => y(t));
113
113
  }
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
114
+ function mt(e) {
115
+ const t = V(e);
116
+ return t ? h({
117
+ containerUrl: rt(t),
118
+ documentName: t.path ? t.path.split("/").pop() : null,
119
+ resourceHash: t.fragment
120
120
  }) : {};
121
121
  }
122
- async function rt(t, e, r) {
123
- r = r ?? window.fetch.bind(r);
124
- const a = t.storageUrls[0], o = `${a}settings/${e}TypeIndex`;
125
- return await N(o, { fetch: r }) ? `${a}settings/${e}TypeIndex-${S()}` : o;
122
+ async function nt(e, t, a) {
123
+ a = a ?? window.fetch.bind(a);
124
+ const r = e.storageUrls[0], s = `${r}settings/${t}TypeIndex`;
125
+ return await J(s, { fetch: a }) ? `${r}settings/${t}TypeIndex-${$()}` : s;
126
126
  }
127
- async function q(t, e, r) {
128
- if (t.writableProfileUrl === null)
127
+ async function R(e, t, a) {
128
+ if (e.writableProfileUrl === null)
129
129
  throw new Error("Can't create type index without a writable profile document");
130
- r = r ?? window.fetch.bind(r);
131
- const a = await rt(t, e, r), o = e === "public" ? "<> a <http://www.w3.org/ns/solid/terms#TypeIndex> ." : `
130
+ a = a ?? window.fetch.bind(a);
131
+ const r = await nt(e, t, a), s = t === "public" ? "<> a <http://www.w3.org/ns/solid/terms#TypeIndex> ." : `
132
132
  <> a
133
133
  <http://www.w3.org/ns/solid/terms#TypeIndex>,
134
134
  <http://www.w3.org/ns/solid/terms#UnlistedDocument> .
135
- `, s = `
135
+ `, i = `
136
136
  INSERT DATA {
137
- <${t.webId}> <http://www.w3.org/ns/solid/terms#${e}TypeIndex> <${a}> .
137
+ <${e.webId}> <http://www.w3.org/ns/solid/terms#${t}TypeIndex> <${r}> .
138
138
  }
139
139
  `;
140
- return await H(a, o, r), await J(t.writableProfileUrl, s, r), a;
141
- }
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();
145
- }
146
- async function lt(t, e) {
147
- return q(t, "public", e);
148
- }
149
- async function dt(t, e) {
150
- return q(t, "private", e);
151
- }
152
- async function ft(t, e, r) {
153
- return C(t, e, "solid:instanceContainer", r);
154
- }
155
- async function mt(t, e, r) {
156
- return C(t, e, "solid:instance", r);
157
- }
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);
140
+ return await z(r, s, a), await F(e.writableProfileUrl, i, a), r;
141
+ }
142
+ async function A(e, t, a, r) {
143
+ const s = await p(e, { fetch: r });
144
+ return (Array.isArray(t) ? t : [t]).map((l) => s.statements(void 0, "rdf:type", "solid:TypeRegistration").filter((n) => s.contains(n.subject.value, "solid:forClass", l)).map((n) => s.statements(n.subject.value, a)).flat().map((n) => n.object.value).filter((n) => !!n)).flat();
145
+ }
146
+ async function yt(e, t) {
147
+ return R(e, "public", t);
148
+ }
149
+ async function wt(e, t) {
150
+ return R(e, "private", t);
151
+ }
152
+ async function ht(e, t, a) {
153
+ return A(e, t, "solid:instanceContainer", a);
154
+ }
155
+ async function Tt(e, t, a) {
156
+ return A(e, t, "solid:instance", a);
157
+ }
158
+ async function C(e, t) {
159
+ var i;
160
+ t = t ?? window.fetch.bind(window);
161
+ const s = ((i = ((await t(e, { method: "HEAD" })).headers.get("Link") ?? "").match(/<([^>]+)>;\s*rel="acl"/)) == null ? void 0 : i[1]) ?? null;
162
+ if (!s)
163
+ throw new Error(`Could not find ACL Resource for '${e}'`);
164
+ return X(S(e), s);
165
+ }
166
+ async function L(e, t, a) {
167
+ a = a ?? await C(e, t);
168
+ const r = await H(a ?? "", { fetch: t });
169
+ if (!r)
170
+ return L(S(e), t);
171
+ if (r.isACPResource())
172
+ throw new tt(e, "ACP");
173
+ return r;
174
+ }
175
+ async function vt(e, t) {
176
+ const a = await C(e, t), r = await L(e, t, a);
177
177
  return h({
178
- url: r,
179
- effectiveUrl: a.url,
180
- document: a
178
+ url: a,
179
+ effectiveUrl: r.url,
180
+ document: r
181
181
  });
182
182
  }
183
+ class st {
184
+ constructor() {
185
+ o(this, "termType", "DefaultGraph");
186
+ o(this, "value", "");
187
+ }
188
+ equals(t) {
189
+ return this.termType === (t == null ? void 0 : t.termType) && this.value === t.value;
190
+ }
191
+ }
192
+ class w {
193
+ constructor(t) {
194
+ o(this, "termType", "NamedNode");
195
+ o(this, "value");
196
+ this.value = t;
197
+ }
198
+ equals(t) {
199
+ return this.termType === (t == null ? void 0 : t.termType) && this.value === t.value;
200
+ }
201
+ }
202
+ const ot = new w(G("xsd:string"));
203
+ class it {
204
+ constructor(t, a = "", r = ot) {
205
+ o(this, "termType", "Literal");
206
+ o(this, "value");
207
+ o(this, "language");
208
+ o(this, "datatype");
209
+ this.value = t, this.language = a, this.datatype = r;
210
+ }
211
+ equals(t) {
212
+ return this.termType === (t == null ? void 0 : t.termType) && this.value === t.value && this.language === t.language && this.datatype.equals(t.datatype);
213
+ }
214
+ }
215
+ class gt {
216
+ constructor(t, a, r) {
217
+ o(this, "termType", "Quad");
218
+ o(this, "value", "");
219
+ o(this, "subject");
220
+ o(this, "predicate");
221
+ o(this, "object");
222
+ o(this, "graph");
223
+ this.subject = typeof t == "string" ? new w(t) : t, this.predicate = typeof a == "string" ? new w(a) : a, this.object = typeof r == "string" ? new it(r) : r, this.graph = new st();
224
+ }
225
+ equals(t) {
226
+ return this.termType === (t == null ? void 0 : t.termType) && this.subject.equals(t.subject) && this.predicate.equals(t.predicate) && this.object.equals(t.object);
227
+ }
228
+ }
183
229
  export {
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,
213
- Ct as parseTurtle,
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
230
+ Pt as MalformedSolidDocumentError,
231
+ jt as NetworkRequestError,
232
+ Dt as NotFoundError,
233
+ st as RDFDefaultGraph,
234
+ it as RDFLiteral,
235
+ w as RDFNamedNode,
236
+ gt as RDFQuad,
237
+ Ut as SolidDocument,
238
+ qt as SolidDocumentFormat,
239
+ Et as SolidDocumentPermission,
240
+ Q as SolidStore,
241
+ $t as SolidThing,
242
+ k as UnauthorizedError,
243
+ dt as UnsuccessfulNetworkRequestError,
244
+ tt as UnsupportedAuthorizationProtocolError,
245
+ St as compactJsonLDGraph,
246
+ wt as createPrivateTypeIndex,
247
+ yt as createPublicTypeIndex,
248
+ z as createSolidDocument,
249
+ Rt as defineIRIPrefix,
250
+ G as expandIRI,
251
+ ft as fetchLoginUserProfile,
252
+ p as fetchSolidDocument,
253
+ vt as fetchSolidDocumentACL,
254
+ H as fetchSolidDocumentIfFound,
255
+ ht as findContainerRegistrations,
256
+ Tt as findInstanceRegistrations,
257
+ At as isJsonLDGraph,
258
+ Ct as jsonldToQuads,
259
+ pt as mintJsonLDIdentifiers,
260
+ Lt as normalizeJsonLD,
261
+ It as normalizeSparql,
262
+ Nt as normalizeTurtle,
263
+ mt as parseResourceSubject,
264
+ Qt as parseTurtle,
265
+ kt as quadToTurtle,
266
+ zt as quadsToJsonLD,
267
+ Ft as quadsToTurtle,
268
+ J as solidDocumentExists,
269
+ Jt as sparqlToQuads,
270
+ Ht as sparqlToQuadsSync,
271
+ Gt as turtleToQuads,
272
+ Ot as turtleToQuadsSync,
273
+ F as updateSolidDocument
223
274
  };
224
275
  //# sourceMappingURL=noeldemartin-solid-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"noeldemartin-solid-utils.js","sources":["../src/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/wac.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? (messageOrResponse as Response);\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? (messageOrResponse as Response);\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\n }\n\n}\n","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch, FetchSolidDocumentOptions } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...string[]];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(\n webIdDocument: SolidDocument,\n options?: FetchSolidDocumentOptions,\n): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map((quad) => quad.object.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map((quad) => quad.subject.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const _document = await fetchSolidDocument(url, options);\n\n documents[url] = _document;\n store.addQuads(_document.getQuads());\n\n addReferencedDocumentUrls(_document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some((document) => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some((document) => document === false),\n writableProfileUrl: webIdDocument.isUserWritable()\n ? webIdDocument.url\n : (Object.values(documents).find(\n (document): document is SolidDocument => !!document && document.isUserWritable(),\n )?.url ?? null),\n };\n}\n\nasync function fetchUserProfile(webId: string, options: FetchUserProfileOptions = {}): Promise<SolidUserProfile> {\n const requestOptions: FetchSolidDocumentOptions = {\n fetch: options.fetch,\n\n // Needed for CSS v7.1.3.\n // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972\n cache: 'no-store',\n };\n\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, requestOptions);\n\n if (!document.isPersonalProfile() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, options);\n const storageUrls = store.statements(webId, 'pim:storage').map((storage) => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, requestOptions));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n await options.onLoaded?.(store);\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\n ...objectWithoutEmpty({\n name: store.statement(webId, 'vcard:fn')?.object.value ?? store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchUserProfileOptions {\n fetch?: Fetch;\n onLoaded?(store: SolidStore): Promise<unknown> | unknown;\n}\n\nexport interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {\n required?: boolean;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options);\n }\n\n const fetchProfile = silenced((url) => fetchUserProfile(url, options));\n\n return (\n (await fetchProfile(loginUrl)) ??\n (await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))) ??\n (await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me')))\n );\n}\n","import { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@noeldemartin/solid-utils/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/')) return null;\n\n if (parts.path.match(/^\\/[^/]*$/)) return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld) return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue)) __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue)) propertyValue.forEach((value) => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, (clone) => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts\n ? {}\n : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport {\n createSolidDocument,\n fetchSolidDocument,\n solidDocumentExists,\n updateSolidDocument,\n} from '@noeldemartin/solid-utils/helpers/io';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\nimport type { SolidUserProfile } from '@noeldemartin/solid-utils/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return (await solidDocumentExists(typeIndexUrl, { fetch }))\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody =\n type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n await updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, { fetch });\n const types = Array.isArray(type) ? type : [type];\n\n return types\n .map((_type) =>\n typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter((statement) => typeIndex.contains(statement.subject.value, 'solid:forClass', _type))\n .map((statement) => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map((statement) => statement.object.value)\n .filter((url) => !!url))\n .flat();\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\n// eslint-disable-next-line max-len\nimport UnsupportedAuthorizationProtocolError from '@noeldemartin/solid-utils/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@noeldemartin/solid-utils/helpers/io';\nimport type SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? (await fetchACLResourceUrl(resourceUrl, fetch));\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', { fetch });\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(\n documentUrl: string,\n fetch: Fetch,\n): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\n}\n"],"names":["getErrorMessage","messageOrResponse","response","UnsuccessfulRequestError","JSError","__publicField","UnsupportedAuthorizationProtocolError","url","protocol","options","fetchExtendedUserProfile","webIdDocument","store","SolidStore","documents","addReferencedDocumentUrls","document","quad","profileDocumentUrl","loadProfileDocuments","_document","fetchSolidDocument","error","UnauthorizedError","_a","fetchUserProfile","webId","requestOptions","documentUrl","urlRoute","writableProfileUrl","cloaked","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","parentDocument","silenced","arrayUnique","objectWithoutEmpty","_b","_c","_d","_e","_f","fetchLoginUserProfile","loginUrl","fetchProfile","urlRoot","getContainerPath","parts","arr","getContainerUrl","containerPath","__mintJsonLDIdentifiers","jsonld","uuid","propertyValue","isObject","isArray","value","mintJsonLDIdentifiers","tap","objectDeepClone","clone","parseResourceSubject","subject","urlParse","mintTypeIndexUrl","user","type","fetch","storageUrl","typeIndexUrl","solidDocumentExists","createTypeIndex","typeIndexBody","profileUpdateBody","createSolidDocument","updateSolidDocument","findRegistrations","predicate","typeIndex","_type","statement","createPublicTypeIndex","createPrivateTypeIndex","findContainerRegistrations","findInstanceRegistrations","fetchACLResourceUrl","resourceUrl","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","fetchSolidDocumentIfFound","fetchSolidDocumentACL"],"mappings":";;;;;;AAEA,SAASA,EAAgBC,GAAsCC,GAA6B;AACxF,SAAAA,IAAWA,KAAaD,GAEjB,OAAOA,KAAsB,WAC9B,GAAGA,CAAiB,cAAcC,EAAS,MAAM,kBACjD,cAAcA,EAAS,GAAG,aAAaA,EAAS,MAAM;AAChE;AAEA,MAAqBC,WAAiCC,EAAQ;AAAA,EAM1D,YAAYH,GAAsCC,GAAqB;AAC7D,UAAAF,EAAgBC,GAAmBC,CAAQ,CAAC;AAL/C,IAAAG,EAAA;AAOH,SAAK,WAAWH,KAAaD;AAAA,EAAA;AAGrC;ACnBA,MAAqBK,UAA8CF,EAAQ;AAAA,EAKvE,YAAYG,GAAaC,GAAkBC,GAA0B;AACjE,UAAM,mBA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ClBf,GACAH,GACAC,GACiB;AACjB,SAAOS,EAAkBP,GAAcH,GAAM,kBAAkBC,CAAK;AACxE;AC1GA,eAAekB,EAAoBC,GAAqBnB,GAA+B;;AACnF,EAAAA,IAAQA,KAAS,OAAO,MAAM,KAAK,MAAM;AAIzC,QAAMlE,MAAMiB,MAFS,MAAMiD,EAAMmB,GAAa,EAAE,QAAQ,QAAQ,GAChC,QAAQ,IAAI,MAAM,KAAK,IAChC,MAAM,wBAAwB,MAAzC,gBAAApE,EAA6C,OAAM;AAE/D,MAAI,CAACjB;AACD,UAAM,IAAI,MAAM,oCAAoCqF,CAAW,GAAG;AAGtE,SAAOC,EAAWC,EAA0BF,CAAW,GAAGrF,CAAG;AACjE;AAEA,eAAewF,EACXH,GACAnB,GACAuB,GACsB;AACtB,EAAAA,IAAiBA,KAAmB,MAAML,EAAoBC,GAAanB,CAAK;AAEhF,QAAMwB,IAAc,MAAMC,EAA0BF,KAAkB,IAAI,EAAE,OAAAvB,GAAO;AAEnF,MAAI,CAACwB;AACD,WAAOF,EAAkBD,EAA0BF,CAAW,GAAGnB,CAAK;AAGtE,MAAAwB,EAAY;AACN,UAAA,IAAI3F,EAAsCsF,GAAa,KAAK;AAG/D,SAAAK;AACX;AAEsB,eAAAE,GAClBvE,GACA6C,GAKD;AACC,QAAMlE,IAAM,MAAMoF,EAAoB/D,GAAa6C,CAAK,GAClDzD,IAAW,MAAM+E,EAAkBnE,GAAa6C,GAAOlE,CAAG;AAEhE,SAAOkC,EAAmB;AAAA,IACtB,KAAAlC;AAAA,IACA,cAAcS,EAAS;AAAA,IACvB,UAAAA;AAAA,EAAA,CACH;AACL;"}
1
+ {"version":3,"file":"noeldemartin-solid-utils.js","sources":["../src/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/wac.ts","../src/rdf/RDFDefaultGraph.ts","../src/rdf/RDFNamedNode.ts","../src/rdf/constants.ts","../src/rdf/RDFLiteral.ts","../src/rdf/RDFQuad.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? (messageOrResponse as Response);\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? (messageOrResponse as Response);\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\n }\n\n}\n","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch, FetchSolidDocumentOptions } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...string[]];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(\n webIdDocument: SolidDocument,\n options?: FetchSolidDocumentOptions,\n): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map((quad) => quad.object.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map((quad) => quad.subject.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const _document = await fetchSolidDocument(url, options);\n\n documents[url] = _document;\n store.addQuads(_document.getQuads());\n\n addReferencedDocumentUrls(_document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some((document) => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some((document) => document === false),\n writableProfileUrl: webIdDocument.isUserWritable()\n ? webIdDocument.url\n : (Object.values(documents).find(\n (document): document is SolidDocument => !!document && document.isUserWritable(),\n )?.url ?? null),\n };\n}\n\nasync function fetchUserProfile(webId: string, options: FetchUserProfileOptions = {}): Promise<SolidUserProfile> {\n const requestOptions: FetchSolidDocumentOptions = {\n fetch: options.fetch,\n\n // Needed for CSS v7.1.3.\n // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972\n cache: 'no-store',\n };\n\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, requestOptions);\n\n if (!document.isPersonalProfile() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, options);\n const storageUrls = store.statements(webId, 'pim:storage').map((storage) => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, requestOptions));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n await options.onLoaded?.(store);\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\n ...objectWithoutEmpty({\n name: store.statement(webId, 'vcard:fn')?.object.value ?? store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchUserProfileOptions {\n fetch?: Fetch;\n onLoaded?(store: SolidStore): Promise<unknown> | unknown;\n}\n\nexport interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {\n required?: boolean;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options);\n }\n\n const fetchProfile = silenced((url) => fetchUserProfile(url, options));\n\n return (\n (await fetchProfile(loginUrl)) ??\n (await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))) ??\n (await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me')))\n );\n}\n","import { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@noeldemartin/solid-utils/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/')) return null;\n\n if (parts.path.match(/^\\/[^/]*$/)) return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld) return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue)) __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue)) propertyValue.forEach((value) => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, (clone) => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts\n ? {}\n : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport {\n createSolidDocument,\n fetchSolidDocument,\n solidDocumentExists,\n updateSolidDocument,\n} from '@noeldemartin/solid-utils/helpers/io';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\nimport type { SolidUserProfile } from '@noeldemartin/solid-utils/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return (await solidDocumentExists(typeIndexUrl, { fetch }))\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody =\n type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n await updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, { fetch });\n const types = Array.isArray(type) ? type : [type];\n\n return types\n .map((_type) =>\n typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter((statement) => typeIndex.contains(statement.subject.value, 'solid:forClass', _type))\n .map((statement) => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map((statement) => statement.object.value)\n .filter((url) => !!url))\n .flat();\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\n// eslint-disable-next-line max-len\nimport UnsupportedAuthorizationProtocolError from '@noeldemartin/solid-utils/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@noeldemartin/solid-utils/helpers/io';\nimport type SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? (await fetchACLResourceUrl(resourceUrl, fetch));\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', { fetch });\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(\n documentUrl: string,\n fetch: Fetch,\n): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\n}\n","import type { DefaultGraph, Term } from '@rdfjs/types';\n\nexport default class RDFDefaultGraph implements DefaultGraph {\n\n public termType = 'DefaultGraph' as const;\n public value = '' as const;\n\n public equals(other: Term | null | undefined): boolean {\n return this.termType === other?.termType && this.value === other.value;\n }\n\n}\n","import type { NamedNode, Term } from '@rdfjs/types';\n\nexport default class RDFNamedNode implements NamedNode {\n\n public termType = 'NamedNode' as const;\n public value: string;\n\n constructor(value: string) {\n this.value = value;\n }\n\n public equals(other: Term | null | undefined): boolean {\n return this.termType === other?.termType && this.value === other.value;\n }\n\n}\n","import { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nimport RDFNamedNode from './RDFNamedNode';\n\nexport const DATATYPE_STRING = new RDFNamedNode(expandIRI('xsd:string'));\n","import type { Literal, NamedNode, Term } from '@rdfjs/types';\n\nimport { DATATYPE_STRING } from './constants';\n\nexport default class RDFLiteral implements Literal {\n\n public termType = 'Literal' as const;\n public value: string;\n public language: string;\n public datatype: NamedNode;\n\n constructor(value: string, language: string = '', datatype: NamedNode = DATATYPE_STRING) {\n this.value = value;\n this.language = language;\n this.datatype = datatype;\n }\n\n public equals(other: Term | null | undefined): boolean {\n return (\n this.termType === other?.termType &&\n this.value === other.value &&\n this.language === other.language &&\n this.datatype.equals(other.datatype)\n );\n }\n\n}\n","import type { Quad, Quad_Graph, Quad_Object, Quad_Predicate, Quad_Subject, Term } from '@rdfjs/types';\n\nimport RDFDefaultGraph from './RDFDefaultGraph';\nimport RDFLiteral from './RDFLiteral';\nimport RDFNamedNode from './RDFNamedNode';\n\nexport default class RDFQuad implements Quad {\n\n public termType = 'Quad' as const;\n public value = '' as const;\n public subject: Quad_Subject;\n public predicate: Quad_Predicate;\n public object: Quad_Object;\n public graph: Quad_Graph;\n\n constructor(subject: string | Quad_Subject, predicate: string | Quad_Predicate, object: string | Quad_Object) {\n this.subject = typeof subject === 'string' ? new RDFNamedNode(subject) : subject;\n this.predicate = typeof predicate === 'string' ? new RDFNamedNode(predicate) : predicate;\n this.object = typeof object === 'string' ? new RDFLiteral(object) : object;\n this.graph = new RDFDefaultGraph();\n }\n\n public equals(other: Term | null | undefined): boolean {\n return (\n this.termType === other?.termType &&\n this.subject.equals(other.subject) &&\n this.predicate.equals(other.predicate) &&\n this.object.equals(other.object)\n );\n }\n\n}\n"],"names":["getErrorMessage","messageOrResponse","response","UnsuccessfulRequestError","JSError","__publicField","UnsupportedAuthorizationProtocolError","url","protocol","options","fetchExtendedUserProfile","webIdDocument","store","SolidStore","documents","addReferencedDocumentUrls","document","quad","profileDocumentUrl","loadProfileDocuments","_document","fetchSolidDocument","error","UnauthorizedError","_a","fetchUserProfile","webId","requestOptions","documentUrl","urlRoute","writableProfileUrl","cloaked","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","parentDocument","silenced","arrayUnique","objectWithoutEmpty","_b","_c","_d","_e","_f","fetchLoginUserProfile","loginUrl","fetchProfile","urlRoot","getContainerPath","parts","arr","getContainerUrl","containerPath","__mintJsonLDIdentifiers","jsonld","uuid","propertyValue","isObject","isArray","value","mintJsonLDIdentifiers","tap","objectDeepClone","clone","parseResourceSubject","subject","urlParse","mintTypeIndexUrl","user","type","fetch","storageUrl","typeIndexUrl","solidDocumentExists","createTypeIndex","typeIndexBody","profileUpdateBody","createSolidDocument","updateSolidDocument","findRegistrations","predicate","typeIndex","_type","statement","createPublicTypeIndex","createPrivateTypeIndex","findContainerRegistrations","findInstanceRegistrations","fetchACLResourceUrl","resourceUrl","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","fetchSolidDocumentIfFound","fetchSolidDocumentACL","RDFDefaultGraph","other","RDFNamedNode","DATATYPE_STRING","expandIRI","RDFLiteral","language","datatype","RDFQuad","object"],"mappings":";;;;;;AAEA,SAASA,EAAgBC,GAAsCC,GAA6B;AACxF,SAAAA,IAAWA,KAAaD,GAEjB,OAAOA,KAAsB,WAC9B,GAAGA,CAAiB,cAAcC,EAAS,MAAM,kBACjD,cAAcA,EAAS,GAAG,aAAaA,EAAS,MAAM;AAChE;AAEA,MAAqBC,WAAiCC,EAAQ;AAAA,EAM1D,YAAYH,GAAsCC,GAAqB;AAC7D,UAAAF,EAAgBC,GAAmBC,CAAQ,CAAC;AAL/C,IAAAG,EAAA;AAOH,SAAK,WAAWH,KAAaD;AAAA,EAAA;AAGrC;ACnBA,MAAqBK,WAA8CF,EAAQ;AAAA,EAKvE,YAAYG,GAAaC,GAAkBC,GAA0B;AACjE,UAAM,mBAAmBF,CAAG,oDAAoDC,CAAQ,KAAKC,CAAO;AAJxF,IAAAJ,EAAA;AACA,IAAAA,EAAA;AAKZ,SAAK,MAAME,GACX,KAAK,WAAWC;AAAA,EAAA;AAGxB;ACMA,eAAeE,GACXC,GACAF,GAKD;;AACC,QAAMG,IAAQ,IAAIC,EAAWF,EAAc,UAAU,GAC/CG,IAA0D,EAAE,CAACH,EAAc,GAAG,GAAGA,EAAc,GAC/FI,IAA4B,CAACC,MAA4B;AAEtD,IAAAA,EAAA,WAAW,QAAW,uBAAuB,EAC7C,IAAI,CAACC,MAASA,EAAK,OAAO,KAAK,EAC/B,QAAQ,CAACC,MAAwBJ,EAAUI,CAAkB,IAAIJ,EAAUI,CAAkB,KAAK,IAAK,GAEvGF,EAAA,WAAW,QAAW,mBAAmB,EACzC,IAAI,CAACC,MAASA,EAAK,QAAQ,KA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A,EAGb,OAAON,GAAyC;AACnD,WACI,KAAK,cAAaA,KAAA,gBAAAA,EAAO,aACzB,KAAK,UAAUA,EAAM,SACrB,KAAK,aAAaA,EAAM,YACxB,KAAK,SAAS,OAAOA,EAAM,QAAQ;AAAA,EAAA;AAI/C;ACpBA,MAAqBO,GAAwB;AAAA,EASzC,YAAYxC,GAAgCe,GAAoC0B,GAA8B;AAPvG,IAAAxG,EAAA,kBAAW;AACX,IAAAA,EAAA,eAAQ;AACR,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAGH,SAAK,UAAU,OAAO+D,KAAY,WAAW,IAAIkC,EAAalC,CAAO,IAAIA,GACzE,KAAK,YAAY,OAAOe,KAAc,WAAW,IAAImB,EAAanB,CAAS,IAAIA,GAC/E,KAAK,SAAS,OAAO0B,KAAW,WAAW,IAAIJ,GAAWI,CAAM,IAAIA,GAC/D,KAAA,QAAQ,IAAIT,GAAgB;AAAA,EAAA;AAAA,EAG9B,OAAOC,GAAyC;AAE/C,WAAA,KAAK,cAAaA,KAAA,gBAAAA,EAAO,aACzB,KAAK,QAAQ,OAAOA,EAAM,OAAO,KACjC,KAAK,UAAU,OAAOA,EAAM,SAAS,KACrC,KAAK,OAAO,OAAOA,EAAM,MAAM;AAAA,EAAA;AAI3C;"}
package/dist/testing.d.ts CHANGED
@@ -6,7 +6,7 @@ export declare interface EqualityResult {
6
6
  }
7
7
 
8
8
  declare type JsonLD = Partial<{
9
- '@context': Record<string, unknown>;
9
+ '@context': Record<string, unknown> | string;
10
10
  '@id': string;
11
11
  '@type': null | string | string[];
12
12
  }> & {
@@ -22,6 +22,14 @@ export declare function turtleEquals(expected: string, actual: string): Equality
22
22
  export { }
23
23
 
24
24
 
25
+ declare module '@vitest/expect' {
26
+ interface Assertion<T> extends VitestSolidMatchers<T> {
27
+ }
28
+ interface AsymmetricMatchersContaining extends VitestSolidMatchers {
29
+ }
30
+ }
31
+
32
+
25
33
  declare global {
26
34
  namespace Chai {
27
35
  interface Assertion extends ChaiSolidAssertions {
@@ -30,11 +38,3 @@ declare global {
30
38
  }
31
39
  }
32
40
  }
33
-
34
-
35
- declare module '@vitest/expect' {
36
- interface Assertion<T> extends VitestSolidMatchers<T> {
37
- }
38
- interface AsymmetricMatchersContaining extends VitestSolidMatchers {
39
- }
40
- }