@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.508449b33de64b0bcade86b642c9793381434231

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/chai.d.ts +31 -0
  2. package/dist/chai.js +23 -0
  3. package/dist/chai.js.map +1 -0
  4. package/dist/helpers-DGXMj9cx.js +107 -0
  5. package/dist/helpers-DGXMj9cx.js.map +1 -0
  6. package/dist/io-wCcrq4b9.js +401 -0
  7. package/dist/io-wCcrq4b9.js.map +1 -0
  8. package/dist/noeldemartin-solid-utils.d.ts +61 -65
  9. package/dist/noeldemartin-solid-utils.js +224 -0
  10. package/dist/noeldemartin-solid-utils.js.map +1 -0
  11. package/dist/testing.d.ts +40 -0
  12. package/dist/testing.js +7 -0
  13. package/dist/testing.js.map +1 -0
  14. package/dist/vitest.d.ts +50 -0
  15. package/dist/vitest.js +55 -0
  16. package/dist/vitest.js.map +1 -0
  17. package/package.json +67 -63
  18. package/src/chai/assertions.ts +35 -0
  19. package/src/chai/index.ts +19 -0
  20. package/src/errors/UnauthorizedError.ts +1 -3
  21. package/src/errors/UnsuccessfulNetworkRequestError.ts +2 -2
  22. package/src/helpers/auth.test.ts +221 -0
  23. package/src/helpers/auth.ts +28 -27
  24. package/src/helpers/identifiers.test.ts +76 -0
  25. package/src/helpers/identifiers.ts +14 -17
  26. package/src/helpers/index.ts +0 -1
  27. package/src/helpers/interop.ts +23 -16
  28. package/src/helpers/io.test.ts +228 -0
  29. package/src/helpers/io.ts +57 -77
  30. package/src/helpers/jsonld.ts +6 -6
  31. package/src/helpers/vocabs.ts +3 -6
  32. package/src/helpers/wac.test.ts +64 -0
  33. package/src/helpers/wac.ts +10 -6
  34. package/src/index.ts +4 -0
  35. package/src/models/SolidDocument.test.ts +77 -0
  36. package/src/models/SolidDocument.ts +14 -18
  37. package/src/models/SolidStore.ts +22 -12
  38. package/src/models/SolidThing.ts +5 -7
  39. package/src/models/index.ts +2 -0
  40. package/src/{helpers/testing.ts → testing/helpers.ts} +24 -27
  41. package/src/testing/hepers.test.ts +329 -0
  42. package/src/testing/index.ts +1 -2
  43. package/src/types/index.ts +2 -0
  44. package/src/types/n3.d.ts +0 -2
  45. package/src/vitest/index.ts +20 -0
  46. package/src/vitest/matchers.ts +68 -0
  47. package/.github/workflows/ci.yml +0 -16
  48. package/.nvmrc +0 -1
  49. package/CHANGELOG.md +0 -70
  50. package/dist/noeldemartin-solid-utils.cjs.js +0 -2
  51. package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
  52. package/dist/noeldemartin-solid-utils.esm.js +0 -2
  53. package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
  54. package/dist/noeldemartin-solid-utils.umd.js +0 -90
  55. package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
  56. package/noeldemartin.config.js +0 -9
  57. package/src/main.ts +0 -5
  58. package/src/plugins/chai/assertions.ts +0 -40
  59. package/src/plugins/chai/index.ts +0 -5
  60. package/src/plugins/cypress/types.d.ts +0 -15
  61. package/src/plugins/index.ts +0 -2
  62. package/src/plugins/jest/index.ts +0 -5
  63. package/src/plugins/jest/matchers.ts +0 -65
  64. package/src/plugins/jest/types.d.ts +0 -14
  65. package/src/testing/ResponseStub.ts +0 -46
  66. package/src/testing/mocking.ts +0 -33
