@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.8a6a0b585adc7a1c329fb0fed5c420bb72cdccda
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/noeldemartin-solid-utils.d.ts +13 -65
- package/dist/noeldemartin-solid-utils.js +590 -0
- package/dist/noeldemartin-solid-utils.js.map +1 -0
- package/package.json +55 -63
- package/src/helpers/auth.test.ts +221 -0
- package/src/helpers/auth.ts +28 -27
- package/src/helpers/identifiers.test.ts +76 -0
- package/src/helpers/identifiers.ts +1 -1
- package/src/helpers/index.ts +0 -1
- package/src/helpers/interop.ts +23 -16
- package/src/helpers/io.test.ts +228 -0
- package/src/helpers/io.ts +57 -77
- package/src/helpers/jsonld.ts +6 -6
- package/src/helpers/wac.test.ts +64 -0
- package/src/helpers/wac.ts +10 -6
- package/src/index.ts +3 -0
- package/src/models/SolidDocument.test.ts +77 -0
- package/src/models/SolidDocument.ts +14 -18
- package/src/models/SolidStore.ts +22 -12
- package/src/models/SolidThing.ts +5 -7
- package/src/models/index.ts +2 -0
- package/.github/workflows/ci.yml +0 -16
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -70
- package/dist/noeldemartin-solid-utils.cjs.js +0 -2
- package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
- package/dist/noeldemartin-solid-utils.esm.js +0 -2
- package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
- package/dist/noeldemartin-solid-utils.umd.js +0 -90
- package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
- package/noeldemartin.config.js +0 -9
- package/src/helpers/testing.ts +0 -190
- package/src/main.ts +0 -5
- package/src/plugins/chai/assertions.ts +0 -40
- package/src/plugins/chai/index.ts +0 -5
- package/src/plugins/cypress/types.d.ts +0 -15
- package/src/plugins/index.ts +0 -2
- package/src/plugins/jest/index.ts +0 -5
- package/src/plugins/jest/matchers.ts +0 -65
- package/src/plugins/jest/types.d.ts +0 -14
- package/src/testing/ResponseStub.ts +0 -46
- package/src/testing/index.ts +0 -2
- package/src/testing/mocking.ts +0 -33
package/src/helpers/jsonld.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { JsonLdDocument } from '
|
|
1
|
+
import * as jsonld from 'jsonld';
|
|
2
|
+
import type { JsonLdDocument } from 'jsonld';
|
|
3
3
|
|
|
4
4
|
export type JsonLD = Partial<{
|
|
5
5
|
'@context': Record<string, unknown>;
|
|
@@ -13,8 +13,8 @@ export type JsonLDGraph = {
|
|
|
13
13
|
'@graph': JsonLDResource[];
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export async function compactJsonLDGraph(
|
|
17
|
-
const compactedJsonLD = await
|
|
16
|
+
export async function compactJsonLDGraph(json: JsonLDGraph): Promise<JsonLDGraph> {
|
|
17
|
+
const compactedJsonLD = await jsonld.compact(json as JsonLdDocument, {});
|
|
18
18
|
|
|
19
19
|
if ('@graph' in compactedJsonLD) {
|
|
20
20
|
return compactedJsonLD as JsonLDGraph;
|
|
@@ -27,6 +27,6 @@ export async function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGra
|
|
|
27
27
|
return { '@graph': [] };
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export function isJsonLDGraph(
|
|
31
|
-
return '@graph' in
|
|
30
|
+
export function isJsonLDGraph(json: JsonLD): json is JsonLDGraph {
|
|
31
|
+
return '@graph' in json;
|
|
32
32
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { FakeResponse, FakeServer } from '@noeldemartin/testing';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line max-len
|
|
5
|
+
import UnsupportedAuthorizationProtocolError from '@noeldemartin/solid-utils/errors/UnsupportedAuthorizationProtocolError';
|
|
6
|
+
|
|
7
|
+
import { fetchSolidDocumentACL } from './wac';
|
|
8
|
+
|
|
9
|
+
describe('WAC helpers', () => {
|
|
10
|
+
|
|
11
|
+
it('resolves relative ACL urls', async () => {
|
|
12
|
+
// Arrange
|
|
13
|
+
const server = new FakeServer();
|
|
14
|
+
const documentUrl = 'https://example.com/alice/movies/my-favorite-movie';
|
|
15
|
+
|
|
16
|
+
server.respondOnce(documentUrl, FakeResponse.success(undefined, { Link: '<my-favorite-movie.acl>;rel="acl"' }));
|
|
17
|
+
server.respondOnce(
|
|
18
|
+
`${documentUrl}.acl`,
|
|
19
|
+
FakeResponse.success(`
|
|
20
|
+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
|
|
21
|
+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
|
22
|
+
|
|
23
|
+
<#owner>
|
|
24
|
+
a acl:Authorization;
|
|
25
|
+
acl:agent <https://example.com/alice/profile/card#me>;
|
|
26
|
+
acl:accessTo <./my-favorite-movie> ;
|
|
27
|
+
acl:mode acl:Read, acl:Write, acl:Control .
|
|
28
|
+
`),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// Act
|
|
32
|
+
const { url, effectiveUrl, document } = await fetchSolidDocumentACL(documentUrl, server.fetch);
|
|
33
|
+
|
|
34
|
+
// Assert
|
|
35
|
+
expect(url).toEqual(`${documentUrl}.acl`);
|
|
36
|
+
expect(effectiveUrl).toEqual(url);
|
|
37
|
+
expect(document.contains(`${documentUrl}.acl#owner`, 'rdf:type', 'acl:Authorization')).toBe(true);
|
|
38
|
+
|
|
39
|
+
expect(server.getRequests()).toHaveLength(2);
|
|
40
|
+
expect(server.getRequest(documentUrl)?.method).toEqual('HEAD');
|
|
41
|
+
expect(server.getRequest(url)).not.toBeNull();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('fails with ACP resources', async () => {
|
|
45
|
+
// Arrange
|
|
46
|
+
const server = new FakeServer();
|
|
47
|
+
const documentUrl = 'https://example.com/alice/movies/my-favorite-movie';
|
|
48
|
+
|
|
49
|
+
server.respondOnce(documentUrl, FakeResponse.success(undefined, { Link: '<my-favorite-movie.acl>;rel="acl"' }));
|
|
50
|
+
server.respondOnce(
|
|
51
|
+
`${documentUrl}.acl`,
|
|
52
|
+
FakeResponse.success(undefined, {
|
|
53
|
+
Link: '<http://www.w3.org/ns/solid/acp#AccessControlResource>; rel="type"',
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// Act
|
|
58
|
+
const promisedDocument = fetchSolidDocumentACL(documentUrl, server.fetch);
|
|
59
|
+
|
|
60
|
+
// Assert
|
|
61
|
+
await expect(promisedDocument).rejects.toBeInstanceOf(UnsupportedAuthorizationProtocolError);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
});
|
package/src/helpers/wac.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import type
|
|
3
|
+
// eslint-disable-next-line max-len
|
|
4
|
+
import UnsupportedAuthorizationProtocolError from '@noeldemartin/solid-utils/errors/UnsupportedAuthorizationProtocolError';
|
|
5
|
+
import { fetchSolidDocumentIfFound } from '@noeldemartin/solid-utils/helpers/io';
|
|
6
|
+
import type SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';
|
|
7
|
+
import type { Fetch } from '@noeldemartin/solid-utils/helpers/io';
|
|
7
8
|
|
|
8
9
|
async function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {
|
|
9
10
|
fetch = fetch ?? window.fetch.bind(window);
|
|
@@ -24,7 +25,7 @@ async function fetchEffectiveACL(
|
|
|
24
25
|
fetch: Fetch,
|
|
25
26
|
aclResourceUrl?: string | null,
|
|
26
27
|
): Promise<SolidDocument> {
|
|
27
|
-
aclResourceUrl = aclResourceUrl ?? await fetchACLResourceUrl(resourceUrl, fetch);
|
|
28
|
+
aclResourceUrl = aclResourceUrl ?? (await fetchACLResourceUrl(resourceUrl, fetch));
|
|
28
29
|
|
|
29
30
|
const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', { fetch });
|
|
30
31
|
|
|
@@ -39,7 +40,10 @@ async function fetchEffectiveACL(
|
|
|
39
40
|
return aclDocument;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
export async function fetchSolidDocumentACL(
|
|
43
|
+
export async function fetchSolidDocumentACL(
|
|
44
|
+
documentUrl: string,
|
|
45
|
+
fetch: Fetch,
|
|
46
|
+
): Promise<{
|
|
43
47
|
url: string;
|
|
44
48
|
effectiveUrl: string;
|
|
45
49
|
document: SolidDocument;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';
|
|
4
|
+
import { turtleToQuadsSync } from '@noeldemartin/solid-utils/helpers';
|
|
5
|
+
|
|
6
|
+
describe('SolidDocument', () => {
|
|
7
|
+
|
|
8
|
+
it('Identifies storage documents', () => {
|
|
9
|
+
const hasStorageHeader = (link: string) => {
|
|
10
|
+
const document = new SolidDocument('', [], new Headers({ Link: link }));
|
|
11
|
+
|
|
12
|
+
return document.isStorage();
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/* eslint-disable max-len */
|
|
16
|
+
expect(hasStorageHeader('')).toBe(false);
|
|
17
|
+
expect(hasStorageHeader('<http://www.w3.org/ns/pim/space#Storage>; rel="type"')).toBe(true);
|
|
18
|
+
expect(hasStorageHeader('<http://www.w3.org/ns/pim/space#Storage>; rel="something-else"; rel="type"')).toBe(
|
|
19
|
+
true,
|
|
20
|
+
);
|
|
21
|
+
expect(
|
|
22
|
+
hasStorageHeader(
|
|
23
|
+
'<http://www.w3.org/ns/pim/space#Storage>; rel="something-else", <http://example.com>; rel="type"',
|
|
24
|
+
),
|
|
25
|
+
).toBe(false);
|
|
26
|
+
/* eslint-enable max-len */
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('Parses last modified from header', () => {
|
|
30
|
+
const document = new SolidDocument('', [], new Headers({ 'Last-Modified': 'Fri, 03 Sept 2021 16:09:12 GMT' }));
|
|
31
|
+
|
|
32
|
+
expect(document.getLastModified()).toEqual(new Date(1630685352000));
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('Parses last modified from document purl:modified', () => {
|
|
36
|
+
const document = new SolidDocument(
|
|
37
|
+
'https://pod.example.org/my-document',
|
|
38
|
+
turtleToQuadsSync(
|
|
39
|
+
`
|
|
40
|
+
<./fallback>
|
|
41
|
+
<http://purl.org/dc/terms/modified>
|
|
42
|
+
"2021-09-03T16:23:25.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
|
|
43
|
+
|
|
44
|
+
<>
|
|
45
|
+
<http://purl.org/dc/terms/modified>
|
|
46
|
+
"2021-09-03T16:09:12.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
|
|
47
|
+
`,
|
|
48
|
+
{ baseIRI: 'https://pod.example.org/my-document' },
|
|
49
|
+
),
|
|
50
|
+
new Headers({ 'Last-Modified': 'invalid date' }),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(document.getLastModified()).toEqual(new Date(1630685352000));
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('Parses last modified from any purl date', () => {
|
|
57
|
+
const document = new SolidDocument(
|
|
58
|
+
'https://pod.example.org/my-document',
|
|
59
|
+
turtleToQuadsSync(
|
|
60
|
+
`
|
|
61
|
+
<./fallback-one>
|
|
62
|
+
<http://purl.org/dc/terms/modified>
|
|
63
|
+
"2021-05-03T16:09:12.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
|
|
64
|
+
|
|
65
|
+
<./fallback-two>
|
|
66
|
+
<http://purl.org/dc/terms/created>
|
|
67
|
+
"2021-09-03T16:09:12.000Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
|
|
68
|
+
`,
|
|
69
|
+
{ baseIRI: 'https://pod.example.org/my-document' },
|
|
70
|
+
),
|
|
71
|
+
new Headers({ 'Last-Modified': 'invalid date' }),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
expect(document.getLastModified()).toEqual(new Date(1630685352000));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';
|
|
2
|
-
import type { Quad } from '
|
|
2
|
+
import type { Quad } from '@rdfjs/types';
|
|
3
3
|
|
|
4
|
-
import { expandIRI } from '
|
|
4
|
+
import { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';
|
|
5
5
|
|
|
6
6
|
import SolidStore from './SolidStore';
|
|
7
7
|
|
|
@@ -25,16 +25,13 @@ export default class SolidDocument extends SolidStore {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public isACPResource(): boolean {
|
|
28
|
-
return !!this.headers
|
|
28
|
+
return !!this.headers
|
|
29
|
+
.get('Link')
|
|
29
30
|
?.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
public isPersonalProfile(): boolean {
|
|
33
|
-
return !!this.statement(
|
|
34
|
-
this.url,
|
|
35
|
-
expandIRI('rdf:type'),
|
|
36
|
-
expandIRI('foaf:PersonalProfileDocument'),
|
|
37
|
-
);
|
|
34
|
+
return !!this.statement(this.url, expandIRI('rdf:type'), expandIRI('foaf:PersonalProfileDocument'));
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
public isStorage(): boolean {
|
|
@@ -54,10 +51,12 @@ export default class SolidDocument extends SolidStore {
|
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
public getLastModified(): Date | null {
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
??
|
|
54
|
+
return (
|
|
55
|
+
parseDate(this.headers.get('last-modified')) ??
|
|
56
|
+
parseDate(this.statement(this.url, 'purl:modified')?.object.value) ??
|
|
57
|
+
this.getLatestDocumentDate() ??
|
|
58
|
+
null
|
|
59
|
+
);
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
protected expandIRI(iri: string): string {
|
|
@@ -65,14 +64,11 @@ export default class SolidDocument extends SolidStore {
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
private getLatestDocumentDate(): Date | null {
|
|
68
|
-
const dates = [
|
|
69
|
-
|
|
70
|
-
...this.statements(undefined, 'purl:created'),
|
|
71
|
-
]
|
|
72
|
-
.map(statement => parseDate(statement.object.value))
|
|
67
|
+
const dates = [...this.statements(undefined, 'purl:modified'), ...this.statements(undefined, 'purl:created')]
|
|
68
|
+
.map((statement) => parseDate(statement.object.value))
|
|
73
69
|
.filter((date): date is Date => date !== null);
|
|
74
70
|
|
|
75
|
-
return dates.length > 0 ? dates.reduce((a, b) => a > b ? a : b) : null;
|
|
71
|
+
return dates.length > 0 ? dates.reduce((a, b) => (a > b ? a : b)) : null;
|
|
76
72
|
}
|
|
77
73
|
|
|
78
74
|
private getPermissionsFromWAC(type: string): SolidDocumentPermission[] {
|
package/src/models/SolidStore.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { Quad } from '
|
|
1
|
+
import type { BlankNode, Literal, NamedNode, Quad, Variable } from '@rdfjs/types';
|
|
2
2
|
|
|
3
|
-
import { expandIRI } from '
|
|
3
|
+
import { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';
|
|
4
4
|
|
|
5
5
|
import SolidThing from './SolidThing';
|
|
6
6
|
|
|
7
|
+
export type Term = NamedNode | Literal | BlankNode | Quad | Variable;
|
|
8
|
+
|
|
7
9
|
export default class SolidStore {
|
|
8
10
|
|
|
9
11
|
private quads: Quad[];
|
|
@@ -24,21 +26,21 @@ export default class SolidStore {
|
|
|
24
26
|
this.quads.push(...quads);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
public statements(subject?: string, predicate?: string, object?: string): Quad[] {
|
|
29
|
+
public statements(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad[] {
|
|
28
30
|
return this.quads.filter(
|
|
29
|
-
statement =>
|
|
30
|
-
(!object || statement.object
|
|
31
|
-
(!subject || statement.subject
|
|
32
|
-
(!predicate || statement.predicate
|
|
31
|
+
(statement) =>
|
|
32
|
+
(!object || this.termMatches(statement.object, object)) &&
|
|
33
|
+
(!subject || this.termMatches(statement.subject, subject)) &&
|
|
34
|
+
(!predicate || this.termMatches(statement.predicate, predicate)),
|
|
33
35
|
);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
public statement(subject?: string, predicate?: string, object?: string): Quad | null {
|
|
38
|
+
public statement(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad | null {
|
|
37
39
|
const statement = this.quads.find(
|
|
38
|
-
|
|
39
|
-
(!object ||
|
|
40
|
-
(!subject ||
|
|
41
|
-
(!predicate ||
|
|
40
|
+
(_statement) =>
|
|
41
|
+
(!object || this.termMatches(_statement.object, object)) &&
|
|
42
|
+
(!subject || this.termMatches(_statement.subject, subject)) &&
|
|
43
|
+
(!predicate || this.termMatches(_statement.predicate, predicate)),
|
|
42
44
|
);
|
|
43
45
|
|
|
44
46
|
return statement ?? null;
|
|
@@ -58,4 +60,12 @@ export default class SolidStore {
|
|
|
58
60
|
return expandIRI(iri);
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
protected termMatches(term: Term, value: Term | string): boolean {
|
|
64
|
+
if (typeof value === 'string') {
|
|
65
|
+
return this.expandIRI(value) === term.value;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return term.termType === term.termType && term.value === value.value;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
}
|
package/src/models/SolidThing.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Quad } from '
|
|
1
|
+
import type { Quad } from '@rdfjs/types';
|
|
2
2
|
|
|
3
|
-
import { expandIRI } from '
|
|
3
|
+
import { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';
|
|
4
4
|
|
|
5
5
|
export default class SolidThing {
|
|
6
6
|
|
|
@@ -13,15 +13,13 @@ export default class SolidThing {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
public value(property: string): string | undefined {
|
|
16
|
-
return this.quads
|
|
17
|
-
.find(quad => quad.predicate.value === expandIRI(property))
|
|
18
|
-
?.object.value;
|
|
16
|
+
return this.quads.find((quad) => quad.predicate.value === expandIRI(property))?.object.value;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
public values(property: string): string[] {
|
|
22
20
|
return this.quads
|
|
23
|
-
.filter(quad => quad.predicate.value === expandIRI(property))
|
|
24
|
-
.map(quad => quad.object.value);
|
|
21
|
+
.filter((quad) => quad.predicate.value === expandIRI(property))
|
|
22
|
+
.map((quad) => quad.object.value);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
}
|
package/src/models/index.ts
CHANGED
package/.github/workflows/ci.yml
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on: [push, pull_request]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
ci:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
steps:
|
|
9
|
-
- uses: actions/checkout@v3
|
|
10
|
-
- uses: actions/setup-node@v3
|
|
11
|
-
with:
|
|
12
|
-
node-version-file: '.nvmrc'
|
|
13
|
-
- run: npm ci
|
|
14
|
-
- run: npm run build
|
|
15
|
-
- run: npm run lint
|
|
16
|
-
- run: npm run test
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v16
|
package/CHANGELOG.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
|
|
7
|
-
## [v0.5.0](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.5.0) - 2025-01-05
|
|
8
|
-
|
|
9
|
-
### Added
|
|
10
|
-
|
|
11
|
-
- `ldp:` prefix.
|
|
12
|
-
- `toEqualTurtle` matcher.
|
|
13
|
-
|
|
14
|
-
### Fixed
|
|
15
|
-
|
|
16
|
-
- Parsing JsonLD with anonymous subjects (meaning subjects with ids such as `#it`, without a full url).
|
|
17
|
-
|
|
18
|
-
### Changed
|
|
19
|
-
|
|
20
|
-
- `@types/rdf-js` dependency for `@rdfjs/types`.
|
|
21
|
-
- Many of the `fetch*` helpers now take an options object instead of a `fetch` method.
|
|
22
|
-
- Disabled caching when reading user profiles, in order to fix an issue with CSS v7.1.3 (See [CommunitySolidServer/CommunitySolidServer#1972](https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972)).
|
|
23
|
-
|
|
24
|
-
### Removed
|
|
25
|
-
|
|
26
|
-
- Faking helpers have been extracted into `@noeldemartin/testing` in order to avoid including them (and the `faker` dependency) on production bundles.
|
|
27
|
-
|
|
28
|
-
## [v0.4.0](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.4.0) - 2023-12-17
|
|
29
|
-
|
|
30
|
-
### Changed
|
|
31
|
-
|
|
32
|
-
- Retrieving user profiles will now fail if no storage urls are found. In reality, this is only an improvement for the TypeScript types since [according to the spec](https://solidproject.org/TR/protocol#storage-resource) this should never happen.
|
|
33
|
-
|
|
34
|
-
### Deprecated
|
|
35
|
-
|
|
36
|
-
- Interoperability helpers such as `createPublicTypeIndex`, `createPrivateTypeIndex`, `findContainerRegistrations`, and `findInstanceRegistrations`. Use [soukai-solid interoperability helpers](https://github.com/noeldemartin/soukai-solid#interoperability) instead.
|
|
37
|
-
|
|
38
|
-
### Removed
|
|
39
|
-
|
|
40
|
-
- Required jest dependencies. This was previously causing some problems using other test runners like [Vitest](https://vitest.dev/).
|
|
41
|
-
|
|
42
|
-
## [v0.3.0](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.3.0) - 2023-03-10
|
|
43
|
-
|
|
44
|
-
### Fixed
|
|
45
|
-
|
|
46
|
-
- Tree-shaking by declaring `"sideEffects": false`.
|
|
47
|
-
|
|
48
|
-
### Changed
|
|
49
|
-
|
|
50
|
-
- `fetchLoginUserProfile` now takes an options object instead of an optional fetch function.
|
|
51
|
-
|
|
52
|
-
## [v0.2.0](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.2.0) - 2023-01-20
|
|
53
|
-
|
|
54
|
-
### Added
|
|
55
|
-
|
|
56
|
-
- `rdf:` prefix for `http://www.w3.org/1999/02/22-rdf-syntax-ns#` (previously was `rdfs:`).
|
|
57
|
-
|
|
58
|
-
### Changed
|
|
59
|
-
|
|
60
|
-
- The `rdfs:` has been changed to be `http://www.w3.org/2000/01/rdf-schema#`.
|
|
61
|
-
|
|
62
|
-
## [v0.1.1](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.1.1) - 2021-09-04
|
|
63
|
-
|
|
64
|
-
No documented changes.
|
|
65
|
-
|
|
66
|
-
## [v0.1.0](https://github.com/NoelDeMartin/solid-utils/releases/tag/v0.1.0) - 2021-09-04
|
|
67
|
-
|
|
68
|
-
### Added
|
|
69
|
-
|
|
70
|
-
- Everything!
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("core-js/modules/es.object.to-string.js"),require("core-js/modules/es.reflect.to-string-tag.js"),require("core-js/modules/es.reflect.construct.js");var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/assertThisInitialized"),r=require("@babel/runtime/helpers/inherits"),n=require("@babel/runtime/helpers/possibleConstructorReturn"),u=require("@babel/runtime/helpers/getPrototypeOf"),o=require("@babel/runtime/helpers/defineProperty");require("core-js/modules/es.array.concat.js");var a=require("@noeldemartin/utils"),s=require("@babel/runtime/helpers/createClass");require("core-js/modules/es.object.keys.js"),require("core-js/modules/es.symbol.js"),require("core-js/modules/es.array.filter.js"),require("core-js/modules/esnext.async-iterator.filter.js"),require("core-js/modules/esnext.iterator.filter.js"),require("core-js/modules/es.object.get-own-property-descriptor.js"),require("core-js/modules/es.object.get-own-property-descriptors.js");var i=require("@babel/runtime/helpers/slicedToArray"),c=require("@babel/runtime/helpers/asyncToGenerator"),l=require("@babel/runtime/regenerator");require("core-js/modules/esnext.async-iterator.for-each.js"),require("core-js/modules/esnext.iterator.constructor.js"),require("core-js/modules/esnext.iterator.for-each.js"),require("core-js/modules/web.dom-collections.for-each.js"),require("core-js/modules/es.array.map.js"),require("core-js/modules/esnext.async-iterator.map.js"),require("core-js/modules/esnext.iterator.map.js"),require("core-js/modules/es.object.entries.js"),require("core-js/modules/esnext.async-iterator.some.js"),require("core-js/modules/esnext.iterator.some.js"),require("core-js/modules/es.object.values.js"),require("core-js/modules/es.array.find.js"),require("core-js/modules/esnext.async-iterator.find.js"),require("core-js/modules/esnext.iterator.find.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js");var f=require("@babel/runtime/helpers/toConsumableArray");require("core-js/modules/es.array.slice.js"),require("core-js/modules/es.string.starts-with.js"),require("core-js/modules/es.string.split.js"),require("core-js/modules/es.function.name.js"),require("core-js/modules/es.array.from.js"),require("core-js/modules/es.regexp.test.js"),require("core-js/modules/es.symbol.description.js"),require("core-js/modules/es.symbol.iterator.js"),require("core-js/modules/es.array.flat-map.js"),require("core-js/modules/es.array.unscopables.flat-map.js"),require("core-js/modules/esnext.async-iterator.flat-map.js"),require("core-js/modules/esnext.iterator.flat-map.js"),require("core-js/modules/es.array.iterator.js"),require("core-js/modules/es.set.js"),require("core-js/modules/es.string.iterator.js"),require("core-js/modules/esnext.set.add-all.js"),require("core-js/modules/esnext.set.delete-all.js"),require("core-js/modules/esnext.set.difference.js"),require("core-js/modules/esnext.set.every.js"),require("core-js/modules/esnext.set.filter.js"),require("core-js/modules/esnext.set.find.js"),require("core-js/modules/esnext.set.intersection.js"),require("core-js/modules/esnext.set.is-disjoint-from.js"),require("core-js/modules/esnext.set.is-subset-of.js"),require("core-js/modules/esnext.set.is-superset-of.js"),require("core-js/modules/esnext.set.join.js"),require("core-js/modules/esnext.set.map.js"),require("core-js/modules/esnext.set.reduce.js"),require("core-js/modules/esnext.set.some.js"),require("core-js/modules/esnext.set.symmetric-difference.js"),require("core-js/modules/esnext.set.union.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.array.join.js"),require("core-js/modules/es.array.sort.js"),require("core-js/modules/esnext.async-iterator.reduce.js"),require("core-js/modules/esnext.iterator.reduce.js"),require("core-js/modules/es.promise.js"),require("core-js/modules/es.array.includes.js"),require("core-js/modules/es.array.flat.js"),require("core-js/modules/es.array.unscopables.flat.js");var d=require("md5"),p=require("@noeldemartin/solid-utils-external");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("core-js/modules/es.string.match.js"),require("core-js/modules/es.string.includes.js"),require("core-js/modules/es.regexp.constructor.js"),require("core-js/modules/es.regexp.sticky.js"),require("core-js/modules/es.regexp.to-string.js"),require("core-js/modules/es.object.assign.js");var v=h(e),m=h(t),y=h(r),x=h(n),b=h(u),j=h(o),w=h(s),g=h(i),q=h(c),k=h(l),R=h(f),E=h(d);function P(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}exports.SolidDocumentFormat=void 0,(exports.SolidDocumentFormat||(exports.SolidDocumentFormat={})).Turtle="Turtle";var I=function(e){y.default(MalformedSolidDocumentError,e);var t=P(MalformedSolidDocumentError);function MalformedSolidDocumentError(e,r,n){var u;return v.default(this,MalformedSolidDocumentError),u=t.call(this,function(e,t,r){return e?"Malformed ".concat(t," document found at ").concat(e," - ").concat(r):"Malformed ".concat(t," document - ").concat(r)}(e,r,n)),j.default(m.default(u),"documentUrl",void 0),j.default(m.default(u),"documentFormat",void 0),j.default(m.default(u),"malformationDetails",void 0),u.documentUrl=e,u.documentFormat=r,u.malformationDetails=n,u}return MalformedSolidDocumentError}(a.JSError);function T(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var D=function(e){y.default(NetworkRequestError,e);var t=T(NetworkRequestError);function NetworkRequestError(e,r){var n;return v.default(this,NetworkRequestError),n=t.call(this,"Request failed trying to fetch ".concat(e),r),j.default(m.default(n),"url",void 0),n.url=e,n}return NetworkRequestError}(a.JSError);function S(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var O=function(e){y.default(NotFoundError,e);var t=S(NotFoundError);function NotFoundError(e){var r;return v.default(this,NotFoundError),r=t.call(this,"Document with '".concat(e,"' url not found")),j.default(m.default(r),"url",void 0),r.url=e,r}return NotFoundError}(a.JSError);function A(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var U=function(e){y.default(UnauthorizedError,e);var t=A(UnauthorizedError);function UnauthorizedError(e,r){var n;return v.default(this,UnauthorizedError),n=t.call(this,function(e,t){return"Unauthorized".concat(403===t?" (Forbidden)":"",": ").concat(e)}(e,r)),j.default(m.default(n),"url",void 0),j.default(m.default(n),"responseStatus",void 0),n.url=e,n.responseStatus=r,n}return w.default(UnauthorizedError,[{key:"forbidden",get:function(){return void 0!==this.responseStatus?403===this.responseStatus:void 0}}]),UnauthorizedError}(a.JSError);function C(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var B=function(e){y.default(UnsuccessfulRequestError,e);var t=C(UnsuccessfulRequestError);function UnsuccessfulRequestError(e,r){var n;return v.default(this,UnsuccessfulRequestError),n=t.call(this,function(e,t){var r;return t=null!==(r=t)&&void 0!==r?r:e,"string"==typeof e?"".concat(e," (returned ").concat(t.status," status code)"):"Request to ".concat(t.url," returned ").concat(t.status," status code")}(e,r)),j.default(m.default(n),"response",void 0),n.response=null!=r?r:e,n}return UnsuccessfulRequestError}(a.JSError);function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var F=function(e){y.default(UnsupportedAuthorizationProtocolError,e);var t=N(UnsupportedAuthorizationProtocolError);function UnsupportedAuthorizationProtocolError(e,r,n){var u;return v.default(this,UnsupportedAuthorizationProtocolError),u=t.call(this,"The resource at ".concat(e," is using an unsupported authorization protocol (").concat(r,")"),n),j.default(m.default(u),"url",void 0),j.default(m.default(u),"protocol",void 0),u.url=e,u.protocol=r,u}return UnsupportedAuthorizationProtocolError}(a.JSError),L={acl:"http://www.w3.org/ns/auth/acl#",foaf:"http://xmlns.com/foaf/0.1/",ldp:"http://www.w3.org/ns/ldp#",pim:"http://www.w3.org/ns/pim/space#",purl:"http://purl.org/dc/terms/",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",schema:"https://schema.org/",solid:"http://www.w3.org/ns/solid/terms#",vcard:"http://www.w3.org/2006/vcard/ns#"};function z(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.startsWith("http"))return e;var r=e.split(":"),n=g.default(r,2),u=n[0],o=n[1];if(u&&o){var a,s,i,c=null!==(a=null!==(s=L[u])&&void 0!==s?s:null===(i=t.extraContext)||void 0===i?void 0:i[u])&&void 0!==a?a:null;if(!c)throw new Error("Can't expand IRI with unknown prefix: '".concat(e,"'"));return c+o}if(!t.defaultPrefix)throw new Error("Can't expand IRI without a default prefix: '".concat(e,"'"));return t.defaultPrefix+u}var W,M=function(){function e(t,r){v.default(this,e),j.default(this,"url",void 0),j.default(this,"quads",void 0),this.url=t,this.quads=r}return w.default(e,[{key:"value",value:function(e){var t;return null===(t=this.quads.find((function(t){return t.predicate.value===z(e)})))||void 0===t?void 0:t.object.value}},{key:"values",value:function(e){return this.quads.filter((function(t){return t.predicate.value===z(e)})).map((function(e){return e.object.value}))}}]),e}(),Q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];v.default(this,e),j.default(this,"quads",void 0),this.quads=t}return w.default(e,[{key:"isEmpty",value:function(){return 0===this.statements.length}},{key:"getQuads",value:function(){return this.quads.slice(0)}},{key:"addQuads",value:function(e){var t;(t=this.quads).push.apply(t,R.default(e))}},{key:"statements",value:function(e,t,r){var n=this;return this.quads.filter((function(u){return!(r&&u.object.value!==n.expandIRI(r)||e&&u.subject.value!==n.expandIRI(e)||t&&u.predicate.value!==n.expandIRI(t))}))}},{key:"statement",value:function(e,t,r){var n=this,u=this.quads.find((function(u){return!(r&&u.object.value!==n.expandIRI(r)||e&&u.subject.value!==n.expandIRI(e)||t&&u.predicate.value!==n.expandIRI(t))}));return null!=u?u:null}},{key:"contains",value:function(e,t,r){return null!==this.statement(e,t,r)}},{key:"getThing",value:function(e){var t=this.statements(e);return new M(e,t)}},{key:"expandIRI",value:function(e){return z(e)}}]),e}();function J(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}exports.SolidDocumentPermission=void 0,(W=exports.SolidDocumentPermission||(exports.SolidDocumentPermission={})).Read="read",W.Write="write",W.Append="append",W.Control="control";var _=function(e){y.default(r,e);var t=J(r);function r(e,n,u){var o;return v.default(this,r),o=t.call(this,n),j.default(m.default(o),"url",void 0),j.default(m.default(o),"headers",void 0),o.url=e,o.headers=u,o}return w.default(r,[{key:"isACPResource",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/))}},{key:"isPersonalProfile",value:function(){return!!this.statement(this.url,z("rdf:type"),z("foaf:PersonalProfileDocument"))}},{key:"isStorage",value:function(){var e;return!(null===(e=this.headers.get("Link"))||void 0===e||!e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/))}},{key:"isUserWritable",value:function(){return this.getUserPermissions().includes(exports.SolidDocumentPermission.Write)}},{key:"getUserPermissions",value:function(){return this.getPermissionsFromWAC("user")}},{key:"getPublicPermissions",value:function(){return this.getPermissionsFromWAC("public")}},{key:"getLastModified",value:function(){var e,t,r,n;return null!==(e=null!==(t=null!==(r=a.parseDate(this.headers.get("last-modified")))&&void 0!==r?r:a.parseDate(null===(n=this.statement(this.url,"purl:modified"))||void 0===n?void 0:n.object.value))&&void 0!==t?t:this.getLatestDocumentDate())&&void 0!==e?e:null}},{key:"expandIRI",value:function(e){return z(e,{defaultPrefix:this.url})}},{key:"getLatestDocumentDate",value:function(){var e=[].concat(R.default(this.statements(void 0,"purl:modified")),R.default(this.statements(void 0,"purl:created"))).map((function(e){return a.parseDate(e.object.value)})).filter((function(e){return null!==e}));return e.length>0?e.reduce((function(e,t){return e>t?e:t})):null}},{key:"getPermissionsFromWAC",value:function(e){var t,r,n,u=null!==(t=this.headers.get("WAC-Allow"))&&void 0!==t?t:"",o=null!==(r=null===(n=a.stringMatch(u,new RegExp("".concat(e,'="([^"]+)"'))))||void 0===n?void 0:n[1])&&void 0!==r?r:"";return a.arrayFilter([o.includes("read")&&exports.SolidDocumentPermission.Read,o.includes("write")&&exports.SolidDocumentPermission.Write,o.includes("append")&&exports.SolidDocumentPermission.Append,o.includes("control")&&exports.SolidDocumentPermission.Control])}}]),r}(Q);function H(){return(H=q.default(k.default.mark((function e(t){var r;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p.compactJsonLD(t,{});case 2:if(!("@graph"in(r=e.sent))){e.next=5;break}return e.abrupt("return",r);case 5:if(!("@id"in r)){e.next=7;break}return e.abrupt("return",{"@graph":[r]});case 7:return e.abrupt("return",{"@graph":[]});case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $(e){return"@graph"in e}function G(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return X(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return X(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var K="anonymous://".length;function V(e,t){return Y.apply(this,arguments)}function Y(){return(Y=q.default(k.default.mark((function e(t,r){var n,u,o,a,s;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={headers:{Accept:"text/turtle"}},null!=r&&r.cache&&(n.cache=r.cache),e.prev=2,o=null!==(u=null==r?void 0:r.fetch)&&void 0!==u?u:window.fetch,e.next=6,o(t,n);case 6:if(404!==(a=e.sent).status){e.next=9;break}throw new O(t);case 9:if(![401,403].includes(a.status)){e.next=11;break}throw new U(t,a.status);case 11:return e.next=13,a.text();case 13:return s=e.sent,e.abrupt("return",{body:s,headers:a.headers});case 17:if(e.prev=17,e.t0=e.catch(2),!(e.t0 instanceof U)){e.next=21;break}throw e.t0;case 21:if(!(e.t0 instanceof O)){e.next=23;break}throw e.t0;case 23:throw new D(t,{cause:e.t0});case 24:case"end":return e.stop()}}),e,null,[[2,17]])})))).apply(this,arguments)}function Z(e){var t,r=e.slice(0),n={},u=G(a.arr(e).flatMap((function(e,t){return a.tap(a.arrayFilter(["BlankNode"===e.object.termType?e.object.value:null,"BlankNode"===e.subject.termType?e.subject.value:null]),(function(e){return e.forEach((function(e){var r;return(null!==(r=n[e])&&void 0!==r?r:n[e]=new Set).add(t)}))}))})).filter().unique());try{var o=function(){var u,o=t.value,s=n[o],i=E.default(a.arr(s).map((function(t){return e[t]})).filter((function(e){var t=e.subject,r=t.termType,n=t.value;return"BlankNode"===r&&n===o})).map((function(e){var t=e.predicate,r=e.object;return"BlankNode"===r.termType?t.value:t.value+r.value})).sorted().join()),c=G(s);try{for(c.s();!(u=c.n()).done;){for(var l=u.value,f=r[l],d={subject:f.subject,object:f.object},h=0,v=Object.entries(d);h<v.length;h++){var m=g.default(v[h],2),y=m[0],x=m[1];"BlankNode"===x.termType&&x.value===o&&(d[y]=p.createBlankNode(i))}a.arrayReplace(r,f,p.createQuad(d.subject,f.predicate,d.object))}}catch(e){c.e(e)}finally{c.f()}};for(u.s();!(t=u.n()).done;)o()}catch(e){u.e(e)}finally{u.f()}return r}function ee(e){return e.map((function(e){return" "+me(e)})).sort().join("\n")}function te(e){var t;null!==(t=e["@id"])&&void 0!==t&&t.startsWith("#")&&(e["@id"]="anonymous://"+e["@id"])}function re(e){var t,r=G(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;n.subject.value.startsWith("anonymous://")&&(n.subject.value=n.subject.value.slice(K))}}catch(e){r.e(e)}finally{r.f()}}function ne(e,t,r){return ue.apply(this,arguments)}function ue(){return(ue=q.default(k.default.mark((function e(t,r,n){var u,o;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch.bind(window),e.next=3,we(r);case 3:return o=e.sent,e.next=6,n(t,{method:"PUT",headers:{"Content-Type":"text/turtle"},body:r});case 6:return e.abrupt("return",new _(t,o,new Headers({})));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function oe(e,t){return ae.apply(this,arguments)}function ae(){return(ae=q.default(k.default.mark((function e(t,r){var n,u,o,a;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,V(t,r);case 2:return n=e.sent,u=n.body,o=n.headers,e.next=7,we(u,{baseIRI:t});case 7:return a=e.sent,e.abrupt("return",new _(t,a,o));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function se(e,t){return ie.apply(this,arguments)}function ie(){return(ie=q.default(k.default.mark((function e(t,r){var n;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,oe(t,r);case 3:return n=e.sent,e.abrupt("return",n);case 7:if(e.prev=7,e.t0=e.catch(0),e.t0 instanceof O){e.next=11;break}throw e.t0;case 11:return e.abrupt("return",null);case 12:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function ce(e,t){return le.apply(this,arguments)}function le(){return(le=q.default(k.default.mark((function e(t,r){var n,u;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!$(t)){e.next=5;break}return e.next=3,Promise.all(t["@graph"].map((function(e){return ce(e,r)})));case 3:return n=e.sent,e.abrupt("return",n.flat());case 5:return te(t),e.next=8,p.jsonLDToRDF(t,{base:r});case 8:return re(u=e.sent),e.abrupt("return",u);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fe(e){var t=je(e);return Object.entries(t).reduce((function(e,t){var r=g.default(t,2),n=r[0],u=ee(r[1]);return e.concat("".concat(n.toUpperCase()," DATA {\n").concat(u,"\n}"))}),[]).join(" ;\n")}function de(e){return ee(qe(e))}function pe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=a.objectWithoutEmpty({baseIRI:t.baseIRI}),n=new p.TurtleParser(r),u={quads:[],containsRelativeIRIs:!1};return new Promise((function(r,o){var a=n._resolveRelativeIRI;n._resolveRelativeIRI=function(){return u.containsRelativeIRIs=!0,n._resolveRelativeIRI=a,n._resolveRelativeIRI.apply(n,arguments)},n.parse(e,(function(e,n){var a;e?o(new I(null!==(a=t.baseIRI)&&void 0!==a?a:null,exports.SolidDocumentFormat.Turtle,e.message)):n?u.quads.push(n):r(u)}))}))}function he(){return(he=q.default(k.default.mark((function e(t){var r;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p.jsonLDFromRDF(t);case 2:return r=e.sent,e.abrupt("return",{"@graph":r});case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ve(e){return(new p.TurtleWriter).quadsToString(e)}function me(e){return(new p.TurtleWriter).quadsToString([e]).slice(0,-1)}function ye(e,t){return xe.apply(this,arguments)}function xe(){return(xe=q.default(k.default.mark((function e(t,r){var n;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,oe(t,r);case 3:return n=e.sent,e.abrupt("return",!n.isEmpty());case 7:return e.prev=7,e.t0=e.catch(0),e.abrupt("return",!1);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})))).apply(this,arguments)}function be(){return be=q.default(k.default.mark((function e(t){var r,n,u,o=arguments;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},n=a.stringMatchAll(t,/(\w+) DATA {([^}]+)}/g),u={},e.next=5,Promise.all(R.default(n).map(function(){var e=q.default(k.default.mark((function e(t){var n,o;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t[1].toLowerCase(),o=t[2],e.next=4,we(o,r);case 4:u[n]=e.sent;case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()));case 5:return e.abrupt("return",u);case 6:case"end":return e.stop()}}),e)}))),be.apply(this,arguments)}function je(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a.stringMatchAll(e,/(\w+) DATA {([^}]+)}/g),u={},o=G(n);try{for(o.s();!(t=o.n()).done;){var s=t.value,i=s[1].toLowerCase(),c=s[2];u[i]=qe(c,r)}}catch(e){o.e(e)}finally{o.f()}return u}function we(e){return ge.apply(this,arguments)}function ge(){return ge=q.default(k.default.mark((function e(t){var r,n,u,o=arguments;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.length>1&&void 0!==o[1]?o[1]:{},e.next=3,pe(t,r);case 3:return n=e.sent,u=n.quads,e.abrupt("return",u);case 6:case"end":return e.stop()}}),e)}))),ge.apply(this,arguments)}function qe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=a.objectWithoutEmpty({baseIRI:t.baseIRI}),n=new p.TurtleParser(r);try{var u=n.parse(e);return t.normalizeBlankNodes?Z(u):u}catch(e){var o,s;throw new I(null!==(o=t.baseIRI)&&void 0!==o?o:null,exports.SolidDocumentFormat.Turtle,null!==(s=e.message)&&void 0!==s?s:"")}}function ke(e,t,r){return Re.apply(this,arguments)}function Re(){return(Re=q.default(k.default.mark((function e(t,r,n){var u;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch.bind(window),e.next=3,n(t,{method:"PATCH",headers:{"Content-Type":"application/sparql-update"},body:r});case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ee(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function Pe(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ee(Object(r),!0).forEach((function(t){j.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ee(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function Ie(e,t){return Te.apply(this,arguments)}function Te(){return Te=q.default(k.default.mark((function e(t,r){var n,u,o,a,s,i;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=new Q(t.getQuads()),a=j.default({},t.url,t),s=function(e){e.statements(void 0,"foaf:isPrimaryTopicOf").map((function(e){return e.object.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null})),e.statements(void 0,"foaf:primaryTopic").map((function(e){return e.subject.value})).forEach((function(e){var t;return a[e]=null!==(t=a[e])&&void 0!==t?t:null}))},i=function(){var e=q.default(k.default.mark((function e(){var t,n,u,i,c;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,n=Object.entries(a);case 1:if(!(t<n.length)){e.next=23;break}if(u=g.default(n[t],2),i=u[0],null===u[1]){e.next=5;break}return e.abrupt("continue",20);case 5:return e.prev=5,e.next=8,oe(i,r);case 8:c=e.sent,a[i]=c,o.addQuads(c.getQuads()),s(c),e.next=20;break;case 14:if(e.prev=14,e.t0=e.catch(5),!(e.t0 instanceof U)){e.next=19;break}return a[i]=!1,e.abrupt("continue",20);case 19:throw e.t0;case 20:t++,e.next=1;break;case 23:case"end":return e.stop()}}),e,null,[[5,14]])})));return function(){return e.apply(this,arguments)}}(),s(t);case 5:return e.next=7,i();case 7:if(Object.values(a).some((function(e){return null===e}))){e.next=5;break}case 8:return e.abrupt("return",{store:o,cloaked:Object.values(a).some((function(e){return!1===e})),writableProfileUrl:t.isUserWritable()?t.url:null!==(n=null===(u=Object.values(a).find((function(e){return!!e&&e.isUserWritable()})))||void 0===u?void 0:u.url)&&void 0!==n?n:null});case 9:case"end":return e.stop()}}),e)}))),Te.apply(this,arguments)}function De(e){return Se.apply(this,arguments)}function Se(){return Se=q.default(k.default.mark((function e(t){var r,n,u,o,s,i,c,l,f,d,p,h,v,m,y,x,b,j,w,g,q,R=arguments;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f=R.length>1&&void 0!==R[1]?R[1]:{},d={fetch:f.fetch,cache:"no-store"},p=a.urlRoute(t),e.next=5,oe(p,d);case 5:if((h=e.sent).isPersonalProfile()||h.contains(t,"solid:oidcIssuer")){e.next=8;break}throw new Error("".concat(t," is not a valid webId."));case 8:return e.next=10,Ie(h,f);case 10:v=e.sent,m=v.store,y=v.writableProfileUrl,x=v.cloaked,b=m.statements(t,"pim:storage").map((function(e){return e.object.value})),j=m.statement(t,"solid:publicTypeIndex"),w=m.statement(t,"solid:privateTypeIndex"),g=a.urlParentDirectory(p);case 18:if(!g||0!==b.length){e.next=28;break}return e.next=21,a.silenced(oe(g,d));case 21:if(null==(q=e.sent)||!q.isStorage()){e.next=25;break}return b.push(g),e.abrupt("break",28);case 25:g=a.urlParentDirectory(g),e.next=18;break;case 28:if(0!==b.length){e.next=30;break}throw new Error("Could not find any storage for ".concat(t,"."));case 30:return e.next=32,null===(r=f.onLoaded)||void 0===r?void 0:r.call(f,new Q(m.statements(t)));case 32:return e.abrupt("return",Pe({webId:t,cloaked:x,writableProfileUrl:y,storageUrls:a.arrayUnique(b)},a.objectWithoutEmpty({name:null!==(n=null===(u=m.statement(t,"vcard:fn"))||void 0===u?void 0:u.object.value)&&void 0!==n?n:null===(o=m.statement(t,"foaf:name"))||void 0===o?void 0:o.object.value,avatarUrl:null!==(s=null===(i=m.statement(t,"vcard:hasPhoto"))||void 0===i?void 0:i.object.value)&&void 0!==s?s:null===(c=m.statement(t,"foaf:img"))||void 0===c?void 0:c.object.value,oidcIssuerUrl:null===(l=m.statement(t,"solid:oidcIssuer"))||void 0===l?void 0:l.object.value,publicTypeIndexUrl:null==j?void 0:j.object.value,privateTypeIndexUrl:null==w?void 0:w.object.value})));case 33:case"end":return e.stop()}}),e)}))),Se.apply(this,arguments)}function Oe(){return Oe=q.default(k.default.mark((function e(t){var r,n,u,o,s=arguments;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(u=s.length>1&&void 0!==s[1]?s[1]:{}).required){e.next=3;break}return e.abrupt("return",De(t,u));case 3:return o=a.silenced((function(e){return De(e,u)})),e.next=6,o(t);case 6:if(e.t2=n=e.sent,e.t1=null!==e.t2,!e.t1){e.next=10;break}e.t1=void 0!==n;case 10:if(!e.t1){e.next=14;break}e.t3=n,e.next=17;break;case 14:return e.next=16,o(t.replace(/\/$/,"").concat("/profile/card#me"));case 16:e.t3=e.sent;case 17:if(e.t4=r=e.t3,e.t0=null!==e.t4,!e.t0){e.next=21;break}e.t0=void 0!==r;case 21:if(!e.t0){e.next=25;break}e.t5=r,e.next=28;break;case 25:return e.next=27,o(a.urlRoot(t).concat("/profile/card#me"));case 27:e.t5=e.sent;case 28:return e.abrupt("return",e.t5);case 29:case"end":return e.stop()}}),e)}))),Oe.apply(this,arguments)}function Ae(e){var t=function(e){return e.path&&e.path.startsWith("/")?e.path.match(/^\/[^/]*$/)?"/":"/".concat(a.arr(e.path.split("/")).filter().slice(0,-1).join("/"),"/").replace("//","/"):null}(e);return e.protocol&&e.domain?"".concat(e.protocol,"://").concat(e.domain).concat(null!=t?t:"/"):t}function Ue(e){var t;if("@type"in e&&!("@value"in e)){e["@id"]=null!==(t=e["@id"])&&void 0!==t?t:a.uuid();for(var r=0,n=Object.values(e);r<n.length;r++){var u=n[r];a.isObject(u)&&Ue(u),a.isArray(u)&&u.forEach((function(e){return a.isObject(e)&&Ue(e)}))}}}function Ce(e,t,r){return Be.apply(this,arguments)}function Be(){return(Be=q.default(k.default.mark((function e(t,r,n){var u,o,s;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(u=n)&&void 0!==u?u:window.fetch.bind(n),o=t.storageUrls[0],s="".concat(o,"settings/").concat(r,"TypeIndex"),e.next=5,ye(s,{fetch:n});case 5:if(!e.sent){e.next=9;break}e.t0="".concat(o,"settings/").concat(r,"TypeIndex-").concat(a.uuid()),e.next=10;break;case 9:e.t0=s;case 10:return e.abrupt("return",e.t0);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ne(e,t,r){return Fe.apply(this,arguments)}function Fe(){return(Fe=q.default(k.default.mark((function e(t,r,n){var u,o,a,s;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!==t.writableProfileUrl){e.next=2;break}throw new Error("Can't create type index without a writable profile document");case 2:return n=null!==(u=n)&&void 0!==u?u:window.fetch.bind(n),e.next=5,Ce(t,r,n);case 5:return o=e.sent,a="public"===r?"<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .":"\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n ",s="\n INSERT DATA {\n <".concat(t.webId,"> <http://www.w3.org/ns/solid/terms#").concat(r,"TypeIndex> <").concat(o,"> .\n }\n "),e.next=10,ne(o,a,n);case 10:return e.next=12,ke(t.writableProfileUrl,s,n);case 12:return e.abrupt("return",o);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Le(e,t,r,n){return ze.apply(this,arguments)}function ze(){return(ze=q.default(k.default.mark((function e(t,r,n,u){var o,a;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,oe(t,{fetch:u});case 2:return o=e.sent,a=Array.isArray(r)?r:[r],e.abrupt("return",a.map((function(e){return o.statements(void 0,"rdf:type","solid:TypeRegistration").filter((function(t){return o.contains(t.subject.value,"solid:forClass",e)})).map((function(e){return o.statements(e.subject.value,n)})).flat().map((function(e){return e.object.value})).filter((function(e){return!!e}))})).flat());case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function We(){return(We=q.default(k.default.mark((function e(t,r){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ne(t,"public",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Me(){return(Me=q.default(k.default.mark((function e(t,r){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ne(t,"private",r));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Qe(){return(Qe=q.default(k.default.mark((function e(t,r,n){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Le(t,r,"solid:instanceContainer",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Je(){return(Je=q.default(k.default.mark((function e(t,r,n){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Le(t,r,"solid:instance",n));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _e(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return He(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return He(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,u=function(){};return{s:u,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:u}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function He(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function $e(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=b.default(e);if(t){var u=b.default(this).constructor;r=Reflect.construct(n,arguments,u)}else r=n.apply(this,arguments);return x.default(this,r)}}var Ge={},Xe={"%uuid%":"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},Ke=function(e){y.default(ExpectedQuadAssertionError,e);var t=$e(ExpectedQuadAssertionError);function ExpectedQuadAssertionError(e){var r;return v.default(this,ExpectedQuadAssertionError),r=t.call(this,"Couldn't find the following triple: ".concat(me(e))),j.default(m.default(r),"expectedQuad",void 0),r.expectedQuad=e,r}return ExpectedQuadAssertionError}(a.JSError);function Ve(e,t){var r,n=_e(e);try{var u=function(){var e=r.value,n=t.find((function(t){return n=t,function(e,t){if(e.termType!==t.termType)return!1;if("Literal"===e.termType&&"Literal"===t.termType){if(e.datatype.value!==t.datatype.value)return!1;if(!Ye(e.value))return"http://www.w3.org/2001/XMLSchema#dateTime"===e.datatype.value?new Date(e.value).getTime()===new Date(t.value).getTime():e.value===t.value}return Ze(e.value,t.value)}((r=e).object,n.object)&&Ze(r.subject.value,n.subject.value)&&Ze(r.predicate.value,n.predicate.value);var r,n}));if(!n)throw new Ke(e);a.arrayRemove(t,n)};for(n.s();!(r=n.n()).done;)u()}catch(e){n.e(e)}finally{n.f()}}function Ye(e){return/\[\[(.*\]\[)?([^\]]+)\]\]/.test(e)}function Ze(e,t){var r,n;return Ye(e)?(null!==(n=(r=Ge)[e])&&void 0!==n?n:r[e]=function(e){var t,r=[],n=[],u=e,o=_e(a.stringMatchAll(e,/\[\[((.*?)\]\[)?([^\]]+)\]\]/g));try{for(o.s();!(t=o.n()).done;){var s=t.value;s[2]&&r.push(s[2]),n.push(s[3]),u=u.replace(s[0],"%PATTERN".concat(n.length-1,"%"))}}catch(e){o.e(e)}finally{o.f()}u=u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");for(var i=0,c=Object.entries(n);i<c.length;i++){var l,f=g.default(c[i],2),d=f[0],p=f[1];u=u.replace("%PATTERN".concat(d,"%"),null!==(l=Xe[p])&&void 0!==l?l:p)}return new RegExp(u)}(e)).test(t):e===t}function et(){Ge={}}function tt(e,t){return rt.apply(this,arguments)}function rt(){return(rt=q.default(k.default.mark((function e(t,r){var n,u,o,a,s;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return et(),e.next=3,ce(t);case 3:return n=e.sent,e.next=6,ce(r);case 6:if(u=e.sent,o=ve(n),a=ve(u),s=function(e,t){return{success:e,message:t,expected:o,actual:a}},n.length===u.length){e.next=12;break}return e.abrupt("return",s(!1,"Expected ".concat(n.length," triples, found ").concat(u.length,".")));case 12:e.prev=12,Ve(n,u),e.next=21;break;case 16:if(e.prev=16,e.t0=e.catch(12),e.t0 instanceof Ke){e.next=20;break}throw e.t0;case 20:return e.abrupt("return",s(!1,e.t0.message));case 21:return e.abrupt("return",s(!0,"jsonld matches"));case 22:case"end":return e.stop()}}),e,null,[[12,16]])})))).apply(this,arguments)}function nt(e,t){var r;et();for(var n=je(e,{normalizeBlankNodes:!0}),u=je(t,{normalizeBlankNodes:!0}),o=function(r,n){return{success:r,message:n,expected:e,actual:t}},s=0,i=Object.keys(n);s<i.length;s++){var c=i[s];if(!(c in u))return o(!1,"Couldn't find expected ".concat(c," operation."));var l=a.pull(n,c),f=a.pull(u,c);if(l.length!==f.length)return o(!1,"Expected ".concat(l.length," ").concat(c," triples, found ").concat(f.length,"."));try{Ve(l,f)}catch(e){if(!(e instanceof Ke))throw e;return o(!1,"Couldn't find the following ".concat(c," triple: ").concat(me(e.expectedQuad)))}}var d=null!==(r=Object.keys(u)[0])&&void 0!==r?r:null;return d?o(!1,"Did not expect to find ".concat(d," triples.")):o(!0,"sparql matches")}function ut(e,t){et();var r=qe(e,{normalizeBlankNodes:!0}),n=qe(t,{normalizeBlankNodes:!0}),u=function(r,n){return{success:r,message:n,expected:e,actual:t}};if(r.length!==n.length)return u(!1,"Expected ".concat(r.length," triples, found ").concat(n.length,"."));try{Ve(r,n)}catch(e){if(!(e instanceof Ke))throw e;return u(!1,e.message)}return u(!0,"turtle matches")}function ot(e,t){return at.apply(this,arguments)}function at(){return(at=q.default(k.default.mark((function e(t,r){var n,u,o,s,i,c,l;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null!==(n=r)&&void 0!==n?n:window.fetch.bind(window),e.next=3,r(t,{method:"HEAD"});case 3:if(i=e.sent,c=null!==(u=i.headers.get("Link"))&&void 0!==u?u:"",l=null!==(o=null===(s=c.match(/<([^>]+)>;\s*rel="acl"/))||void 0===s?void 0:s[1])&&void 0!==o?o:null){e.next=8;break}throw new Error("Could not find ACL Resource for '".concat(t,"'"));case 8:return e.abrupt("return",a.urlResolve(a.requireUrlParentDirectory(t),l));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function st(e,t,r){return it.apply(this,arguments)}function it(){return(it=q.default(k.default.mark((function e(t,r,n){var u,o,s;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(u=n)||void 0===u){e.next=4;break}e.t0=u,e.next=7;break;case 4:return e.next=6,ot(t,r);case 6:e.t0=e.sent;case 7:return n=e.t0,e.next=10,se(null!==(o=n)&&void 0!==o?o:"",{fetch:r});case 10:if(s=e.sent){e.next=13;break}return e.abrupt("return",st(a.requireUrlParentDirectory(t),r));case 13:if(!s.isACPResource()){e.next=15;break}throw new F(t,"ACP");case 15:return e.abrupt("return",s);case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function ct(){return(ct=q.default(k.default.mark((function e(t,r){var n,u;return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ot(t,r);case 2:return n=e.sent,e.next=5,st(t,r,n);case 5:return u=e.sent,e.abrupt("return",a.objectWithoutEmpty({url:n,effectiveUrl:u.url,document:u}));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var lt={turtle:function(e){var t=this._obj,r=this.assert.bind(this),n=ut(e,t);r(n.success,n.message,"",n.expected,n.actual)},sparql:function(e){var t=this._obj,r=this.assert.bind(this),n=nt(e,t);r(n.success,n.message,"",n.expected,n.actual)}};function ft(e,t){var r=e.success,n=t.context.utils;return{pass:r,message:r?function(){return[e.message,n.matcherHint(t.hint)].join("\n\n")}:function(){return[e.message,n.matcherHint(t.hint),["Expected: not ".concat(n.printExpected(t.expected)),"Received: ".concat(n.printReceived(t.received))].join("\n")].join("\n\n")}}}var dt={toEqualJsonLD:function(e,t){var r=this;return q.default(k.default.mark((function n(){var u;return k.default.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,tt(t,e);case 2:return u=n.sent,n.abrupt("return",ft(u,{context:r,hint:"toEqualJsonLD",expected:t,received:e}));case 4:case"end":return n.stop()}}),n)})))()},toEqualSparql:function(e,t){return ft(nt(t,e),{context:this,hint:"toEqualSparql",expected:fe(t),received:fe(e)})},toEqualTurtle:function(e,t){return ft(ut(t,e),{context:this,hint:"toEqualTurtle",expected:de(t),received:de(e)})}};function pt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var ht=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200;v.default(this,e),j.default(this,"rawBody",void 0),j.default(this,"body",void 0),j.default(this,"bodyUsed",void 0),j.default(this,"headers",void 0),j.default(this,"ok",void 0),j.default(this,"redirected",void 0),j.default(this,"status",void 0),j.default(this,"statusText",void 0),j.default(this,"trailer",void 0),j.default(this,"type",void 0),j.default(this,"url",void 0),this.rawBody=t,this.headers=new Headers(r),this.status=n}var t,r,n,u,o;return w.default(e,[{key:"arrayBuffer",value:(o=q.default(k.default.mark((function e(){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.arrayBuffer is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return o.apply(this,arguments)})},{key:"blob",value:(u=q.default(k.default.mark((function e(){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.blob is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return u.apply(this,arguments)})},{key:"formData",value:(n=q.default(k.default.mark((function e(){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("ResponseStub.formData is not implemented");case 1:case"end":return e.stop()}}),e)}))),function(){return n.apply(this,arguments)})},{key:"json",value:(r=q.default(k.default.mark((function e(){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",JSON.parse(this.rawBody));case 1:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"text",value:(t=q.default(k.default.mark((function e(){return k.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.rawBody);case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"clone",value:function(){return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pt(Object(r),!0).forEach((function(t){j.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},this)}}]),e}();exports.MalformedSolidDocumentError=I,exports.NetworkRequestError=D,exports.NotFoundError=O,exports.ResponseStub=ht,exports.SolidDocument=_,exports.SolidStore=Q,exports.SolidThing=M,exports.UnauthorizedError=U,exports.UnsuccessfulNetworkRequestError=B,exports.UnsupportedAuthorizationProtocolError=F,exports.compactJsonLDGraph=function(e){return H.apply(this,arguments)},exports.createPrivateTypeIndex=function(e,t){return Me.apply(this,arguments)},exports.createPublicTypeIndex=function(e,t){return We.apply(this,arguments)},exports.createSolidDocument=ne,exports.defineIRIPrefix=function(e,t){L[e]=t},exports.expandIRI=z,exports.fetchLoginUserProfile=function(e){return Oe.apply(this,arguments)},exports.fetchSolidDocument=oe,exports.fetchSolidDocumentACL=function(e,t){return ct.apply(this,arguments)},exports.fetchSolidDocumentIfFound=se,exports.findContainerRegistrations=function(e,t,r){return Qe.apply(this,arguments)},exports.findInstanceRegistrations=function(e,t,r){return Je.apply(this,arguments)},exports.installChaiPlugin=function(){chai.use((function(e){return Object.entries(lt).forEach((function(t){var r=g.default(t,2),n=r[0],u=r[1];return e.Assertion.addMethod(n,u)}))}))},exports.installJestPlugin=function(){expect.extend(dt)},exports.isJsonLDGraph=$,exports.jsonldEquals=tt,exports.jsonldToQuads=ce,exports.mintJsonLDIdentifiers=function(e){return a.tap(a.objectDeepClone(e),(function(e){return Ue(e)}))},exports.mockFetch=function(){var e=[],t={mockResponse:function(t,r,n){e.push(new ht(t,r,n))},mockNotFoundResponse:function(){e.push(new ht("",{},404))}},r=jest.fn(q.default(k.default.mark((function t(){var r;return k.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",null!==(r=e.shift())&&void 0!==r?r:a.fail("fetch mock called without response"));case 1:case"end":return t.stop()}}),t)}))));return Object.assign(r,t),r},exports.normalizeSparql=fe,exports.normalizeTurtle=de,exports.parseResourceSubject=function(e){var t=a.urlParse(e);return t?a.objectWithoutEmpty({containerUrl:Ae(t),documentName:t.path?t.path.split("/").pop():null,resourceHash:t.fragment}):{}},exports.parseTurtle=pe,exports.quadToTurtle=me,exports.quadsToJsonLD=function(e){return he.apply(this,arguments)},exports.quadsToTurtle=ve,exports.solidDocumentExists=ye,exports.sparqlEquals=nt,exports.sparqlToQuads=function(e){return be.apply(this,arguments)},exports.sparqlToQuadsSync=je,exports.turtleEquals=ut,exports.turtleToQuads=we,exports.turtleToQuadsSync=qe,exports.updateSolidDocument=ke;
|
|
2
|
-
//# sourceMappingURL=noeldemartin-solid-utils.cjs.js.map
|