solid-logic 6.0.1-4 → 6.0.1-6

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 (102) hide show
  1. package/dist/acl/accessControlSubjects.cjs.js +1 -1
  2. package/dist/acl/accessControlSubjects.cjs.js.map +1 -1
  3. package/dist/acl/accessControlSubjects.esm.js +16 -17
  4. package/dist/acl/aclLogic.cjs.js.map +1 -1
  5. package/dist/acl/aclLogic.esm.js +1 -2
  6. package/dist/authSession/authSession.cjs.js.map +1 -1
  7. package/dist/authSession/authSession.esm.js +1 -2
  8. package/dist/authSession/events.cjs.js.map +1 -1
  9. package/dist/authSession/events.esm.js +1 -2
  10. package/dist/authSession/flagAuthorizationOnTransitions.cjs.js.map +1 -1
  11. package/dist/authSession/flagAuthorizationOnTransitions.esm.js +1 -2
  12. package/dist/authSession/identityState.cjs.js.map +1 -1
  13. package/dist/authSession/identityState.esm.js +1 -2
  14. package/dist/authSession/issuer.cjs.js.map +1 -1
  15. package/dist/authSession/issuer.esm.js +1 -2
  16. package/dist/authSession/session.cjs.js +1 -1
  17. package/dist/authSession/session.cjs.js.map +1 -1
  18. package/dist/authSession/session.esm.js +2 -3
  19. package/dist/authSession/session.esm.js.map +1 -1
  20. package/dist/authn/SolidAuthnLogic.cjs.js +1 -1
  21. package/dist/authn/SolidAuthnLogic.cjs.js.map +1 -1
  22. package/dist/authn/SolidAuthnLogic.esm.js +41 -42
  23. package/dist/authn/authUtil.cjs.js.map +1 -1
  24. package/dist/authn/authUtil.esm.js +1 -2
  25. package/dist/authn/serverLogout.cjs.js.map +1 -1
  26. package/dist/authn/serverLogout.esm.js +1 -2
  27. package/dist/chat/chatLogic.cjs.js.map +1 -1
  28. package/dist/chat/chatLogic.esm.js +1 -2
  29. package/dist/directory/catalogDirectory.cjs.js +1 -1
  30. package/dist/directory/catalogDirectory.cjs.js.map +1 -1
  31. package/dist/directory/catalogDirectory.esm.js +15 -16
  32. package/dist/directory/contactsDirectory.cjs.js.map +1 -1
  33. package/dist/directory/contactsDirectory.esm.js +1 -2
  34. package/dist/directory/directoryHelpers.cjs.js.map +1 -1
  35. package/dist/directory/directoryHelpers.esm.js +1 -2
  36. package/dist/directory/directoryLogic.cjs.js +1 -1
  37. package/dist/directory/directoryLogic.cjs.js.map +1 -1
  38. package/dist/directory/directoryLogic.esm.js +14 -15
  39. package/dist/directory/friendsDirectory.cjs.js.map +1 -1
  40. package/dist/directory/friendsDirectory.esm.js +1 -2
  41. package/dist/inbox/inboxLogic.cjs.js.map +1 -1
  42. package/dist/inbox/inboxLogic.esm.js +1 -2
  43. package/dist/index.cjs.js +1 -1
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.d.ts +2 -1
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.esm.js +11 -11
  48. package/dist/index.esm.js.map +1 -1
  49. package/dist/issuer/issuerLogic.cjs.js.map +1 -1
  50. package/dist/issuer/issuerLogic.esm.js +1 -2
  51. package/dist/logic/CustomError.cjs.js.map +1 -1
  52. package/dist/logic/CustomError.esm.js +1 -2
  53. package/dist/logic/solidLogic.cjs.js +1 -1
  54. package/dist/logic/solidLogic.cjs.js.map +1 -1
  55. package/dist/logic/solidLogic.esm.js +17 -18
  56. package/dist/logic/solidLogicSingleton.cjs.js +1 -1
  57. package/dist/logic/solidLogicSingleton.cjs.js.map +1 -1
  58. package/dist/logic/solidLogicSingleton.esm.js +6 -7
  59. package/dist/profile/profileAclDocuments.cjs.js.map +1 -1
  60. package/dist/profile/profileAclDocuments.esm.js +1 -2
  61. package/dist/profile/profileDocuments.cjs.js +6 -2
  62. package/dist/profile/profileDocuments.cjs.js.map +1 -1
  63. package/dist/profile/profileDocuments.esm.js +2 -10
  64. package/dist/profile/profileDocuments.esm.js.map +1 -1
  65. package/dist/profile/profileLogic.cjs.js +1 -1
  66. package/dist/profile/profileLogic.cjs.js.map +1 -1
  67. package/dist/profile/profileLogic.esm.js +47 -48
  68. package/dist/resource/resourceHttp.cjs.js.map +1 -1
  69. package/dist/resource/resourceHttp.esm.js +1 -2
  70. package/dist/resource/resourceLogic.cjs.js +1 -1
  71. package/dist/resource/resourceLogic.cjs.js.map +1 -1
  72. package/dist/resource/resourceLogic.d.ts.map +1 -1
  73. package/dist/resource/resourceLogic.esm.js +186 -81
  74. package/dist/resource/resourceLogic.esm.js.map +1 -1
  75. package/dist/resource/resourceMetadata.cjs.js.map +1 -1
  76. package/dist/resource/resourceMetadata.esm.js +1 -2
  77. package/dist/typeIndex/typeIndexAclDocuments.cjs.js.map +1 -1
  78. package/dist/typeIndex/typeIndexAclDocuments.esm.js +1 -2
  79. package/dist/typeIndex/typeIndexDocuments.cjs.js +7 -3
  80. package/dist/typeIndex/typeIndexDocuments.cjs.js.map +1 -1
  81. package/dist/typeIndex/typeIndexDocuments.esm.js +3 -14
  82. package/dist/typeIndex/typeIndexDocuments.esm.js.map +1 -1
  83. package/dist/typeIndex/typeIndexLogic.cjs.js.map +1 -1
  84. package/dist/typeIndex/typeIndexLogic.esm.js +1 -2
  85. package/dist/types.cjs.js +2 -0
  86. package/dist/types.cjs.js.map +1 -0
  87. package/dist/types.d.ts +19 -0
  88. package/dist/types.d.ts.map +1 -1
  89. package/dist/types.esm.js +9 -0
  90. package/dist/types.esm.js.map +1 -0
  91. package/dist/util/containerLogic.cjs.js.map +1 -1
  92. package/dist/util/containerLogic.esm.js +1 -2
  93. package/dist/util/debug.cjs.js.map +1 -1
  94. package/dist/util/debug.esm.js +1 -2
  95. package/dist/util/ns.cjs.js.map +1 -1
  96. package/dist/util/ns.esm.js +1 -2
  97. package/dist/util/utilityLogic.cjs.js +1 -1
  98. package/dist/util/utilityLogic.cjs.js.map +1 -1
  99. package/dist/util/utilityLogic.esm.js +42 -43
  100. package/dist/util/utils.cjs.js.map +1 -1
  101. package/dist/util/utils.esm.js +1 -2
  102. package/package.json +5 -5
@@ -1,39 +1,140 @@
1
- import { ns as e } from "../util/ns.esm.js";
2
- import { ACL_LINK as t } from "../acl/aclLogic.esm.js";
1
+ import { ACL_LINK as e } from "../acl/aclLogic.esm.js";
2
+ import { ns as t } from "../util/ns.esm.js";
3
3
  import { assertSuccessfulHttpResponse as n, isMissingError as r } from "./resourceHttp.esm.js";
4
4
  import { readWacAccessInfo as i } from "./resourceMetadata.esm.js";