@@ -0,0 +1 @@
1
+ {"version":3,"file":"io-wCcrq4b9.js","sources":["../src/errors/MalformedSolidDocumentError.ts","../src/errors/NetworkRequestError.ts","../src/errors/NotFoundError.ts","../src/errors/UnauthorizedError.ts","../src/helpers/vocabs.ts","../src/models/SolidThing.ts","../src/models/SolidStore.ts","../src/models/SolidDocument.ts","../src/helpers/jsonld.ts","../src/helpers/io.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nfunction errorMessage(\n documentUrl: string | null,\n documentFormat: SolidDocumentFormat,\n malformationDetails: string,\n): string {\n return documentUrl\n ? `Malformed ${documentFormat} document found at ${documentUrl} - ${malformationDetails}`\n : `Malformed ${documentFormat} document - ${malformationDetails}`;\n}\n\nexport enum SolidDocumentFormat {\n Turtle = 'Turtle',\n}\n\nexport default class MalformedSolidDocumentError extends JSError {\n\n public readonly documentUrl: string | null;\n public readonly documentFormat: SolidDocumentFormat;\n public readonly malformationDetails: string;\n\n constructor(documentUrl: string | null, documentFormat: SolidDocumentFormat, malformationDetails: string) {\n super(errorMessage(documentUrl, documentFormat, malformationDetails));\n\n this.documentUrl = documentUrl;\n this.documentFormat = documentFormat;\n this.malformationDetails = malformationDetails;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class NetworkRequestError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string, options?: JSErrorOptions) {\n super(`Request failed trying to fetch ${url}`, options);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nexport default class NotFoundError extends JSError {\n\n public readonly url: string;\n\n constructor(url: string) {\n super(`Document with '${url}' url not found`);\n\n this.url = url;\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\n\nfunction errorMessage(url: string, responseStatus?: number): string {\n const typeInfo = responseStatus === 403 ? ' (Forbidden)' : '';\n\n return `Unauthorized${typeInfo}: ${url}`;\n}\n\nexport default class UnauthorizedError extends JSError {\n\n public readonly url: string;\n public readonly responseStatus?: number;\n\n constructor(url: string, responseStatus?: number) {\n super(errorMessage(url, responseStatus));\n\n this.url = url;\n this.responseStatus = responseStatus;\n }\n\n public get forbidden(): boolean | undefined {\n return typeof this.responseStatus !== 'undefined' ? this.responseStatus === 403 : undefined;\n }\n\n}\n","export type RDFContext = Record<string, string>;\n\nexport interface ExpandIRIOptions {\n defaultPrefix: string;\n extraContext: RDFContext;\n}\n\nconst knownPrefixes: RDFContext = {\n acl: 'http://www.w3.org/ns/auth/acl#',\n foaf: 'http://xmlns.com/foaf/0.1/',\n ldp: 'http://www.w3.org/ns/ldp#',\n pim: 'http://www.w3.org/ns/pim/space#',\n purl: 'http://purl.org/dc/terms/',\n rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rdfs: 'http://www.w3.org/2000/01/rdf-schema#',\n schema: 'https://schema.org/',\n solid: 'http://www.w3.org/ns/solid/terms#',\n vcard: 'http://www.w3.org/2006/vcard/ns#',\n};\n\nexport function defineIRIPrefix(name: string, value: string): void {\n knownPrefixes[name] = value;\n}\n\nexport function expandIRI(iri: string, options: Partial<ExpandIRIOptions> = {}): string {\n if (iri.startsWith('http')) return iri;\n\n const [prefix, name] = iri.split(':');\n\n if (prefix && name) {\n const expandedPrefix = knownPrefixes[prefix] ?? options.extraContext?.[prefix] ?? null;\n\n if (!expandedPrefix) throw new Error(`Can't expand IRI with unknown prefix: '${iri}'`);\n\n return expandedPrefix + name;\n }\n\n if (!options.defaultPrefix) throw new Error(`Can't expand IRI without a default prefix: '${iri}'`);\n\n return options.defaultPrefix + prefix;\n}\n","import type { Quad } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nexport default class SolidThing {\n\n public readonly url: string;\n private quads: Quad[];\n\n public constructor(url: string, quads: Quad[]) {\n this.url = url;\n this.quads = quads;\n }\n\n public value(property: string): string | undefined {\n return this.quads.find((quad) => quad.predicate.value === expandIRI(property))?.object.value;\n }\n\n public values(property: string): string[] {\n return this.quads\n .filter((quad) => quad.predicate.value === expandIRI(property))\n .map((quad) => quad.object.value);\n }\n\n}\n","import type { BlankNode, Literal, NamedNode, Quad, Variable } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nimport SolidThing from './SolidThing';\n\nexport type Term = NamedNode | Literal | BlankNode | Quad | Variable;\n\nexport default class SolidStore {\n\n private quads: Quad[];\n\n public constructor(quads: Quad[] = []) {\n this.quads = quads;\n }\n\n public isEmpty(): boolean {\n return this.statements.length === 0;\n }\n\n public getQuads(): Quad[] {\n return this.quads.slice(0);\n }\n\n public addQuads(quads: Quad[]): void {\n this.quads.push(...quads);\n }\n\n public statements(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad[] {\n return this.quads.filter(\n (statement) =>\n (!object || this.termMatches(statement.object, object)) &&\n (!subject || this.termMatches(statement.subject, subject)) &&\n (!predicate || this.termMatches(statement.predicate, predicate)),\n );\n }\n\n public statement(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad | null {\n const statement = this.quads.find(\n (_statement) =>\n (!object || this.termMatches(_statement.object, object)) &&\n (!subject || this.termMatches(_statement.subject, subject)) &&\n (!predicate || this.termMatches(_statement.predicate, predicate)),\n );\n\n return statement ?? null;\n }\n\n public contains(subject: string, predicate?: string, object?: string): boolean {\n return this.statement(subject, predicate, object) !== null;\n }\n\n public getThing(subject: string): SolidThing {\n const statements = this.statements(subject);\n\n return new SolidThing(subject, statements);\n }\n\n protected expandIRI(iri: string): string {\n return expandIRI(iri);\n }\n\n protected termMatches(term: Term, value: Term | string): boolean {\n if (typeof value === 'string') {\n return this.expandIRI(value) === term.value;\n }\n\n return term.termType === term.termType && term.value === value.value;\n }\n\n}\n","import { arrayFilter, parseDate, stringMatch } from '@noeldemartin/utils';\nimport type { Quad } from '@rdfjs/types';\n\nimport { expandIRI } from '@noeldemartin/solid-utils/helpers/vocabs';\n\nimport SolidStore from './SolidStore';\n\nexport enum SolidDocumentPermission {\n Read = 'read',\n Write = 'write',\n Append = 'append',\n Control = 'control',\n}\n\nexport default class SolidDocument extends SolidStore {\n\n public readonly url: string;\n public readonly headers: Headers;\n\n public constructor(url: string, quads: Quad[], headers: Headers) {\n super(quads);\n\n this.url = url;\n this.headers = headers;\n }\n\n public isACPResource(): boolean {\n return !!this.headers\n .get('Link')\n ?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/solid\\/acp#AccessControlResource>;[^,]+rel=\"type\"/);\n }\n\n public isPersonalProfile(): boolean {\n return !!this.statement(this.url, expandIRI('rdf:type'), expandIRI('foaf:PersonalProfileDocument'));\n }\n\n public isStorage(): boolean {\n return !!this.headers.get('Link')?.match(/<http:\\/\\/www\\.w3\\.org\\/ns\\/pim\\/space#Storage>;[^,]+rel=\"type\"/);\n }\n\n public isUserWritable(): boolean {\n return this.getUserPermissions().includes(SolidDocumentPermission.Write);\n }\n\n public getUserPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('user');\n }\n\n public getPublicPermissions(): SolidDocumentPermission[] {\n return this.getPermissionsFromWAC('public');\n }\n\n public getLastModified(): Date | null {\n return (\n parseDate(this.headers.get('last-modified')) ??\n parseDate(this.statement(this.url, 'purl:modified')?.object.value) ??\n this.getLatestDocumentDate() ??\n null\n );\n }\n\n protected expandIRI(iri: string): string {\n return expandIRI(iri, { defaultPrefix: this.url });\n }\n\n private getLatestDocumentDate(): Date | null {\n const dates = [...this.statements(undefined, 'purl:modified'), ...this.statements(undefined, 'purl:created')]\n .map((statement) => parseDate(statement.object.value))\n .filter((date): date is Date => date !== null);\n\n return dates.length > 0 ? dates.reduce((a, b) => (a > b ? a : b)) : null;\n }\n\n private getPermissionsFromWAC(type: string): SolidDocumentPermission[] {\n const wacAllow = this.headers.get('WAC-Allow') ?? '';\n const publicModes = stringMatch<2>(wacAllow, new RegExp(`${type}=\"([^\"]+)\"`))?.[1] ?? '';\n\n return arrayFilter([\n publicModes.includes('read') && SolidDocumentPermission.Read,\n publicModes.includes('write') && SolidDocumentPermission.Write,\n publicModes.includes('append') && SolidDocumentPermission.Append,\n publicModes.includes('control') && SolidDocumentPermission.Control,\n ]);\n }\n\n}\n","import jsonld from 'jsonld';\nimport type { JsonLdDocument } from 'jsonld';\n\nexport type JsonLD = Partial<{\n '@context': Record<string, unknown>;\n '@id': string;\n '@type': null | string | string[];\n}> & { [k: string]: unknown };\n\nexport type JsonLDResource = Omit<JsonLD, '@id'> & { '@id': string };\nexport type JsonLDGraph = {\n '@context'?: Record<string, unknown>;\n '@graph': JsonLDResource[];\n};\n\nexport async function compactJsonLDGraph(json: JsonLDGraph): Promise<JsonLDGraph> {\n const compactedJsonLD = await jsonld.compact(json as JsonLdDocument, {});\n\n if ('@graph' in compactedJsonLD) {\n return compactedJsonLD as JsonLDGraph;\n }\n\n if ('@id' in compactedJsonLD) {\n return { '@graph': [compactedJsonLD] } as JsonLDGraph;\n }\n\n return { '@graph': [] };\n}\n\nexport function isJsonLDGraph(json: JsonLD): json is JsonLDGraph {\n return '@graph' in json;\n}\n","import jsonld from 'jsonld';\nimport md5 from 'md5';\nimport { arr, arrayFilter, arrayReplace, objectWithoutEmpty, stringMatchAll, tap } from '@noeldemartin/utils';\nimport { BlankNode as N3BlankNode, Quad as N3Quad, Parser, Writer } from 'n3';\nimport type { JsonLdDocument } from 'jsonld';\nimport type { Quad } from '@rdfjs/types';\nimport type { Term } from 'n3';\n\nimport SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';\n\n// eslint-disable-next-line max-len\nimport MalformedSolidDocumentError, { SolidDocumentFormat } from '@noeldemartin/solid-utils/errors/MalformedSolidDocumentError';\nimport NetworkRequestError from '@noeldemartin/solid-utils/errors/NetworkRequestError';\nimport NotFoundError from '@noeldemartin/solid-utils/errors/NotFoundError';\nimport UnauthorizedError from '@noeldemartin/solid-utils/errors/UnauthorizedError';\nimport { isJsonLDGraph } from '@noeldemartin/solid-utils/helpers/jsonld';\nimport type { JsonLD, JsonLDGraph, JsonLDResource } from '@noeldemartin/solid-utils/helpers/jsonld';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare type AnyFetch = (input: any, options?: any) => Promise<Response>;\nexport declare type TypedFetch = (input: RequestInfo, options?: RequestInit) => Promise<Response>;\nexport declare type Fetch = TypedFetch | AnyFetch;\n\nconst ANONYMOUS_PREFIX = 'anonymous://';\nconst ANONYMOUS_PREFIX_LENGTH = ANONYMOUS_PREFIX.length;\n\nasync function fetchRawSolidDocument(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<{ body: string; headers: Headers }> {\n const requestOptions: RequestInit = {\n headers: { Accept: 'text/turtle' },\n };\n\n if (options?.cache) {\n requestOptions.cache = options.cache;\n }\n\n try {\n const fetch = options?.fetch ?? window.fetch;\n const response = await fetch(url, requestOptions);\n\n if (response.status === 404) throw new NotFoundError(url);\n\n if ([401, 403].includes(response.status)) throw new UnauthorizedError(url, response.status);\n\n const body = await response.text();\n\n return {\n body,\n headers: response.headers,\n };\n } catch (error) {\n if (error instanceof UnauthorizedError) throw error;\n\n if (error instanceof NotFoundError) throw error;\n\n throw new NetworkRequestError(url, { cause: error });\n }\n}\n\nfunction normalizeBlankNodes(quads: Quad[]): Quad[] {\n const normalizedQuads = quads.slice(0);\n const quadsIndexes: Record<string, Set<number>> = {};\n const blankNodeIds = arr(quads)\n .flatMap((quad, index) =>\n tap(\n arrayFilter([\n quad.object.termType === 'BlankNode' ? quad.object.value : null,\n quad.subject.termType === 'BlankNode' ? quad.subject.value : null,\n ]),\n (ids) => ids.forEach((id) => (quadsIndexes[id] ??= new Set()).add(index)),\n ))\n .filter()\n .unique();\n\n for (const originalId of blankNodeIds) {\n const quadIndexes = quadsIndexes[originalId] as Set<number>;\n const normalizedId = md5(\n arr(quadIndexes)\n .map((index) => quads[index] as Quad)\n .filter(({ subject: { termType, value } }) => termType === 'BlankNode' && value === originalId)\n .map(({ predicate, object }) =>\n object.termType === 'BlankNode' ? predicate.value : predicate.value + object.value)\n .sorted()\n .join(),\n );\n\n for (const index of quadIndexes) {\n const quad = normalizedQuads[index] as Quad;\n const terms: Record<string, Term> = {\n subject: quad.subject as Term,\n object: quad.object as Term,\n };\n\n for (const [termName, termValue] of Object.entries(terms)) {\n if (termValue.termType !== 'BlankNode' || termValue.value !== originalId) continue;\n\n terms[termName] = new N3BlankNode(normalizedId) as Term;\n }\n\n arrayReplace(\n normalizedQuads,\n quad,\n new N3Quad(terms.subject as Term, quad.predicate as Term, terms.object as Term),\n );\n }\n }\n\n return normalizedQuads;\n}\n\nfunction normalizeQuads(quads: Quad[]): string {\n return quads\n .map((quad) => ' ' + quadToTurtle(quad))\n .sort()\n .join('\\n');\n}\n\nfunction preprocessSubjects(json: JsonLD): void {\n if (!json['@id']?.startsWith('#')) {\n return;\n }\n\n json['@id'] = ANONYMOUS_PREFIX + json['@id'];\n}\n\nfunction postprocessSubjects(quads: Quad[]): void {\n for (const quad of quads) {\n if (!quad.subject.value.startsWith(ANONYMOUS_PREFIX)) {\n continue;\n }\n\n quad.subject.value = quad.subject.value.slice(ANONYMOUS_PREFIX_LENGTH);\n }\n}\n\nexport interface FetchSolidDocumentOptions {\n fetch?: Fetch;\n cache?: RequestCache;\n}\n\nexport interface ParsingOptions {\n baseIRI: string;\n normalizeBlankNodes: boolean;\n}\n\nexport interface RDFGraphData {\n quads: Quad[];\n containsRelativeIRIs: boolean;\n}\n\nexport async function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const statements = await turtleToQuads(body);\n\n await fetch(url, {\n method: 'PUT',\n headers: { 'Content-Type': 'text/turtle' },\n body,\n });\n\n return new SolidDocument(url, statements, new Headers({}));\n}\n\nexport async function fetchSolidDocument(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument> {\n const { body: data, headers } = await fetchRawSolidDocument(url, options);\n const statements = await turtleToQuads(data, { baseIRI: url });\n\n return new SolidDocument(url, statements, headers);\n}\n\nexport async function fetchSolidDocumentIfFound(\n url: string,\n options?: FetchSolidDocumentOptions,\n): Promise<SolidDocument | null> {\n try {\n const document = await fetchSolidDocument(url, options);\n\n return document;\n } catch (error) {\n if (!(error instanceof NotFoundError)) throw error;\n\n return null;\n }\n}\n\nexport async function jsonldToQuads(json: JsonLD, baseIRI?: string): Promise<Quad[]> {\n if (isJsonLDGraph(json)) {\n const graphQuads = await Promise.all(json['@graph'].map((resource) => jsonldToQuads(resource, baseIRI)));\n\n return graphQuads.flat();\n }\n\n preprocessSubjects(json);\n\n const quads = await (jsonld.toRDF(json as JsonLdDocument, { base: baseIRI }) as Promise<Quad[]>);\n\n postprocessSubjects(quads);\n\n return quads;\n}\n\nexport function normalizeSparql(sparql: string): string {\n const quads = sparqlToQuadsSync(sparql);\n\n return Object.entries(quads)\n .reduce((normalizedOperations, [operation, _quads]) => {\n const normalizedQuads = normalizeQuads(_quads);\n\n return normalizedOperations.concat(`${operation.toUpperCase()} DATA {\\n${normalizedQuads}\\n}`);\n }, [] as string[])\n .join(' ;\\n');\n}\n\nexport function normalizeTurtle(sparql: string): string {\n const quads = turtleToQuadsSync(sparql);\n\n return normalizeQuads(quads);\n}\n\nexport function parseTurtle(turtle: string, options: Partial<ParsingOptions> = {}): Promise<RDFGraphData> {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new Parser(parserOptions);\n const data: RDFGraphData = {\n quads: [],\n containsRelativeIRIs: false,\n };\n\n return new Promise((resolve, reject) => {\n const resolveRelativeIRI = parser._resolveRelativeIRI;\n\n parser._resolveRelativeIRI = (...args) => {\n data.containsRelativeIRIs = true;\n parser._resolveRelativeIRI = resolveRelativeIRI;\n\n return parser._resolveRelativeIRI(...args);\n };\n\n parser.parse(turtle, (error, quad) => {\n if (error) {\n reject(\n new MalformedSolidDocumentError(options.baseIRI ?? null, SolidDocumentFormat.Turtle, error.message),\n );\n\n return;\n }\n\n if (!quad) {\n // data.quads = options.normalizeBlankNodes\n // ? normalizeBlankNodes(data.quads)\n // : data.quads;\n\n resolve(data);\n\n return;\n }\n\n data.quads.push(quad);\n });\n });\n}\n\nexport async function quadsToJsonLD(quads: Quad[]): Promise<JsonLDGraph> {\n const graph = await jsonld.fromRDF(quads);\n\n return {\n '@graph': graph as JsonLDResource[],\n };\n}\n\nexport function quadsToTurtle(quads: Quad[]): string {\n const writer = new Writer();\n\n return writer.quadsToString(quads);\n}\n\nexport function quadToTurtle(quad: Quad): string {\n const writer = new Writer();\n\n return writer.quadsToString([quad]).slice(0, -1);\n}\n\nexport async function solidDocumentExists(url: string, options?: FetchSolidDocumentOptions): Promise<boolean> {\n try {\n const document = await fetchSolidDocument(url, options);\n\n return !document.isEmpty();\n } catch (error) {\n return false;\n }\n}\n\nexport async function sparqlToQuads(\n sparql: string,\n options: Partial<ParsingOptions> = {},\n): Promise<Record<string, Quad[]>> {\n const operations = stringMatchAll<3>(sparql, /(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n await Promise.all(\n [...operations].map(async (operation) => {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = await turtleToQuads(operationBody, options);\n }),\n );\n\n return quads;\n}\n\nexport function sparqlToQuadsSync(sparql: string, options: Partial<ParsingOptions> = {}): Record<string, Quad[]> {\n const operations = stringMatchAll<3>(sparql, /(\\w+) DATA {([^}]+)}/g);\n const quads: Record<string, Quad[]> = {};\n\n for (const operation of operations) {\n const operationName = operation[1].toLowerCase();\n const operationBody = operation[2];\n\n quads[operationName] = turtleToQuadsSync(operationBody, options);\n }\n\n return quads;\n}\n\nexport async function turtleToQuads(turtle: string, options: Partial<ParsingOptions> = {}): Promise<Quad[]> {\n const { quads } = await parseTurtle(turtle, options);\n\n return quads;\n}\n\nexport function turtleToQuadsSync(turtle: string, options: Partial<ParsingOptions> = {}): Quad[] {\n const parserOptions = objectWithoutEmpty({ baseIRI: options.baseIRI });\n const parser = new Parser(parserOptions);\n\n try {\n const quads = parser.parse(turtle);\n\n return options.normalizeBlankNodes ? normalizeBlankNodes(quads) : quads;\n } catch (error) {\n throw new MalformedSolidDocumentError(\n options.baseIRI ?? null,\n SolidDocumentFormat.Turtle,\n (error as Error).message ?? '',\n );\n }\n}\n\nexport async function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void> {\n fetch = fetch ?? window.fetch.bind(window);\n\n await fetch(url, {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/sparql-update' },\n body,\n });\n}\n"],"names":["errorMessage","documentUrl","documentFormat","malformationDetails","SolidDocumentFormat","MalformedSolidDocumentError","JSError","__publicField","NetworkRequestError","url","options","NotFoundError","responseStatus","UnauthorizedError","knownPrefixes","defineIRIPrefix","name","value","expandIRI","iri","prefix","expandedPrefix","_a","SolidThing","quads","property","quad","SolidStore","subject","predicate","object","statement","_statement","statements","term","SolidDocumentPermission","SolidDocument","headers","parseDate","dates","date","a","b","type","wacAllow","publicModes","stringMatch","arrayFilter","compactJsonLDGraph","json","compactedJsonLD","jsonld","isJsonLDGraph","ANONYMOUS_PREFIX","ANONYMOUS_PREFIX_LENGTH","fetchRawSolidDocument","requestOptions","response","error","normalizeBlankNodes","normalizedQuads","quadsIndexes","blankNodeIds","arr","index","tap","ids","id","originalId","quadIndexes","normalizedId","md5","termType","terms","termName","termValue","N3BlankNode","arrayReplace","N3Quad","normalizeQuads","quadToTurtle","preprocessSubjects","postprocessSubjects","createSolidDocument","body","fetch","turtleToQuads","fetchSolidDocument","data","fetchSolidDocumentIfFound","jsonldToQuads","baseIRI","resource","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","_quads","normalizeTurtle","turtleToQuadsSync","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","Parser","resolve","reject","resolveRelativeIRI","args","quadsToJsonLD","quadsToTurtle","Writer","solidDocumentExists","sparqlToQuads","operations","stringMatchAll","operationName","operationBody","updateSolidDocument"],"mappings":";;;;;;;AAEA,SAASA,EACLC,GACAC,GACAC,GACM;AACC,SAAAF,IACD,aAAaC,CAAc,sBAAsBD,CAAW,MAAME,CAAmB,KACrF,aAAaD,CAAc,eAAeC,CAAmB;AACvE;AAEY,IAAAC,sBAAAA,OACRA,EAAA,SAAS,UADDA,IAAAA,KAAA,CAAA,CAAA;AAIZ,MAAqBC,UAAoCC,EAAQ;AAAA,EAM7D,YAAYL,GAA4BC,GAAqCC,GAA6B;AACtG,UAAMH,EAAaC,GAAaC,GAAgBC,CAAmB,CAAC;AALxD,IAAAI,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAKZ,SAAK,cAAcN,GACnB,KAAK,iBAAiBC,GACtB,KAAK,sBAAsBC;AAAA,EAAA;AA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AuB,GAC9DtE,IAAgC,CAAC;AAEvC,aAAWyE,KAAamB,GAAY;AAChC,UAAME,IAAgBrB,EAAU,CAAC,EAAE,YAAY,GACzCsB,IAAgBtB,EAAU,CAAC;AAEjC,IAAAzE,EAAM8F,CAAa,IAAIlB,EAAkBmB,GAAe7G,CAAO;AAAA,EAAA;AAG5D,SAAAc;AACX;AAEA,eAAsB8D,EAAcgB,GAAgB5F,IAAmC,IAAqB;AACxG,QAAM,EAAE,OAAAc,EAAM,IAAI,MAAM6E,GAAYC,GAAQ5F,CAAO;AAE5C,SAAAc;AACX;AAEO,SAAS4E,EAAkBE,GAAgB5F,IAAmC,IAAY;AAC7F,QAAM6F,IAAgBC,EAAmB,EAAE,SAAS9F,EAAQ,SAAS,GAC/D+F,IAAS,IAAIC,EAAOH,CAAa;AAEnC,MAAA;AACM,UAAA/E,IAAQiF,EAAO,MAAMH,CAAM;AAEjC,WAAO5F,EAAQ,sBAAsBiD,EAAoBnC,CAAK,IAAIA;AAAA,WAC7DkC,GAAO;AACZ,UAAM,IAAIrD;AAAA,MACNK,EAAQ,WAAW;AAAA,MACnBN,EAAoB;AAAA,MACnBsD,EAAgB,WAAW;AAAA,IAChC;AAAA,EAAA;AAER;AAEsB,eAAA8D,GAAoB/G,GAAa2E,GAAcC,GAA8B;AAC/F,EAAAA,IAAQA,KAAS,OAAO,MAAM,KAAK,MAAM,GAEzC,MAAMA,EAAM5E,GAAK;AAAA,IACb,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,4BAA4B;AAAA,IACvD,MAAA2E;AAAA,EAAA,CACH;AACL;"}
@@ -1,24 +1,19 @@
1
- declare global {
2
-
3
- namespace jest {
4
-
5
- // TODO generate automatically
6
- interface Matchers<R> {
7
- toEqualSparql(sparql: string): R;
8
- toEqualTurtle(turtle: string): R;
9
- toEqualJsonLD(jsonld: JsonLD): Promise<R>;
10
- }
11
-
12
- }
13
-
14
- }
1
+ import { BlankNode } from '@rdfjs/types';
15
2
  import { JSError } from '@noeldemartin/utils';
