@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.
- package/dist/chai.d.ts +8 -8
- package/dist/chai.js +1 -1
- package/dist/{helpers-DGXMj9cx.js → helpers-Cm2bMMlG.js} +2 -2
- package/dist/{helpers-DGXMj9cx.js.map → helpers-Cm2bMMlG.js.map} +1 -1
- package/dist/{io-wCcrq4b9.js → io-DqYt65s_.js} +136 -126
- package/dist/io-DqYt65s_.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +50 -9
- package/dist/noeldemartin-solid-utils.js +224 -173
- package/dist/noeldemartin-solid-utils.js.map +1 -1
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +1 -1
- package/dist/vitest.d.ts +9 -9
- package/dist/vitest.js +2 -2
- package/package.json +11 -4
- package/src/helpers/auth.test.ts +21 -23
- package/src/helpers/io.test.ts +50 -1
- package/src/helpers/io.ts +19 -3
- package/src/helpers/jsonld.ts +1 -1
- package/src/helpers/vocabs.ts +1 -0
- package/src/helpers/wac.test.ts +15 -11
- package/src/index.ts +1 -0
- package/src/rdf/RDFDefaultGraph.ts +12 -0
- package/src/rdf/RDFLiteral.ts +27 -0
- package/src/rdf/RDFNamedNode.ts +16 -0
- package/src/rdf/RDFQuad.ts +32 -0
- package/src/rdf/constants.ts +5 -0
- package/src/rdf/index.ts +4 -0
- package/src/testing/setup.ts +4 -0
- package/dist/io-wCcrq4b9.js.map +0 -1
package/dist/testing.js
CHANGED
package/dist/vitest.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare const _default: {
|
|
|
18
18
|
export declare function installVitestSolidMatchers(): void;
|
|
19
19
|
|
|
20
20
|
declare type JsonLD = Partial<{
|
|
21
|
-
'@context': Record<string, unknown
|
|
21
|
+
'@context': Record<string, unknown> | string;
|
|
22
22
|
'@id': string;
|
|
23
23
|
'@type': null | string | string[];
|
|
24
24
|
}> & {
|
|
@@ -32,6 +32,14 @@ export declare type VitestSolidMatchers<R = unknown> = {
|
|
|
32
32
|
export { }
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
declare module '@vitest/expect' {
|
|
36
|
+
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
37
|
+
}
|
|
38
|
+
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
35
43
|
declare global {
|
|
36
44
|
namespace Chai {
|
|
37
45
|
interface Assertion extends ChaiSolidAssertions {
|
|
@@ -40,11 +48,3 @@ declare global {
|
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
declare module '@vitest/expect' {
|
|
46
|
-
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
47
|
-
}
|
|
48
|
-
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
49
|
-
}
|
|
50
|
-
}
|
package/dist/vitest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect as l } from "vitest";
|
|
2
|
-
import { n as r, b as i } from "./io-
|
|
3
|
-
import { t as o, s as u, j as c } from "./helpers-
|
|
2
|
+
import { n as r, b as i } from "./io-DqYt65s_.js";
|
|
3
|
+
import { t as o, s as u, j as c } from "./helpers-Cm2bMMlG.js";
|
|
4
4
|
function a(e, t) {
|
|
5
5
|
const s = e.success, n = t.state.utils;
|
|
6
6
|
return { pass: s, message: s ? () => [e.message, n.matcherHint(t.hint)].join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noeldemartin/solid-utils",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1-next.bf3a764266964fbc17b114eddb9cdb074e1dbef6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -35,24 +35,31 @@
|
|
|
35
35
|
"test:ci": "vitest --run --reporter verbose",
|
|
36
36
|
"verify": "noeldemartin-verify"
|
|
37
37
|
},
|
|
38
|
+
"packageManager": "pnpm@10.27.0",
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@noeldemartin/utils": "^0.7.
|
|
40
|
+
"@noeldemartin/utils": "^0.7.1",
|
|
40
41
|
"@rdfjs/types": "^2.0.1",
|
|
41
42
|
"jsonld": "^8.3.3",
|
|
42
43
|
"md5": "^2.3.0",
|
|
43
44
|
"n3": "^1.24.2"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
47
|
+
"@arethetypeswrong/cli": "^0.17.4",
|
|
46
48
|
"@noeldemartin/eslint-config-typescript": "^0.1.2",
|
|
47
|
-
"@noeldemartin/
|
|
48
|
-
"@noeldemartin/
|
|
49
|
+
"@noeldemartin/eslint-plugin": "^0.1.0",
|
|
50
|
+
"@noeldemartin/scripts": "next",
|
|
51
|
+
"@noeldemartin/testing": "next",
|
|
49
52
|
"@tsconfig/node22": "^22.0.0",
|
|
50
53
|
"@types/chai": "^5.2.0",
|
|
51
54
|
"@types/jsonld": "^1.5.15",
|
|
52
55
|
"@types/md5": "^2.3.5",
|
|
53
56
|
"@types/n3": "^1.24.1",
|
|
54
57
|
"@types/node": "^22.13.10",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
55
59
|
"@vitest/expect": "^3.0.9",
|
|
60
|
+
"eslint": "^8.57.1",
|
|
61
|
+
"prettier-eslint-cli": "^8.0.1",
|
|
62
|
+
"publint": "^0.3.12",
|
|
56
63
|
"typescript": "^5.8.2",
|
|
57
64
|
"vite": "^6.2.2",
|
|
58
65
|
"vite-plugin-dts": "4.5.0",
|
package/src/helpers/auth.test.ts
CHANGED
|
@@ -10,10 +10,9 @@ describe('Auth helpers', () => {
|
|
|
10
10
|
|
|
11
11
|
it('reads NSS profiles', async () => {
|
|
12
12
|
// Arrange
|
|
13
|
-
const server = new FakeServer();
|
|
14
13
|
const webId = 'https://alice.solidcommunity.net/profile/card#me';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
FakeServer.respondOnce(
|
|
17
16
|
'https://alice.solidcommunity.net/profile/card',
|
|
18
17
|
FakeResponse.success(
|
|
19
18
|
`
|
|
@@ -41,10 +40,10 @@ describe('Auth helpers', () => {
|
|
|
41
40
|
);
|
|
42
41
|
|
|
43
42
|
// Act
|
|
44
|
-
const profile = await fetchLoginUserProfile(webId, { fetch:
|
|
43
|
+
const profile = await fetchLoginUserProfile(webId, { fetch: FakeServer.fetch });
|
|
45
44
|
|
|
46
45
|
// Assert
|
|
47
|
-
expect(
|
|
46
|
+
expect(FakeServer.getRequests()).toHaveLength(1);
|
|
48
47
|
|
|
49
48
|
expect(profile).toEqual({
|
|
50
49
|
webId,
|
|
@@ -60,12 +59,11 @@ describe('Auth helpers', () => {
|
|
|
60
59
|
|
|
61
60
|
it('reads ESS profiles (public)', async () => {
|
|
62
61
|
// Arrange
|
|
63
|
-
const server = new FakeServer();
|
|
64
62
|
const webId = 'https://id.inrupt.com/alice';
|
|
65
63
|
|
|
66
64
|
// The first request returns a 303 to `${webId}?lookup`,
|
|
67
65
|
// but in order to simplify mocking requests we're assuming it doesn't.
|
|
68
|
-
|
|
66
|
+
FakeServer.respondOnce(
|
|
69
67
|
'https://id.inrupt.com/alice',
|
|
70
68
|
FakeResponse.success(`
|
|
71
69
|
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
|
@@ -81,16 +79,16 @@ describe('Auth helpers', () => {
|
|
|
81
79
|
foaf:isPrimaryTopicOf <https://storage.inrupt.com/storage-hash/extendedProfile> .
|
|
82
80
|
`),
|
|
83
81
|
);
|
|
84
|
-
|
|
82
|
+
FakeServer.respondOnce(
|
|
85
83
|
'https://storage.inrupt.com/storage-hash/extendedProfile',
|
|
86
84
|
new FakeResponse(undefined, undefined, 401),
|
|
87
85
|
);
|
|
88
86
|
|
|
89
87
|
// Act
|
|
90
|
-
const profile = await fetchLoginUserProfile(webId, { fetch:
|
|
88
|
+
const profile = await fetchLoginUserProfile(webId, { fetch: FakeServer.fetch });
|
|
91
89
|
|
|
92
90
|
// Assert
|
|
93
|
-
expect(
|
|
91
|
+
expect(FakeServer.getRequests()).toHaveLength(2);
|
|
94
92
|
|
|
95
93
|
expect(profile).toEqual({
|
|
96
94
|
webId,
|
|
@@ -103,12 +101,11 @@ describe('Auth helpers', () => {
|
|
|
103
101
|
|
|
104
102
|
it('reads ESS profiles (authenticated)', async () => {
|
|
105
103
|
// Arrange
|
|
106
|
-
const server = new FakeServer();
|
|
107
104
|
const webId = 'https://id.inrupt.com/alice';
|
|
108
105
|
|
|
109
106
|
// The first request returns a 303 to `${webId}?lookup`,
|
|
110
107
|
// but in order to simplify mocking requests we're assuming it doesn't.
|
|
111
|
-
|
|
108
|
+
FakeServer.respondOnce(
|
|
112
109
|
'https://id.inrupt.com/alice',
|
|
113
110
|
FakeResponse.success(`
|
|
114
111
|
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
|
@@ -124,7 +121,7 @@ describe('Auth helpers', () => {
|
|
|
124
121
|
foaf:isPrimaryTopicOf <https://storage.inrupt.com/storage-hash/extendedProfile> .
|
|
125
122
|
`),
|
|
126
123
|
);
|
|
127
|
-
|
|
124
|
+
FakeServer.respondOnce(
|
|
128
125
|
'https://storage.inrupt.com/storage-hash/extendedProfile',
|
|
129
126
|
FakeResponse.success(
|
|
130
127
|
`
|
|
@@ -145,10 +142,10 @@ describe('Auth helpers', () => {
|
|
|
145
142
|
);
|
|
146
143
|
|
|
147
144
|
// Act
|
|
148
|
-
const profile = await fetchLoginUserProfile(webId, { fetch:
|
|
145
|
+
const profile = await fetchLoginUserProfile(webId, { fetch: FakeServer.fetch });
|
|
149
146
|
|
|
150
147
|
// Assert
|
|
151
|
-
expect(
|
|
148
|
+
expect(FakeServer.getRequests()).toHaveLength(2);
|
|
152
149
|
|
|
153
150
|
expect(profile).toEqual({
|
|
154
151
|
webId,
|
|
@@ -162,7 +159,6 @@ describe('Auth helpers', () => {
|
|
|
162
159
|
|
|
163
160
|
it('reads use.id profiles', async () => {
|
|
164
161
|
// Arrange
|
|
165
|
-
const server = new FakeServer();
|
|
166
162
|
const webId = 'https://use.id/alice';
|
|
167
163
|
const profileTurtle = `
|
|
168
164
|
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
|
@@ -181,17 +177,20 @@ describe('Auth helpers', () => {
|
|
|
181
177
|
|
|
182
178
|
// The first request returns a 303 to `${webId}/profile`,
|
|
183
179
|
// but in order to simplify mocking requests we're assuming it doesn't.
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
FakeServer.respondOnce(
|
|
181
|
+
'https://use.id/alice',
|
|
182
|
+
FakeResponse.success(profileTurtle, { 'WAC-Allow': 'user="read"' }),
|
|
183
|
+
);
|
|
184
|
+
FakeServer.respondOnce(
|
|
186
185
|
'https://use.id/alice/profile',
|
|
187
186
|
FakeResponse.success(profileTurtle, { 'WAC-Allow': 'user="read"' }),
|
|
188
187
|
);
|
|
189
188
|
|
|
190
189
|
// Act
|
|
191
|
-
const profile = await fetchLoginUserProfile(webId, { fetch:
|
|
190
|
+
const profile = await fetchLoginUserProfile(webId, { fetch: FakeServer.fetch });
|
|
192
191
|
|
|
193
192
|
// Assert
|
|
194
|
-
expect(
|
|
193
|
+
expect(FakeServer.getRequests()).toHaveLength(2);
|
|
195
194
|
|
|
196
195
|
expect(profile).toEqual({
|
|
197
196
|
webId,
|
|
@@ -204,18 +203,17 @@ describe('Auth helpers', () => {
|
|
|
204
203
|
|
|
205
204
|
it('throws errors reading required profiles', async () => {
|
|
206
205
|
// Arrange
|
|
207
|
-
const server = new FakeServer();
|
|
208
206
|
const webId = 'https://pod.example.com/profile/card#me';
|
|
209
207
|
|
|
210
|
-
|
|
208
|
+
FakeServer.respondOnce('https://pod.example.com/profile/card', FakeResponse.success('invalid turtle'));
|
|
211
209
|
|
|
212
210
|
// Act
|
|
213
|
-
const fetchProfile = fetchLoginUserProfile(webId, { fetch:
|
|
211
|
+
const fetchProfile = fetchLoginUserProfile(webId, { fetch: FakeServer.fetch, required: true });
|
|
214
212
|
|
|
215
213
|
// Assert
|
|
216
214
|
await expect(fetchProfile).rejects.toBeInstanceOf(MalformedSolidDocumentError);
|
|
217
215
|
|
|
218
|
-
expect(
|
|
216
|
+
expect(FakeServer.getRequests()).toHaveLength(1);
|
|
219
217
|
});
|
|
220
218
|
|
|
221
219
|
});
|
package/src/helpers/io.test.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
jsonldToQuads,
|
|
5
|
+
normalizeJsonLD,
|
|
6
|
+
normalizeSparql,
|
|
7
|
+
quadsToJsonLD,
|
|
8
|
+
sparqlToQuadsSync,
|
|
9
|
+
turtleToQuadsSync,
|
|
10
|
+
} from './io';
|
|
4
11
|
import type { Quad } from '@rdfjs/types';
|
|
5
12
|
|
|
6
13
|
describe('IO', () => {
|
|
@@ -200,6 +207,48 @@ describe('IO', () => {
|
|
|
200
207
|
expect(quads[1].object.value).toEqual('John Doe');
|
|
201
208
|
});
|
|
202
209
|
|
|
210
|
+
it('normalizes jsonld', async () => {
|
|
211
|
+
// Arrange
|
|
212
|
+
const json = {
|
|
213
|
+
'@graph': [
|
|
214
|
+
{
|
|
215
|
+
'@context': { '@vocab': 'https://schema.org/' },
|
|
216
|
+
'@id': '#it',
|
|
217
|
+
'@type': 'Movie',
|
|
218
|
+
'name': 'Spirited Away',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
'@context': { '@vocab': 'https://vocab.noeldemartin.com/crdt/' },
|
|
222
|
+
'@id': '#it-metadata',
|
|
223
|
+
'@type': 'Metadata',
|
|
224
|
+
'resource': { '@id': '#it' },
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const clone = structuredClone(json);
|
|
230
|
+
|
|
231
|
+
// Act
|
|
232
|
+
const normalized = await normalizeJsonLD(json);
|
|
233
|
+
|
|
234
|
+
// Assert
|
|
235
|
+
expect(json).toEqual(clone);
|
|
236
|
+
expect(normalized).toEqual({
|
|
237
|
+
'@graph': [
|
|
238
|
+
{
|
|
239
|
+
'@id': '#it',
|
|
240
|
+
'@type': ['https://schema.org/Movie'],
|
|
241
|
+
'https://schema.org/name': [{ '@value': 'Spirited Away' }],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
'@id': '#it-metadata',
|
|
245
|
+
'@type': ['https://vocab.noeldemartin.com/crdt/Metadata'],
|
|
246
|
+
'https://vocab.noeldemartin.com/crdt/resource': [{ '@id': '#it' }],
|
|
247
|
+
},
|
|
248
|
+
],
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
203
252
|
it('converts quads to jsonld', async () => {
|
|
204
253
|
// Arrange
|
|
205
254
|
const quads = turtleToQuadsSync(`
|
package/src/helpers/io.ts
CHANGED
|
@@ -123,15 +123,25 @@ function preprocessSubjects(json: JsonLD): void {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
json['@id'] = ANONYMOUS_PREFIX + json['@id'];
|
|
126
|
+
|
|
127
|
+
for (const [field, value] of Object.entries(json)) {
|
|
128
|
+
if (typeof value !== 'object' || value === null || !('@id' in value)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
preprocessSubjects(json[field] as JsonLD);
|
|
133
|
+
}
|
|
126
134
|
}
|
|
127
135
|
|
|
128
136
|
function postprocessSubjects(quads: Quad[]): void {
|
|
129
137
|
for (const quad of quads) {
|
|
130
|
-
if (
|
|
131
|
-
|
|
138
|
+
if (quad.subject.value.startsWith(ANONYMOUS_PREFIX)) {
|
|
139
|
+
quad.subject.value = quad.subject.value.slice(ANONYMOUS_PREFIX_LENGTH);
|
|
132
140
|
}
|
|
133
141
|
|
|
134
|
-
|
|
142
|
+
if (quad.object.value.startsWith(ANONYMOUS_PREFIX)) {
|
|
143
|
+
quad.object.value = quad.object.value.slice(ANONYMOUS_PREFIX_LENGTH);
|
|
144
|
+
}
|
|
135
145
|
}
|
|
136
146
|
}
|
|
137
147
|
|
|
@@ -202,6 +212,12 @@ export async function jsonldToQuads(json: JsonLD, baseIRI?: string): Promise<Qua
|
|
|
202
212
|
return quads;
|
|
203
213
|
}
|
|
204
214
|
|
|
215
|
+
export async function normalizeJsonLD(json: JsonLD, baseIRI?: string): Promise<JsonLD> {
|
|
216
|
+
const quads = await jsonldToQuads(structuredClone(json), baseIRI);
|
|
217
|
+
|
|
218
|
+
return quadsToJsonLD(quads);
|
|
219
|
+
}
|
|
220
|
+
|
|
205
221
|
export function normalizeSparql(sparql: string): string {
|
|
206
222
|
const quads = sparqlToQuadsSync(sparql);
|
|
207
223
|
|
package/src/helpers/jsonld.ts
CHANGED
|
@@ -2,7 +2,7 @@ import jsonld from 'jsonld';
|
|
|
2
2
|
import type { JsonLdDocument } from 'jsonld';
|
|
3
3
|
|
|
4
4
|
export type JsonLD = Partial<{
|
|
5
|
-
'@context': Record<string, unknown
|
|
5
|
+
'@context': Record<string, unknown> | string;
|
|
6
6
|
'@id': string;
|
|
7
7
|
'@type': null | string | string[];
|
|
8
8
|
}> & { [k: string]: unknown };
|
package/src/helpers/vocabs.ts
CHANGED
|
@@ -16,6 +16,7 @@ const knownPrefixes: RDFContext = {
|
|
|
16
16
|
schema: 'https://schema.org/',
|
|
17
17
|
solid: 'http://www.w3.org/ns/solid/terms#',
|
|
18
18
|
vcard: 'http://www.w3.org/2006/vcard/ns#',
|
|
19
|
+
xsd: 'http://www.w3.org/2001/XMLSchema#',
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
export function defineIRIPrefix(name: string, value: string): void {
|
package/src/helpers/wac.test.ts
CHANGED
|
@@ -10,11 +10,13 @@ describe('WAC helpers', () => {
|
|
|
10
10
|
|
|
11
11
|
it('resolves relative ACL urls', async () => {
|
|
12
12
|
// Arrange
|
|
13
|
-
const server = new FakeServer();
|
|
14
13
|
const documentUrl = 'https://example.com/alice/movies/my-favorite-movie';
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
FakeServer.respondOnce(
|
|
16
|
+
documentUrl,
|
|
17
|
+
FakeResponse.success(undefined, { Link: '<my-favorite-movie.acl>;rel="acl"' }),
|
|
18
|
+
);
|
|
19
|
+
FakeServer.respondOnce(
|
|
18
20
|
`${documentUrl}.acl`,
|
|
19
21
|
FakeResponse.success(`
|
|
20
22
|
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
|
|
@@ -29,25 +31,27 @@ describe('WAC helpers', () => {
|
|
|
29
31
|
);
|
|
30
32
|
|
|
31
33
|
// Act
|
|
32
|
-
const { url, effectiveUrl, document } = await fetchSolidDocumentACL(documentUrl,
|
|
34
|
+
const { url, effectiveUrl, document } = await fetchSolidDocumentACL(documentUrl, FakeServer.fetch);
|
|
33
35
|
|
|
34
36
|
// Assert
|
|
35
37
|
expect(url).toEqual(`${documentUrl}.acl`);
|
|
36
38
|
expect(effectiveUrl).toEqual(url);
|
|
37
39
|
expect(document.contains(`${documentUrl}.acl#owner`, 'rdf:type', 'acl:Authorization')).toBe(true);
|
|
38
40
|
|
|
39
|
-
expect(
|
|
40
|
-
expect(
|
|
41
|
-
expect(
|
|
41
|
+
expect(FakeServer.getRequests()).toHaveLength(2);
|
|
42
|
+
expect(FakeServer.getRequest(documentUrl)?.method).toEqual('HEAD');
|
|
43
|
+
expect(FakeServer.getRequest(url)).not.toBeNull();
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
it('fails with ACP resources', async () => {
|
|
45
47
|
// Arrange
|
|
46
|
-
const server = new FakeServer();
|
|
47
48
|
const documentUrl = 'https://example.com/alice/movies/my-favorite-movie';
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
FakeServer.respondOnce(
|
|
51
|
+
documentUrl,
|
|
52
|
+
FakeResponse.success(undefined, { Link: '<my-favorite-movie.acl>;rel="acl"' }),
|
|
53
|
+
);
|
|
54
|
+
FakeServer.respondOnce(
|
|
51
55
|
`${documentUrl}.acl`,
|
|
52
56
|
FakeResponse.success(undefined, {
|
|
53
57
|
Link: '<http://www.w3.org/ns/solid/acp#AccessControlResource>; rel="type"',
|
|
@@ -55,7 +59,7 @@ describe('WAC helpers', () => {
|
|
|
55
59
|
);
|
|
56
60
|
|
|
57
61
|
// Act
|
|
58
|
-
const promisedDocument = fetchSolidDocumentACL(documentUrl,
|
|
62
|
+
const promisedDocument = fetchSolidDocumentACL(documentUrl, FakeServer.fetch);
|
|
59
63
|
|
|
60
64
|
// Assert
|
|
61
65
|
await expect(promisedDocument).rejects.toBeInstanceOf(UnsupportedAuthorizationProtocolError);
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DefaultGraph, Term } from '@rdfjs/types';
|
|
2
|
+
|
|
3
|
+
export default class RDFDefaultGraph implements DefaultGraph {
|
|
4
|
+
|
|
5
|
+
public termType = 'DefaultGraph' as const;
|
|
6
|
+
public value = '' as const;
|
|
7
|
+
|
|
8
|
+
public equals(other: Term | null | undefined): boolean {
|
|
9
|
+
return this.termType === other?.termType && this.value === other.value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Literal, NamedNode, Term } from '@rdfjs/types';
|
|
2
|
+
|
|
3
|
+
import { DATATYPE_STRING } from './constants';
|
|
4
|
+
|
|
5
|
+
export default class RDFLiteral implements Literal {
|
|
6
|
+
|
|
7
|
+
public termType = 'Literal' as const;
|
|
8
|
+
public value: string;
|
|
9
|
+
public language: string;
|
|
10
|
+
public datatype: NamedNode;
|
|
11
|
+
|
|
12
|
+
constructor(value: string, language: string = '', datatype: NamedNode = DATATYPE_STRING) {
|
|
13
|
+
this.value = value;
|
|
14
|
+
this.language = language;
|
|
15
|
+
this.datatype = datatype;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public equals(other: Term | null | undefined): boolean {
|
|
19
|
+
return (
|
|
20
|
+
this.termType === other?.termType &&
|
|
21
|
+
this.value === other.value &&
|
|
22
|
+
this.language === other.language &&
|
|
23
|
+
this.datatype.equals(other.datatype)
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { NamedNode, Term } from '@rdfjs/types';
|
|
2
|
+
|
|
3
|
+
export default class RDFNamedNode implements NamedNode {
|
|
4
|
+
|
|
5
|
+
public termType = 'NamedNode' as const;
|
|
6
|
+
public value: string;
|
|
7
|
+
|
|
8
|
+
constructor(value: string) {
|
|
9
|
+
this.value = value;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public equals(other: Term | null | undefined): boolean {
|
|
13
|
+
return this.termType === other?.termType && this.value === other.value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Quad, Quad_Graph, Quad_Object, Quad_Predicate, Quad_Subject, Term } from '@rdfjs/types';
|
|
2
|
+
|
|
3
|
+
import RDFDefaultGraph from './RDFDefaultGraph';
|
|
4
|
+
import RDFLiteral from './RDFLiteral';
|
|
5
|
+
import RDFNamedNode from './RDFNamedNode';
|
|
6
|
+
|
|
7
|
+
export default class RDFQuad implements Quad {
|
|
8
|
+
|
|
9
|
+
public termType = 'Quad' as const;
|
|
10
|
+
public value = '' as const;
|
|
11
|
+
public subject: Quad_Subject;
|
|
12
|
+
public predicate: Quad_Predicate;
|
|
13
|
+
public object: Quad_Object;
|
|
14
|
+
public graph: Quad_Graph;
|
|
15
|
+
|
|
16
|
+
constructor(subject: string | Quad_Subject, predicate: string | Quad_Predicate, object: string | Quad_Object) {
|
|
17
|
+
this.subject = typeof subject === 'string' ? new RDFNamedNode(subject) : subject;
|
|
18
|
+
this.predicate = typeof predicate === 'string' ? new RDFNamedNode(predicate) : predicate;
|
|
19
|
+
this.object = typeof object === 'string' ? new RDFLiteral(object) : object;
|
|
20
|
+
this.graph = new RDFDefaultGraph();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public equals(other: Term | null | undefined): boolean {
|
|
24
|
+
return (
|
|
25
|
+
this.termType === other?.termType &&
|
|
26
|
+
this.subject.equals(other.subject) &&
|
|
27
|
+
this.predicate.equals(other.predicate) &&
|
|
28
|
+
this.object.equals(other.object)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
package/src/rdf/index.ts
ADDED
package/dist/io-wCcrq4b9.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"io-wCcrq4b9.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends JSError {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string, options?: JSErrorOptions) {\n super(`Request failed trying to fetch ${url}`, options);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends JSError {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined' ? this.responseStatus === 403 : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n acl: 'http://www.w3.org/ns/auth/acl#',\n foaf: 'http://xmlns.com/foaf/0.1/',\n ldp: 'http://www.w3.org/ns/ldp#',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http')) return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (prefix && name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix) throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix) throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads.find((quad) => quad.predicate.value === expandIRI(property))?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter((quad) => quad.predicate.value === expandIRI(property))\n .map((quad) => quad.object.value);\n }\n\n}\n","import type { BlankNode, Literal, NamedNode, Quad, Variable } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport type Term = NamedNode | Literal | BlankNode | Quad | Variable;\n\nexport default class SolidStore {\n\n private quads: Quad[];\n\n public constructor(quads: Quad[] = []) {\n this.quads = quads;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public getQuads(): Quad[] {\n return this.quads.slice(0);\n }\n\n public addQuads(quads: Quad[]): void {\n this.quads.push(...quads);\n }\n\n public statements(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad[] {\n return this.quads.filter(\n (statement) =>\n (!object || this.termMatches(statement.object, object)) &&\n (!subject || this.termMatches(statement.subject, subject)) &&\n (!predicate || this.termMatches(statement.predicate, predicate)),\n );\n }\n\n public statement(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad | null {\n const statement = this.quads.find(\n (_statement) =>\n (!object || this.termMatches(_statement.object, object)) &&\n (!subject || this.termMatches(_statement.subject, subject)) &&\n (!predicate || this.termMatches(_statement.predicate, predicate)),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n protected expandIRI(iri: string): string {\n return expandIRI(iri);\n }\n\n protected termMatches(term: Term, value: Term | string): boolean {\n if (typeof value === 'string') {\n return this.expandIRI(value) === term.value;\n }\n\n return term.termType === term.termType && term.value === value.value;\n }\n\n}\n","import { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nimport SolidStore from './SolidStore';\n\nexport enum SolidDocumentPermission {\n Read = 'read',\n Write = 'write',\n Append = 'append',\n Control = 'control',\n}\n\nexport default class SolidDocument extends SolidStore {\n\n public readonly url: string;\n public readonly headers: Headers;\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n super(quads);\n\n this.url = url;\n this.headers = headers;\n }\n\n public isACPResource(): boolean {\n return !!this.headers\n .get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(this.url, expandIRI('rdf:type'), expandIRI('foaf:PersonalProfileDocument'));\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public isUserWritable(): boolean {\n return this.getUserPermissions().includes(SolidDocumentPermission.Write);\n }\n\n public getUserPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('user');\n }\n\n public getPublicPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('public');\n }\n\n public getLastModified(): Date | null {\n return (\n parseDate(this.headers.get('last-modified')) ??\n parseDate(this.statement(this.url, 'purl:modified')?.object.value) ??\n this.getLatestDocumentDate() ??\n null\n );\n }\n\n protected expandIRI(iri: string): string {\n return expandIRI(iri, { defaultPrefix: this.url });\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [...this.statements(undefined, 'purl:modified'), ...this.statements(undefined, 'purl:created')]\n .map((statement) => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => (a > b ? a : b)) : null;\n }\n\n private getPermissionsFromWAC(type: string): SolidDocumentPermission[] {\n const wacAllow = this.headers.get('WAC-Allow') ?? '';\n const publicModes = stringMatch<2>(wacAllow, new RegExp(`${type}=\"([^\"]+)\"`))?.[1] ?? '';\n\n return arrayFilter([\n publicModes.includes('read') && SolidDocumentPermission.Read,\n publicModes.includes('write') && SolidDocumentPermission.Write,\n publicModes.includes('append') && SolidDocumentPermission.Append,\n publicModes.includes('control') && SolidDocumentPermission.Control,\n ]);\n }\n\n}\n","import jsonld from 'jsonld';\nimport type { JsonLdDocument } from 'jsonld';\n\nexport type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = {\n '@context'?: Record<string, unknown>;\n '@graph': JsonLDResource[];\n};\n\nexport async function compactJsonLDGraph(json: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await jsonld.compact(json as JsonLdDocument, {});\n\n if ('@graph' in compactedJsonLD) {\n return compactedJsonLD as JsonLDGraph;\n }\n\n if ('@id' in compactedJsonLD) {\n return { '@graph': [compactedJsonLD] } as JsonLDGraph;\n }\n\n return { '@graph': [] };\n}\n\nexport function isJsonLDGraph(json: JsonLD): json is JsonLDGraph {\n return '@graph' in json;\n}\n","import jsonld from 'jsonld';\nimport md5 from 'md5';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser, Writer } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport type { Quad } from '@rdfjs/types';\nimport type { Term } from 'n3';\n\nimport SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';\n\n// eslint-disable-next-line max-len\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@noeldemartin/solid-utils/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@noeldemartin/solid-utils/errors/NetworkRequestError';\nimport NotFoundError from '@noeldemartin/solid-utils/errors/NotFoundError';\nimport UnauthorizedError from '@noeldemartin/solid-utils/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@noeldemartin/solid-utils/helpers/jsonld';\nimport type { JsonLD, JsonLDGraph, JsonLDResource } from '@noeldemartin/solid-utils/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<Response>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nconst ANONYMOUS_PREFIX = 'anonymous://';\nconst ANONYMOUS_PREFIX_LENGTH = ANONYMOUS_PREFIX.length;\n\nasync function fetchRawSolidDocument(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<{ body: string; headers: Headers }> {\n const requestOptions: RequestInit = {\n headers: { Accept: 'text/turtle' },\n };\n\n if (options?.cache) {\n requestOptions.cache = options.cache;\n }\n\n try {\n const fetch = options?.fetch ?? window.fetch;\n const response = await fetch(url, requestOptions);\n\n if (response.status === 404) throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status)) throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError) throw error;\n\n if (error instanceof NotFoundError) throw error;\n\n throw new NetworkRequestError(url, { cause: error });\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) =>\n tap(\n arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]),\n (ids) => ids.forEach((id) => (quadsIndexes[id] ??= new Set()).add(index)),\n ))\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const quadIndexes = quadsIndexes[originalId] as Set<number>;\n const normalizedId = md5(\n arr(quadIndexes)\n .map((index) => quads[index] as Quad)\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(({ predicate, object }) =>\n object.termType === 'BlankNode' ? predicate.value : predicate.value + object.value)\n .sorted()\n .join(),\n );\n\n for (const index of quadIndexes) {\n const quad = normalizedQuads[index] as Quad;\n const terms: Record<string, Term> = {\n subject: quad.subject as Term,\n object: quad.object as Term,\n };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId) continue;\n\n terms[termName] = new N3BlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n new N3Quad(terms.subject as Term, quad.predicate as Term, terms.object as Term),\n );\n }\n }\n\n return normalizedQuads;\n}\n\nfunction normalizeQuads(quads: Quad[]): string {\n return quads\n .map((quad) => ' ' + quadToTurtle(quad))\n .sort()\n .join('\\n');\n}\n\nfunction preprocessSubjects(json: JsonLD): void {\n if (!json['@id']?.startsWith('#')) {\n return;\n }\n\n json['@id'] = ANONYMOUS_PREFIX + json['@id'];\n}\n\nfunction postprocessSubjects(quads: Quad[]): void {\n for (const quad of quads) {\n if (!quad.subject.value.startsWith(ANONYMOUS_PREFIX)) {\n continue;\n }\n\n quad.subject.value = quad.subject.value.slice(ANONYMOUS_PREFIX_LENGTH);\n }\n}\n\nexport interface FetchSolidDocumentOptions {\n fetch?: Fetch;\n cache?: RequestCache;\n}\n\nexport interface ParsingOptions {\n baseIRI: string;\n normalizeBlankNodes: boolean;\n}\n\nexport interface RDFGraphData {\n quads: Quad[];\n containsRelativeIRIs: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, options);\n const statements = await turtleToQuads(data, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, options);\n\n return document;\n } catch (error) {\n if (!(error instanceof NotFoundError)) throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(json: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(json)) {\n const graphQuads = await Promise.all(json['@graph'].map((resource) => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n preprocessSubjects(json);\n\n const quads = await (jsonld.toRDF(json as JsonLdDocument, { base: baseIRI }) as Promise<Quad[]>);\n\n postprocessSubjects(quads);\n\n return quads;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object.entries(quads)\n .reduce((normalizedOperations, [operation, _quads]) => {\n const normalizedQuads = normalizeQuads(_quads);\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function normalizeTurtle(sparql: string): string {\n const quads = turtleToQuadsSync(sparql);\n\n return normalizeQuads(quads);\n}\n\nexport function parseTurtle(turtle: string, options: Partial<ParsingOptions> = {}): Promise<RDFGraphData> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new Parser(parserOptions);\n const data: RDFGraphData = {\n quads: [],\n containsRelativeIRIs: false,\n };\n\n return new Promise((resolve, reject) => {\n const resolveRelativeIRI = parser._resolveRelativeIRI;\n\n parser._resolveRelativeIRI = (...args) => {\n data.containsRelativeIRIs = true;\n parser._resolveRelativeIRI = resolveRelativeIRI;\n\n return parser._resolveRelativeIRI(...args);\n };\n\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(options.baseIRI ?? null, SolidDocumentFormat.Turtle, error.message),\n );\n\n return;\n }\n\n if (!quad) {\n // data.quads = options.normalizeBlankNodes\n // ? normalizeBlankNodes(data.quads)\n // : data.quads;\n\n resolve(data);\n\n return;\n }\n\n data.quads.push(quad);\n });\n });\n}\n\nexport async function quadsToJsonLD(quads: Quad[]): Promise<JsonLDGraph> {\n const graph = await jsonld.fromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\n };\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new Writer();\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new Writer();\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, options?: FetchSolidDocumentOptions): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, options);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = stringMatchAll<3>(sparql, /(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all(\n [...operations].map(async (operation) => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }),\n );\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = stringMatchAll<3>(sparql, /(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const { quads } = await parseTurtle(turtle, options);\n\n return quads;\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new Parser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes ? normalizeBlankNodes(quads) : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n (error as Error).message ?? '',\n );\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch.bind(window);\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n"],"names":["errorMessage","documentUrl","documentFormat","malformationDetails","SolidDocumentFormat","MalformedSolidDocumentError","JSError","__publicField","NetworkRequestError","url","options","NotFoundError","responseStatus","UnauthorizedError","knownPrefixes","defineIRIPrefix","name","value","expandIRI","iri","prefix","expandedPrefix","_a","SolidThing","quads","property","quad","SolidStore","subject","predicate","object","statement","_statement","statements","term","SolidDocumentPermission","SolidDocument","headers","parseDate","dates","date","a","b","type","wacAllow","publicModes","stringMatch","arrayFilter","compactJsonLDGraph","json","compactedJsonLD","jsonld","isJsonLDGraph","ANONYMOUS_PREFIX","ANONYMOUS_PREFIX_LENGTH","fetchRawSolidDocument","requestOptions","response","error","normalizeBlankNodes","normalizedQuads","quadsIndexes","blankNodeIds","arr","index","tap","ids","id","originalId","quadIndexes","normalizedId","md5","termType","terms","termName","termValue","N3BlankNode","arrayReplace","N3Quad","normalizeQuads","quadToTurtle","preprocessSubjects","postprocessSubjects","createSolidDocument","body","fetch","turtleToQuads","fetchSolidDocument","data","fetchSolidDocumentIfFound","jsonldToQuads","baseIRI","resource","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","_quads","normalizeTurtle","turtleToQuadsSync","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","Parser","resolve","reject","resolveRelativeIRI","args","quadsToJsonLD","quadsToTurtle","Writer","solidDocumentExists","sparqlToQuads","operations","stringMatchAll","operationName","operationBody","updateSolidDocument"],"mappings":";;;;;;;AAEA,SAASA,EACLC,GACAC,GACAC,GACM;AACC,SAAAF,IACD,aAAaC,CAAc,sBAAsBD,CAAW,MAAME,CAAmB,KACrF,aAAaD,CAAc,eAAeC,CAAmB;AACvE;AAEY,IAAAC,sBAAAA,OACRA,EAAA,SAAS,UADDA,IAAAA,KAAA,CAAA,CAAA;AAIZ,MAAqBC,UAAoCC,EAAQ;AAAA,EAM7D,YAAYL,GAA4BC,GAAqCC,GAA6B;AACtG,UAAMH,EAAaC,GAAaC,GAAgBC,CAAmB,CAAC;AALxD,IAAAI,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAKZ,SAAK,cAAcN,GACnB,KAAK,iBAAiBC,GACtB,KAAK,sBAAsBC;AAAA,EAAA;AAGnC;AC3BA,MAAqBK,UAA4BF,EAAQ;AAAA,EAIrD,YAAYG,GAAaC,GAA0B;AACzC,UAAA,kCAAkCD,CAAG,IAAIC,CAAO;AAH1C,IAAAH,EAAA;AAKZ,SAAK,MAAME;AAAA,EAAA;AAGnB;ACXA,MAAqBE,UAAsBL,EAAQ;AAAA,EAI/C,YAAYG,GAAa;AACf,UAAA,kBAAkBA,CAAG,iBAAiB;AAHhC,IAAAF,EAAA;AAKZ,SAAK,MAAME;AAAA,EAAA;AAGnB;ACVA,SAAST,EAAaS,GAAaG,GAAiC;AAGzD,SAAA,eAFUA,MAAmB,MAAM,iBAAiB,EA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