5
- import { sym as a } from "rdflib";
6
- //#region src/resource/resourceLogic.ts
7
- function o(o, s, c, l) {
8
- function u(e) {
9
- return c.createContainer(e);
5
+ import { ResourceUploadError as a } from "../types.esm.js";
6
+ import { Util as o, sym as s } from "rdflib";
7
+ import * as c from "mime-types";
8
+ // src/resource/resourceLogic.ts
9
+ function l(l, u, d, f) {
10
+ function p(e, t) {
11
+ let n = (e, t) => {
12
+ let n = typeof t == "object" && t ? t : void 0, r = n?.response?.status, i = n?.status, o = typeof r == "number" ? r : typeof i == "number" ? i : void 0, s = t instanceof Error ? t.message : typeof n?.message == "string" ? n.message : typeof t == "string" ? t : "Upload failed";
13
+ return new a(s, e, o);
14
+ };
15
+ return Promise.all(e.map((e) => new Promise((r) => {
16
+ let i = new FileReader();
17
+ i.onload = (i) => {
18
+ try {
19
+ let o = i.target?.result;
20
+ if (!(o instanceof ArrayBuffer)) {
21
+ r({
22
+ success: !1,
23
+ file: e,
24
+ error: n(void 0, /* @__PURE__ */ Error("Unable to read file as an ArrayBuffer"))
25
+ });
26
+ return;
27
+ }
28
+ let s = "", u = e.type;
29
+ if (u) {
30
+ let t = c.extension(e.type);
31
+ t && t !== "false" && !e.name.endsWith(`.${t}`) && e.type !== c.lookup(e.name) && (s = `_.${t}`);
32
+ } else if (u = c.lookup(e.name) || "", !u) {
33
+ r({
34
+ success: !1,
35
+ file: e,
36
+ error: n(void 0, /* @__PURE__ */ Error("Filename has no recognized content type"))
37
+ });
38
+ return;
39
+ }
40
+ let d = `${t}${t.endsWith("/") ? "" : "/"}${encodeURIComponent(e.name)}${s}`;
41
+ l.fetcher.webOperation("PUT", d, {
42
+ data: o,
43
+ contentType: u
44
+ }).then((t) => r(t.ok ? {
45
+ success: !0,
46
+ file: e,
47
+ uploadedUri: d
48
+ } : {
49
+ success: !1,
50
+ file: e,
51
+ error: new a(`HTTP error on PUT! Status: ${t.status}`, d, t.status)
52
+ }), (t) => r({
53
+ success: !1,
54
+ file: e,
55
+ error: n(d, t)
56
+ }));
57
+ } catch (t) {
58
+ r({
59
+ success: !1,
60
+ file: e,
61
+ error: n(void 0, t)
62
+ });
63
+ }
64
+ }, i.onerror = () => {
65
+ r({
66
+ success: !1,
67
+ file: e,
68
+ error: n(void 0, /* @__PURE__ */ Error("Unable to read file"))
69
+ });
70
+ }, i.onabort = () => {
71
+ r({
72
+ success: !1,
73
+ file: e,
74
+ error: n(void 0, /* @__PURE__ */ Error("File reading was aborted"))
75
+ });
76
+ };
77
+ try {
78
+ i.readAsArrayBuffer(e);
79
+ } catch (t) {
80
+ r({
81
+ success: !1,
82
+ file: e,
83
+ error: n(void 0, t)
84
+ });
85
+ }
86
+ }).catch((t) => ({
87
+ success: !1,
88
+ file: e,
89
+ error: n(void 0, t)
90
+ }))));
10
91
  }
11
- function d(e) {
12
- return c.isContainer(e);
92
+ function m(e) {
93
+ return d.createContainer(e);
13
94
  }
14
- function f(e) {
15
- return c.getContainerMemberCount(e);
95
+ function h(e) {
96
+ return d.isContainer(e);
16
97
  }
17
- function p(e) {
18
- return c.getContainerElements(e);
98
+ function g(e) {
99
+ return d.getContainerMemberCount(e);
19
100
  }
20
- function m(e) {
101
+ function _(e) {
102
+ return d.getContainerElements(e);
103
+ }
104
+ function v(e) {
21
105
  let t = e.uri.endsWith("/") ? e.uri : `${e.uri}/`;
22
- return o.sym(`${t}index.ttl#this`);
106
+ return l.sym(`${t}index.ttl#this`);
23
107
  }
24
- function h(t) {
25
- return o.holds(t, e.ldp("contains"), m(t).doc());
108
+ function y(e) {
109
+ return l.holds(e, t.ldp("contains"), v(e).doc());
26
110
  }
27
- function g(t) {
28
- return o.holds(t, e.rdf("type"), e.space("Storage"), t.doc());
111
+ function b(e) {
112
+ return l.holds(e, t.rdf("type"), t.space("Storage"), e.doc());
29
113
  }
30
- function _(e) {
114
+ function x(e) {
31
115
  let t = e.dir();
32
116
  if (!t) return !1;
33
117
  let n = e.uri.slice(t.uri.length);
34
118
  return n.startsWith(".") || n.endsWith(".acl") || n.endsWith(".meta") || n.endsWith("~");
35
119
  }
36
- function v(e) {
120
+ function S(e, t) {
121
+ let n = l.findTypeURIs(e), r = t.toLowerCase(), i = o.mediaTypeClass(`${r}/*`).uri.split("*")[0];
122
+ return Object.keys(n).some((e) => e.startsWith(i)) || {
123
+ audio: "http://purl.org/dc/dcmitype/Sound",
124
+ image: "http://purl.org/dc/dcmitype/Image",
125
+ video: "http://purl.org/dc/dcmitype/MovingImage"
126
+ }[r] in n ? !0 : (l.fetcher.getHeader(e, "content-type") || []).some((e) => e.split(";", 1)[0].trim().toLowerCase().startsWith(`${r}/`));
127
+ }
128
+ function C(e) {
129
+ return S(e, "image");
130
+ }
131
+ function w(e) {
132
+ return S(e, "audio");
133
+ }
134
+ function T(e) {
135
+ return S(e, "video");
136
+ }
137
+ function E(e) {
37
138
  let t = typeof e == "string" ? e : e.value;
38
139
  try {
39
140
  let e = new URL(t);
@@ -42,31 +143,31 @@ function o(o, s, c, l) {
42
143
  return !1;
43
144
  }
44
145
  }
45
- function y(n, r) {
46
- let a, s = !1, c = !1, l = !1, u = !1, d, f;
146
+ function D(n, r) {
147
+ let a, o = !1, s = !1, c = !1, u = !1, d, f;
47
148
  if (r.headers) {
48
149
  a = r.headers.get("content-type")?.split(";")[0] ?? void 0;
49
- let t = i(r.headers.get("wac-allow"));
50
- s = t.canEdit, c = t.canManageAccess, l = t.isPublic, u = t.isPublicKnown, d = r.headers.get("etag") ?? void 0, f = o.anyValue(n, e.dct("modified")) || o.anyValue(n, e.dc("modified")) || void 0;
150
+ let e = i(r.headers.get("wac-allow"));
151
+ o = e.canEdit, s = e.canManageAccess, c = e.isPublic, u = e.isPublicKnown, d = r.headers.get("etag") ?? void 0, f = l.anyValue(n, t.dct("modified")) || l.anyValue(n, t.dc("modified")) || void 0;
51
152
  }
52
- (!r.headers || !r.headers.get("content-type")) && (!r.headers || !r.headers.get("wac-allow") || !r.headers.get("etag")) && o.each(null, o.sym("http://www.w3.org/2007/ont/link#requestedURI"), n).map((t) => {
53
- let r = o.any(t, o.sym("http://www.w3.org/2007/ont/link#response"));
153
+ r.headers && r.headers.get("content-type") || r.headers && r.headers.get("wac-allow") && r.headers.get("etag") || l.each(null, l.sym("http://www.w3.org/2007/ont/link#requestedURI"), n).map((e) => {
154
+ let r = l.any(e, l.sym("http://www.w3.org/2007/ont/link#response"));
54
155
  if (r && r.termType === "NamedNode") {
55
- let t = o.anyValue(r, e.httph("content-type")) || void 0;
56
- a === void 0 && (a = t);
57
- let p = o.anyValue(r, e.httph("wac-allow")) || o.anyValue(r, e.httph("WAC-Allow")), m = i(p);
58
- s ||= m.canEdit, c ||= m.canManageAccess, l ||= m.isPublic, u ||= m.isPublicKnown;
59
- let h = o.anyValue(r, e.httph("etag")) || void 0;
60
- d === void 0 && (d = h), f = o.anyValue(n, e.dct("modified")) || o.anyValue(n, e.dc("modified")) || void 0;
156
+ let e = l.anyValue(r, t.httph("content-type")) || void 0;
157
+ a === void 0 && (a = e);
158
+ let p = l.anyValue(r, t.httph("wac-allow")) || l.anyValue(r, t.httph("WAC-Allow")), m = i(p);
159
+ o ||= m.canEdit, s ||= m.canManageAccess, c ||= m.isPublic, u ||= m.isPublicKnown;
160
+ let h = l.anyValue(r, t.httph("etag")) || void 0;
161
+ d === void 0 && (d = h), f = l.anyValue(n, t.dct("modified")) || l.anyValue(n, t.dc("modified")) || void 0;
61
162
  }
62
163
  });
63
- let p = o.any(n, t)?.value || void 0;
164
+ let p = l.any(n, e)?.value || void 0;
64
165
  return {
65
166
  contentType: a,
66
167
  access: {
67
- canEdit: s,
68
- canManageAccess: c,
69
- isPublic: l,
168
+ canEdit: o,
169
+ canManageAccess: s,
170
+ isPublic: c,
70
171
  isPublicKnown: u
71
172
  },
72
173
  aclUri: p,
@@ -74,32 +175,32 @@ function o(o, s, c, l) {
74
175
  modified: f
75
176
  };
76
177
  }
77
- async function b(e) {
78
- let t = await o.fetcher.webOperation("HEAD", e.uri);
79
- return n(t, "HEAD"), y(e, t);
178
+ async function O(e) {
179
+ let t = await l.fetcher.webOperation("HEAD", e.uri);
180
+ return n(t, "HEAD"), D(e, t);
80
181
  }
81
- async function x(t) {
82
- let n = o.any(t, e.ldp("contains")) || t.dir();
182
+ async function k(e) {
183
+ let n = l.any(e, t.ldp("contains")) || e.dir();
83
184
  if (!n || n.termType !== "NamedNode") return !1;
84
185
  try {
85
- return (await b(n)).access.canEdit;
186
+ return (await O(n)).access.canEdit;
86
187
  } catch {
87
188
  return !1;
88
189
  }
89
190
  }
90
- async function S(e) {
91
- return x(e);
191
+ async function A(e) {
192
+ return k(e);
92
193
  }
93
- async function C(e) {
94
- return b(e);
194
+ async function j(e) {
195
+ return O(e);
95
196
  }
96
- async function w(e) {
197
+ async function M(e) {
97
198
  try {
98
- let t = await o.fetcher.webOperation("GET", e.uri);
199
+ let t = await l.fetcher.webOperation("GET", e.uri);
99
200
  n(t, "GET");
100
201
  let r = t.responseText;
101
202
  if (r === void 0) throw Error("No text in response object");
102
- let i = y(e, t);
203
+ let i = D(e, t);
103
204
  if (!i.contentType) throw Error("No content-type available");
104
205
  return {
105
206
  content: r,
@@ -109,10 +210,10 @@ function o(o, s, c, l) {
109
210
  throw Error(`Error reading file: ${e instanceof Error ? e.message : String(e)}`);
110
211
  }
111
212
  }
112
- async function T(e) {
213
+ async function N(e) {
113
214
  let t;
114
215
  try {
115
- t = await b(e);
216
+ t = await O(e);
116
217
  } catch {
117
218
  t = {
118
219
  contentType: void 0,
@@ -126,7 +227,7 @@ function o(o, s, c, l) {
126
227
  modified: void 0
127
228
  };
128
229
  }
129
- let n = await S(e), r = {
230
+ let n = await A(e), r = {
130
231
  canEdit: t.access?.canEdit ?? !1,
131
232
  canManageAccess: t.access?.canManageAccess ?? !1,
132
233
  isPublic: t.access?.isPublic ?? !1,
@@ -138,49 +239,53 @@ function o(o, s, c, l) {
138
239
  access: r
139
240
  };
140
241
  }
141
- async function E(e, t) {
242
+ async function P(e, t) {
142
243
  if (t) try {
143
- await l.deleteTypeIndexRegistrationForResource(e, t);
244
+ await f.deleteTypeIndexRegistrationForResource(e, t);
144
245
  } catch {}
145
246
  }
146
- async function D(t, i = {}) {
147
- let s = t.dir();
148
- if (d(t)) {
149
- let e = await c.getContainerMembers(t);
150
- await Promise.all(e.map((e) => D(a(e), i)));
247
+ async function F(e, i = {}) {
248
+ let a = e.dir();
249
+ if (h(e)) {
250
+ let t = await d.getContainerMembers(e);
251
+ await Promise.all(t.map((e) => F(s(e), i)));
151
252
  }
152
- let l;
253
+ let o;
153
254
  try {
154
- l = await o.fetcher._fetch(t.value, { method: "DELETE" }), n(l, "DELETE", { allowNotFound: !0 });
255
+ o = await l.fetcher._fetch(e.value, { method: "DELETE" }), n(o, "DELETE", { allowNotFound: !0 });
155
256
  } catch (e) {
156
257
  if (!r(e)) throw e;
157
258
  }
158
- return i.deleteTypeIndexes && await E(t, i.user), s && o.removeMatches(s, e.ldp("contains"), t, s.doc()), o.removeDocument(t), o.fetcher.unload(t.doc()), l;
259
+ return i.deleteTypeIndexes && await P(e, i.user), a && l.removeMatches(a, t.ldp("contains"), e), l.removeDocument(e), l.fetcher.unload(e.doc()), o;
159
260
  }
160
- async function O(e, t) {
161
- await D(e, {
261
+ async function I(e, t) {
262
+ await F(e, {
162
263
  deleteTypeIndexes: !0,
163
264
  user: t
164
265
  });
165
266
  }
166
267
  return {
167
- recursiveDelete: D,
168
- deleteResourceAndTypeIndexIfExists: O,
169
- fetchMetadata: C,
170
- fetchMetadataWithDelete: T,
171
- fetchContentAndMetadata: w,
172
- createContainer: u,
173
- isContainer: d,
174
- getContainerMembers: p,
175
- getContainerMemberCount: f,
176
- getContainerIndexThing: m,
177
- containerHasIndexDocument: h,
178
- isStorageRoot: g,
179
- isHiddenFile: _,
180
- isWebId: v
268
+ uploadFiles: p,
269
+ recursiveDelete: F,
270
+ deleteResourceAndTypeIndexIfExists: I,
271
+ fetchMetadata: j,
272
+ fetchMetadataWithDelete: N,
273
+ fetchContentAndMetadata: M,
274
+ createContainer: m,
275
+ isContainer: h,
276
+ getContainerMembers: _,
277
+ getContainerMemberCount: g,
278
+ getContainerIndexThing: v,
279
+ containerHasIndexDocument: y,
280
+ isStorageRoot: b,
281
+ isHiddenFile: x,
282
+ isMediaType: S,
283
+ isImage: C,
284
+ isAudio: w,
285
+ isVideo: T,
286
+ isWebId: E
181
287
  };
182
288
  }
183
- //#endregion
184
- export { o as createResourceLogic };
289
+ export { l as createResourceLogic };
185
290
 
186
291
  //# sourceMappingURL=resourceLogic.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"resourceLogic.esm.js","names":["createResourceLogic","createContainer","containerLogic","url","isContainer","resourceNode","getContainerMemberCount","getContainerMembers","getContainerIndexThing","folderUri","containerNode","store","containerHasIndexDocument","ns","isStorageRoot","isHiddenFile","directory","pathEnd","isWebId","uri","resource","parsed","readMetadata","contentType","canEdit","canManageAccess","isPublic","isPublicKnown","eTag","modified","response","accessFlags","readWacAccessInfo","subject","responseNode","req","responseContentType","wacAllow","responseETag","aclUri","ACL_LINK","fetchHeadMetadata","assertSuccessfulHttpResponse","userCanWriteToContainingContainer","userCanDeleteResource","fetchMetadata","fetchContentAndMetadata","content","metadata","error","fetchMetadataWithDelete","resourceMetadata","canDelete","access","deleteTypeIndexesForResource","user","typeIndexLogic","recursiveDelete","resourceParent","containerMembers","sym","options","deleted","isMissingError","deleteResourceAndTypeIndexIfExists"],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { type ResourceAccess, type ResourceAccessWithDelete, type ResourceContent, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type TypeIndexLogic } from '../types'\nimport type { AclLogic } from '../types'\n\nexport function createResourceLogic(store, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function getContainerMembers(resourceNode: NamedNode) {\n return containerLogic.getContainerElements(resourceNode)\n }\n\n function getContainerIndexThing(containerNode: NamedNode) {\n const folderUri = containerNode.uri.endsWith('/') ? containerNode.uri : `${containerNode.uri}/`\n return store.sym(`${folderUri}index.ttl#this`)\n }\n\n function containerHasIndexDocument(containerNode: NamedNode) {\n return store.holds(\n containerNode,\n ns.ldp('contains'),\n getContainerIndexThing(containerNode).doc()\n )\n }\n\n function isStorageRoot(resourceNode: NamedNode) {\n return store.holds(\n resourceNode,\n ns.rdf('type'),\n ns.space('Storage'),\n resourceNode.doc()\n )\n }\n\n function isHiddenFile(resourceNode: NamedNode) {\n const directory = resourceNode.dir()\n if (!directory) {\n return false\n }\n\n const pathEnd = resourceNode.uri.slice(directory.uri.length)\n return pathEnd.startsWith('.') || pathEnd.endsWith('.acl') || pathEnd.endsWith('.meta') || pathEnd.endsWith('~')\n }\n\n function isWebId(resource: string | NamedNode) {\n const uri = typeof resource === 'string' ? resource : resource.value\n\n try {\n const parsed = new URL(uri)\n return parsed.hash === '#me' && /\\/profile\\/card\\.ttl$/.test(parsed.pathname)\n } catch (_error) {\n return false\n }\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let canManageAccess = false\n let isPublic = false\n let isPublicKnown = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n canManageAccess = accessFlags.canManageAccess\n isPublic = accessFlags.isPublic\n isPublicKnown = accessFlags.isPublicKnown\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n canManageAccess = canManageAccess || accessFlags.canManageAccess\n isPublic = isPublic || accessFlags.isPublic\n isPublicKnown = isPublicKnown || accessFlags.isPublicKnown\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, canManageAccess, isPublic, isPublicKnown }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchContentAndMetadata(subject: NamedNode): Promise<ResourceContent> {\n try {\n const response = await store.fetcher.webOperation('GET', subject.uri)\n assertSuccessfulHttpResponse(response, 'GET')\n\n const content = (response as Response & { responseText?: string }).responseText\n if (content === undefined) {\n throw new Error('No text in response object')\n }\n\n const metadata = readMetadata(subject, response)\n if (!metadata.contentType) {\n throw new Error('No content-type available')\n }\n\n return { content, metadata }\n } catch (error) {\n throw new Error(`Error reading file: ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, canManageAccess: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n canManageAccess: resourceMetadata.access?.canManageAccess ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n isPublicKnown: resourceMetadata.access?.isPublicKnown ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode, resourceParent.doc())\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n return {\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n fetchContentAndMetadata,\n createContainer,\n isContainer,\n getContainerMembers,\n getContainerMemberCount,\n getContainerIndexThing,\n containerHasIndexDocument,\n isStorageRoot,\n isHiddenFile,\n isWebId\n }\n}\n"],"mappings":";;;;;;AAQA,SAAgBA,EAAoB,GAAO,GAAoB,GAAgB,GAA+C;CAC5H,SAASC,EAAgB,GAAa;EACpC,OAAOC,EAAe,gBAAgBC,CAAG;CAC3C;CAEA,SAASC,EAAY,GAAyB;EAC5C,OAAOF,EAAe,YAAYG,CAAY;CAChD;CAEA,SAASC,EAAwB,GAAyB;EACxD,OAAOJ,EAAe,wBAAwBG,CAAY;CAC5D;CAEA,SAASE,EAAo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AAG,IAAI,UAAU,GAAGR,GAAcqD,EAAe,IAAI,CAAC,GAG5F/C,EAAM,eAAeN,CAAY,GACjCM,EAAM,QAAQ,OAAON,EAAa,IAAI,CAAC,GAChCyD;CACT;CAEA,eAAeE,EAAmC,GAAyB,GAAyB;EAClG,MAAMP,EAAgBpD,GAAc;GAAE,mBAAmB;GAAM;EAAK,CAAC;CACvE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"resourceLogic.esm.js","names":["mime","createResourceLogic","uploadFiles","getUploadError","uploadError","error","responseStatus","directStatus","status","message","ResourceUploadError","destUri","files","reader","data","event","suffix","contentType","file","extension","destination","resolve","response","createContainer","containerLogic","url","isContainer","resourceNode","getContainerMemberCount","getContainerMembers","getContainerIndexThing","folderUri","containerNode","store","containerHasIndexDocument","ns","isStorageRoot","isHiddenFile","directory","pathEnd","isMediaType","typeURIs","normalizedMediaType","mediaType","mediaTypePrefix","Util","typeURI","isImage","isAudio","isVideo","isWebId","uri","resource","parsed","readMetadata","canEdit","canManageAccess","isPublic","isPublicKnown","eTag","modified","accessFlags","readWacAccessInfo","subject","responseNode","req","responseContentType","wacAllow","responseETag","aclUri","ACL_LINK","fetchHeadMetadata","assertSuccessfulHttpResponse","userCanWriteToContainingContainer","userCanDeleteResource","fetchMetadata","fetchContentAndMetadata","content","metadata","fetchMetadataWithDelete","resourceMetadata","canDelete","access","deleteTypeIndexesForResource","user","typeIndexLogic","recursiveDelete","resourceParent","containerMembers","sym","options","deleted","isMissingError","deleteResourceAndTypeIndexIfExists"],"sources":["../../src/resource/resourceLogic.ts"],"sourcesContent":["import { NamedNode, sym, Util } from 'rdflib'\nimport { ACL_LINK } from '../acl/aclLogic'\nimport { ns } from '../util/ns'\nimport { assertSuccessfulHttpResponse, isMissingError } from './resourceHttp'\nimport { readWacAccessInfo } from './resourceMetadata'\nimport { ResourceUploadError, type ResourceAccess, type ResourceAccessWithDelete, type ResourceContent, type ResourceDeleteOptions, type ResourceLogic, type ResourceMetadata, type ResourceMetadataWithDelete, type ResourceUploadResult, type TypeIndexLogic } from '../types'\nimport type { AclLogic } from '../types'\nimport * as mime from 'mime-types'\n\nexport function createResourceLogic(store, aclLogic: AclLogic, containerLogic, typeIndexLogic: TypeIndexLogic): ResourceLogic {\n function uploadFiles (\n files: File[],\n destination: string\n ): Promise<ResourceUploadResult[]> {\n const getUploadError = (destUri: string | undefined, error: unknown) => {\n const uploadError = typeof error === 'object' && error !== null\n ? error as { response?: { status?: unknown }, status?: unknown, message?: unknown }\n : undefined\n const responseStatus = uploadError?.response?.status\n const directStatus = uploadError?.status\n const status = typeof responseStatus === 'number'\n ? responseStatus\n : typeof directStatus === 'number' ? directStatus : undefined\n const message = error instanceof Error\n ? error.message\n : typeof uploadError?.message === 'string'\n ? uploadError.message\n : typeof error === 'string' ? error : 'Upload failed'\n return new ResourceUploadError(message, destUri, status)\n }\n\n const upload = (file: File): Promise<ResourceUploadResult> => new Promise<ResourceUploadResult>(resolve => {\n const reader = new FileReader()\n reader.onload = event => {\n try {\n const data = event.target?.result\n if (!(data instanceof ArrayBuffer)) {\n resolve({ success: false, file, error: getUploadError(undefined, new Error('Unable to read file as an ArrayBuffer')) })\n return\n }\n\n let suffix = ''\n let contentType = file.type\n if (!contentType) {\n contentType = mime.lookup(file.name) || ''\n if (!contentType) {\n resolve({ success: false, file, error: getUploadError(undefined, new Error('Filename has no recognized content type')) })\n return\n }\n } else {\n const extension = mime.extension(file.type)\n if (extension && extension !== 'false' && !file.name.endsWith(`.${extension}`) && file.type !== mime.lookup(file.name)) {\n suffix = `_.${extension}`\n }\n }\n\n const destUri = `${destination}${destination.endsWith('/') ? '' : '/'}${encodeURIComponent(file.name)}${suffix}`\n\n store.fetcher.webOperation('PUT', destUri, { data, contentType }).then(\n response => resolve(response.ok\n ? { success: true, file, uploadedUri: destUri }\n : { success: false, file, error: new ResourceUploadError(`HTTP error on PUT! Status: ${response.status}`, destUri, response.status) }),\n error => resolve({ success: false, file, error: getUploadError(destUri, error) })\n )\n } catch (error) {\n resolve({ success: false, file, error: getUploadError(undefined, error) })\n }\n }\n reader.onerror = () => {\n resolve({ success: false, file, error: getUploadError(undefined, new Error('Unable to read file')) })\n }\n reader.onabort = () => {\n resolve({ success: false, file, error: getUploadError(undefined, new Error('File reading was aborted')) })\n }\n try {\n reader.readAsArrayBuffer(file)\n } catch (error) {\n resolve({ success: false, file, error: getUploadError(undefined, error) })\n }\n }).catch(error => ({\n success: false as const,\n file,\n error: getUploadError(undefined, error)\n }))\n\n return Promise.all(files.map(upload))\n }\n\n function createContainer(url: string) {\n return containerLogic.createContainer(url)\n }\n\n function isContainer(resourceNode: NamedNode) {\n return containerLogic.isContainer(resourceNode)\n }\n\n function getContainerMemberCount(resourceNode: NamedNode) {\n return containerLogic.getContainerMemberCount(resourceNode)\n }\n\n function getContainerMembers(resourceNode: NamedNode) {\n return containerLogic.getContainerElements(resourceNode)\n }\n\n function getContainerIndexThing(containerNode: NamedNode) {\n const folderUri = containerNode.uri.endsWith('/') ? containerNode.uri : `${containerNode.uri}/`\n return store.sym(`${folderUri}index.ttl#this`)\n }\n\n function containerHasIndexDocument(containerNode: NamedNode) {\n return store.holds(\n containerNode,\n ns.ldp('contains'),\n getContainerIndexThing(containerNode).doc()\n )\n }\n\n function isStorageRoot(resourceNode: NamedNode) {\n return store.holds(\n resourceNode,\n ns.rdf('type'),\n ns.space('Storage'),\n resourceNode.doc()\n )\n }\n\n function isHiddenFile(resourceNode: NamedNode) {\n const directory = resourceNode.dir()\n if (!directory) {\n return false\n }\n\n const pathEnd = resourceNode.uri.slice(directory.uri.length)\n return pathEnd.startsWith('.') || pathEnd.endsWith('.acl') || pathEnd.endsWith('.meta') || pathEnd.endsWith('~')\n }\n\n function isMediaType(resourceNode: NamedNode, mediaType: string) {\n const typeURIs = store.findTypeURIs(resourceNode as any)\n const normalizedMediaType = mediaType.toLowerCase()\n const mediaTypePrefix = Util.mediaTypeClass(`${normalizedMediaType}/*`).uri.split('*')[0]\n\n if (Object.keys(typeURIs).some(typeURI => typeURI.startsWith(mediaTypePrefix))) {\n return true\n }\n\n const mediaTypeClasses: Record<string, string> = {\n audio: 'http://purl.org/dc/dcmitype/Sound',\n image: 'http://purl.org/dc/dcmitype/Image',\n video: 'http://purl.org/dc/dcmitype/MovingImage'\n }\n if (mediaTypeClasses[normalizedMediaType] in typeURIs) {\n return true\n }\n\n const contentTypes = store.fetcher.getHeader(resourceNode, 'content-type') || []\n return contentTypes.some((contentType: string) =>\n contentType.split(';', 1)[0].trim().toLowerCase().startsWith(`${normalizedMediaType}/`)\n )\n }\n\n function isImage(resourceNode: NamedNode) {\n return isMediaType(resourceNode, 'image')\n }\n\n function isAudio(resourceNode: NamedNode) {\n return isMediaType(resourceNode, 'audio')\n }\n\n function isVideo(resourceNode: NamedNode) {\n return isMediaType(resourceNode, 'video')\n }\n\n function isWebId(resource: string | NamedNode) {\n const uri = typeof resource === 'string' ? resource : resource.value\n\n try {\n const parsed = new URL(uri)\n return parsed.hash === '#me' && /\\/profile\\/card\\.ttl$/.test(parsed.pathname)\n } catch (_error) {\n return false\n }\n }\n\n function readMetadata(subject: NamedNode, response: Response): ResourceMetadata {\n let contentType: string | undefined\n let canEdit = false\n let canManageAccess = false\n let isPublic = false\n let isPublicKnown = false\n let eTag: string | undefined\n let modified: string | undefined\n\n if (response.headers) {\n const contentTypeHeader = response.headers.get('content-type')\n contentType = contentTypeHeader?.split(';')[0] ?? undefined\n\n const accessFlags = readWacAccessInfo(response.headers.get('wac-allow'))\n canEdit = accessFlags.canEdit\n canManageAccess = accessFlags.canManageAccess\n isPublic = accessFlags.isPublic\n isPublicKnown = accessFlags.isPublicKnown\n eTag = response.headers.get('etag') ?? undefined\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n\n if ((!response.headers || !response.headers.get('content-type')) && (!response.headers || !response.headers.get('wac-allow') || !response.headers.get('etag'))) {\n const reqs = store.each(\n null,\n store.sym('http://www.w3.org/2007/ont/link#requestedURI'),\n subject\n )\n reqs.map((req: any) => {\n const responseNode = store.any(\n req as any,\n store.sym('http://www.w3.org/2007/ont/link#response')\n )\n if (responseNode && responseNode.termType === 'NamedNode') {\n const responseContentType = store.anyValue(responseNode as any, ns.httph('content-type')) || undefined\n if (contentType === undefined) {\n contentType = responseContentType\n }\n const wacAllow = (store.anyValue(responseNode as any, ns.httph('wac-allow')) as string | undefined) ||\n (store.anyValue(responseNode as any, ns.httph('WAC-Allow')) as string | undefined)\n const accessFlags = readWacAccessInfo(wacAllow)\n canEdit = canEdit || accessFlags.canEdit\n canManageAccess = canManageAccess || accessFlags.canManageAccess\n isPublic = isPublic || accessFlags.isPublic\n isPublicKnown = isPublicKnown || accessFlags.isPublicKnown\n const responseETag = store.anyValue(responseNode as any, ns.httph('etag')) || undefined\n if (eTag === undefined) {\n eTag = responseETag\n }\n modified = store.anyValue(subject as any, ns.dct('modified')) || store.anyValue(subject as any, ns.dc('modified')) || undefined\n }\n })\n }\n\n const aclUri = store.any(subject, ACL_LINK)?.value || undefined\n const access: ResourceAccess = { canEdit, canManageAccess, isPublic, isPublicKnown }\n return { contentType, access, aclUri, eTag, modified }\n }\n\n async function fetchHeadMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n const response = await store.fetcher.webOperation('HEAD', subject.uri)\n assertSuccessfulHttpResponse(response, 'HEAD')\n return readMetadata(subject, response)\n }\n\n async function userCanWriteToContainingContainer(resourceNode: NamedNode): Promise<boolean> {\n const containerNode = store.any(resourceNode, ns.ldp('contains')) || resourceNode.dir()\n if (!containerNode || containerNode.termType !== 'NamedNode') {\n return false\n }\n\n try {\n const containerMetadata = await fetchHeadMetadata(containerNode as NamedNode)\n return containerMetadata.access.canEdit\n } catch (_error) {\n return false\n }\n }\n\n async function userCanDeleteResource(resourceNode: NamedNode): Promise<boolean> {\n return userCanWriteToContainingContainer(resourceNode)\n }\n\n async function fetchMetadata(subject: NamedNode): Promise<ResourceMetadata> {\n return fetchHeadMetadata(subject)\n }\n\n async function fetchContentAndMetadata(subject: NamedNode): Promise<ResourceContent> {\n try {\n const response = await store.fetcher.webOperation('GET', subject.uri)\n assertSuccessfulHttpResponse(response, 'GET')\n\n const content = (response as Response & { responseText?: string }).responseText\n if (content === undefined) {\n throw new Error('No text in response object')\n }\n\n const metadata = readMetadata(subject, response)\n if (!metadata.contentType) {\n throw new Error('No content-type available')\n }\n\n return { content, metadata }\n } catch (error) {\n throw new Error(`Error reading file: ${error instanceof Error ? error.message : String(error)}`)\n }\n }\n\n async function fetchMetadataWithDelete(subject: NamedNode): Promise<ResourceMetadataWithDelete> {\n let resourceMetadata: ResourceMetadata\n\n try {\n resourceMetadata = await fetchHeadMetadata(subject)\n } catch (_error) {\n resourceMetadata = {\n contentType: undefined,\n access: { canEdit: false, canManageAccess: false, isPublic: false },\n aclUri: undefined,\n eTag: undefined,\n modified: undefined\n }\n }\n\n const canDelete = await userCanDeleteResource(subject)\n const access: ResourceAccessWithDelete = {\n canEdit: resourceMetadata.access?.canEdit ?? false,\n canManageAccess: resourceMetadata.access?.canManageAccess ?? false,\n isPublic: resourceMetadata.access?.isPublic ?? false,\n isPublicKnown: resourceMetadata.access?.isPublicKnown ?? false,\n canDelete\n }\n return { ...resourceMetadata, access }\n }\n\n async function deleteTypeIndexesForResource(resourceNode: NamedNode, user?: NamedNode | null) {\n if (!user) return\n\n try {\n await typeIndexLogic.deleteTypeIndexRegistrationForResource(resourceNode, user)\n } catch (_error) {\n // Keep resource deletion best-effort even if type-index cleanup fails.\n }\n }\n\n async function recursiveDelete(resourceNode: NamedNode, options: ResourceDeleteOptions = {}) {\n const resourceParent = resourceNode.dir()\n\n if (isContainer(resourceNode)) {\n const containerMembers = await containerLogic.getContainerMembers(resourceNode)\n await Promise.all(containerMembers.map((url) => recursiveDelete(sym(url), options)))\n }\n\n let deleted\n try {\n deleted = await store.fetcher._fetch(resourceNode.value, { method: 'DELETE' })\n assertSuccessfulHttpResponse(deleted, 'DELETE', { allowNotFound: true })\n } catch (error) {\n if (!isMissingError(error)) {\n throw error\n }\n }\n\n if (options.deleteTypeIndexes) {\n await deleteTypeIndexesForResource(resourceNode, options.user)\n }\n\n if (resourceParent) {\n store.removeMatches(resourceParent, ns.ldp('contains'), resourceNode)\n }\n\n store.removeDocument(resourceNode)\n store.fetcher.unload(resourceNode.doc())\n return deleted\n }\n\n async function deleteResourceAndTypeIndexIfExists(resourceNode: NamedNode, user?: NamedNode | null) {\n await recursiveDelete(resourceNode, { deleteTypeIndexes: true, user })\n }\n\n return {\n uploadFiles,\n recursiveDelete,\n deleteResourceAndTypeIndexIfExists,\n fetchMetadata,\n fetchMetadataWithDelete,\n fetchContentAndMetadata,\n createContainer,\n isContainer,\n getContainerMembers,\n getContainerMemberCount,\n getContainerIndexThing,\n containerHasIndexDocument,\n isStorageRoot,\n isHiddenFile,\n isMediaType,\n isImage,\n isAudio,\n isVideo,\n isWebId\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAgBC,EAAoB,GAAO,GAAoB,GAAgB,GAA+C;CAC5H,SAASC,EACP,GACA,GACiC;EACjC,IAAMC,KAAkB,GAA6B,MAAmB;GACtE,IAAMC,IAAc,OAAOC,KAAU,YAAYA,IAC7CA,IACA,KAAA,GACEC,IAAiBF,GAAa,UAAU,QACxCG,IAAeH,GAAa,QAC5BI,IAAS,OAAOF,KAAmB,WACrCA,IACA,OAAOC,KAAiB,WAAWA,IAAe,KAAA,GAChDE,IAAUJ,aAAiB,QAC7BA,EAAM,UACN,OAAOD,GAAa,WAAY,WAC9BA,EAAY,UACZ,OAAOC,KAAU,WAAWA,IAAQ;GAC1C,OAAO,IAAIK,EAAoBD,GAASE,GAASH,CAAM;EACzD;EAwDA,OAAO,QAAQ,IAAII,EAAM,KAtDT,MAA8C,IAAI,SAA8B,MAAW;GACzG,IAAMC,IAAS,IAAI,WAAW;GAuC9B,AAtCA,EAAO,UA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AAS,UAAU,EAAE,eAAe,GAAK,CAAC;EACzE,SAAStF,GAAO;GACd,IAAI,CAACuF,EAAevF,CAAK,GACvB,MAAMA;EAEV;EAYA,OAVIqF,EAAQ,qBACV,MAAMP,EAA6BxD,GAAc+D,EAAQ,IAAI,GAG3DH,KACFtD,EAAM,cAAcsD,GAAgBpD,EAAG,IAAI,UAAU,GAAGR,CAAY,GAGtEM,EAAM,eAAeN,CAAY,GACjCM,EAAM,QAAQ,OAAON,EAAa,IAAI,CAAC,GAChCgE;CACT;CAEA,eAAeE,EAAmC,GAAyB,GAAyB;EAClG,MAAMP,EAAgB3D,GAAc;GAAE,mBAAmB;GAAM;EAAK,CAAC;CACvE;CAEA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"resourceMetadata.cjs.js","names":["parseWacAllowHeader","permissions","headerValue","entry","match","permissionGroup","accessModes","modes","mode","readWacAccessInfo","wacAllow","userModes","publicModes"],"sources":["../../src/resource/resourceMetadata.ts"],"sourcesContent":["function parseWacAllowHeader (headerValue: string | null | undefined) {\n const permissions = new Map<string, Set<string>>()\n if (!headerValue) return permissions\n\n for (const entry of headerValue.split(',')) {\n const match = entry.trim().match(/^([A-Za-z]+)\\s*=\\s*\"([^\"]*)\"$/)\n if (match) {\n const [, permissionGroup, accessModes] = match\n const modes = accessModes.trim().split(/\\s+/).filter(Boolean)\n permissions.set(permissionGroup.toLowerCase(), new Set(modes.map(mode => mode.toLowerCase())))\n }\n }\n\n return permissions\n}\n\nexport function readWacAccessInfo (wacAllow: string | null | undefined) {\n if (!wacAllow) {\n return { canEdit: false, canManageAccess: false, isPublic: false, isPublicKnown: false }\n }\n\n const permissions = parseWacAllowHeader(wacAllow)\n const userModes = permissions.get('user') ?? new Set<string>()\n const publicModes = permissions.get('public') ?? new Set<string>()\n\n return {\n canEdit: userModes.has('write'),\n canManageAccess: userModes.has('control'),\n isPublic: publicModes.has('read') || publicModes.has('write'),\n isPublicKnown: true\n }\n}\n"],"mappings":"AAAA,SAASA,EAAqB,EAAwC,CACpE,IAAMC,EAAc,IAAI,IACxB,GAAI,CAACC,EAAa,OAAOD,EAEzB,IAAK,IAAME,KAASD,EAAY,MAAM,GAAG,EAAG,CAC1C,IAAME,EAAQD,EAAM,KAAK,CAAC,CAAC,MAAM,+BAA+B,EAChE,GAAIC,EAAO,CACT,GAAM,EAAGC,EAAiBC,GAAeF,EACnCG,EAAQD,EAAY,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EAC5DL,EAAY,IAAII,EAAgB,YAAY,EAAG,IAAI,IAAIE,EAAM,IAAI,GAAQC,EAAK,YAAY,CAAC,CAAC,CAAC,CAC/F,CACF,CAEA,OAAOP,CACT,CAEA,SAAgBQ,EAAmB,EAAqC,CACtE,GAAI,CAACC,EACH,MAAO,CAAE,QAAS,GAAO,gBAAiB,GAAO,SAAU,GAAO,cAAe,EAAM,EAGzF,IAAMT,EAAcD,EAAoBU,CAAQ,EAC1CC,EAAYV,EAAY,IAAI,MAAM,GAAK,IAAI,IAC3CW,EAAcX,EAAY,IAAI,QAAQ,GAAK,IAAI,IAErD,MAAO,CACL,QAASU,EAAU,IAAI,OAAO,EAC9B,gBAAiBA,EAAU,IAAI,SAAS,EACxC,SAAUC,EAAY,IAAI,MAAM,GAAKA,EAAY,IAAI,OAAO,EAC5D,cAAe,EACjB,CACF"}
1
+ {"version":3,"file":"resourceMetadata.cjs.js","names":["parseWacAllowHeader","permissions","headerValue","entry","match","permissionGroup","accessModes","modes","mode","readWacAccessInfo","wacAllow","userModes","publicModes"],"sources":["../../src/resource/resourceMetadata.ts"],"sourcesContent":["function parseWacAllowHeader (headerValue: string | null | undefined) {\n const permissions = new Map<string, Set<string>>()\n if (!headerValue) return permissions\n\n for (const entry of headerValue.split(',')) {\n const match = entry.trim().match(/^([A-Za-z]+)\\s*=\\s*\"([^\"]*)\"$/)\n if (match) {\n const [, permissionGroup, accessModes] = match\n const modes = accessModes.trim().split(/\\s+/).filter(Boolean)\n permissions.set(permissionGroup.toLowerCase(), new Set(modes.map(mode => mode.toLowerCase())))\n }\n }\n\n return permissions\n}\n\nexport function readWacAccessInfo (wacAllow: string | null | undefined) {\n if (!wacAllow) {\n return { canEdit: false, canManageAccess: false, isPublic: false, isPublicKnown: false }\n }\n\n const permissions = parseWacAllowHeader(wacAllow)\n const userModes = permissions.get('user') ?? new Set<string>()\n const publicModes = permissions.get('public') ?? new Set<string>()\n\n return {\n canEdit: userModes.has('write'),\n canManageAccess: userModes.has('control'),\n isPublic: publicModes.has('read') || publicModes.has('write'),\n isPublicKnown: true\n }\n}\n"],"mappings":"AAAA,SAASA,EAAqB,EAAwC,CACpE,IAAMC,EAAc,IAAI,IACxB,GAAI,CAACC,EAAa,OAAOD,EAEzB,IAAK,IAAME,KAASD,EAAY,MAAM,GAAG,EAAG,CAC1C,IAAME,EAAQD,EAAM,KAAK,CAAC,CAAC,MAAM,+BAA+B,EAChE,GAAIC,EAAO,CACT,GAAM,EAAGC,EAAiBC,GAAeF,EACnCG,EAAQD,EAAY,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO,EAC5DL,EAAY,IAAII,EAAgB,YAAY,EAAG,IAAI,IAAIE,EAAM,IAAI,GAAQC,EAAK,YAAY,CAAC,CAAC,CAAC,CAC/F,CACF,CAEA,OAAOP,CACT,CAEA,SAAgBQ,EAAmB,EAAqC,CACtE,GAAI,CAACC,EACH,MAAO,CAAE,QAAS,GAAO,gBAAiB,GAAO,SAAU,GAAO,cAAe,EAAM,EAGzF,IAAMT,EAAcD,EAAoBU,CAAQ,EAC1CC,EAAYV,EAAY,IAAI,MAAM,GAAK,IAAI,IAC3CW,EAAcX,EAAY,IAAI,QAAQ,GAAK,IAAI,IAErD,MAAO,CACL,QAASU,EAAU,IAAI,OAAO,EAC9B,gBAAiBA,EAAU,IAAI,SAAS,EACxC,SAAUC,EAAY,IAAI,MAAM,GAAKA,EAAY,IAAI,OAAO,EAC5D,cAAe,EACjB,CACF,C"}
@@ -1,4 +1,4 @@
1
- //#region src/resource/resourceMetadata.ts
1
+ // src/resource/resourceMetadata.ts
2
2
  function e(e) {
3
3
  let t = /* @__PURE__ */ new Map();
4
4
  if (!e) return t;
@@ -26,7 +26,6 @@ function t(t) {
26
26
  isPublicKnown: !0
27
27
  };
28
28
  }
29
- //#endregion
30
29
  export { t as readWacAccessInfo };
31
30
 
32
31
  //# sourceMappingURL=resourceMetadata.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeIndexAclDocuments.cjs.js","names":["publicTypeIndexAclDocument","fileName","publicTypeIndexUri","webId"],"sources":["../../src/typeIndex/typeIndexAclDocuments.ts"],"sourcesContent":["export function publicTypeIndexAclDocument(webId: string, publicTypeIndexUri: string): string {\n const fileName = new URL(publicTypeIndexUri).pathname.split('/').pop() || 'publicTypeIndex.ttl'\n return [\n '# ACL resource for the Public Type Index',\n '',\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '@prefix foaf: <http://xmlns.com/foaf/0.1/>.',\n '',\n '<#owner>',\n ' a acl:Authorization;',\n '',\n ' acl:agent',\n ` <${webId}>;`,\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode',\n ' acl:Read, acl:Write, acl:Control.',\n '',\n '# Public-readable',\n '<#public>',\n ' a acl:Authorization;',\n '',\n ' acl:agentClass foaf:Agent;',\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode acl:Read.'\n ].join('\\n')\n}\n"],"mappings":"AAAA,SAAgBA,EAA2B,EAAe,EAAoC,CAC1F,IAAMC,EAAW,IAAI,IAAIC,CAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,sBAC1E,MAAO,CACH,2CACA,GACA,iDACA,8CACA,GACA,WACA,2BACA,GACA,gBACA,YAAYC,EAAM,IAClB,GACA,uBAAuBF,EAAS,IAChC,GACA,eACA,4CACA,GACA,oBACA,YACA,2BACA,GACA,iCACA,GACA,uBAAuBA,EAAS,IAChC,GACA,wBACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
1
+ {"version":3,"file":"typeIndexAclDocuments.cjs.js","names":["publicTypeIndexAclDocument","fileName","publicTypeIndexUri","webId"],"sources":["../../src/typeIndex/typeIndexAclDocuments.ts"],"sourcesContent":["export function publicTypeIndexAclDocument(webId: string, publicTypeIndexUri: string): string {\n const fileName = new URL(publicTypeIndexUri).pathname.split('/').pop() || 'publicTypeIndex.ttl'\n return [\n '# ACL resource for the Public Type Index',\n '',\n '@prefix acl: <http://www.w3.org/ns/auth/acl#>.',\n '@prefix foaf: <http://xmlns.com/foaf/0.1/>.',\n '',\n '<#owner>',\n ' a acl:Authorization;',\n '',\n ' acl:agent',\n ` <${webId}>;`,\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode',\n ' acl:Read, acl:Write, acl:Control.',\n '',\n '# Public-readable',\n '<#public>',\n ' a acl:Authorization;',\n '',\n ' acl:agentClass foaf:Agent;',\n '',\n ` acl:accessTo <./${fileName}>;`,\n '',\n ' acl:mode acl:Read.'\n ].join('\\n')\n}\n"],"mappings":"AAAA,SAAgBA,EAA2B,EAAe,EAAoC,CAC1F,IAAMC,EAAW,IAAI,IAAIC,CAAkB,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC,IAAI,GAAK,sBAC1E,MAAO,CACH,2CACA,GACA,iDACA,8CACA,GACA,WACA,2BACA,GACA,gBACA,YAAYC,EAAM,IAClB,GACA,uBAAuBF,EAAS,IAChC,GACA,eACA,4CACA,GACA,oBACA,YACA,2BACA,GACA,iCACA,GACA,uBAAuBA,EAAS,IAChC,GACA,wBACJ,CAAC,CAAC,KAAK;CAAI,CACf,C"}
@@ -1,4 +1,4 @@
1
- //#region src/typeIndex/typeIndexAclDocuments.ts
1
+ // src/typeIndex/typeIndexAclDocuments.ts
2
2
  function e(e, t) {
3
3
  let n = new URL(t).pathname.split("/").pop() || "publicTypeIndex.ttl";
4
4
  return [
@@ -29,7 +29,6 @@ function e(e, t) {
29
29
  " acl:mode acl:Read."
30
30
  ].join("\n");
31
31
  }
32
- //#endregion
33
32
  export { e as publicTypeIndexAclDocument };
34
33
 
35
34
  //# sourceMappingURL=typeIndexAclDocuments.esm.js.map
@@ -1,4 +1,8 @@
1
- function e(){return[`@prefix solid: <http://www.w3.org/ns/solid/terms#>.`,`<>`,` a solid:TypeIndex ;`,` a solid:ListedDocument.`].join(`
2
- `)}function t(){return[`@prefix solid: <http://www.w3.org/ns/solid/terms#>.`,`<>`,` a solid:TypeIndex ;`,` a solid:UnlistedDocument.`].join(`
3
- `)}exports.privateTypeIndexDocument=t,exports.publicTypeIndexDocument=e;
1
+ function e(){return`@prefix solid: <http://www.w3.org/ns/solid/terms#>.
2
+ <>
3
+ a solid:TypeIndex ;
4
+ a solid:ListedDocument.`}function t(){return`@prefix solid: <http://www.w3.org/ns/solid/terms#>.
5
+ <>
6
+ a solid:TypeIndex ;
7
+ a solid:UnlistedDocument.`}exports.privateTypeIndexDocument=t,exports.publicTypeIndexDocument=e;
4
8
  //# sourceMappingURL=typeIndexDocuments.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeIndexDocuments.cjs.js","names":["publicTypeIndexDocument","privateTypeIndexDocument"],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":"AAAA,SAAgBA,GAAkC,CAC9C,MAAO,CACH,sDACA,KACA,0BACA,6BACJ,CAAC,CAAC,KAAK;CAAI,CACf,CAEA,SAAgBC,GAAmC,CAC/C,MAAO,CACH,sDACA,KACA,0BACA,+BACJ,CAAC,CAAC,KAAK;CAAI,CACf"}
1
+ {"version":3,"file":"typeIndexDocuments.cjs.js","names":["publicTypeIndexDocument","privateTypeIndexDocument"],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":"AAAA,SAAgBA,GAAkC,CAC9C,MAAO;;;4BAMX,CAEA,SAAgBC,GAAmC,CAC/C,MAAO;;;8BAMX,C"}
@@ -1,21 +1,10 @@
1
- //#region src/typeIndex/typeIndexDocuments.ts
1
+ // src/typeIndex/typeIndexDocuments.ts
2
2
  function e() {
3
- return [
4
- "@prefix solid: <http://www.w3.org/ns/solid/terms#>.",
5
- "<>",
6
- " a solid:TypeIndex ;",
7
- " a solid:ListedDocument."
8
- ].join("\n");
3
+ return "@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n<>\n a solid:TypeIndex ;\n a solid:ListedDocument.";
9
4
  }
10
5
  function t() {
11
- return [
12
- "@prefix solid: <http://www.w3.org/ns/solid/terms#>.",
13
- "<>",
14
- " a solid:TypeIndex ;",
15
- " a solid:UnlistedDocument."
16
- ].join("\n");
6
+ return "@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n<>\n a solid:TypeIndex ;\n a solid:UnlistedDocument.";
17
7
  }
18
- //#endregion
19
8
  export { t as privateTypeIndexDocument, e as publicTypeIndexDocument };
20
9
 
21
10
  //# sourceMappingURL=typeIndexDocuments.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeIndexDocuments.esm.js","names":["publicTypeIndexDocument","privateTypeIndexDocument"],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":";AAAA,SAAgBA,IAAkC;CAC9C,OAAO;EACH;EACA;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf;AAEA,SAAgBC,IAAmC;CAC/C,OAAO;EACH;EACA;EACA;EACA;CACJ,CAAC,CAAC,KAAK,IAAI;AACf"}
1
+ {"version":3,"file":"typeIndexDocuments.esm.js","names":["publicTypeIndexDocument","privateTypeIndexDocument"],"sources":["../../src/typeIndex/typeIndexDocuments.ts"],"sourcesContent":["export function publicTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:ListedDocument.'\n ].join('\\n')\n}\n\nexport function privateTypeIndexDocument(): string {\n return [\n '@prefix solid: <http://www.w3.org/ns/solid/terms#>.',\n '<>',\n ' a solid:TypeIndex ;',\n ' a solid:UnlistedDocument.'\n ].join('\\n')\n}"],"mappings":";AAAA,SAAgBA,IAAkC;CAC9C,OAAO;AAMX;AAEA,SAAgBC,IAAmC;CAC/C,OAAO;AAMX"}