@noeldemartin/solid-utils 0.6.1-next.0d15181b9561088547ef2d0f22a04aef565e06bb → 0.6.1-next.bf3a764266964fbc17b114eddb9cdb074e1dbef6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chai.js +1 -1
- package/dist/{helpers-CIIrVGVG.js → helpers-Cm2bMMlG.js} +2 -2
- package/dist/{helpers-CIIrVGVG.js.map → helpers-Cm2bMMlG.js.map} +1 -1
- package/dist/{io-CT3AW8WO.js → io-DqYt65s_.js} +25 -24
- package/dist/io-DqYt65s_.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +40 -1
- package/dist/noeldemartin-solid-utils.js +224 -174
- package/dist/noeldemartin-solid-utils.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/vitest.d.ts +1 -1
- package/dist/vitest.js +2 -2
- package/package.json +2 -1
- package/src/helpers/jsonld.ts +1 -1
- package/src/helpers/vocabs.ts +1 -0
- package/src/index.ts +1 -0
- package/src/rdf/RDFDefaultGraph.ts +12 -0
- package/src/rdf/RDFLiteral.ts +27 -0
- package/src/rdf/RDFNamedNode.ts +16 -0
- package/src/rdf/RDFQuad.ts +32 -0
- package/src/rdf/constants.ts +5 -0
- package/src/rdf/index.ts +4 -0
- package/dist/io-CT3AW8WO.js.map +0 -1
package/dist/chai.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pull as g, arrayRemove as q, JSError as v, stringMatchAll as j } from "@noeldemartin/utils";
|
|
2
|
-
import { j as m, q as T, s as E, a as y, t as w } from "./io-
|
|
2
|
+
import { j as m, q as T, s as E, a as y, t as w } from "./io-DqYt65s_.js";
|
|
3
3
|
let i = {};
|
|
4
4
|
const Q = {
|
|
5
5
|
"%uuid%": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
|
|
@@ -104,4 +104,4 @@ export {
|
|
|
104
104
|
R as s,
|
|
105
105
|
z as t
|
|
106
106
|
};
|
|
107
|
-
//# sourceMappingURL=helpers-
|
|
107
|
+
//# sourceMappingURL=helpers-Cm2bMMlG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-CIIrVGVG.js","sources":["../src/testing/helpers.ts"],"sourcesContent":["import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from '@rdfjs/types';\n\nimport {\n jsonldToQuads,\n quadToTurtle,\n quadsToTurtle,\n sparqlToQuadsSync,\n turtleToQuadsSync,\n} from '@noeldemartin/solid-utils/helpers/io';\nimport type { JsonLD } from '@noeldemartin/solid-utils/helpers/jsonld';\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) 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>(expected, /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g);\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) return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value) 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 (\n quadObjectEquals(expected.object, actual.object) &&\n quadValueEquals(expected.subject.value, actual.subject.value) &&\n quadValueEquals(expected.predicate.value, actual.predicate.value)\n );\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)) 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)) 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)) 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) 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)) throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n"],"names":["patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","JSError","expectedQuad","quadToTurtle","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","quadEquals","arrayRemove","containsPatterns","value","createPatternRegexp","expected","patternAliases","patternMatches","stringMatchAll","patterns","expectedRegExp","patternMatch","patternIndex","pattern","quadValueEquals","actual","quadObjectEquals","resetPatterns","jsonldEquals","jsonldToQuads","expectedTurtle","quadsToTurtle","actualTurtle","result","success","message","error","sparqlEquals","expectedOperations","sparqlToQuadsSync","actualOperations","operation","pull","unexpectedOperation","turtleEquals","turtleToQuadsSync"],"mappings":";;AAYA,IAAIA,IAA+C,CAAC;AACpD,MAAMC,IAA0C;AAAA,EAC5C,UAAU;AACd;AAEA,MAAMC,UAAmCC,EAAQ;AAAA,EAE7C,YAA4BC,GAAoB;AAC5C,UAAM,uCAAuCC,EAAaD,CAAY,CAAC,EAAE,GADjD,KAAA,eAAAA;AAAA,EAAA;AAIhC;AAEA,SAASE,EAAyBC,GAAuBC,GAA2B;AAChF,aAAWJ,KAAgBG,GAAe;AAChC,UAAAE,IAAeD,EAAY,KAAK,CAACE,MAAeC,EAAWP,GAAcM,CAAU,CAAC;AAE1F,QAAI,CAACD,EAAoB,OAAA,IAAIP,EAA2BE,CAAY;AAEpE,IAAAQ,EAAYJ,GAAaC,CAAY;AAAA,EAAA;AAE7C;AAEA,SAASI,EAAiBC,GAAwB;AACvC,SAAA,4BAA4B,KAAKA,CAAK;AACjD;AAEA,SAASC,EAAoBC,GAA0B;AACnD,QAAMC,IAAiB,CAAC,GAClBC,IAAiBC,EAAyBH,GAAU,+BAA+B,GACnFI,IAAqB,CAAC;AAC5B,MAAIC,IAAiBL;AAErB,aAAWM,KAAgBJ;AACvB,IAAAI,EAAa,CAAC,KAAKL,EAAe,KAAKK,EAAa,CAAC,CAAC,GAE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AW;AAAA,aAC9C6B,GAAO;AACR,UAAA,EAAEA,aAAiBnC,GAAmC,OAAAmC;AAEnD,aAAAH;AAAA,QACH;AAAA,QACA,+BAA+BQ,CAAS,YAAYrC,EAAagC,EAAM,YAAY,CAAC;AAAA,MACxF;AAAA,IAAA;AAAA,EACJ;AAGJ,QAAMO,IAAsB,OAAO,KAAKH,CAAgB,EAAE,CAAC,KAAK;AAChE,SAAIG,IAA4BV,EAAO,IAAO,0BAA0BU,CAAmB,WAAW,IAE/FV,EAAO,IAAM,gBAAgB;AACxC;AAEgB,SAAAW,EAAa7B,GAAkBU,GAAgC;AAE7D,EAAAE,EAAA;AAEd,QAAMrB,IAAgBuC,EAAkB9B,GAAU,EAAE,qBAAqB,IAAM,GACzER,IAAcsC,EAAkBpB,GAAQ,EAAE,qBAAqB,IAAM,GACrEQ,IAAS,CAACC,GAAkBC,OAAqB,EAAE,SAAAD,GAAS,SAAAC,GAAS,UAAApB,GAAU,QAAAU;AAEjF,MAAAnB,EAAc,WAAWC,EAAY;AAC9B,WAAA0B,EAAO,IAAO,YAAY3B,EAAc,MAAM,mBAAmBC,EAAY,MAAM,GAAG;AAE7F,MAAA;AACA,IAAAF,EAAyBC,GAAeC,CAAW;AAAA,WAC9C6B,GAAO;AACR,QAAA,EAAEA,aAAiBnC,GAAmC,OAAAmC;AAEnD,WAAAH,EAAO,IAAOG,EAAM,OAAO;AAAA,EAAA;AAG/B,SAAAH,EAAO,IAAM,gBAAgB;AACxC;"}
|
|
1
|
+
{"version":3,"file":"helpers-Cm2bMMlG.js","sources":["../src/testing/helpers.ts"],"sourcesContent":["import { JSError, arrayRemove, pull, stringMatchAll } from '@noeldemartin/utils';\nimport type { Quad, Quad_Object } from '@rdfjs/types';\n\nimport {\n jsonldToQuads,\n quadToTurtle,\n quadsToTurtle,\n sparqlToQuadsSync,\n turtleToQuadsSync,\n} from '@noeldemartin/solid-utils/helpers/io';\nimport type { JsonLD } from '@noeldemartin/solid-utils/helpers/jsonld';\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) 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>(expected, /\\[\\[((.*?)\\]\\[)?([^\\]]+)\\]\\]/g);\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) return false;\n\n if (expected.termType === 'Literal' && actual.termType === 'Literal') {\n if (expected.datatype.value !== actual.datatype.value) 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 (\n quadObjectEquals(expected.object, actual.object) &&\n quadValueEquals(expected.subject.value, actual.subject.value) &&\n quadValueEquals(expected.predicate.value, actual.predicate.value)\n );\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)) 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)) 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)) 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) 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)) throw error;\n\n return result(false, error.message);\n }\n\n return result(true, 'turtle matches');\n}\n"],"names":["patternsRegExpsIndex","builtInPatterns","ExpectedQuadAssertionError","JSError","expectedQuad","quadToTurtle","assertExpectedQuadsExist","expectedQuads","actualQuads","matchingQuad","actualQuad","quadEquals","arrayRemove","containsPatterns","value","createPatternRegexp","expected","patternAliases","patternMatches","stringMatchAll","patterns","expectedRegExp","patternMatch","patternIndex","pattern","quadValueEquals","actual","quadObjectEquals","resetPatterns","jsonldEquals","jsonldToQuads","expectedTurtle","quadsToTurtle","actualTurtle","result","success","message","error","sparqlEquals","expectedOperations","sparqlToQuadsSync","actualOperations","operation","pull","unexpectedOperation","turtleEquals","turtleToQuadsSync"],"m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AAcsC,EAAkBpB,GAAQ,EAAE,qBAAqB,IAAM,GACrEQ,IAAS,CAACC,GAAkBC,OAAqB,EAAE,SAAAD,GAAS,SAAAC,GAAS,UAAApB,GAAU,QAAAU;AAEjF,MAAAnB,EAAc,WAAWC,EAAY;AAC9B,WAAA0B,EAAO,IAAO,YAAY3B,EAAc,MAAM,mBAAmBC,EAAY,MAAM,GAAG;AAE7F,MAAA;AACA,IAAAF,EAAyBC,GAAeC,CAAW;AAAA,WAC9C6B,GAAO;AACR,QAAA,EAAEA,aAAiBnC,GAAmC,OAAAmC;AAEnD,WAAAH,EAAO,IAAOG,EAAM,OAAO;AAAA,EAAA;AAG/B,SAAAH,EAAO,IAAM,gBAAgB;AACxC;"}
|
|
@@ -3,7 +3,7 @@ var Q = (r, t, e) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var i = (r, t, e) => Q(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import m from "jsonld";
|
|
5
5
|
import z from "md5";
|
|
6
|
-
import { JSError as f, parseDate as p, stringMatch as W, arrayFilter as
|
|
6
|
+
import { JSError as f, parseDate as p, stringMatch as W, arrayFilter as x, objectWithoutEmpty as T, stringMatchAll as q, arr as b, tap as F, arrayReplace as B } from "@noeldemartin/utils";
|
|
7
7
|
import { Parser as j, Writer as S, BlankNode as O, Quad as U } from "n3";
|
|
8
8
|
function J(r, t, e) {
|
|
9
9
|
return r ? `Malformed ${t} document found at ${r} - ${e}` : `Malformed ${t} document - ${e}`;
|
|
@@ -56,7 +56,8 @@ const D = {
|
|
|
56
56
|
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
|
|
57
57
|
schema: "https://schema.org/",
|
|
58
58
|
solid: "http://www.w3.org/ns/solid/terms#",
|
|
59
|
-
vcard: "http://www.w3.org/2006/vcard/ns#"
|
|
59
|
+
vcard: "http://www.w3.org/2006/vcard/ns#",
|
|
60
|
+
xsd: "http://www.w3.org/2001/XMLSchema#"
|
|
60
61
|
};
|
|
61
62
|
function lt(r, t) {
|
|
62
63
|
D[r] = t;
|
|
@@ -126,7 +127,7 @@ class X {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
var Y = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(Y || {});
|
|
129
|
-
class
|
|
130
|
+
class M extends X {
|
|
130
131
|
constructor(e, s, n) {
|
|
131
132
|
super(s);
|
|
132
133
|
i(this, "url");
|
|
@@ -170,7 +171,7 @@ class A extends X {
|
|
|
170
171
|
getPermissionsFromWAC(e) {
|
|
171
172
|
var a;
|
|
172
173
|
const s = this.headers.get("WAC-Allow") ?? "", n = ((a = W(s, new RegExp(`${e}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
|
|
173
|
-
return
|
|
174
|
+
return x([
|
|
174
175
|
n.includes("read") && "read",
|
|
175
176
|
n.includes("write") && "write",
|
|
176
177
|
n.includes("append") && "append",
|
|
@@ -206,7 +207,7 @@ async function K(r, t) {
|
|
|
206
207
|
}
|
|
207
208
|
function Z(r) {
|
|
208
209
|
const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => F(
|
|
209
|
-
|
|
210
|
+
x([
|
|
210
211
|
n.object.termType === "BlankNode" ? n.object.value : null,
|
|
211
212
|
n.subject.termType === "BlankNode" ? n.subject.value : null
|
|
212
213
|
]),
|
|
@@ -232,7 +233,7 @@ function Z(r) {
|
|
|
232
233
|
}
|
|
233
234
|
return t;
|
|
234
235
|
}
|
|
235
|
-
function
|
|
236
|
+
function A(r) {
|
|
236
237
|
return r.map((t) => " " + st(t)).sort().join(`
|
|
237
238
|
`);
|
|
238
239
|
}
|
|
@@ -255,11 +256,11 @@ async function ht(r, t, e) {
|
|
|
255
256
|
method: "PUT",
|
|
256
257
|
headers: { "Content-Type": "text/turtle" },
|
|
257
258
|
body: t
|
|
258
|
-
}), new
|
|
259
|
+
}), new M(r, s, new Headers({}));
|
|
259
260
|
}
|
|
260
261
|
async function C(r, t) {
|
|
261
262
|
const { body: e, headers: s } = await K(r, t), n = await y(e, { baseIRI: r });
|
|
262
|
-
return new
|
|
263
|
+
return new M(r, n, s);
|
|
263
264
|
}
|
|
264
265
|
async function ft(r, t) {
|
|
265
266
|
try {
|
|
@@ -283,7 +284,7 @@ async function pt(r, t) {
|
|
|
283
284
|
function wt(r) {
|
|
284
285
|
const t = nt(r);
|
|
285
286
|
return Object.entries(t).reduce((e, [s, n]) => {
|
|
286
|
-
const a =
|
|
287
|
+
const a = A(n);
|
|
287
288
|
return e.concat(`${s.toUpperCase()} DATA {
|
|
288
289
|
${a}
|
|
289
290
|
}`);
|
|
@@ -292,10 +293,10 @@ ${a}
|
|
|
292
293
|
}
|
|
293
294
|
function mt(r) {
|
|
294
295
|
const t = k(r);
|
|
295
|
-
return
|
|
296
|
+
return A(t);
|
|
296
297
|
}
|
|
297
298
|
function et(r, t = {}) {
|
|
298
|
-
const e =
|
|
299
|
+
const e = T({ baseIRI: t.baseIRI }), s = new j(e), n = {
|
|
299
300
|
quads: [],
|
|
300
301
|
containsRelativeIRIs: !1
|
|
301
302
|
};
|
|
@@ -356,7 +357,7 @@ async function y(r, t = {}) {
|
|
|
356
357
|
return e;
|
|
357
358
|
}
|
|
358
359
|
function k(r, t = {}) {
|
|
359
|
-
const e =
|
|
360
|
+
const e = T({ baseIRI: t.baseIRI }), s = new j(e);
|
|
360
361
|
try {
|
|
361
362
|
const n = s.parse(r);
|
|
362
363
|
return t.normalizeBlankNodes ? Z(n) : n;
|
|
@@ -386,25 +387,25 @@ export {
|
|
|
386
387
|
yt as d,
|
|
387
388
|
ft as e,
|
|
388
389
|
C as f,
|
|
389
|
-
g,
|
|
390
|
-
|
|
391
|
-
|
|
390
|
+
d as g,
|
|
391
|
+
g as h,
|
|
392
|
+
w as i,
|
|
392
393
|
E as j,
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
394
|
+
pt as k,
|
|
395
|
+
rt as l,
|
|
396
|
+
It as m,
|
|
396
397
|
mt as n,
|
|
397
|
-
|
|
398
|
+
y as o,
|
|
398
399
|
et as p,
|
|
399
400
|
gt as q,
|
|
400
|
-
|
|
401
|
+
dt as r,
|
|
401
402
|
nt as s,
|
|
402
403
|
k as t,
|
|
403
404
|
bt as u,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
V as v,
|
|
406
|
+
lt as w,
|
|
407
|
+
M as x,
|
|
407
408
|
Y as y,
|
|
408
409
|
H as z
|
|
409
410
|
};
|
|
410
|
-
//# sourceMappingURL=io-
|
|
411
|
+
//# sourceMappingURL=io-DqYt65s_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io-DqYt65s_.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 xsd: 'http://www.w3.org/2001/XMLSchema#',\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> | string;\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 for (const [field, value] of Object.entries(json)) {\n if (typeof value !== 'object' || value === null || !('@id' in value)) {\n continue;\n }\n\n preprocessSubjects(json[field] as JsonLD);\n }\n}\n\nfunction postprocessSubjects(quads: Quad[]): void {\n for (const quad of quads) {\n if (quad.subject.value.startsWith(ANONYMOUS_PREFIX)) {\n quad.subject.value = quad.subject.value.slice(ANONYMOUS_PREFIX_LENGTH);\n }\n\n if (quad.object.value.startsWith(ANONYMOUS_PREFIX)) {\n quad.object.value = quad.object.value.slice(ANONYMOUS_PREFIX_LENGTH);\n }\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 async function normalizeJsonLD(json: JsonLD, baseIRI?: string): Promise<JsonLD> {\n const quads = await jsonldToQuads(structuredClone(json), baseIRI);\n\n return quadsToJsonLD(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","field","postprocessSubjects","createSolidDocument","body","fetch","turtleToQuads","fetchSolidDocument","data","fetchSolidDocumentIfFound","jsonldToQuads","baseIRI","resource","normalizeJsonLD","quadsToJsonLD","normalizeSparql","sparql","sparqlToQuadsSync","normalizedOperations","operation","_quads","normalizeTurtle","turtleToQuadsSync","parseTurtle","turtle","parserOptions","objectWithoutEmpty","parser","Parser","resolve","reject","resolveRelativeIRI","args","quadsToTurtle","Writer","solidDocumentExists","sparqlToQuads","operations","stringMatchAll","operationName","operationBody","updateSolidDocument"],"mappings":";;;;;;;AAEA,SAASA,EACLC,GACAC,GACAC,GACM;AACC,SAAAF,IACD,aAAaC,CAAc,sBAAsBD,CAAW,MAAME,CAAmB,KACrF,aAAaD,CAAc,eAAeC,CAAmB;AACvE;AAEY,IAAAC,sBAAAA,OACRA,EAAA,SAAS,UADDA,IAAAA,KAAA,CAAA,CAAA;AAIZ,MAAqBC,UAAoCC,EAAQ;AAAA,EAM7D,YAAYL,GAA4BC,GAAqCC,GAA6B;AACtG,UAAMH,EAAaC,GAAaC,GAAgBC,CAAmB,CAAC;AALxD,IAAAI,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAKZ,SAAK,cAAcN,GACnB,KAAK,iBAAiBC,GACtB,KAAK,sBAAsBC;AAAA,EAAA;AAGnC;AC3BA,MAAqBK,UAA4BF,EAAQ;AAAA,EAIrD,YAAYG,GAAaC,GAA0B;AACzC,U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AEzC,MAAMA,EAAM7E,GAAK;AAAA,IACb,QAAQ;AAAA,IACR,SAAS,EAAE,gBAAgB,4BAA4B;AAAA,IACvD,MAAA4E;AAAA,EAAA,CACH;AACL;"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { BlankNode } from '@rdfjs/types';
|
|
2
|
+
import { DefaultGraph } from '@rdfjs/types';
|
|
2
3
|
import { JSError } from '@noeldemartin/utils';
|
|
3
4
|
import { JSErrorOptions } from '@noeldemartin/utils';
|
|
4
5
|
import { Literal } from '@rdfjs/types';
|
|
5
6
|
import { MatcherState } from '@vitest/expect';
|
|
6
7
|
import { NamedNode } from '@rdfjs/types';
|
|
7
8
|
import { Quad } from '@rdfjs/types';
|
|
9
|
+
import { Quad_Graph } from '@rdfjs/types';
|
|
10
|
+
import { Quad_Object } from '@rdfjs/types';
|
|
11
|
+
import { Quad_Predicate } from '@rdfjs/types';
|
|
12
|
+
import { Quad_Subject } from '@rdfjs/types';
|
|
13
|
+
import { Term as Term_2 } from '@rdfjs/types';
|
|
8
14
|
import { Variable } from '@rdfjs/types';
|
|
9
15
|
|
|
10
16
|
export declare type AnyFetch = (input: any, options?: any) => Promise<Response>;
|
|
@@ -98,7 +104,7 @@ export declare function findInstanceRegistrations(typeIndexUrl: string, type: st
|
|
|
98
104
|
export declare function isJsonLDGraph(json: JsonLD): json is JsonLDGraph;
|
|
99
105
|
|
|
100
106
|
export declare type JsonLD = Partial<{
|
|
101
|
-
'@context': Record<string, unknown
|
|
107
|
+
'@context': Record<string, unknown> | string;
|
|
102
108
|
'@id': string;
|
|
103
109
|
'@type': null | string | string[];
|
|
104
110
|
}> & {
|
|
@@ -158,11 +164,44 @@ export declare function quadToTurtle(quad: Quad): string;
|
|
|
158
164
|
|
|
159
165
|
export declare type RDFContext = Record<string, string>;
|
|
160
166
|
|
|
167
|
+
export declare class RDFDefaultGraph implements DefaultGraph {
|
|
168
|
+
termType: "DefaultGraph";
|
|
169
|
+
value: "";
|
|
170
|
+
equals(other: Term_2 | null | undefined): boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
161
173
|
export declare interface RDFGraphData {
|
|
162
174
|
quads: Quad[];
|
|
163
175
|
containsRelativeIRIs: boolean;
|
|
164
176
|
}
|
|
165
177
|
|
|
178
|
+
export declare class RDFLiteral implements Literal {
|
|
179
|
+
termType: "Literal";
|
|
180
|
+
value: string;
|
|
181
|
+
language: string;
|
|
182
|
+
datatype: NamedNode;
|
|
183
|
+
constructor(value: string, language?: string, datatype?: NamedNode);
|
|
184
|
+
equals(other: Term_2 | null | undefined): boolean;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export declare class RDFNamedNode implements NamedNode {
|
|
188
|
+
termType: "NamedNode";
|
|
189
|
+
value: string;
|
|
190
|
+
constructor(value: string);
|
|
191
|
+
equals(other: Term_2 | null | undefined): boolean;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export declare class RDFQuad implements Quad {
|
|
195
|
+
termType: "Quad";
|
|
196
|
+
value: "";
|
|
197
|
+
subject: Quad_Subject;
|
|
198
|
+
predicate: Quad_Predicate;
|
|
199
|
+
object: Quad_Object;
|
|
200
|
+
graph: Quad_Graph;
|
|
201
|
+
constructor(subject: string | Quad_Subject, predicate: string | Quad_Predicate, object: string | Quad_Object);
|
|
202
|
+
equals(other: Term_2 | null | undefined): boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
166
205
|
export declare class SolidDocument extends SolidStore {
|
|
167
206
|
readonly url: string;
|
|
168
207
|
readonly headers: Headers;
|