16
- import type { JSErrorOptions } from '@noeldemartin/utils';
17
- import type { Quad } from 'rdf-js';
3
+ import { JSErrorOptions } from '@noeldemartin/utils';
4
+ import { Literal } from '@rdfjs/types';
5
+ import { MatcherState } from '@vitest/expect';
6
+ import { NamedNode } from '@rdfjs/types';
7
+ import { Quad } from '@rdfjs/types';
8
+ import { Variable } from '@rdfjs/types';
18
9
 
19
10
  export declare type AnyFetch = (input: any, options?: any) => Promise<Response>;
20
11
 
21
- export declare function compactJsonLDGraph(jsonld: JsonLDGraph): Promise<JsonLDGraph>;
12
+ export declare type ChaiSolidAssertions = {
13
+ [assertion in keyof typeof _default]: (typeof _default)[assertion];
14
+ };
15
+
16
+ export declare function compactJsonLDGraph(json: JsonLDGraph): Promise<JsonLDGraph>;
22
17
 
23
18
  /**
24
19
  * @deprecated Use soukai-solid instead
@@ -32,14 +27,28 @@ export declare function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fe
32
27
 
33
28
  export declare function createSolidDocument(url: string, body: string, fetch?: Fetch): Promise<SolidDocument>;
34
29
 
35
- export declare function defineIRIPrefix(name: string, value: string): void;
30
+ declare const _default: {
31
+ turtle(this: Chai.AssertionStatic, graph: string): void;
32
+ sparql(this: Chai.AssertionStatic, query: string): void;
33
+ equalityResult(this: Chai.AssertionStatic): void;
34
+ };
36
35
 
37
- export declare interface EqualityResult {
38
- success: boolean;
39
- message: string;
40
- expected: string;
41
- actual: string;
42
- }
36
+ declare const _default_2: {
37
+ toEqualJsonLD(this: MatcherState, received: any, expected: JsonLD): Promise<{
38
+ pass: boolean;
39
+ message: () => string;
40
+ }>;
41
+ toEqualSparql(this: MatcherState, received: any, expected: string): {
42
+ pass: boolean;
43
+ message: () => string;
44
+ };
45
+ toEqualTurtle(this: MatcherState, received: any, expected: string): {
46
+ pass: boolean;
47
+ message: () => string;
48
+ };
49
+ };
50
+
51
+ export declare function defineIRIPrefix(name: string, value: string): void;
43
52
 
44
53
  export declare function expandIRI(iri: string, options?: Partial<ExpandIRIOptions>): string;
45
54
 
@@ -56,11 +65,6 @@ export declare interface FetchLoginUserProfileOptions extends FetchUserProfileOp
56
65
  required?: boolean;
57
66
  }
58
67
 
59
- export declare interface FetchMockMethods {
60
- mockResponse(body?: string, headers?: Record<string, string>, status?: number): void;
61
- mockNotFoundResponse(): void;
62
- }
63
-
64
68
  export declare function fetchSolidDocument(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument>;
65
69
 
66
70
  export declare function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{
@@ -91,11 +95,7 @@ export declare function findContainerRegistrations(typeIndexUrl: string, type: s
91
95
  */
