@noeldemartin/solid-utils 0.4.0 → 0.5.0
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/.github/workflows/ci.yml +16 -0
- package/CHANGELOG.md +21 -0
- package/README.md +1 -1
- package/dist/noeldemartin-solid-utils.cjs.js +1 -1
- package/dist/noeldemartin-solid-utils.cjs.js.map +1 -1
- package/dist/noeldemartin-solid-utils.d.ts +17 -25
- package/dist/noeldemartin-solid-utils.esm.js +1 -1
- package/dist/noeldemartin-solid-utils.esm.js.map +1 -1
- package/dist/noeldemartin-solid-utils.umd.js +16 -16
- package/dist/noeldemartin-solid-utils.umd.js.map +1 -1
- package/package.json +3 -4
- package/src/helpers/auth.ts +25 -11
- package/src/helpers/interop.ts +4 -6
- package/src/helpers/io.ts +64 -11
- package/src/helpers/vocabs.ts +1 -0
- package/src/helpers/wac.ts +1 -1
- package/src/plugins/jest/matchers.ts +12 -2
- package/src/plugins/jest/types.d.ts +1 -0
- package/src/testing/index.ts +0 -1
- package/.semaphore/semaphore.yml +0 -26
- package/src/testing/faking.ts +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noeldemartin-solid-utils.cjs.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/vocabs.ts","../src/models/SolidDocument.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/helpers/wac.ts","../src/plugins/chai/assertions.ts","../src/plugins/jest/matchers.ts","../src/testing/faking.ts","../src/testing/ResponseStub.ts","../src/plugins/chai/index.ts","../src/plugins/jest/index.ts","../src/testing/mocking.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'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? messageOrResponse as Response;\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? messageOrResponse as Response;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\n }\n\n}\n","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 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'))\n 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)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/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.get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdf:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\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 parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\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 = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\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 type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/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\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.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 { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\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?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(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}\n","import { compactJsonLD } from '@noeldemartin/solid-utils-external';\nimport type { JsonLdDocument } from '@noeldemartin/solid-utils-external';\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(jsonld: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await compactJsonLD(jsonld 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(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import md5 from 'md5';\nimport {\n TurtleParser,\n TurtleWriter,\n createBlankNode,\n createQuad,\n jsonLDFromRDF,\n jsonLDToRDF,\n} from '@noeldemartin/solid-utils-external';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\nimport type { JsonLdDocument, Term } from '@noeldemartin/solid-utils-external';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD, JsonLDGraph, JsonLDResource } from '@/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\nasync function fetchRawSolidDocument(url: string, fetch: Fetch): Promise<{ body: string; headers: Headers }> {\n const options = {\n headers: { Accept: 'text/turtle' },\n };\n\n try {\n const response = await fetch(url, options);\n\n if (response.status === 404)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n 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)\n throw error;\n\n if (error instanceof NotFoundError)\n 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(\n (quad, index) => 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 )\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(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\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)\n continue;\n\n terms[termName] = createBlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n createQuad(\n terms.subject as Term,\n quad.predicate as Term,\n terms.object as Term,\n ),\n );\n }\n }\n\n return normalizedQuads;\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, fetch?: Fetch): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, fetch ?? window.fetch);\n const statements = await turtleToQuads(data, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(url: string, fetch?: Fetch): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n return document;\n } catch (error) {\n if (!(error instanceof NotFoundError))\n throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(resource => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n return jsonLDToRDF(jsonld as JsonLdDocument, { base: baseIRI }) as Promise<Quad[]>;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object\n .entries(quads)\n .reduce((normalizedOperations, [operation, quads]) => {\n const normalizedQuads = quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function parseTurtle(turtle: string, options: Partial<ParsingOptions> = {}): Promise<RDFGraphData> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new TurtleParser(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(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\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 jsonLDFromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\n };\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, fetch?: Fetch): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, fetch);\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([...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 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 TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : 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","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...string[]];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(webIdDocument: SolidDocument, fetch?: Fetch): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map(quad => quad.object.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map(quad => quad.subject.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const document = await fetchSolidDocument(url, fetch);\n\n documents[url] = document;\n store.addQuads(document.getQuads());\n\n addReferencedDocumentUrls(document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some(document => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some(document => document === false),\n writableProfileUrl:\n webIdDocument.isUserWritable()\n ? webIdDocument.url\n : Object\n .values(documents)\n .find((document): document is SolidDocument => !!document && document.isUserWritable())\n ?.url ?? null,\n };\n}\n\nasync function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUserProfile> {\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, fetch);\n\n if (!document.isPersonalProfile() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, fetch);\n const storageUrls = store.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, fetch));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\n ...objectWithoutEmpty({\n name:\n store.statement(webId, 'vcard:fn')?.object.value ??\n store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchLoginUserProfileOptions {\n required?: boolean;\n fetch?: Fetch;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options.fetch);\n }\n\n const fetchProfile = silenced(url => fetchUserProfile(url, options.fetch));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/'))\n return null;\n\n if (parts.path.match(/^\\/[^/]*$/))\n return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld)\n return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue))\n __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue))\n propertyValue.forEach(value => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, clone => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts ? {} : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, fetch)\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody = type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await Promise.all([\n createSolidDocument(typeIndexUrl, typeIndexBody, fetch),\n updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch),\n ]);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, fetch);\n const types = Array.isArray(type) ? type : [type];\n\n return types.map(\n type => typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter(statement => typeIndex.contains(statement.subject.value, 'solid:forClass', type))\n .map(statement => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map(statement => statement.object.value)\n .filter(url => !!url),\n ).flat();\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { JsonLD } from '@/helpers/jsonld';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\nconst builtInPatterns: Record<string, string> = {\n '%uuid%': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n};\n\nclass ExpectedQuadAssertionError extends JSError {\n\n constructor(public readonly expectedQuad: Quad) {\n super(`Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n}\n\nfunction assertExpectedQuadsExist(expectedQuads: Quad[], actualQuads: Quad[]): void {\n for (const expectedQuad of expectedQuads) {\n const matchingQuad = actualQuads.find(actualQuad => quadEquals(expectedQuad, actualQuad));\n\n if (!matchingQuad)\n throw new ExpectedQuadAssertionError(expectedQuad);\n\n arrayRemove(actualQuads, matchingQuad);\n }\n}\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction createPatternRegexp(expected: string): RegExp {\n const patternAliases = [];\n const patternMatches = stringMatchAll<4, 1 | 2>(\n expected,\n /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g,\n );\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n patternMatch[2] && patternAliases.push(patternMatch[2]);\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, builtInPatterns[pattern] ?? pattern);\n }\n\n return new RegExp(expectedRegExp);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n return containsPatterns(expected)\n ? (patternsRegExpsIndex[expected] ??= createPatternRegexp(expected)).test(actual)\n : expected === actual;\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(\n false,\n `Couldn't find the following ${operation} triple: ${quadToTurtle(error.expectedQuad)}`,\n );\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\nimport UnsupportedAuthorizationProtocolError from '@/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@/helpers/io';\nimport type SolidDocument from '@/models/SolidDocument';\nimport type { Fetch } from '@/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? await fetchACLResourceUrl(resourceUrl, fetch);\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', fetch);\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import { normalizeSparql } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n ].join('\\n\\n')\n : () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n');\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n};\n\nexport default matchers;\n","import { faker } from '@noeldemartin/faker';\nimport { stringToSlug } from '@noeldemartin/utils';\n\nexport interface ContainerOptions {\n baseUrl: string;\n}\n\nexport interface DocumentOptions extends ContainerOptions {\n containerUrl: string;\n name: string;\n}\n\nexport interface ResourceOptions extends DocumentOptions {\n documentUrl: string;\n hash: string;\n}\n\nexport function fakeContainerUrl(options: Partial<ContainerOptions> = {}): string {\n const baseUrl = options.baseUrl ?? faker.internet.url();\n\n return baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';\n}\n\nexport function fakeDocumentUrl(options: Partial<DocumentOptions> = {}): string {\n const containerUrl = options.containerUrl ?? fakeContainerUrl(options);\n const name = options.name ?? faker.random.word();\n\n return containerUrl + stringToSlug(name);\n}\n\nexport function fakeResourceUrl(options: Partial<ResourceOptions> = {}): string {\n const documentUrl = options.documentUrl ?? fakeDocumentUrl(options);\n const hash = options.hash ?? 'it';\n\n return documentUrl + '#' + hash;\n}\n","export default class ResponseStub implements Response {\n\n private rawBody: string;\n\n public readonly body!: ReadableStream<Uint8Array> | null;\n public readonly bodyUsed!: boolean;\n public readonly headers: Headers;\n public readonly ok!: boolean;\n public readonly redirected!: boolean;\n public readonly status: number;\n public readonly statusText!: string;\n public readonly trailer!: Promise<Headers>;\n public readonly type!: ResponseType;\n public readonly url!: string;\n\n public constructor(rawBody: string = '', headers: Record<string, string> = {}, status: number = 200) {\n this.rawBody = rawBody;\n this.headers = new Headers(headers);\n this.status = status;\n }\n\n public async arrayBuffer(): Promise<ArrayBuffer> {\n throw new Error('ResponseStub.arrayBuffer is not implemented');\n }\n\n public async blob(): Promise<Blob> {\n throw new Error('ResponseStub.blob is not implemented');\n }\n\n public async formData(): Promise<FormData> {\n throw new Error('ResponseStub.formData is not implemented');\n }\n\n public async json(): Promise<unknown> {\n return JSON.parse(this.rawBody);\n }\n\n public async text(): Promise<string> {\n return this.rawBody;\n }\n\n public clone(): Response {\n return { ...this };\n }\n\n}\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n","import { fail } from '@noeldemartin/utils';\nimport type { GetClosureArgs } from '@noeldemartin/utils';\n\nimport type { Fetch } from '@/helpers/io';\n\nimport ResponseStub from './ResponseStub';\n\nexport interface FetchMockMethods {\n mockResponse(body?: string, headers?: Record<string, string>, status?: number): void;\n mockNotFoundResponse(): void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mockFetch<T = any>(): T {\n const responses: ResponseStub[] = [];\n const methods: FetchMockMethods = {\n mockResponse(body, headers, status) {\n responses.push(new ResponseStub(body, headers, status));\n },\n mockNotFoundResponse() {\n responses.push(new ResponseStub('', {}, 404));\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const fetchMock = jest.fn(async (...args: GetClosureArgs<Fetch>) => {\n return responses.shift() ?? fail<Response>('fetch mock called without response');\n });\n\n Object.assign(fetchMock, methods);\n\n return fetchMock as unknown as T;\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","documentUrl","documentFormat","malformationDetails","errorMessage","JSError","NetworkRequestError","url","options","NotFoundError","UnauthorizedError","responseStatus","this","undefined","UnsuccessfulRequestError","messageOrResponse","response","status","getErrorMessage","UnsupportedAuthorizationProtocolError","protocol","knownPrefixes","acl","foaf","pim","purl","rdf","rdfs","schema","solid","vcard","expandIRI","iri","startsWith","split","prefix","name","expandedPrefix","extraContext","_options$extraContext","Error","defaultPrefix","SolidDocumentPermission","SolidThing","quads","property","find","quad","predicate","value","_this$quads$find","object","filter","map","SolidStore","statements","length","slice","push","subject","statement","_this","_this2","SolidDocument","headers","get","_this$headers$get","match","_this$headers$get2","getUserPermissions","includes","Write","getPermissionsFromWAC","parseDate","_this$statement","getLatestDocumentDate","dates","date","reduce","a","b","type","wacAllow","publicModes","stringMatch","RegExp","_stringMatch","arrayFilter","Read","Append","Control","jsonld","compactJsonLD","compactedJsonLD","isJsonLDGraph","fetchRawSolidDocument","fetch","Accept","text","body","_context","cause","normalizeBlankNodes","normalizedQuads","quadsIndexes","arr","flatMap","index","tap","termType","ids","forEach","id","Set","add","unique","originalId","quadIndexes","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","createBlankNode","arrayReplace","createQuad","createSolidDocument","window","bind","turtleToQuads","method","Headers","fetchSolidDocument","data","baseIRI","fetchSolidDocumentIfFound","document","_context4","jsonldToQuads","Promise","all","resource","graphQuads","flat","jsonLDToRDF","base","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","quadToTurtle","sort","concat","toUpperCase","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","TurtleParser","containsRelativeIRIs","resolve","reject","resolveRelativeIRI","_resolveRelativeIRI","parse","error","Turtle","message","jsonLDFromRDF","graph","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","isEmpty","operations","stringMatchAll","_toConsumableArray","operationName","toLowerCase","operationBody","turtleToQuadsSync","updateSolidDocument","fetchExtendedUserProfile","webIdDocument","store","getQuads","documents","addReferencedDocumentUrls","profileDocumentUrl","loadProfileDocuments","addQuads","values","some","cloaked","writableProfileUrl","isUserWritable","_Object$values$find","fetchUserProfile","webId","urlRoute","isPersonalProfile","contains","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","arrayUnique","_store$statement","_store$statement2","avatarUrl","_store$statement3","_store$statement4","oidcIssuerUrl","_store$statement5","publicTypeIndexUrl","privateTypeIndexUrl","loginUrl","required","fetchProfile","replace","urlRoot","getContainerUrl","parts","containerPath","path","getContainerPath","domain","__mintJsonLDIdentifiers","uuid","propertyValue","isObject","isArray","mintTypeIndexUrl","user","storageUrl","typeIndexUrl","createTypeIndex","typeIndexBody","profileUpdateBody","findRegistrations","typeIndex","types","Array","patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","expectedQuad","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","actual","expected","datatype","containsPatterns","Date","getTime","quadValueEquals","quadObjectEquals","arrayRemove","test","_patternsRegExpsIndex","patternAliases","patterns","expectedRegExp","patternMatch","patternIndex","pattern","createPatternRegexp","resetPatterns","jsonldEquals","expectedTurtle","actualTurtle","result","success","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","fetchACLResourceUrl","resourceUrl","resourceHead","linkHeader","_linkHeader$match","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","isACPResource","effectiveUrl","assertions","_obj","assert","query","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","fakeContainerUrl","baseUrl","faker","internet","endsWith","fakeDocumentUrl","containerUrl","random","word","stringToSlug","ResponseStub","rawBody","JSON","hash","chai","use","_chai","Assertion","addMethod","expect","extend","objectDeepClone","clone","responses","methods","mockResponse","mockNotFoundResponse","fetchMock","jest","fn","shift","fail","assign","urlParse","documentName","pop","resourceHash","fragment"],"mappings":"shKAYYA,oCAAAA,8BAAAA,qDAISC,iIAMLC,EAA4BC,EAAqCC,0EApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,wJAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,wCAXsBE,8cCbpCC,yGAILC,EAAaC,2GACmBD,GAAOC,0CAE1CD,IAAMA,gCAP8BF,8cCD5BI,uFAILF,qFACgBA,6DAEnBA,IAAMA,0BAPwBF,8cCMtBK,mGAKLH,EAAaI,gEAX7B,SAAsBJ,EAAaI,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBJ,GASzBH,CAAaG,EAAKI,2FAEnBJ,IAAMA,IACNI,eAAiBA,6DAG1B,uBAC0C,IAAxBC,KAAKD,eAC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AAQP,2BAAeuU,GAAgBhU,GACrDwU,YAAOxU,EAAQwU,oBAAQ,YAEtB/U,EAAc,IAAM+U,0aE/B3BC,KAAKC,KAAI,SAAAC,UAASxN,OAAOC,QAAQuL,IAAYpM,SAAQ,iCAAE3E,OAAMkG,cAAY6M,EAAMC,UAAUC,UAAUjT,EAAMkG,+CCAzGgN,OAAOC,OAAOvB,qHTwCoBrO,UAC3BiB,MAAI4O,kBAAgB7P,IAA2B,SAAA8P,UAAS1G,GAAwB0G,wCU9BjFC,EAA4B,GAC5BC,EAA4B,CAC9BC,sBAAazP,EAAMnC,EAAS/C,GACxByU,EAAUhS,KAAK,IAAImR,GAAa1O,EAAMnC,EAAS/C,KAEnD4U,gCACIH,EAAUhS,KAAK,IAAImR,GAAa,GAAI,GAAI,QAK1CiB,EAAYC,KAAKC,6BAAG,6HACfN,EAAUO,uBAAWC,OAAe,0FAG/CvO,OAAOwO,OAAOL,EAAWH,GAElBG,oEVgB0BnS,OAC3B+K,EAAQ0H,WAASzS,UAEf+K,EAAaxE,qBAAmB,CACpCuK,aAAchG,GAAgBC,GAC9B2H,aAAc3H,EAAME,KAAOF,EAAME,KAAK1M,MAAM,KAAKoU,MAAQ,KACzDC,aAAc7H,EAAM8H,WAHR"}
|
|
1
|
+
{"version":3,"file":"noeldemartin-solid-utils.cjs.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/vocabs.ts","../src/models/SolidDocument.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/testing.ts","../src/helpers/wac.ts","../src/plugins/chai/assertions.ts","../src/plugins/jest/matchers.ts","../src/testing/ResponseStub.ts","../src/plugins/chai/index.ts","../src/plugins/jest/index.ts","../src/testing/mocking.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'\n ? this.responseStatus === 403\n : undefined;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? messageOrResponse as Response;\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? messageOrResponse as Response;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\n }\n\n}\n","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'))\n 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)\n throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix)\n throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/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.get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(\n this.url,\n expandIRI('rdf:type'),\n expandIRI('foaf:PersonalProfileDocument'),\n );\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 parseDate(this.headers.get('last-modified'))\n ?? parseDate(this.statement(this.url, 'purl:modified')?.object.value)\n ?? this.getLatestDocumentDate()\n ?? null;\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 = [\n ...this.statements(undefined, 'purl:modified'),\n ...this.statements(undefined, 'purl:created'),\n ]\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 type { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/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\n .find(quad => quad.predicate.value === expandIRI(property))\n ?.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 { Quad } from 'rdf-js';\n\nimport { expandIRI } from '@/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\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?: string, predicate?: string, object?: string): Quad[] {\n return this.quads.filter(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(predicate)),\n );\n }\n\n public statement(subject?: string, predicate?: string, object?: string): Quad | null {\n const statement = this.quads.find(\n statement =>\n (!object || statement.object.value === this.expandIRI(object)) &&\n (!subject || statement.subject.value === this.expandIRI(subject)) &&\n (!predicate || statement.predicate.value === this.expandIRI(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}\n","import { compactJsonLD } from '@noeldemartin/solid-utils-external';\nimport type { JsonLdDocument } from '@noeldemartin/solid-utils-external';\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(jsonld: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await compactJsonLD(jsonld 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(jsonld: JsonLD): jsonld is JsonLDGraph {\n return '@graph' in jsonld;\n}\n","import md5 from 'md5';\nimport {\n TurtleParser,\n TurtleWriter,\n createBlankNode,\n createQuad,\n jsonLDFromRDF,\n jsonLDToRDF,\n} from '@noeldemartin/solid-utils-external';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport type { Quad } from 'rdf-js';\nimport type { JsonLdDocument, Term } from '@noeldemartin/solid-utils-external';\n\nimport SolidDocument from '@/models/SolidDocument';\n\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@/errors/NetworkRequestError';\nimport NotFoundError from '@/errors/NotFoundError';\nimport UnauthorizedError from '@/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@/helpers/jsonld';\nimport type { JsonLD, JsonLDGraph, JsonLDResource } from '@/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)\n throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status))\n 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)\n throw error;\n\n if (error instanceof NotFoundError)\n 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(\n (quad, index) => 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 )\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(\n ({ predicate, object }) => object.termType === 'BlankNode'\n ? predicate.value\n : predicate.value + object.value,\n )\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)\n continue;\n\n terms[termName] = createBlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n createQuad(\n terms.subject as Term,\n quad.predicate as Term,\n terms.object as Term,\n ),\n );\n }\n }\n\n return normalizedQuads;\n}\n\nfunction normalizeQuads(quads: Quad[]): string {\n return quads.map(quad => ' ' + quadToTurtle(quad)).sort().join('\\n');\n}\n\nfunction preprocessSubjects(jsonld: JsonLD): void {\n if (!jsonld['@id']?.startsWith('#')) {\n return;\n }\n\n jsonld['@id'] = ANONYMOUS_PREFIX + jsonld['@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))\n throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(jsonld)) {\n const graphQuads = await Promise.all(jsonld['@graph'].map(resource => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n preprocessSubjects(jsonld);\n\n const quads = await (jsonLDToRDF(jsonld 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\n .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 TurtleParser(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(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n error.message,\n ),\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 jsonLDFromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\n };\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new TurtleWriter;\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new TurtleWriter;\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([...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 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 TurtleParser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes\n ? normalizeBlankNodes(quads)\n : 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","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch, FetchSolidDocumentOptions } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...string[]];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(webIdDocument: SolidDocument, options?: FetchSolidDocumentOptions): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map(quad => quad.object.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map(quad => quad.subject.value)\n .forEach(profileDocumentUrl => documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null);\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const document = await fetchSolidDocument(url, options);\n\n documents[url] = document;\n store.addQuads(document.getQuads());\n\n addReferencedDocumentUrls(document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some(document => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some(document => document === false),\n writableProfileUrl:\n webIdDocument.isUserWritable()\n ? webIdDocument.url\n : Object\n .values(documents)\n .find((document): document is SolidDocument => !!document && document.isUserWritable())\n ?.url ?? null,\n };\n}\n\nasync function fetchUserProfile(webId: string, options: FetchUserProfileOptions = {}): Promise<SolidUserProfile> {\n const requestOptions: FetchSolidDocumentOptions = {\n fetch: options.fetch,\n\n // Needed for CSS v7.1.3.\n // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972\n cache: 'no-store',\n };\n\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, requestOptions);\n\n if (!document.isPersonalProfile() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, options);\n const storageUrls = store.statements(webId, 'pim:storage').map(storage => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, requestOptions));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n await options.onLoaded?.(new SolidStore(store.statements(webId)));\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\n ...objectWithoutEmpty({\n name:\n store.statement(webId, 'vcard:fn')?.object.value ??\n store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchUserProfileOptions {\n fetch?: Fetch;\n onLoaded?(store: SolidStore): Promise<unknown> | unknown;\n}\n\nexport interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {\n required?: boolean;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options);\n }\n\n const fetchProfile = silenced(url => fetchUserProfile(url, options));\n\n return await fetchProfile(loginUrl)\n ?? await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))\n ?? await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me'));\n}\n","import { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/'))\n return null;\n\n if (parts.path.match(/^\\/[^/]*$/))\n return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld)\n return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue))\n __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue))\n propertyValue.forEach(value => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, clone => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts ? {} : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport { createSolidDocument, fetchSolidDocument, solidDocumentExists, updateSolidDocument } from '@/helpers/io';\nimport type { Fetch } from '@/helpers/io';\nimport type { SolidUserProfile } from '@/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return await solidDocumentExists(typeIndexUrl, { fetch })\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody = type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n await updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, { fetch });\n const types = Array.isArray(type) ? type : [type];\n\n return types.map(\n type => typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter(statement => typeIndex.contains(statement.subject.value, 'solid:forClass', type))\n .map(statement => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map(statement => statement.object.value)\n .filter(url => !!url),\n ).flat();\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { JsonLD } from '@/helpers/jsonld';\nimport type { Quad, Quad_Object } from 'rdf-js';\n\nimport { jsonldToQuads, quadToTurtle, quadsToTurtle, sparqlToQuadsSync, turtleToQuadsSync } from './io';\n\nlet patternsRegExpsIndex: Record<string, RegExp> = {};\nconst builtInPatterns: Record<string, string> = {\n '%uuid%': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n};\n\nclass ExpectedQuadAssertionError extends JSError {\n\n constructor(public readonly expectedQuad: Quad) {\n super(`Couldn't find the following triple: ${quadToTurtle(expectedQuad)}`);\n }\n\n}\n\nfunction assertExpectedQuadsExist(expectedQuads: Quad[], actualQuads: Quad[]): void {\n for (const expectedQuad of expectedQuads) {\n const matchingQuad = actualQuads.find(actualQuad => quadEquals(expectedQuad, actualQuad));\n\n if (!matchingQuad)\n throw new ExpectedQuadAssertionError(expectedQuad);\n\n arrayRemove(actualQuads, matchingQuad);\n }\n}\n\nfunction containsPatterns(value: string): boolean {\n return /\\[\\[(.*\\]\\[)?([^\\]]+)\\]\\]/.test(value);\n}\n\nfunction createPatternRegexp(expected: string): RegExp {\n const patternAliases = [];\n const patternMatches = stringMatchAll<4, 1 | 2>(\n expected,\n /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g,\n );\n const patterns: string[] = [];\n let expectedRegExp = expected;\n\n for (const patternMatch of patternMatches) {\n patternMatch[2] && patternAliases.push(patternMatch[2]);\n\n patterns.push(patternMatch[3]);\n\n expectedRegExp = expectedRegExp.replace(patternMatch[0], `%PATTERN${patterns.length - 1}%`);\n }\n\n expectedRegExp = expectedRegExp.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&');\n\n for (const [patternIndex, pattern] of Object.entries(patterns)) {\n expectedRegExp = expectedRegExp.replace(`%PATTERN${patternIndex}%`, builtInPatterns[pattern] ?? pattern);\n }\n\n return new RegExp(expectedRegExp);\n}\n\nfunction quadValueEquals(expected: string, actual: string): boolean {\n return containsPatterns(expected)\n ? (patternsRegExpsIndex[expected] ??= createPatternRegexp(expected)).test(actual)\n : expected === actual;\n}\n\nfunction quadObjectEquals(expected: Quad_Object, actual: Quad_Object): boolean {\n if (expected.termType !== actual.termType)\n return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value)\n return false;\n\n if (!containsPatterns(expected.value))\n return expected.datatype.value === 'http://www.w3.org/2001/XMLSchema#dateTime'\n ? new Date(expected.value).getTime() === new Date(actual.value).getTime()\n : expected.value === actual.value;\n }\n\n return quadValueEquals(expected.value, actual.value);\n}\n\nfunction quadEquals(expected: Quad, actual: Quad): boolean {\n return quadObjectEquals(expected.object, actual.object)\n && quadValueEquals(expected.subject.value, actual.subject.value)\n && quadValueEquals(expected.predicate.value, actual.predicate.value);\n}\n\nfunction resetPatterns(): void {\n patternsRegExpsIndex = {};\n}\n\nexport interface EqualityResult {\n success: boolean;\n message: string;\n expected: string;\n actual: string;\n}\n\nexport async function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult> {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = await jsonldToQuads(expected);\n const actualQuads = await jsonldToQuads(actual);\n const expectedTurtle = quadsToTurtle(expectedQuads);\n const actualTurtle = quadsToTurtle(actualQuads);\n const result = (success: boolean, message: string) => ({\n success,\n message,\n expected: expectedTurtle,\n actual: actualTurtle,\n });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'jsonld matches');\n}\n\nexport function sparqlEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedOperations = sparqlToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualOperations = sparqlToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n for (const operation of Object.keys(expectedOperations)) {\n if (!(operation in actualOperations))\n return result(false, `Couldn't find expected ${operation} operation.`);\n\n const expectedQuads = pull(expectedOperations, operation);\n const actualQuads = pull(actualOperations, operation);\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} ${operation} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(\n false,\n `Couldn't find the following ${operation} triple: ${quadToTurtle(error.expectedQuad)}`,\n );\n }\n }\n\n const unexpectedOperation = Object.keys(actualOperations)[0] ?? null;\n if (unexpectedOperation)\n return result(false, `Did not expect to find ${unexpectedOperation} triples.`);\n\n return result(true, 'sparql matches');\n}\n\nexport function turtleEquals(expected: string, actual: string): EqualityResult {\n // TODO catch parsing errors and improve message.\n resetPatterns();\n\n const expectedQuads = turtleToQuadsSync(expected, { normalizeBlankNodes: true });\n const actualQuads = turtleToQuadsSync(actual, { normalizeBlankNodes: true });\n const result = (success: boolean, message: string) => ({ success, message, expected, actual });\n\n if (expectedQuads.length !== actualQuads.length)\n return result(false, `Expected ${expectedQuads.length} triples, found ${actualQuads.length}.`);\n\n try {\n assertExpectedQuadsExist(expectedQuads, actualQuads);\n } catch (error) {\n if (!(error instanceof ExpectedQuadAssertionError))\n throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\nimport UnsupportedAuthorizationProtocolError from '@/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@/helpers/io';\nimport type SolidDocument from '@/models/SolidDocument';\nimport type { Fetch } from '@/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? await fetchACLResourceUrl(resourceUrl, fetch);\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', { fetch });\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\n}\n","import { sparqlEquals, turtleEquals } from '@/helpers/testing';\n\ntype CustomAssertions = {\n [assertion in keyof typeof assertions]: typeof assertions[assertion];\n};\n\ndeclare global {\n\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n\n interface Assertion extends CustomAssertions {}\n interface Include extends CustomAssertions {}\n\n }\n\n}\n\nconst assertions: Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void> = {\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n};\n\nexport default assertions;\n","import { normalizeSparql, normalizeTurtle } from '@/helpers/io';\nimport { jsonldEquals, sparqlEquals, turtleEquals } from '@/helpers/testing';\nimport type { EqualityResult } from '@/helpers/testing';\n\ninterface FormatResultOptions {\n context: jest.MatcherContext;\n hint: string;\n expected: unknown;\n received: unknown;\n}\n\nfunction formatResult(result: EqualityResult, options: FormatResultOptions) {\n const pass = result.success;\n const utils = options.context.utils;\n const message = pass\n ? () => [\n result.message,\n utils.matcherHint(options.hint),\n ].join('\\n\\n')\n : () => [\n result.message,\n utils.matcherHint(options.hint),\n [\n `Expected: not ${utils.printExpected(options.expected)}`,\n `Received: ${utils.printReceived(options.received)}`,\n ].join('\\n'),\n ].join('\\n\\n');\n\n return { pass, message };\n}\n\nconst matchers: jest.ExpectExtendMap = {\n async toEqualJsonLD(received, expected) {\n const result = await jsonldEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualJsonLD',\n expected,\n received,\n });\n },\n toEqualSparql(received, expected) {\n const result = sparqlEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualSparql',\n expected: normalizeSparql(expected),\n received: normalizeSparql(received),\n });\n },\n toEqualTurtle(received, expected) {\n const result = turtleEquals(expected, received);\n\n return formatResult(result, {\n context: this,\n hint: 'toEqualTurtle',\n expected: normalizeTurtle(expected),\n received: normalizeTurtle(received),\n });\n },\n};\n\nexport default matchers;\n","export default class ResponseStub implements Response {\n\n private rawBody: string;\n\n public readonly body!: ReadableStream<Uint8Array> | null;\n public readonly bodyUsed!: boolean;\n public readonly headers: Headers;\n public readonly ok!: boolean;\n public readonly redirected!: boolean;\n public readonly status: number;\n public readonly statusText!: string;\n public readonly trailer!: Promise<Headers>;\n public readonly type!: ResponseType;\n public readonly url!: string;\n\n public constructor(rawBody: string = '', headers: Record<string, string> = {}, status: number = 200) {\n this.rawBody = rawBody;\n this.headers = new Headers(headers);\n this.status = status;\n }\n\n public async arrayBuffer(): Promise<ArrayBuffer> {\n throw new Error('ResponseStub.arrayBuffer is not implemented');\n }\n\n public async blob(): Promise<Blob> {\n throw new Error('ResponseStub.blob is not implemented');\n }\n\n public async formData(): Promise<FormData> {\n throw new Error('ResponseStub.formData is not implemented');\n }\n\n public async json(): Promise<unknown> {\n return JSON.parse(this.rawBody);\n }\n\n public async text(): Promise<string> {\n return this.rawBody;\n }\n\n public clone(): Response {\n return { ...this };\n }\n\n}\n","import assertions from './assertions';\n\nexport function installChaiPlugin(): void {\n chai.use(_chai => Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method)));\n}\n","import matchers from './matchers';\n\nexport function installJestPlugin(): void {\n expect.extend(matchers);\n}\n","import { fail } from '@noeldemartin/utils';\nimport type { GetClosureArgs } from '@noeldemartin/utils';\n\nimport type { Fetch } from '@/helpers/io';\n\nimport ResponseStub from './ResponseStub';\n\nexport interface FetchMockMethods {\n mockResponse(body?: string, headers?: Record<string, string>, status?: number): void;\n mockNotFoundResponse(): void;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mockFetch<T = any>(): T {\n const responses: ResponseStub[] = [];\n const methods: FetchMockMethods = {\n mockResponse(body, headers, status) {\n responses.push(new ResponseStub(body, headers, status));\n },\n mockNotFoundResponse() {\n responses.push(new ResponseStub('', {}, 404));\n },\n };\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const fetchMock = jest.fn(async (...args: GetClosureArgs<Fetch>) => {\n return responses.shift() ?? fail<Response>('fetch mock called without response');\n });\n\n Object.assign(fetchMock, methods);\n\n return fetchMock as unknown as T;\n}\n"],"names":["SolidDocumentFormat","MalformedSolidDocumentError","documentUrl","documentFormat","malformationDetails","errorMessage","JSError","NetworkRequestError","url","options","NotFoundError","UnauthorizedError","responseStatus","this","undefined","UnsuccessfulRequestError","messageOrResponse","response","status","getErrorMessage","UnsupportedAuthorizationProtocolError","protocol","knownPrefixes","acl","foaf","ldp","pim","purl","rdf","rdfs","schema","solid","vcard","expandIRI","iri","startsWith","split","prefix","name","expandedPrefix","extraContext","_options$extraContext","Error","defaultPrefix","SolidDocumentPermission","SolidThing","quads","property","find","quad","predicate","value","_this$quads$find","object","filter","map","SolidStore","statements","length","slice","push","subject","statement","_this","_this2","SolidDocument","headers","get","_this$headers$get","match","_this$headers$get2","getUserPermissions","includes","Write","getPermissionsFromWAC","parseDate","_this$statement","getLatestDocumentDate","dates","date","reduce","a","b","type","wacAllow","publicModes","stringMatch","RegExp","_stringMatch","arrayFilter","Read","Append","Control","jsonld","compactJsonLD","compactedJsonLD","isJsonLDGraph","ANONYMOUS_PREFIX_LENGTH","fetchRawSolidDocument","requestOptions","Accept","cache","fetch","window","text","body","_context","cause","normalizeBlankNodes","normalizedQuads","quadsIndexes","arr","flatMap","index","tap","termType","ids","forEach","id","Set","add","unique","originalId","quadIndexes","normalizedId","md5","sorted","join","terms","Object","entries","termName","termValue","createBlankNode","arrayReplace","createQuad","normalizeQuads","quadToTurtle","sort","preprocessSubjects","_jsonld$Id","postprocessSubjects","createSolidDocument","bind","turtleToQuads","method","Headers","fetchSolidDocument","data","baseIRI","fetchSolidDocumentIfFound","document","_context4","jsonldToQuads","Promise","all","resource","graphQuads","flat","jsonLDToRDF","base","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","concat","toUpperCase","normalizeTurtle","turtleToQuadsSync","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","TurtleParser","containsRelativeIRIs","resolve","reject","resolveRelativeIRI","_resolveRelativeIRI","parse","error","Turtle","message","jsonLDFromRDF","graph","quadsToTurtle","TurtleWriter","quadsToString","solidDocumentExists","isEmpty","operations","stringMatchAll","_toConsumableArray","operationName","toLowerCase","operationBody","updateSolidDocument","fetchExtendedUserProfile","webIdDocument","store","getQuads","documents","addReferencedDocumentUrls","profileDocumentUrl","loadProfileDocuments","addQuads","values","some","cloaked","writableProfileUrl","isUserWritable","_Object$values$find","fetchUserProfile","webId","urlRoute","isPersonalProfile","contains","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","silenced","parentDocument","isStorage","onLoaded","_options$onLoaded","arrayUnique","_store$statement","_store$statement2","avatarUrl","_store$statement3","_store$statement4","oidcIssuerUrl","_store$statement5","publicTypeIndexUrl","privateTypeIndexUrl","loginUrl","required","fetchProfile","replace","urlRoot","getContainerUrl","parts","containerPath","path","getContainerPath","domain","__mintJsonLDIdentifiers","uuid","propertyValue","isObject","isArray","mintTypeIndexUrl","user","storageUrl","typeIndexUrl","createTypeIndex","typeIndexBody","profileUpdateBody","findRegistrations","typeIndex","types","Array","patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","expectedQuad","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","actual","expected","datatype","containsPatterns","Date","getTime","quadValueEquals","quadObjectEquals","arrayRemove","test","_patternsRegExpsIndex","patternAliases","patterns","expectedRegExp","patternMatch","patternIndex","pattern","createPatternRegexp","resetPatterns","jsonldEquals","expectedTurtle","actualTurtle","result","success","sparqlEquals","expectedOperations","actualOperations","keys","pull","unexpectedOperation","turtleEquals","fetchACLResourceUrl","resourceUrl","resourceHead","linkHeader","_linkHeader$match","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","isACPResource","effectiveUrl","assertions","_obj","assert","query","formatResult","pass","utils","context","matcherHint","hint","printExpected","printReceived","received","matchers","toEqualJsonLD","toEqualSparql","toEqualTurtle","ResponseStub","rawBody","JSON","chai","use","_chai","Assertion","addMethod","expect","extend","objectDeepClone","clone","responses","methods","mockResponse","mockNotFoundResponse","fetchMock","jest","fn","shift","fail","assign","urlParse","containerUrl","documentName","pop","resourceHash","fragment"],"mappings":"+7JAYYA,oCAAAA,8BAAAA,qDAISC,iIAMLC,EAA4BC,EAAqCC,0EApBjF,SACIF,EACAC,EACAC,UAEOF,sBACYC,gCAAoCD,gBAAiBE,uBACrDD,yBAA6BC,GActCC,CAAaH,EAAaC,EAAgBC,wJAE3CF,YAAcA,IACdC,eAAiBA,IACjBC,oBAAsBA,wCAXsBE,8cCbpCC,yGAILC,EAAaC,2GACmBD,GAAOC,0CAE1CD,IAAMA,gCAP8BF,8cCD5BI,uFAILF,qFACgBA,6DAEnBA,IAAMA,0BAPwBF,8cCMtBK,mGAKLH,EAAaI,gEAX7B,SAAsBJ,EAAaI,+BACK,MAAnBA,EAAyB,eAAiB,gBAExBJ,GASzBH,CAAaG,EAAKI,2FAEnBJ,IAAMA,IACNI,eAAiBA,6DAG1B,uBAC0C,IAAxBC,KAAKD,eACW,MAAxBC,KAAKD,oBACLE,yBAfiCR,8cCE1BS,wHAMLC,EAAsCC,uEAdtD,SAAyBD,EAAsCC,gBAC3DA,YAAWA,iBAAYD,EAEa,iBAAtBA,YACLA,wBAA+BC,EAASC,6CAC7BD,EAAST,yBAAgBS,EAASC,uBAU5CC,CAAgBH,EAAmBC,gDAEpCA,SAAWA,MAAAA,EAAAA,EAAYD,qCATkBV,8cCPjCc,+JAKLZ,EAAaa,EAAkBZ,8GACdD,8DAAuDa,OAAaZ,oFAExFD,IAAMA,IACNa,SAAWA,kDAT2Cf,WCI7DgB,EAA4B,CAC9BC,IAAK,iCACLC,KAAM,6BACNC,IAAK,4BACLC,IAAK,kCACLC,KAAM,4BACNC,IAAK,8CACLC,KAAM,wCACNC,OAAQ,sBACRC,MAAO,oCACPC,MAAO,6CAOKC,EAAUC,OAAazB,yDAAqC,MACp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,SAAQ,iCAAE/E,OAAM2G,cAAYoM,EAAMC,UAAUC,UAAUjT,EAAM2G,+CCAzGuM,OAAOC,OAAOb,qHRwCoB/O,UAC3BqB,MAAIwO,kBAAgB7P,IAA2B,SAAA8P,UAAShG,GAAwBgG,wCS9BjFC,EAA4B,GAC5BC,EAA4B,CAC9BC,sBAAarP,EAAMvC,EAAShD,GACxB0U,EAAUhS,KAAK,IAAIoR,GAAavO,EAAMvC,EAAShD,KAEnD6U,gCACIH,EAAUhS,KAAK,IAAIoR,GAAa,GAAI,GAAI,QAK1CgB,EAAYC,KAAKC,6BAAG,6HACfN,EAAUO,uBAAWC,OAAe,0FAG/CnO,OAAOoO,OAAOL,EAAWH,GAElBG,+FTgB0BnS,OAC3ByL,EAAQgH,WAASzS,UAEfyL,EAAazE,qBAAmB,CACpC0L,aAAclH,GAAgBC,GAC9BkH,aAAclH,EAAME,KAAOF,EAAME,KAAKpN,MAAM,KAAKqU,MAAQ,KACzDC,aAAcpH,EAAMqH,WAHR"}
|
|
@@ -5,6 +5,7 @@ declare global {
|
|
|
5
5
|
// TODO generate automatically
|
|
6
6
|
interface Matchers<R> {
|
|
7
7
|
toEqualSparql(sparql: string): R;
|
|
8
|
+
toEqualTurtle(turtle: string): R;
|
|
8
9
|
toEqualJsonLD(jsonld: JsonLD): Promise<R>;
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -19,10 +20,6 @@ export declare type AnyFetch = (input: any, options?: any) => Promise<Response>;
|
|
|
19
20
|
|
|
20
21
|
export declare function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGraph>;
|
|
21
22
|
|
|
22
|
-
export declare interface ContainerOptions {
|
|
23
|
-
baseUrl: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
23
|
/**
|
|
27
24
|
* @deprecated Use soukai-solid instead
|
|
28
25
|
*/
|
|
@@ -37,11 +34,6 @@ export declare function createSolidDocument(url: string, body: string, fetch?: F
|
|
|
37
34
|
|
|
38
35
|
export declare function defineIRIPrefix(name: string, value: string): void;
|
|
39
36
|
|
|
40
|
-
export declare interface DocumentOptions extends ContainerOptions {
|
|
41
|
-
containerUrl: string;
|
|
42
|
-
name: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
37
|
export declare interface EqualityResult {
|
|
46
38
|
success: boolean;
|
|
47
39
|
message: string;
|
|
@@ -56,19 +48,12 @@ export declare interface ExpandIRIOptions {
|
|
|
56
48
|
extraContext: RDFContext;
|
|
57
49
|
}
|
|
58
50
|
|
|
59
|
-
export declare function fakeContainerUrl(options?: Partial<ContainerOptions>): string;
|
|
60
|
-
|
|
61
|
-
export declare function fakeDocumentUrl(options?: Partial<DocumentOptions>): string;
|
|
62
|
-
|
|
63
|
-
export declare function fakeResourceUrl(options?: Partial<ResourceOptions>): string;
|
|
64
|
-
|
|
65
51
|
export declare type Fetch = TypedFetch | AnyFetch;
|
|
66
52
|
|
|
67
53
|
export declare function fetchLoginUserProfile(loginUrl: string, options?: FetchLoginUserProfileOptions): Promise<SolidUserProfile | null>;
|
|
68
54
|
|
|
69
|
-
export declare interface FetchLoginUserProfileOptions {
|
|
55
|
+
export declare interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {
|
|
70
56
|
required?: boolean;
|
|
71
|
-
fetch?: Fetch;
|
|
72
57
|
}
|
|
73
58
|
|
|
74
59
|
export declare interface FetchMockMethods {
|
|
@@ -76,7 +61,7 @@ export declare interface FetchMockMethods {
|
|
|
76
61
|
mockNotFoundResponse(): void;
|
|
77
62
|
}
|
|
78
63
|
|
|
79
|
-
export declare function fetchSolidDocument(url: string,
|
|
64
|
+
export declare function fetchSolidDocument(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument>;
|
|
80
65
|
|
|
81
66
|
export declare function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{
|
|
82
67
|
url: string;
|
|
@@ -84,7 +69,17 @@ export declare function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch)
|
|
|
84
69
|
document: SolidDocument;
|
|
85
70
|
}>;
|
|
86
71
|
|
|
87
|
-
export declare function fetchSolidDocumentIfFound(url: string,
|
|
72
|
+
export declare function fetchSolidDocumentIfFound(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument | null>;
|
|
73
|
+
|
|
74
|
+
export declare interface FetchSolidDocumentOptions {
|
|
75
|
+
fetch?: Fetch;
|
|
76
|
+
cache?: RequestCache;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export declare interface FetchUserProfileOptions {
|
|
80
|
+
fetch?: Fetch;
|
|
81
|
+
onLoaded?(store: SolidStore): Promise<unknown> | unknown;
|
|
82
|
+
}
|
|
88
83
|
|
|
89
84
|
/**
|
|
90
85
|
* @deprecated Use soukai-solid instead
|
|
@@ -141,6 +136,8 @@ export declare class NetworkRequestError extends JSError {
|
|
|
141
136
|
|
|
142
137
|
export declare function normalizeSparql(sparql: string): string;
|
|
143
138
|
|
|
139
|
+
export declare function normalizeTurtle(sparql: string): string;
|
|
140
|
+
|
|
144
141
|
export declare class NotFoundError extends JSError {
|
|
145
142
|
readonly url: string;
|
|
146
143
|
constructor(url: string);
|
|
@@ -168,11 +165,6 @@ export declare interface RDFGraphData {
|
|
|
168
165
|
containsRelativeIRIs: boolean;
|
|
169
166
|
}
|
|
170
167
|
|
|
171
|
-
export declare interface ResourceOptions extends DocumentOptions {
|
|
172
|
-
documentUrl: string;
|
|
173
|
-
hash: string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
168
|
export declare class ResponseStub implements Response {
|
|
177
169
|
private rawBody;
|
|
178
170
|
readonly body: ReadableStream<Uint8Array> | null;
|
|
@@ -210,7 +202,7 @@ export declare class SolidDocument extends SolidStore {
|
|
|
210
202
|
private getPermissionsFromWAC;
|
|
211
203
|
}
|
|
212
204
|
|
|
213
|
-
export declare function solidDocumentExists(url: string,
|
|
205
|
+
export declare function solidDocumentExists(url: string, options?: FetchSolidDocumentOptions): Promise<boolean>;
|
|
214
206
|
|
|
215
207
|
export declare enum SolidDocumentFormat {
|
|
216
208
|
Turtle = "Turtle"
|