@noeldemartin/solid-utils 0.6.0 → 0.6.1-next.bf3a764266964fbc17b114eddb9cdb074e1dbef6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chai.d.ts +8 -8
- package/dist/chai.js +1 -1
- package/dist/{helpers-DGXMj9cx.js → helpers-Cm2bMMlG.js} +2 -2
- package/dist/{helpers-DGXMj9cx.js.map → helpers-Cm2bMMlG.js.map} +1 -1
- package/dist/{io-wCcrq4b9.js → io-DqYt65s_.js} +136 -126
- package/dist/io-DqYt65s_.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +50 -9
- package/dist/noeldemartin-solid-utils.js +224 -173
- package/dist/noeldemartin-solid-utils.js.map +1 -1
- package/dist/testing.d.ts +9 -9
- package/dist/testing.js +1 -1
- package/dist/vitest.d.ts +9 -9
- package/dist/vitest.js +2 -2
- package/package.json +11 -4
- package/src/helpers/auth.test.ts +21 -23
- package/src/helpers/io.test.ts +50 -1
- package/src/helpers/io.ts +19 -3
- package/src/helpers/jsonld.ts +1 -1
- package/src/helpers/vocabs.ts +1 -0
- package/src/helpers/wac.test.ts +15 -11
- package/src/index.ts +1 -0
- package/src/rdf/RDFDefaultGraph.ts +12 -0
- package/src/rdf/RDFLiteral.ts +27 -0
- package/src/rdf/RDFNamedNode.ts +16 -0
- package/src/rdf/RDFQuad.ts +32 -0
- package/src/rdf/constants.ts +5 -0
- package/src/rdf/index.ts +4 -0
- package/src/testing/setup.ts +4 -0
- package/dist/io-wCcrq4b9.js.map +0 -1
package/dist/chai.d.ts
CHANGED
|
@@ -13,6 +13,14 @@ export declare function installChaiSolidAssertions(): void;
|
|
|
13
13
|
export { }
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
declare module '@vitest/expect' {
|
|
17
|
+
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
18
|
+
}
|
|
19
|
+
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
16
24
|
declare global {
|
|
17
25
|
namespace Chai {
|
|
18
26
|
interface Assertion extends ChaiSolidAssertions {
|
|
@@ -21,11 +29,3 @@ declare global {
|
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
declare module '@vitest/expect' {
|
|
27
|
-
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
28
|
-
}
|
|
29
|
-
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
30
|
-
}
|
|
31
|
-
}
|
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-DGXMj9cx.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":";;AA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AAkBpB,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"],"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,SA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
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (r, t, e) =>
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { JSError as
|
|
7
|
-
import { Parser as
|
|
8
|
-
function
|
|
1
|
+
var L = Object.defineProperty;
|
|
2
|
+
var Q = (r, t, e) => t in r ? L(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var i = (r, t, e) => Q(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import m from "jsonld";
|
|
5
|
+
import z from "md5";
|
|
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
|
+
import { Parser as j, Writer as S, BlankNode as O, Quad as U } from "n3";
|
|
8
|
+
function J(r, t, e) {
|
|
9
9
|
return r ? `Malformed ${t} document found at ${r} - ${e}` : `Malformed ${t} document - ${e}`;
|
|
10
10
|
}
|
|
11
|
-
var
|
|
12
|
-
class P extends
|
|
11
|
+
var g = /* @__PURE__ */ ((r) => (r.Turtle = "Turtle", r))(g || {});
|
|
12
|
+
class P extends f {
|
|
13
13
|
constructor(e, s, n) {
|
|
14
|
-
super(
|
|
14
|
+
super(J(e, s, n));
|
|
15
15
|
i(this, "documentUrl");
|
|
16
16
|
i(this, "documentFormat");
|
|
17
17
|
i(this, "malformationDetails");
|
|
18
18
|
this.documentUrl = e, this.documentFormat = s, this.malformationDetails = n;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
class
|
|
21
|
+
class _ extends f {
|
|
22
22
|
constructor(e, s) {
|
|
23
23
|
super(`Request failed trying to fetch ${e}`, s);
|
|
24
24
|
i(this, "url");
|
|
25
25
|
this.url = e;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class w extends f {
|
|
29
29
|
constructor(e) {
|
|
30
30
|
super(`Document with '${e}' url not found`);
|
|
31
31
|
i(this, "url");
|
|
32
32
|
this.url = e;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function G(r, t) {
|
|
36
36
|
return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${r}`;
|
|
37
37
|
}
|
|
38
|
-
class
|
|
38
|
+
class v extends f {
|
|
39
39
|
constructor(e, s) {
|
|
40
|
-
super(
|
|
40
|
+
super(G(e, s));
|
|
41
41
|
i(this, "url");
|
|
42
42
|
i(this, "responseStatus");
|
|
43
43
|
this.url = e, this.responseStatus = s;
|
|
@@ -46,7 +46,7 @@ class R extends h {
|
|
|
46
46
|
return typeof this.responseStatus < "u" ? this.responseStatus === 403 : void 0;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const D = {
|
|
50
50
|
acl: "http://www.w3.org/ns/auth/acl#",
|
|
51
51
|
foaf: "http://xmlns.com/foaf/0.1/",
|
|
52
52
|
ldp: "http://www.w3.org/ns/ldp#",
|
|
@@ -56,24 +56,25 @@ const j = {
|
|
|
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
|
-
function
|
|
62
|
-
|
|
62
|
+
function lt(r, t) {
|
|
63
|
+
D[r] = t;
|
|
63
64
|
}
|
|
64
|
-
function
|
|
65
|
+
function d(r, t = {}) {
|
|
65
66
|
var n;
|
|
66
67
|
if (r.startsWith("http")) return r;
|
|
67
68
|
const [e, s] = r.split(":");
|
|
68
69
|
if (e && s) {
|
|
69
|
-
const a =
|
|
70
|
+
const a = D[e] ?? ((n = t.extraContext) == null ? void 0 : n[e]) ?? null;
|
|
70
71
|
if (!a) throw new Error(`Can't expand IRI with unknown prefix: '${r}'`);
|
|
71
72
|
return a + s;
|
|
72
73
|
}
|
|
73
74
|
if (!t.defaultPrefix) throw new Error(`Can't expand IRI without a default prefix: '${r}'`);
|
|
74
75
|
return t.defaultPrefix + e;
|
|
75
76
|
}
|
|
76
|
-
class
|
|
77
|
+
class H {
|
|
77
78
|
constructor(t, e) {
|
|
78
79
|
i(this, "url");
|
|
79
80
|
i(this, "quads");
|
|
@@ -81,13 +82,13 @@ class J {
|
|
|
81
82
|
}
|
|
82
83
|
value(t) {
|
|
83
84
|
var e;
|
|
84
|
-
return (e = this.quads.find((s) => s.predicate.value ===
|
|
85
|
+
return (e = this.quads.find((s) => s.predicate.value === d(t))) == null ? void 0 : e.object.value;
|
|
85
86
|
}
|
|
86
87
|
values(t) {
|
|
87
|
-
return this.quads.filter((e) => e.predicate.value ===
|
|
88
|
+
return this.quads.filter((e) => e.predicate.value === d(t)).map((e) => e.object.value);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
class
|
|
91
|
+
class X {
|
|
91
92
|
constructor(t = []) {
|
|
92
93
|
i(this, "quads");
|
|
93
94
|
this.quads = t;
|
|
@@ -116,17 +117,17 @@ class _ {
|
|
|
116
117
|
}
|
|
117
118
|
getThing(t) {
|
|
118
119
|
const e = this.statements(t);
|
|
119
|
-
return new
|
|
120
|
+
return new H(t, e);
|
|
120
121
|
}
|
|
121
122
|
expandIRI(t) {
|
|
122
|
-
return
|
|
123
|
+
return d(t);
|
|
123
124
|
}
|
|
124
125
|
termMatches(t, e) {
|
|
125
126
|
return typeof e == "string" ? this.expandIRI(e) === t.value : t.termType === t.termType && t.value === e.value;
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
var
|
|
129
|
-
class
|
|
129
|
+
var Y = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(Y || {});
|
|
130
|
+
class M extends X {
|
|
130
131
|
constructor(e, s, n) {
|
|
131
132
|
super(s);
|
|
132
133
|
i(this, "url");
|
|
@@ -138,7 +139,7 @@ class D extends _ {
|
|
|
138
139
|
return !!((e = this.headers.get("Link")) != null && e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/));
|
|
139
140
|
}
|
|
140
141
|
isPersonalProfile() {
|
|
141
|
-
return !!this.statement(this.url,
|
|
142
|
+
return !!this.statement(this.url, d("rdf:type"), d("foaf:PersonalProfileDocument"));
|
|
142
143
|
}
|
|
143
144
|
isStorage() {
|
|
144
145
|
var e;
|
|
@@ -158,19 +159,19 @@ class D extends _ {
|
|
|
158
159
|
}
|
|
159
160
|
getLastModified() {
|
|
160
161
|
var e;
|
|
161
|
-
return
|
|
162
|
+
return p(this.headers.get("last-modified")) ?? p((e = this.statement(this.url, "purl:modified")) == null ? void 0 : e.object.value) ?? this.getLatestDocumentDate() ?? null;
|
|
162
163
|
}
|
|
163
164
|
expandIRI(e) {
|
|
164
|
-
return
|
|
165
|
+
return d(e, { defaultPrefix: this.url });
|
|
165
166
|
}
|
|
166
167
|
getLatestDocumentDate() {
|
|
167
|
-
const e = [...this.statements(void 0, "purl:modified"), ...this.statements(void 0, "purl:created")].map((s) =>
|
|
168
|
+
const e = [...this.statements(void 0, "purl:modified"), ...this.statements(void 0, "purl:created")].map((s) => p(s.object.value)).filter((s) => s !== null);
|
|
168
169
|
return e.length > 0 ? e.reduce((s, n) => s > n ? s : n) : null;
|
|
169
170
|
}
|
|
170
171
|
getPermissionsFromWAC(e) {
|
|
171
172
|
var a;
|
|
172
|
-
const s = this.headers.get("WAC-Allow") ?? "", n = ((a =
|
|
173
|
-
return
|
|
173
|
+
const s = this.headers.get("WAC-Allow") ?? "", n = ((a = W(s, new RegExp(`${e}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
|
|
174
|
+
return x([
|
|
174
175
|
n.includes("read") && "read",
|
|
175
176
|
n.includes("write") && "write",
|
|
176
177
|
n.includes("append") && "append",
|
|
@@ -180,100 +181,108 @@ class D extends _ {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
async function dt(r) {
|
|
183
|
-
const t = await
|
|
184
|
+
const t = await m.compact(r, {});
|
|
184
185
|
return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
+
function V(r) {
|
|
187
188
|
return "@graph" in r;
|
|
188
189
|
}
|
|
189
|
-
const
|
|
190
|
-
async function
|
|
190
|
+
const h = "anonymous://", R = h.length;
|
|
191
|
+
async function K(r, t) {
|
|
191
192
|
const e = {
|
|
192
193
|
headers: { Accept: "text/turtle" }
|
|
193
194
|
};
|
|
194
195
|
t != null && t.cache && (e.cache = t.cache);
|
|
195
196
|
try {
|
|
196
197
|
const n = await ((t == null ? void 0 : t.fetch) ?? window.fetch)(r, e);
|
|
197
|
-
if (n.status === 404) throw new
|
|
198
|
-
if ([401, 403].includes(n.status)) throw new
|
|
198
|
+
if (n.status === 404) throw new w(r);
|
|
199
|
+
if ([401, 403].includes(n.status)) throw new v(r, n.status);
|
|
199
200
|
return {
|
|
200
201
|
body: await n.text(),
|
|
201
202
|
headers: n.headers
|
|
202
203
|
};
|
|
203
204
|
} catch (s) {
|
|
204
|
-
throw s instanceof
|
|
205
|
+
throw s instanceof v || s instanceof w ? s : new _(r, { cause: s });
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
-
const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) =>
|
|
209
|
-
|
|
208
|
+
function Z(r) {
|
|
209
|
+
const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => F(
|
|
210
|
+
x([
|
|
210
211
|
n.object.termType === "BlankNode" ? n.object.value : null,
|
|
211
212
|
n.subject.termType === "BlankNode" ? n.subject.value : null
|
|
212
213
|
]),
|
|
213
214
|
(c) => c.forEach((o) => (e[o] ?? (e[o] = /* @__PURE__ */ new Set())).add(a))
|
|
214
215
|
)).filter().unique();
|
|
215
216
|
for (const n of s) {
|
|
216
|
-
const a = e[n], c =
|
|
217
|
+
const a = e[n], c = z(
|
|
217
218
|
b(a).map((o) => r[o]).filter(({ subject: { termType: o, value: u } }) => o === "BlankNode" && u === n).map(({ predicate: o, object: u }) => u.termType === "BlankNode" ? o.value : o.value + u.value).sorted().join()
|
|
218
219
|
);
|
|
219
220
|
for (const o of a) {
|
|
220
|
-
const u = t[o],
|
|
221
|
+
const u = t[o], l = {
|
|
221
222
|
subject: u.subject,
|
|
222
223
|
object: u.object
|
|
223
224
|
};
|
|
224
|
-
for (const [
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
for (const [$, I] of Object.entries(l))
|
|
226
|
+
I.termType !== "BlankNode" || I.value !== n || (l[$] = new O(c));
|
|
227
|
+
B(
|
|
227
228
|
t,
|
|
228
229
|
u,
|
|
229
|
-
new
|
|
230
|
+
new U(l.subject, u.predicate, l.object)
|
|
230
231
|
);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
return t;
|
|
234
235
|
}
|
|
235
236
|
function A(r) {
|
|
236
|
-
return r.map((t) => " " +
|
|
237
|
+
return r.map((t) => " " + st(t)).sort().join(`
|
|
237
238
|
`);
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function N(r) {
|
|
240
241
|
var t;
|
|
241
|
-
(t = r["@id"]) != null && t.startsWith("#")
|
|
242
|
+
if ((t = r["@id"]) != null && t.startsWith("#")) {
|
|
243
|
+
r["@id"] = h + r["@id"];
|
|
244
|
+
for (const [e, s] of Object.entries(r))
|
|
245
|
+
typeof s != "object" || s === null || !("@id" in s) || N(r[e]);
|
|
246
|
+
}
|
|
242
247
|
}
|
|
243
|
-
function
|
|
248
|
+
function tt(r) {
|
|
244
249
|
for (const t of r)
|
|
245
|
-
t.subject.value.startsWith(
|
|
250
|
+
t.subject.value.startsWith(h) && (t.subject.value = t.subject.value.slice(R)), t.object.value.startsWith(h) && (t.object.value = t.object.value.slice(R));
|
|
246
251
|
}
|
|
247
|
-
async function
|
|
252
|
+
async function ht(r, t, e) {
|
|
248
253
|
e = e ?? window.fetch.bind(window);
|
|
249
|
-
const s = await
|
|
254
|
+
const s = await y(t);
|
|
250
255
|
return await e(r, {
|
|
251
256
|
method: "PUT",
|
|
252
257
|
headers: { "Content-Type": "text/turtle" },
|
|
253
258
|
body: t
|
|
254
|
-
}), new
|
|
259
|
+
}), new M(r, s, new Headers({}));
|
|
255
260
|
}
|
|
256
|
-
async function
|
|
257
|
-
const { body: e, headers: s } = await
|
|
258
|
-
return new
|
|
261
|
+
async function C(r, t) {
|
|
262
|
+
const { body: e, headers: s } = await K(r, t), n = await y(e, { baseIRI: r });
|
|
263
|
+
return new M(r, n, s);
|
|
259
264
|
}
|
|
260
|
-
async function
|
|
265
|
+
async function ft(r, t) {
|
|
261
266
|
try {
|
|
262
|
-
return await
|
|
267
|
+
return await C(r, t);
|
|
263
268
|
} catch (e) {
|
|
264
|
-
if (!(e instanceof
|
|
269
|
+
if (!(e instanceof w)) throw e;
|
|
265
270
|
return null;
|
|
266
271
|
}
|
|
267
272
|
}
|
|
268
|
-
async function
|
|
269
|
-
if (
|
|
270
|
-
return (await Promise.all(r["@graph"].map((n) =>
|
|
271
|
-
|
|
272
|
-
const e = await
|
|
273
|
-
return
|
|
273
|
+
async function E(r, t) {
|
|
274
|
+
if (V(r))
|
|
275
|
+
return (await Promise.all(r["@graph"].map((n) => E(n, t)))).flat();
|
|
276
|
+
N(r);
|
|
277
|
+
const e = await m.toRDF(r, { base: t });
|
|
278
|
+
return tt(e), e;
|
|
279
|
+
}
|
|
280
|
+
async function pt(r, t) {
|
|
281
|
+
const e = await E(structuredClone(r), t);
|
|
282
|
+
return rt(e);
|
|
274
283
|
}
|
|
275
|
-
function
|
|
276
|
-
const t =
|
|
284
|
+
function wt(r) {
|
|
285
|
+
const t = nt(r);
|
|
277
286
|
return Object.entries(t).reduce((e, [s, n]) => {
|
|
278
287
|
const a = A(n);
|
|
279
288
|
return e.concat(`${s.toUpperCase()} DATA {
|
|
@@ -282,85 +291,85 @@ ${a}
|
|
|
282
291
|
}, []).join(` ;
|
|
283
292
|
`);
|
|
284
293
|
}
|
|
285
|
-
function
|
|
286
|
-
const t =
|
|
294
|
+
function mt(r) {
|
|
295
|
+
const t = k(r);
|
|
287
296
|
return A(t);
|
|
288
297
|
}
|
|
289
298
|
function et(r, t = {}) {
|
|
290
|
-
const e = T({ baseIRI: t.baseIRI }), s = new
|
|
299
|
+
const e = T({ baseIRI: t.baseIRI }), s = new j(e), n = {
|
|
291
300
|
quads: [],
|
|
292
301
|
containsRelativeIRIs: !1
|
|
293
302
|
};
|
|
294
303
|
return new Promise((a, c) => {
|
|
295
304
|
const o = s._resolveRelativeIRI;
|
|
296
|
-
s._resolveRelativeIRI = (...u) => (n.containsRelativeIRIs = !0, s._resolveRelativeIRI = o, s._resolveRelativeIRI(...u)), s.parse(r, (u,
|
|
305
|
+
s._resolveRelativeIRI = (...u) => (n.containsRelativeIRIs = !0, s._resolveRelativeIRI = o, s._resolveRelativeIRI(...u)), s.parse(r, (u, l) => {
|
|
297
306
|
if (u) {
|
|
298
307
|
c(
|
|
299
|
-
new P(t.baseIRI ?? null,
|
|
308
|
+
new P(t.baseIRI ?? null, g.Turtle, u.message)
|
|
300
309
|
);
|
|
301
310
|
return;
|
|
302
311
|
}
|
|
303
|
-
if (!
|
|
312
|
+
if (!l) {
|
|
304
313
|
a(n);
|
|
305
314
|
return;
|
|
306
315
|
}
|
|
307
|
-
n.quads.push(
|
|
316
|
+
n.quads.push(l);
|
|
308
317
|
});
|
|
309
318
|
});
|
|
310
319
|
}
|
|
311
|
-
async function
|
|
320
|
+
async function rt(r) {
|
|
312
321
|
return {
|
|
313
|
-
"@graph": await
|
|
322
|
+
"@graph": await m.fromRDF(r)
|
|
314
323
|
};
|
|
315
324
|
}
|
|
316
|
-
function
|
|
325
|
+
function gt(r) {
|
|
317
326
|
return new S().quadsToString(r);
|
|
318
327
|
}
|
|
319
|
-
function
|
|
328
|
+
function st(r) {
|
|
320
329
|
return new S().quadsToString([r]).slice(0, -1);
|
|
321
330
|
}
|
|
322
|
-
async function
|
|
331
|
+
async function yt(r, t) {
|
|
323
332
|
try {
|
|
324
|
-
return !(await
|
|
333
|
+
return !(await C(r, t)).isEmpty();
|
|
325
334
|
} catch {
|
|
326
335
|
return !1;
|
|
327
336
|
}
|
|
328
337
|
}
|
|
329
338
|
async function It(r, t = {}) {
|
|
330
|
-
const e =
|
|
339
|
+
const e = q(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
331
340
|
return await Promise.all(
|
|
332
341
|
[...e].map(async (n) => {
|
|
333
342
|
const a = n[1].toLowerCase(), c = n[2];
|
|
334
|
-
s[a] = await
|
|
343
|
+
s[a] = await y(c, t);
|
|
335
344
|
})
|
|
336
345
|
), s;
|
|
337
346
|
}
|
|
338
|
-
function
|
|
339
|
-
const e =
|
|
347
|
+
function nt(r, t = {}) {
|
|
348
|
+
const e = q(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
340
349
|
for (const n of e) {
|
|
341
350
|
const a = n[1].toLowerCase(), c = n[2];
|
|
342
|
-
s[a] =
|
|
351
|
+
s[a] = k(c, t);
|
|
343
352
|
}
|
|
344
353
|
return s;
|
|
345
354
|
}
|
|
346
|
-
async function
|
|
355
|
+
async function y(r, t = {}) {
|
|
347
356
|
const { quads: e } = await et(r, t);
|
|
348
357
|
return e;
|
|
349
358
|
}
|
|
350
|
-
function
|
|
351
|
-
const e = T({ baseIRI: t.baseIRI }), s = new
|
|
359
|
+
function k(r, t = {}) {
|
|
360
|
+
const e = T({ baseIRI: t.baseIRI }), s = new j(e);
|
|
352
361
|
try {
|
|
353
362
|
const n = s.parse(r);
|
|
354
|
-
return t.normalizeBlankNodes ?
|
|
363
|
+
return t.normalizeBlankNodes ? Z(n) : n;
|
|
355
364
|
} catch (n) {
|
|
356
365
|
throw new P(
|
|
357
366
|
t.baseIRI ?? null,
|
|
358
|
-
|
|
367
|
+
g.Turtle,
|
|
359
368
|
n.message ?? ""
|
|
360
369
|
);
|
|
361
370
|
}
|
|
362
371
|
}
|
|
363
|
-
async function
|
|
372
|
+
async function bt(r, t, e) {
|
|
364
373
|
e = e ?? window.fetch.bind(window), await e(r, {
|
|
365
374
|
method: "PATCH",
|
|
366
375
|
headers: { "Content-Type": "application/sparql-update" },
|
|
@@ -369,33 +378,34 @@ async function yt(r, t, e) {
|
|
|
369
378
|
}
|
|
370
379
|
export {
|
|
371
380
|
P as M,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
381
|
+
_ as N,
|
|
382
|
+
X as S,
|
|
383
|
+
v as U,
|
|
384
|
+
st as a,
|
|
385
|
+
wt as b,
|
|
386
|
+
ht as c,
|
|
387
|
+
yt as d,
|
|
388
|
+
ft as e,
|
|
389
|
+
C as f,
|
|
390
|
+
d as g,
|
|
391
|
+
g as h,
|
|
392
|
+
w as i,
|
|
393
|
+
E as j,
|
|
394
|
+
pt as k,
|
|
395
|
+
rt as l,
|
|
396
|
+
It as m,
|
|
397
|
+
mt as n,
|
|
398
|
+
y as o,
|
|
390
399
|
et as p,
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
+
gt as q,
|
|
401
|
+
dt as r,
|
|
402
|
+
nt as s,
|
|
403
|
+
k as t,
|
|
404
|
+
bt as u,
|
|
405
|
+
V as v,
|
|
406
|
+
lt as w,
|
|
407
|
+
M as x,
|
|
408
|
+
Y as y,
|
|
409
|
+
H as z
|
|
400
410
|
};
|
|
401
|
-
//# sourceMappingURL=io-
|
|
411
|
+
//# sourceMappingURL=io-DqYt65s_.js.map
|