92
96
  export declare function findInstanceRegistrations(typeIndexUrl: string, type: string | string[], fetch?: Fetch): Promise<string[]>;
93
97
 
94
- export declare function installChaiPlugin(): void;
95
-
96
- export declare function installJestPlugin(): void;
97
-
98
- export declare function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph;
98
+ export declare function isJsonLDGraph(json: JsonLD): json is JsonLDGraph;
99
99
 
100
100
  export declare type JsonLD = Partial<{
101
101
  '@context': Record<string, unknown>;
@@ -105,8 +105,6 @@ export declare type JsonLD = Partial<{
105
105
  [k: string]: unknown;
106
106
  };
107
107
 
108
- export declare function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult>;
109
-
110
108
  export declare type JsonLDGraph = {
111
109
  '@context'?: Record<string, unknown>;
112
110
  '@graph': JsonLDResource[];
@@ -116,7 +114,7 @@ export declare type JsonLDResource = Omit<JsonLD, '@id'> & {
116
114
  '@id': string;
117
115
  };
118
116
 
119
- export declare function jsonldToQuads(jsonld: JsonLD, baseIRI?: string): Promise<Quad[]>;
117
+ export declare function jsonldToQuads(json: JsonLD, baseIRI?: string): Promise<Quad[]>;
120
118
 
121
119
  export declare class MalformedSolidDocumentError extends JSError {
122
120
  readonly documentUrl: string | null;
@@ -127,8 +125,6 @@ export declare class MalformedSolidDocumentError extends JSError {
127
125
 
128
126
  export declare function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource;
129
127
 
130
- export declare function mockFetch<T = any>(): T;
131
-
132
128
  export declare class NetworkRequestError extends JSError {
133
129
  readonly url: string;
134
130
  constructor(url: string, options?: JSErrorOptions);
@@ -165,27 +161,6 @@ export declare interface RDFGraphData {
165
161
  containsRelativeIRIs: boolean;
166
162
  }
167
163
 
168
- export declare class ResponseStub implements Response {
169
- private rawBody;
170
- readonly body: ReadableStream<Uint8Array> | null;
171
- readonly bodyUsed: boolean;
172
- readonly headers: Headers;
173
- readonly ok: boolean;
174
- readonly redirected: boolean;
175
- readonly status: number;
176
- readonly statusText: string;
177
- readonly trailer: Promise<Headers>;
178
- readonly type: ResponseType;
179
- readonly url: string;
180
- constructor(rawBody?: string, headers?: Record<string, string>, status?: number);
181
- arrayBuffer(): Promise<ArrayBuffer>;
182
- blob(): Promise<Blob>;
183
- formData(): Promise<FormData>;
184
- json(): Promise<unknown>;
185
- text(): Promise<string>;
186
- clone(): Response;
187
- }
188
-
189
164
  export declare class SolidDocument extends SolidStore {
190
165
  readonly url: string;
191
166
  readonly headers: Headers;
@@ -221,11 +196,12 @@ export declare class SolidStore {
221
196
  isEmpty(): boolean;
222
197
  getQuads(): Quad[];
223
198
  addQuads(quads: Quad[]): void;
224
- statements(subject?: string, predicate?: string, object?: string): Quad[];
225
- statement(subject?: string, predicate?: string, object?: string): Quad | null;
199
+ statements(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad[];
200
+ statement(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad | null;
226
201
  contains(subject: string, predicate?: string, object?: string): boolean;
227
202
  getThing(subject: string): SolidThing;
228
203
  protected expandIRI(iri: string): string;
204
+ protected termMatches(term: Term, value: Term | string): boolean;
229
205
  }
230
206
 
231
207
  export declare class SolidThing {
@@ -248,8 +224,6 @@ export declare interface SolidUserProfile {
248
224
  privateTypeIndexUrl?: string;
249
225
  }
250
226
 
251
- export declare function sparqlEquals(expected: string, actual: string): EqualityResult;
252
-
253
227
  export declare function sparqlToQuads(sparql: string, options?: Partial<ParsingOptions>): Promise<Record<string, Quad[]>>;
254
228
 
255
229
  export declare function sparqlToQuadsSync(sparql: string, options?: Partial<ParsingOptions>): Record<string, Quad[]>;
@@ -260,7 +234,7 @@ export declare interface SubjectParts {
260
234
  resourceHash?: string;
261
235
  }
262
236
 
263
- export declare function turtleEquals(expected: string, actual: string): EqualityResult;
237
+ export declare type Term = NamedNode | Literal | BlankNode | Quad | Variable;
264
238
 
265
239
  export declare function turtleToQuads(turtle: string, options?: Partial<ParsingOptions>): Promise<Quad[]>;
266
240
 
@@ -289,4 +263,26 @@ export declare class UnsupportedAuthorizationProtocolError extends JSError {
289
263
 
290
264
  export declare function updateSolidDocument(url: string, body: string, fetch?: Fetch): Promise<void>;
291
265
 
266
+ export declare type VitestSolidMatchers<R = unknown> = {
267
+ [K in keyof typeof _default_2]: (...args: Parameters<(typeof _default_2)[K]> extends [any, ...infer Rest] ? Rest : never) => ReturnType<(typeof _default_2)[K]> extends Promise<any> ? Promise<R> : R;
268
+ };
269
+
292
270
  export { }
271
+
272
+
273
+ declare module '@vitest/expect' {
274
+ interface Assertion<T> extends VitestSolidMatchers<T> {
275
+ }
276
+ interface AsymmetricMatchersContaining extends VitestSolidMatchers {
277
+ }
278
+ }
279
+
280
+
281
+ declare global {
282
+ namespace Chai {
283
+ interface Assertion extends ChaiSolidAssertions {
284
+ }
285
+ interface Include extends ChaiSolidAssertions {
286
+ }
287
+ }
288
+ }
@@ -0,0 +1,224 @@
1
+ var I = Object.defineProperty;
2
+ var L = (t, e, r) => e in t ? I(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var f = (t, e, r) => L(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { f as m, S as k, U as Q, c as H, u as J, d as N, e as z } from "./io-wCcrq4b9.js";
5
+ import { M as yt, N as vt, h as Tt, w as gt, g as xt, x as Pt, y as Ut, m as bt, r as $t, v as Et, o as jt, j as St, b as Dt, n as qt, p as Ct, a as Rt, i as At, q as It, k as Lt, s as kt, l as Qt, t as Ht } from "./io-wCcrq4b9.js";
6
+ import { JSError as E, silenced as j, urlRoot as O, urlRoute as W, urlParentDirectory as U, objectWithoutEmpty as h, arrayUnique as F, tap as M, objectDeepClone as _, urlParse as B, uuid as S, isObject as b, isArray as G, arr as V, urlResolve as K, requireUrlParentDirectory as D } from "@noeldemartin/utils";
7
+ function X(t, e) {
8
+ return e = e ?? t, typeof t == "string" ? `${t} (returned ${e.status} status code)` : `Request to ${e.url} returned ${e.status} status code`;
9
+ }
10
+ class st extends E {
11
+ constructor(r, a) {
12
+ super(X(r, a));
13
+ f(this, "response");
14
+ this.response = a ?? r;
15
+ }
16
+ }
17
+ class Y extends E {
18
+ constructor(r, a, o) {
19
+ super(`The resource at ${r} is using an unsupported authorization protocol (${a})`, o);
20
+ f(this, "url");
21
+ f(this, "protocol");
22
+ this.url = r, this.protocol = a;
23
+ }
24
+ }
25
+ async function Z(t, e) {
26
+ var u;
27
+ const r = new k(t.getQuads()), a = { [t.url]: t }, o = (n) => {
28
+ n.statements(void 0, "foaf:isPrimaryTopicOf").map((i) => i.object.value).forEach((i) => a[i] = a[i] ?? null), n.statements(void 0, "foaf:primaryTopic").map((i) => i.subject.value).forEach((i) => a[i] = a[i] ?? null);
29
+ }, s = async () => {
30
+ for (const [n, i] of Object.entries(a))
31
+ if (i === null)
32
+ try {
33
+ const c = await m(n, e);
34
+ a[n] = c, r.addQuads(c.getQuads()), o(c);
35
+ } catch (c) {
36
+ if (c instanceof Q) {
37
+ a[n] = !1;
38
+ continue;
39
+ }
40
+ throw c;
41
+ }
42
+ };
43
+ o(t);
44
+ do
45
+ await s();
46
+ while (Object.values(a).some((n) => n === null));
47
+ return {
48
+ store: r,
49
+ cloaked: Object.values(a).some((n) => n === !1),
50
+ writableProfileUrl: t.isUserWritable() ? t.url : ((u = Object.values(a).find(
51
+ (n) => !!n && n.isUserWritable()
52
+ )) == null ? void 0 : u.url) ?? null
53
+ };
54
+ }
55
+ async function $(t, e = {}) {
56
+ var y, v, T, g, x, P;
57
+ const r = {
58
+ fetch: e.fetch,
59
+ // Needed for CSS v7.1.3.
60
+ // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972
61
+ cache: "no-store"
62
+ }, a = W(t), o = await m(a, r);
63
+ if (!o.isPersonalProfile() && !o.contains(t, "solid:oidcIssuer"))
64
+ throw new Error(`${t} is not a valid webId.`);
65
+ const { store: s, writableProfileUrl: u, cloaked: n } = await Z(o, e), i = s.statements(t, "pim:storage").map((d) => d.object.value), c = s.statement(t, "solid:publicTypeIndex"), p = s.statement(t, "solid:privateTypeIndex");
66
+ let l = U(a);
67
+ for (; l && i.length === 0; ) {
68
+ const d = await j(m(l, r));
69
+ if (d != null && d.isStorage()) {
70
+ i.push(l);
71
+ break;
72
+ }
73
+ l = U(l);
74
+ }
75
+ if (i.length === 0)
76
+ throw new Error(`Could not find any storage for ${t}.`);
77
+ return await ((y = e.onLoaded) == null ? void 0 : y.call(e, s)), {
78
+ webId: t,
79
+ cloaked: n,
80
+ writableProfileUrl: u,
81
+ storageUrls: F(i),
82
+ ...h({
83
+ name: ((v = s.statement(t, "vcard:fn")) == null ? void 0 : v.object.value) ?? ((T = s.statement(t, "foaf:name")) == null ? void 0 : T.object.value),
84
+ avatarUrl: ((g = s.statement(t, "vcard:hasPhoto")) == null ? void 0 : g.object.value) ?? ((x = s.statement(t, "foaf:img")) == null ? void 0 : x.object.value),
85
+ oidcIssuerUrl: (P = s.statement(t, "solid:oidcIssuer")) == null ? void 0 : P.object.value,
86
+ publicTypeIndexUrl: c == null ? void 0 : c.object.value,
87
+ privateTypeIndexUrl: p == null ? void 0 : p.object.value
88
+ })
89
+ };
90
+ }
91
+ async function it(t, e = {}) {
92
+ if (e.required)
93
+ return $(t, e);
94
+ const r = j((a) => $(a, e));
95
+ return await r(t) ?? await r(t.replace(/\/$/, "").concat("/profile/card#me")) ?? await r(O(t).concat("/profile/card#me"));
96
+ }
97
+ function tt(t) {
98
+ return !t.path || !t.path.startsWith("/") ? null : t.path.match(/^\/[^/]*$/) ? "/" : `/${V(t.path.split("/")).filter().slice(0, -1).join("/")}/`.replace("//", "/");
99
+ }
100
+ function et(t) {
101
+ const e = tt(t);
102
+ return t.protocol && t.domain ? `${t.protocol}://${t.domain}${e ?? "/"}` : e;
103
+ }
104
+ function w(t) {
105
+ if (!(!("@type" in t) || "@value" in t)) {
106
+ t["@id"] = t["@id"] ?? S();
107
+ for (const e of Object.values(t))
108
+ b(e) && w(e), G(e) && e.forEach((r) => b(r) && w(r));
109
+ }
110
+ }
111
+ function ct(t) {
112
+ return M(_(t), (e) => w(e));
113
+ }
114
+ function ut(t) {
115
+ const e = B(t);
116
+ return e ? h({
117
+ containerUrl: et(e),
118
+ documentName: e.path ? e.path.split("/").pop() : null,
119
+ resourceHash: e.fragment
120
+ }) : {};
121
+ }
122
+ async function rt(t, e, r) {
123
+ r = r ?? window.fetch.bind(r);
124
+ const a = t.storageUrls[0], o = `${a}settings/${e}TypeIndex`;
125
+ return await N(o, { fetch: r }) ? `${a}settings/${e}TypeIndex-${S()}` : o;
126
+ }
127
+ async function q(t, e, r) {
128
+ if (t.writableProfileUrl === null)
129
+ throw new Error("Can't create type index without a writable profile document");
130
+ r = r ?? window.fetch.bind(r);
131
+ const a = await rt(t, e, r), o = e === "public" ? "<> a <http://www.w3.org/ns/solid/terms#TypeIndex> ." : `
132
+ <> a
133
+ <http://www.w3.org/ns/solid/terms#TypeIndex>,
134
+ <http://www.w3.org/ns/solid/terms#UnlistedDocument> .
135
+ `, s = `
136
+ INSERT DATA {
137
+ <${t.webId}> <http://www.w3.org/ns/solid/terms#${e}TypeIndex> <${a}> .
138
+ }
139
+ `;
140
+ return await H(a, o, r), await J(t.writableProfileUrl, s, r), a;
141
+ }
142
+ async function C(t, e, r, a) {
143
+ const o = await m(t, { fetch: a });
144
+ return (Array.isArray(e) ? e : [e]).map((u) => o.statements(void 0, "rdf:type", "solid:TypeRegistration").filter((n) => o.contains(n.subject.value, "solid:forClass", u)).map((n) => o.statements(n.subject.value, r)).flat().map((n) => n.object.value).filter((n) => !!n)).flat();
145
+ }
146
+ async function lt(t, e) {
147
+ return q(t, "public", e);
148
+ }
149
+ async function dt(t, e) {
150
+ return q(t, "private", e);
151
+ }
152
+ async function ft(t, e, r) {
153
+ return C(t, e, "solid:instanceContainer", r);
154
+ }
155
+ async function mt(t, e, r) {
156
+ return C(t, e, "solid:instance", r);
157
+ }
158
+ async function R(t, e) {
159
+ var s;
160
+ e = e ?? window.fetch.bind(window);
161
+ const o = ((s = ((await e(t, { method: "HEAD" })).headers.get("Link") ?? "").match(/<([^>]+)>;\s*rel="acl"/)) == null ? void 0 : s[1]) ?? null;
162
+ if (!o)
163
+ throw new Error(`Could not find ACL Resource for '${t}'`);
164
+ return K(D(t), o);
165
+ }
166
+ async function A(t, e, r) {
167
+ r = r ?? await R(t, e);
168
+ const a = await z(r ?? "", { fetch: e });
169
+ if (!a)
170
+ return A(D(t), e);
171
+ if (a.isACPResource())
172
+ throw new Y(t, "ACP");
173
+ return a;
174
+ }
175
+ async function pt(t, e) {
176
+ const r = await R(t, e), a = await A(t, e, r);
177
+ return h({
178
+ url: r,
179
+ effectiveUrl: a.url,
180
+ document: a
181
+ });
182
+ }
183
+ export {
184
+ yt as MalformedSolidDocumentError,
185
+ vt as NetworkRequestError,
186
+ Tt as NotFoundError,
187
+ gt as SolidDocument,
188
+ xt as SolidDocumentFormat,
189
+ Pt as SolidDocumentPermission,
190
+ k as SolidStore,
191
+ Ut as SolidThing,
192
+ Q as UnauthorizedError,
193
+ st as UnsuccessfulNetworkRequestError,
194
+ Y as UnsupportedAuthorizationProtocolError,
195
+ bt as compactJsonLDGraph,
196
+ dt as createPrivateTypeIndex,
197
+ lt as createPublicTypeIndex,
198
+ H as createSolidDocument,
199
+ $t as defineIRIPrefix,
200
+ Et as expandIRI,
201
+ it as fetchLoginUserProfile,
202
+ m as fetchSolidDocument,
203
+ pt as fetchSolidDocumentACL,
204
+ z as fetchSolidDocumentIfFound,
205
+ ft as findContainerRegistrations,
206
+ mt as findInstanceRegistrations,
207
+ jt as isJsonLDGraph,
208
+ St as jsonldToQuads,
209
+ ct as mintJsonLDIdentifiers,
210
+ Dt as normalizeSparql,
211
+ qt as normalizeTurtle,
212
+ ut as parseResourceSubject,
213
+ Ct as parseTurtle,
214
+ Rt as quadToTurtle,
215
+ At as quadsToJsonLD,
216
+ It as quadsToTurtle,
217
+ N as solidDocumentExists,
218
+ Lt as sparqlToQuads,
219
+ kt as sparqlToQuadsSync,
220
+ Qt as turtleToQuads,
221
+ Ht as turtleToQuadsSync,
222
+ J as updateSolidDocument
223
+ };
224
+ //# sourceMappingURL=noeldemartin-solid-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noeldemartin-solid-utils.js","sources":["../src/errors/UnsuccessfulNetworkRequestError.ts","../src/errors/UnsupportedAuthorizationProtocolError.ts","../src/helpers/auth.ts","../src/helpers/identifiers.ts","../src/helpers/interop.ts","../src/helpers/wac.ts"],"sourcesContent":["import { JSError } from '@noeldemartin/utils';\n\nfunction getErrorMessage(messageOrResponse: string | Response, response?: Response): string {\n response = response ?? (messageOrResponse as Response);\n\n return typeof messageOrResponse === 'string'\n ? `${messageOrResponse} (returned ${response.status} status code)`\n : `Request to ${response.url} returned ${response.status} status code`;\n}\n\nexport default class UnsuccessfulRequestError extends JSError {\n\n public response: Response;\n\n constructor(response: Response);\n constructor(message: string, response: Response);\n constructor(messageOrResponse: string | Response, response?: Response) {\n super(getErrorMessage(messageOrResponse, response));\n\n this.response = response ?? (messageOrResponse as Response);\n }\n\n}\n","import { JSError } from '@noeldemartin/utils';\nimport type { JSErrorOptions } from '@noeldemartin/utils';\n\nexport default class UnsupportedAuthorizationProtocolError extends JSError {\n\n public readonly url: string;\n public readonly protocol: string;\n\n constructor(url: string, protocol: string, options?: JSErrorOptions) {\n super(`The resource at ${url} is using an unsupported authorization protocol (${protocol})`, options);\n\n this.url = url;\n this.protocol = protocol;\n }\n\n}\n","import { arrayUnique, objectWithoutEmpty, silenced, urlParentDirectory, urlRoot, urlRoute } from '@noeldemartin/utils';\n\nimport SolidStore from '../models/SolidStore';\nimport UnauthorizedError from '../errors/UnauthorizedError';\nimport type SolidDocument from '../models/SolidDocument';\n\nimport { fetchSolidDocument } from './io';\nimport type { Fetch, FetchSolidDocumentOptions } from './io';\n\nexport interface SolidUserProfile {\n webId: string;\n storageUrls: [string, ...string[]];\n cloaked: boolean;\n writableProfileUrl: string | null;\n name?: string;\n avatarUrl?: string;\n oidcIssuerUrl?: string;\n publicTypeIndexUrl?: string;\n privateTypeIndexUrl?: string;\n}\n\nasync function fetchExtendedUserProfile(\n webIdDocument: SolidDocument,\n options?: FetchSolidDocumentOptions,\n): Promise<{\n store: SolidStore;\n cloaked: boolean;\n writableProfileUrl: string | null;\n}> {\n const store = new SolidStore(webIdDocument.getQuads());\n const documents: Record<string, SolidDocument | false | null> = { [webIdDocument.url]: webIdDocument };\n const addReferencedDocumentUrls = (document: SolidDocument) => {\n document\n .statements(undefined, 'foaf:isPrimaryTopicOf')\n .map((quad) => quad.object.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n document\n .statements(undefined, 'foaf:primaryTopic')\n .map((quad) => quad.subject.value)\n .forEach((profileDocumentUrl) => (documents[profileDocumentUrl] = documents[profileDocumentUrl] ?? null));\n };\n const loadProfileDocuments = async (): Promise<void> => {\n for (const [url, document] of Object.entries(documents)) {\n if (document !== null) {\n continue;\n }\n\n try {\n const _document = await fetchSolidDocument(url, options);\n\n documents[url] = _document;\n store.addQuads(_document.getQuads());\n\n addReferencedDocumentUrls(_document);\n } catch (error) {\n if (error instanceof UnauthorizedError) {\n documents[url] = false;\n\n continue;\n }\n\n throw error;\n }\n }\n };\n\n addReferencedDocumentUrls(webIdDocument);\n\n do {\n await loadProfileDocuments();\n } while (Object.values(documents).some((document) => document === null));\n\n return {\n store,\n cloaked: Object.values(documents).some((document) => document === false),\n writableProfileUrl: webIdDocument.isUserWritable()\n ? webIdDocument.url\n : (Object.values(documents).find(\n (document): document is SolidDocument => !!document && document.isUserWritable(),\n )?.url ?? null),\n };\n}\n\nasync function fetchUserProfile(webId: string, options: FetchUserProfileOptions = {}): Promise<SolidUserProfile> {\n const requestOptions: FetchSolidDocumentOptions = {\n fetch: options.fetch,\n\n // Needed for CSS v7.1.3.\n // See https://github.com/CommunitySolidServer/CommunitySolidServer/issues/1972\n cache: 'no-store',\n };\n\n const documentUrl = urlRoute(webId);\n const document = await fetchSolidDocument(documentUrl, requestOptions);\n\n if (!document.isPersonalProfile() && !document.contains(webId, 'solid:oidcIssuer')) {\n throw new Error(`${webId} is not a valid webId.`);\n }\n\n const { store, writableProfileUrl, cloaked } = await fetchExtendedUserProfile(document, options);\n const storageUrls = store.statements(webId, 'pim:storage').map((storage) => storage.object.value);\n const publicTypeIndex = store.statement(webId, 'solid:publicTypeIndex');\n const privateTypeIndex = store.statement(webId, 'solid:privateTypeIndex');\n\n let parentUrl = urlParentDirectory(documentUrl);\n while (parentUrl && storageUrls.length === 0) {\n const parentDocument = await silenced(fetchSolidDocument(parentUrl, requestOptions));\n\n if (parentDocument?.isStorage()) {\n storageUrls.push(parentUrl);\n\n break;\n }\n\n parentUrl = urlParentDirectory(parentUrl);\n }\n\n if (storageUrls.length === 0) {\n throw new Error(`Could not find any storage for ${webId}.`);\n }\n\n await options.onLoaded?.(store);\n\n return {\n webId,\n cloaked,\n writableProfileUrl,\n storageUrls: arrayUnique(storageUrls) as [string, ...string[]],\n ...objectWithoutEmpty({\n name: store.statement(webId, 'vcard:fn')?.object.value ?? store.statement(webId, 'foaf:name')?.object.value,\n avatarUrl:\n store.statement(webId, 'vcard:hasPhoto')?.object.value ??\n store.statement(webId, 'foaf:img')?.object.value,\n oidcIssuerUrl: store.statement(webId, 'solid:oidcIssuer')?.object.value,\n publicTypeIndexUrl: publicTypeIndex?.object.value,\n privateTypeIndexUrl: privateTypeIndex?.object.value,\n }),\n };\n}\n\nexport interface FetchUserProfileOptions {\n fetch?: Fetch;\n onLoaded?(store: SolidStore): Promise<unknown> | unknown;\n}\n\nexport interface FetchLoginUserProfileOptions extends FetchUserProfileOptions {\n required?: boolean;\n}\n\nexport async function fetchLoginUserProfile(\n loginUrl: string,\n options: FetchLoginUserProfileOptions = {},\n): Promise<SolidUserProfile | null> {\n if (options.required) {\n return fetchUserProfile(loginUrl, options);\n }\n\n const fetchProfile = silenced((url) => fetchUserProfile(url, options));\n\n return (\n (await fetchProfile(loginUrl)) ??\n (await fetchProfile(loginUrl.replace(/\\/$/, '').concat('/profile/card#me'))) ??\n (await fetchProfile(urlRoot(loginUrl).concat('/profile/card#me')))\n );\n}\n","import { arr, isArray, isObject, objectDeepClone, objectWithoutEmpty, tap, urlParse, uuid } from '@noeldemartin/utils';\nimport type { UrlParts } from '@noeldemartin/utils';\nimport type { JsonLD, JsonLDResource } from '@noeldemartin/solid-utils/helpers';\n\nexport interface SubjectParts {\n containerUrl?: string;\n documentName?: string;\n resourceHash?: string;\n}\n\nfunction getContainerPath(parts: UrlParts): string | null {\n if (!parts.path || !parts.path.startsWith('/')) return null;\n\n if (parts.path.match(/^\\/[^/]*$/)) return '/';\n\n return `/${arr(parts.path.split('/')).filter().slice(0, -1).join('/')}/`.replace('//', '/');\n}\n\nfunction getContainerUrl(parts: UrlParts): string | null {\n const containerPath = getContainerPath(parts);\n\n return parts.protocol && parts.domain\n ? `${parts.protocol}://${parts.domain}${containerPath ?? '/'}`\n : containerPath;\n}\n\nfunction __mintJsonLDIdentifiers(jsonld: JsonLD): void {\n if (!('@type' in jsonld) || '@value' in jsonld) return;\n\n jsonld['@id'] = jsonld['@id'] ?? uuid();\n\n for (const propertyValue of Object.values(jsonld)) {\n if (isObject(propertyValue)) __mintJsonLDIdentifiers(propertyValue);\n\n if (isArray(propertyValue)) propertyValue.forEach((value) => isObject(value) && __mintJsonLDIdentifiers(value));\n }\n}\n\nexport function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource {\n return tap(objectDeepClone(jsonld) as JsonLDResource, (clone) => __mintJsonLDIdentifiers(clone));\n}\n\nexport function parseResourceSubject(subject: string): SubjectParts {\n const parts = urlParse(subject);\n\n return !parts\n ? {}\n : objectWithoutEmpty({\n containerUrl: getContainerUrl(parts),\n documentName: parts.path ? parts.path.split('/').pop() : null,\n resourceHash: parts.fragment,\n });\n}\n","import { uuid } from '@noeldemartin/utils';\n\nimport {\n createSolidDocument,\n fetchSolidDocument,\n solidDocumentExists,\n updateSolidDocument,\n} from '@noeldemartin/solid-utils/helpers/io';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\nimport type { SolidUserProfile } from '@noeldemartin/solid-utils/helpers/auth';\n\ntype TypeIndexType = 'public' | 'private';\n\nasync function mintTypeIndexUrl(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const storageUrl = user.storageUrls[0];\n const typeIndexUrl = `${storageUrl}settings/${type}TypeIndex`;\n\n return (await solidDocumentExists(typeIndexUrl, { fetch }))\n ? `${storageUrl}settings/${type}TypeIndex-${uuid()}`\n : typeIndexUrl;\n}\n\nasync function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetch?: Fetch) {\n if (user.writableProfileUrl === null) {\n throw new Error('Can\\'t create type index without a writable profile document');\n }\n\n fetch = fetch ?? window.fetch.bind(fetch);\n\n const typeIndexUrl = await mintTypeIndexUrl(user, type, fetch);\n const typeIndexBody =\n type === 'public'\n ? '<> a <http://www.w3.org/ns/solid/terms#TypeIndex> .'\n : `\n <> a\n <http://www.w3.org/ns/solid/terms#TypeIndex>,\n <http://www.w3.org/ns/solid/terms#UnlistedDocument> .\n `;\n const profileUpdateBody = `\n INSERT DATA {\n <${user.webId}> <http://www.w3.org/ns/solid/terms#${type}TypeIndex> <${typeIndexUrl}> .\n }\n `;\n\n await createSolidDocument(typeIndexUrl, typeIndexBody, fetch);\n await updateSolidDocument(user.writableProfileUrl, profileUpdateBody, fetch);\n\n if (type === 'public') {\n // TODO This is currently implemented in soukai-solid.\n }\n\n return typeIndexUrl;\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nasync function findRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n predicate: string,\n fetch?: Fetch,\n): Promise<string[]> {\n const typeIndex = await fetchSolidDocument(typeIndexUrl, { fetch });\n const types = Array.isArray(type) ? type : [type];\n\n return types\n .map((_type) =>\n typeIndex\n .statements(undefined, 'rdf:type', 'solid:TypeRegistration')\n .filter((statement) => typeIndex.contains(statement.subject.value, 'solid:forClass', _type))\n .map((statement) => typeIndex.statements(statement.subject.value, predicate))\n .flat()\n .map((statement) => statement.object.value)\n .filter((url) => !!url))\n .flat();\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'public', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {\n return createTypeIndex(user, 'private', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findContainerRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);\n}\n\n/**\n * @deprecated Use soukai-solid instead\n */\nexport async function findInstanceRegistrations(\n typeIndexUrl: string,\n type: string | string[],\n fetch?: Fetch,\n): Promise<string[]> {\n return findRegistrations(typeIndexUrl, type, 'solid:instance', fetch);\n}\n","import { objectWithoutEmpty, requireUrlParentDirectory, urlResolve } from '@noeldemartin/utils';\n\n// eslint-disable-next-line max-len\nimport UnsupportedAuthorizationProtocolError from '@noeldemartin/solid-utils/errors/UnsupportedAuthorizationProtocolError';\nimport { fetchSolidDocumentIfFound } from '@noeldemartin/solid-utils/helpers/io';\nimport type SolidDocument from '@noeldemartin/solid-utils/models/SolidDocument';\nimport type { Fetch } from '@noeldemartin/solid-utils/helpers/io';\n\nasync function fetchACLResourceUrl(resourceUrl: string, fetch: Fetch): Promise<string> {\n fetch = fetch ?? window.fetch.bind(window);\n\n const resourceHead = await fetch(resourceUrl, { method: 'HEAD' });\n const linkHeader = resourceHead.headers.get('Link') ?? '';\n const url = linkHeader.match(/<([^>]+)>;\\s*rel=\"acl\"/)?.[1] ?? null;\n\n if (!url) {\n throw new Error(`Could not find ACL Resource for '${resourceUrl}'`);\n }\n\n return urlResolve(requireUrlParentDirectory(resourceUrl), url);\n}\n\nasync function fetchEffectiveACL(\n resourceUrl: string,\n fetch: Fetch,\n aclResourceUrl?: string | null,\n): Promise<SolidDocument> {\n aclResourceUrl = aclResourceUrl ?? (await fetchACLResourceUrl(resourceUrl, fetch));\n\n const aclDocument = await fetchSolidDocumentIfFound(aclResourceUrl ?? '', { fetch });\n\n if (!aclDocument) {\n return fetchEffectiveACL(requireUrlParentDirectory(resourceUrl), fetch);\n }\n\n if (aclDocument.isACPResource()) {\n throw new UnsupportedAuthorizationProtocolError(resourceUrl, 'ACP');\n }\n\n return aclDocument;\n}\n\nexport async function fetchSolidDocumentACL(\n documentUrl: string,\n fetch: Fetch,\n): Promise<{\n url: string;\n effectiveUrl: string;\n document: SolidDocument;\n}> {\n const url = await fetchACLResourceUrl(documentUrl, fetch);\n const document = await fetchEffectiveACL(documentUrl, fetch, url);\n\n return objectWithoutEmpty({\n url,\n effectiveUrl: document.url,\n document,\n });\n}\n"],"names":["getErrorMessage","messageOrResponse","response","UnsuccessfulRequestError","JSError","__publicField","UnsupportedAuthorizationProtocolError","url","protocol","options","fetchExtendedUserProfile","webIdDocument","store","SolidStore","documents","addReferencedDocumentUrls","document","quad","profileDocumentUrl","loadProfileDocuments","_document","fetchSolidDocument","error","UnauthorizedError","_a","fetchUserProfile","webId","requestOptions","documentUrl","urlRoute","writableProfileUrl","cloaked","storageUrls","storage","publicTypeIndex","privateTypeIndex","parentUrl","urlParentDirectory","parentDocument","silenced","arrayUnique","objectWithoutEmpty","_b","_c","_d","_e","_f","fetchLoginUserProfile","loginUrl","fetchProfile","urlRoot","getContainerPath","parts","arr","getContainerUrl","containerPath","__mintJsonLDIdentifiers","jsonld","uuid","propertyValue","isObject","isArray","value","mintJsonLDIdentifiers","tap","objectDeepClone","clone","parseResourceSubject","subject","urlParse","mintTypeIndexUrl","user","type","fetch","storageUrl","typeIndexUrl","solidDocumentExists","createTypeIndex","typeIndexBody","profileUpdateBody","createSolidDocument","updateSolidDocument","findRegistrations","predicate","typeIndex","_type","statement","createPublicTypeIndex","createPrivateTypeIndex","findContainerRegistrations","findInstanceRegistrations","fetchACLResourceUrl","resourceUrl","urlResolve","requireUrlParentDirectory","fetchEffectiveACL","aclResourceUrl","aclDocument","fetchSolidDocumentIfFound","fetchSolidDocumentACL"],"mappings":";;;;;;AAEA,SAASA,EAAgBC,GAAsCC,GAA6B;AACxF,SAAAA,IAAWA,KAAaD,GAEjB,OAAOA,KAAsB,WAC9B,GAAGA,CAAiB,cAAcC,EAAS,MAAM,kBACjD,cAAcA,EAAS,GAAG,aAAaA,EAAS,MAAM;AAChE;AAEA,MAAqBC,WAAiCC,EAAQ;AAAA,EAM1D,YAAYH,GAAsCC,GAAqB;AAC7D,UAAAF,EAAgBC,GAAmBC,CAAQ,CAAC;AAL/C,IAAAG,EAAA;AAOH,SAAK,WAAWH,KAAaD;AAAA,EAAA;AAGrC;ACnBA,MAAqBK,UAA8CF,EAAQ;AAAA,EAKvE,YAAYG,GAAaC,GAAkBC,GAA0B;AACjE,UAAM,mBAAmBF,CAAG,oDAAoDC,CAAQ,KAAKC,CAAO;AAJxF,IAAAJ,EAAA;AACA,IAAAA,EAAA;AAKZ,SAAK,MAAME,GACX,KAAK,WAAWC;AAAA,EAAA;AAGxB;ACMA,eAAeE,EACXC,GACAF,GAKD;;AACC,QAAMG,IAAQ,IAAIC,EAAWF,EA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D,EAAMmB,GAAa,EAAE,QAAQ,QAAQ,GAChC,QAAQ,IAAI,MAAM,KAAK,IAChC,MAAM,wBAAwB,MAAzC,gBAAApE,EAA6C,OAAM;AAE/D,MAAI,CAACjB;AACD,UAAM,IAAI,MAAM,oCAAoCqF,CAAW,GAAG;AAGtE,SAAOC,EAAWC,EAA0BF,CAAW,GAAGrF,CAAG;AACjE;AAEA,eAAewF,EACXH,GACAnB,GACAuB,GACsB;AACtB,EAAAA,IAAiBA,KAAmB,MAAML,EAAoBC,GAAanB,CAAK;AAEhF,QAAMwB,IAAc,MAAMC,EAA0BF,KAAkB,IAAI,EAAE,OAAAvB,GAAO;AAEnF,MAAI,CAACwB;AACD,WAAOF,EAAkBD,EAA0BF,CAAW,GAAGnB,CAAK;AAGtE,MAAAwB,EAAY;AACN,UAAA,IAAI3F,EAAsCsF,GAAa,KAAK;AAG/D,SAAAK;AACX;AAEsB,eAAAE,GAClBvE,GACA6C,GAKD;AACC,QAAMlE,IAAM,MAAMoF,EAAoB/D,GAAa6C,CAAK,GAClDzD,IAAW,MAAM+E,EAAkBnE,GAAa6C,GAAOlE,CAAG;AAEhE,SAAOkC,EAAmB;AAAA,IACtB,KAAAlC;AAAA,IACA,cAAcS,EAAS;AAAA,IACvB,UAAAA;AAAA,EAAA,CACH;AACL;"}
@@ -0,0 +1,40 @@
1
+ export declare interface EqualityResult {
2
+ success: boolean;
3
+ message: string;
4
+ expected: string;
5
+ actual: string;
6
+ }
7
+
8
+ declare type JsonLD = Partial<{
9
+ '@context': Record<string, unknown>;
10
+ '@id': string;
11
+ '@type': null | string | string[];
12
+ }> & {
13
+ [k: string]: unknown;
14
+ };
15
+
16
+ export declare function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult>;
17
+
18
+ export declare function sparqlEquals(expected: string, actual: string): EqualityResult;
19
+
20
+ export declare function turtleEquals(expected: string, actual: string): EqualityResult;
21
+
22
+ export { }
23
+
24
+
25
+ declare module '@vitest/expect' {
26
+ interface Assertion<T> extends VitestSolidMatchers<T> {
27
+ }
28
+ interface AsymmetricMatchersContaining extends VitestSolidMatchers {
29
+ }
30
+ }
31
+
32
+
33
+ declare global {
34
+ namespace Chai {
35
+ interface Assertion extends ChaiSolidAssertions {
36
+ }
37
+ interface Include extends ChaiSolidAssertions {
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,7 @@
1
+ import { j as l, s as q, t as r } from "./helpers-DGXMj9cx.js";
2
+ export {
3
+ l as jsonldEquals,
4
+ q as sparqlEquals,
5
+ r as turtleEquals
6
+ };
7
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}