@noeldemartin/solid-utils 0.6.0-next.cccdc9c7e033588e2df9d1887ceae49788344d84 → 0.6.0-next.cea357c45d71b0c9b778bcf63049fce19ae3129f
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 +31 -0
- package/dist/chai.js +23 -0
- package/dist/chai.js.map +1 -0
- package/dist/helpers-j4nIGcvg.js +107 -0
- package/dist/helpers-j4nIGcvg.js.map +1 -0
- package/dist/io-BiadF9_D.js +410 -0
- package/dist/io-BiadF9_D.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +53 -3
- package/dist/noeldemartin-solid-utils.js +167 -532
- package/dist/noeldemartin-solid-utils.js.map +1 -1
- package/dist/testing.d.ts +40 -0
- package/dist/testing.js +7 -0
- package/dist/testing.js.map +1 -0
- package/dist/vitest.d.ts +50 -0
- package/dist/vitest.js +55 -0
- package/dist/vitest.js.map +1 -0
- package/package.json +23 -10
- package/src/chai/assertions.ts +35 -0
- package/src/chai/index.ts +19 -0
- package/src/errors/UnauthorizedError.ts +1 -3
- package/src/errors/UnsuccessfulNetworkRequestError.ts +2 -2
- package/src/helpers/identifiers.ts +13 -16
- package/src/helpers/io.test.ts +47 -1
- package/src/helpers/io.ts +29 -13
- package/src/helpers/jsonld.ts +5 -5
- package/src/helpers/vocabs.ts +3 -6
- package/src/index.ts +1 -0
- package/src/testing/helpers.ts +187 -0
- package/src/testing/hepers.test.ts +329 -0
- package/src/testing/index.ts +1 -0
- package/src/types/index.ts +2 -0
- package/src/types/n3.d.ts +0 -2
- package/src/vitest/index.ts +20 -0
- package/src/vitest/matchers.ts +68 -0
package/dist/chai.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare type ChaiSolidAssertions = {
|
|
2
|
+
[assertion in keyof typeof _default]: (typeof _default)[assertion];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
declare const _default: {
|
|
6
|
+
turtle(this: Chai.AssertionStatic, graph: string): void;
|
|
7
|
+
sparql(this: Chai.AssertionStatic, query: string): void;
|
|
8
|
+
equalityResult(this: Chai.AssertionStatic): void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export declare function installChaiSolidAssertions(): void;
|
|
12
|
+
|
|
13
|
+
export { }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
declare module '@vitest/expect' {
|
|
17
|
+
interface Assertion<T> extends VitestSolidMatchers<T> {
|
|
18
|
+
}
|
|
19
|
+
interface AsymmetricMatchersContaining extends VitestSolidMatchers {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
declare global {
|
|
25
|
+
namespace Chai {
|
|
26
|
+
interface Assertion extends ChaiSolidAssertions {
|
|
27
|
+
}
|
|
28
|
+
interface Include extends ChaiSolidAssertions {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/dist/chai.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { s as o, t as r } from "./helpers-j4nIGcvg.js";
|
|
2
|
+
const i = {
|
|
3
|
+
turtle(t) {
|
|
4
|
+
const s = this, c = s._obj, a = s.assert.bind(this), e = r(t, c);
|
|
5
|
+
a(e.success, e.message, "", e.expected, e.actual);
|
|
6
|
+
},
|
|
7
|
+
sparql(t) {
|
|
8
|
+
const s = this, c = s._obj, a = s.assert.bind(this), e = o(t, c);
|
|
9
|
+
a(e.success, e.message, "", e.expected, e.actual);
|
|
10
|
+
},
|
|
11
|
+
equalityResult() {
|
|
12
|
+
const t = this, s = t._obj;
|
|
13
|
+
t.assert.bind(this)(s.success, s.message, "", s.expected, s.actual);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function u() {
|
|
17
|
+
var t;
|
|
18
|
+
(t = globalThis.chai) == null || t.use((s) => Object.entries(i).forEach(([c, a]) => s.Assertion.addMethod(c, a)));
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
u as installChaiSolidAssertions
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chai.js.map
|
package/dist/chai.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chai.js","sources":["../src/chai/assertions.ts","../src/chai/index.ts"],"sourcesContent":["import { sparqlEquals, turtleEquals } from '@noeldemartin/solid-utils/testing/helpers';\nimport type { EqualityResult } from '@noeldemartin/solid-utils/testing/helpers';\n\nexport function defineChaiAssertions<T extends Record<string, (this: Chai.AssertionStatic, ...args: any[]) => void>>(\n assertions: T): T {\n return assertions;\n}\n\nexport default defineChaiAssertions({\n turtle(graph: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj as string;\n const assert = self.assert.bind(this);\n const expected = graph;\n const result = turtleEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n sparql(query: string): void {\n const self = this as unknown as Chai.AssertionStatic;\n const actual = self._obj as string;\n const assert = self.assert.bind(this);\n const expected = query;\n const result = sparqlEquals(expected, actual);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n equalityResult(): void {\n const self = this as unknown as Chai.AssertionStatic;\n const result = self._obj as EqualityResult;\n const assert = self.assert.bind(this);\n\n assert(result.success, result.message, '', result.expected, result.actual);\n },\n});\n","import assertions from './assertions';\n\nexport type ChaiSolidAssertions = {\n [assertion in keyof typeof assertions]: (typeof assertions)[assertion];\n};\n\nexport function installChaiSolidAssertions(): void {\n (globalThis as { chai?: Chai.ChaiStatic }).chai?.use((_chai) => {\n return Object.entries(assertions).forEach(([name, method]) => _chai.Assertion.addMethod(name, method));\n });\n}\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Chai {\n interface Assertion extends ChaiSolidAssertions {}\n interface Include extends ChaiSolidAssertions {}\n }\n}\n"],"names":["assertions","graph","self","actual","assert","result","turtleEquals","query","sparqlEquals","installChaiSolidAssertions","_a","_chai","name","method"],"mappings":";AAQA,MAAAA,IAAoC;AAAA,EAChC,OAAOC,GAAqB;AACxB,UAAMC,IAAO,MACPC,IAASD,EAAK,MACdE,IAASF,EAAK,OAAO,KAAK,IAAI,GAE9BG,IAASC,EADEL,GACqBE,CAAM;AAErC,IAAAC,EAAAC,EAAO,SAASA,EAAO,SAAS,IAAIA,EAAO,UAAUA,EAAO,MAAM;AAAA,EAC7E;AAAA,EACA,OAAOE,GAAqB;AACxB,UAAML,IAAO,MACPC,IAASD,EAAK,MACdE,IAASF,EAAK,OAAO,KAAK,IAAI,GAE9BG,IAASG,EADED,GACqBJ,CAAM;AAErC,IAAAC,EAAAC,EAAO,SAASA,EAAO,SAAS,IAAIA,EAAO,UAAUA,EAAO,MAAM;AAAA,EAC7E;AAAA,EACA,iBAAuB;AACnB,UAAMH,IAAO,MACPG,IAASH,EAAK;AAGb,IAFQA,EAAK,OAAO,KAAK,IAAI,EAE7BG,EAAO,SAASA,EAAO,SAAS,IAAIA,EAAO,UAAUA,EAAO,MAAM;AAAA,EAAA;AAEjF;AC5BO,SAASI,IAAmC;;AAC9C,GAAAC,IAAA,WAA0C,SAA1C,QAAAA,EAAgD,IAAI,CAACC,MAC3C,OAAO,QAAQX,CAAU,EAAE,QAAQ,CAAC,CAACY,GAAMC,CAAM,MAAMF,EAAM,UAAU,UAAUC,GAAMC,CAAM,CAAC;AAE7G;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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-BiadF9_D.js";
|
|
3
|
+
let i = {};
|
|
4
|
+
const Q = {
|
|
5
|
+
"%uuid%": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
|
|
6
|
+
};
|
|
7
|
+
class c extends v {
|
|
8
|
+
constructor(e) {
|
|
9
|
+
super(`Couldn't find the following triple: ${y(e)}`), this.expectedQuad = e;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function p(t, e) {
|
|
13
|
+
for (const o of t) {
|
|
14
|
+
const r = e.find((n) => k(o, n));
|
|
15
|
+
if (!r) throw new c(o);
|
|
16
|
+
q(e, r);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function $(t) {
|
|
20
|
+
return /\[\[(.*\]\[)?([^\]]+)\]\]/.test(t);
|
|
21
|
+
}
|
|
22
|
+
function b(t) {
|
|
23
|
+
const e = [], o = j(t, /\[\[((.*?)\]\[)?([^\]]+)\]\]/g), r = [];
|
|
24
|
+
let n = t;
|
|
25
|
+
for (const a of o)
|
|
26
|
+
a[2] && e.push(a[2]), r.push(a[3]), n = n.replace(a[0], `%PATTERN${r.length - 1}%`);
|
|
27
|
+
n = n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
28
|
+
for (const [a, s] of Object.entries(r))
|
|
29
|
+
n = n.replace(`%PATTERN${a}%`, Q[s] ?? s);
|
|
30
|
+
return new RegExp(n);
|
|
31
|
+
}
|
|
32
|
+
function d(t, e) {
|
|
33
|
+
return $(t) ? (i[t] ?? (i[t] = b(t))).test(e) : t === e;
|
|
34
|
+
}
|
|
35
|
+
function O(t, e) {
|
|
36
|
+
if (t.termType !== e.termType) return !1;
|
|
37
|
+
if (t.termType === "Literal" && e.termType === "Literal") {
|
|
38
|
+
if (t.datatype.value !== e.datatype.value) return !1;
|
|
39
|
+
if (!$(t.value))
|
|
40
|
+
return t.datatype.value === "http://www.w3.org/2001/XMLSchema#dateTime" ? new Date(t.value).getTime() === new Date(e.value).getTime() : t.value === e.value;
|
|
41
|
+
}
|
|
42
|
+
return d(t.value, e.value);
|
|
43
|
+
}
|
|
44
|
+
function k(t, e) {
|
|
45
|
+
return O(t.object, e.object) && d(t.subject.value, e.subject.value) && d(t.predicate.value, e.predicate.value);
|
|
46
|
+
}
|
|
47
|
+
function h() {
|
|
48
|
+
i = {};
|
|
49
|
+
}
|
|
50
|
+
async function A(t, e) {
|
|
51
|
+
h();
|
|
52
|
+
const o = await m(t), r = await m(e), n = T(o), a = T(r), s = (u, l) => ({
|
|
53
|
+
success: u,
|
|
54
|
+
message: l,
|
|
55
|
+
expected: n,
|
|
56
|
+
actual: a
|
|
57
|
+
});
|
|
58
|
+
if (o.length !== r.length)
|
|
59
|
+
return s(!1, `Expected ${o.length} triples, found ${r.length}.`);
|
|
60
|
+
try {
|
|
61
|
+
p(o, r);
|
|
62
|
+
} catch (u) {
|
|
63
|
+
if (!(u instanceof c)) throw u;
|
|
64
|
+
return s(!1, u.message);
|
|
65
|
+
}
|
|
66
|
+
return s(!0, "jsonld matches");
|
|
67
|
+
}
|
|
68
|
+
function R(t, e) {
|
|
69
|
+
h();
|
|
70
|
+
const o = E(t, { normalizeBlankNodes: !0 }), r = E(e, { normalizeBlankNodes: !0 }), n = (s, u) => ({ success: s, message: u, expected: t, actual: e });
|
|
71
|
+
for (const s of Object.keys(o)) {
|
|
72
|
+
if (!(s in r)) return n(!1, `Couldn't find expected ${s} operation.`);
|
|
73
|
+
const u = g(o, s), l = g(r, s);
|
|
74
|
+
if (u.length !== l.length)
|
|
75
|
+
return n(!1, `Expected ${u.length} ${s} triples, found ${l.length}.`);
|
|
76
|
+
try {
|
|
77
|
+
p(u, l);
|
|
78
|
+
} catch (f) {
|
|
79
|
+
if (!(f instanceof c)) throw f;
|
|
80
|
+
return n(
|
|
81
|
+
!1,
|
|
82
|
+
`Couldn't find the following ${s} triple: ${y(f.expectedQuad)}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const a = Object.keys(r)[0] ?? null;
|
|
87
|
+
return a ? n(!1, `Did not expect to find ${a} triples.`) : n(!0, "sparql matches");
|
|
88
|
+
}
|
|
89
|
+
function z(t, e) {
|
|
90
|
+
h();
|
|
91
|
+
const o = w(t, { normalizeBlankNodes: !0 }), r = w(e, { normalizeBlankNodes: !0 }), n = (a, s) => ({ success: a, message: s, expected: t, actual: e });
|
|
92
|
+
if (o.length !== r.length)
|
|
93
|
+
return n(!1, `Expected ${o.length} triples, found ${r.length}.`);
|
|
94
|
+
try {
|
|
95
|
+
p(o, r);
|
|
96
|
+
} catch (a) {
|
|
97
|
+
if (!(a instanceof c)) throw a;
|
|
98
|
+
return n(!1, a.message);
|
|
99
|
+
}
|
|
100
|
+
return n(!0, "turtle matches");
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
A as j,
|
|
104
|
+
R as s,
|
|
105
|
+
z as t
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=helpers-j4nIGcvg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-j4nIGcvg.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,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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 T, objectWithoutEmpty as x, 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
|
+
return r ? `Malformed ${t} document found at ${r} - ${e}` : `Malformed ${t} document - ${e}`;
|
|
10
|
+
}
|
|
11
|
+
var g = /* @__PURE__ */ ((r) => (r.Turtle = "Turtle", r))(g || {});
|
|
12
|
+
class P extends f {
|
|
13
|
+
constructor(e, s, n) {
|
|
14
|
+
super(J(e, s, n));
|
|
15
|
+
i(this, "documentUrl");
|
|
16
|
+
i(this, "documentFormat");
|
|
17
|
+
i(this, "malformationDetails");
|
|
18
|
+
this.documentUrl = e, this.documentFormat = s, this.malformationDetails = n;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class _ extends f {
|
|
22
|
+
constructor(e, s) {
|
|
23
|
+
super(`Request failed trying to fetch ${e}`, s);
|
|
24
|
+
i(this, "url");
|
|
25
|
+
this.url = e;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
class w extends f {
|
|
29
|
+
constructor(e) {
|
|
30
|
+
super(`Document with '${e}' url not found`);
|
|
31
|
+
i(this, "url");
|
|
32
|
+
this.url = e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function G(r, t) {
|
|
36
|
+
return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${r}`;
|
|
37
|
+
}
|
|
38
|
+
class v extends f {
|
|
39
|
+
constructor(e, s) {
|
|
40
|
+
super(G(e, s));
|
|
41
|
+
i(this, "url");
|
|
42
|
+
i(this, "responseStatus");
|
|
43
|
+
this.url = e, this.responseStatus = s;
|
|
44
|
+
}
|
|
45
|
+
get forbidden() {
|
|
46
|
+
return typeof this.responseStatus < "u" ? this.responseStatus === 403 : void 0;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const D = {
|
|
50
|
+
acl: "http://www.w3.org/ns/auth/acl#",
|
|
51
|
+
foaf: "http://xmlns.com/foaf/0.1/",
|
|
52
|
+
ldp: "http://www.w3.org/ns/ldp#",
|
|
53
|
+
pim: "http://www.w3.org/ns/pim/space#",
|
|
54
|
+
purl: "http://purl.org/dc/terms/",
|
|
55
|
+
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
56
|
+
rdfs: "http://www.w3.org/2000/01/rdf-schema#",
|
|
57
|
+
schema: "https://schema.org/",
|
|
58
|
+
solid: "http://www.w3.org/ns/solid/terms#",
|
|
59
|
+
vcard: "http://www.w3.org/2006/vcard/ns#"
|
|
60
|
+
};
|
|
61
|
+
function lt(r, t) {
|
|
62
|
+
D[r] = t;
|
|
63
|
+
}
|
|
64
|
+
function d(r, t = {}) {
|
|
65
|
+
var n;
|
|
66
|
+
if (r.startsWith("http")) return r;
|
|
67
|
+
const [e, s] = r.split(":");
|
|
68
|
+
if (e && s) {
|
|
69
|
+
const a = D[e] ?? ((n = t.extraContext) == null ? void 0 : n[e]) ?? null;
|
|
70
|
+
if (!a) throw new Error(`Can't expand IRI with unknown prefix: '${r}'`);
|
|
71
|
+
return a + s;
|
|
72
|
+
}
|
|
73
|
+
if (!t.defaultPrefix) throw new Error(`Can't expand IRI without a default prefix: '${r}'`);
|
|
74
|
+
return t.defaultPrefix + e;
|
|
75
|
+
}
|
|
76
|
+
class H {
|
|
77
|
+
constructor(t, e) {
|
|
78
|
+
i(this, "url");
|
|
79
|
+
i(this, "quads");
|
|
80
|
+
this.url = t, this.quads = e;
|
|
81
|
+
}
|
|
82
|
+
value(t) {
|
|
83
|
+
var e;
|
|
84
|
+
return (e = this.quads.find((s) => s.predicate.value === d(t))) == null ? void 0 : e.object.value;
|
|
85
|
+
}
|
|
86
|
+
values(t) {
|
|
87
|
+
return this.quads.filter((e) => e.predicate.value === d(t)).map((e) => e.object.value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class X {
|
|
91
|
+
constructor(t = []) {
|
|
92
|
+
i(this, "quads");
|
|
93
|
+
this.quads = t;
|
|
94
|
+
}
|
|
95
|
+
isEmpty() {
|
|
96
|
+
return this.statements.length === 0;
|
|
97
|
+
}
|
|
98
|
+
getQuads() {
|
|
99
|
+
return this.quads.slice(0);
|
|
100
|
+
}
|
|
101
|
+
addQuads(t) {
|
|
102
|
+
this.quads.push(...t);
|
|
103
|
+
}
|
|
104
|
+
statements(t, e, s) {
|
|
105
|
+
return this.quads.filter(
|
|
106
|
+
(n) => (!s || this.termMatches(n.object, s)) && (!t || this.termMatches(n.subject, t)) && (!e || this.termMatches(n.predicate, e))
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
statement(t, e, s) {
|
|
110
|
+
return this.quads.find(
|
|
111
|
+
(a) => (!s || this.termMatches(a.object, s)) && (!t || this.termMatches(a.subject, t)) && (!e || this.termMatches(a.predicate, e))
|
|
112
|
+
) ?? null;
|
|
113
|
+
}
|
|
114
|
+
contains(t, e, s) {
|
|
115
|
+
return this.statement(t, e, s) !== null;
|
|
116
|
+
}
|
|
117
|
+
getThing(t) {
|
|
118
|
+
const e = this.statements(t);
|
|
119
|
+
return new H(t, e);
|
|
120
|
+
}
|
|
121
|
+
expandIRI(t) {
|
|
122
|
+
return d(t);
|
|
123
|
+
}
|
|
124
|
+
termMatches(t, e) {
|
|
125
|
+
return typeof e == "string" ? this.expandIRI(e) === t.value : t.termType === t.termType && t.value === e.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var Y = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(Y || {});
|
|
129
|
+
class A extends X {
|
|
130
|
+
constructor(e, s, n) {
|
|
131
|
+
super(s);
|
|
132
|
+
i(this, "url");
|
|
133
|
+
i(this, "headers");
|
|
134
|
+
this.url = e, this.headers = n;
|
|
135
|
+
}
|
|
136
|
+
isACPResource() {
|
|
137
|
+
var e;
|
|
138
|
+
return !!((e = this.headers.get("Link")) != null && e.match(/<http:\/\/www\.w3\.org\/ns\/solid\/acp#AccessControlResource>;[^,]+rel="type"/));
|
|
139
|
+
}
|
|
140
|
+
isPersonalProfile() {
|
|
141
|
+
return !!this.statement(this.url, d("rdf:type"), d("foaf:PersonalProfileDocument"));
|
|
142
|
+
}
|
|
143
|
+
isStorage() {
|
|
144
|
+
var e;
|
|
145
|
+
return !!((e = this.headers.get("Link")) != null && e.match(/<http:\/\/www\.w3\.org\/ns\/pim\/space#Storage>;[^,]+rel="type"/));
|
|
146
|
+
}
|
|
147
|
+
isUserWritable() {
|
|
148
|
+
return this.getUserPermissions().includes(
|
|
149
|
+
"write"
|
|
150
|
+
/* Write */
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
getUserPermissions() {
|
|
154
|
+
return this.getPermissionsFromWAC("user");
|
|
155
|
+
}
|
|
156
|
+
getPublicPermissions() {
|
|
157
|
+
return this.getPermissionsFromWAC("public");
|
|
158
|
+
}
|
|
159
|
+
getLastModified() {
|
|
160
|
+
var e;
|
|
161
|
+
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
|
+
expandIRI(e) {
|
|
164
|
+
return d(e, { defaultPrefix: this.url });
|
|
165
|
+
}
|
|
166
|
+
getLatestDocumentDate() {
|
|
167
|
+
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
|
+
return e.length > 0 ? e.reduce((s, n) => s > n ? s : n) : null;
|
|
169
|
+
}
|
|
170
|
+
getPermissionsFromWAC(e) {
|
|
171
|
+
var a;
|
|
172
|
+
const s = this.headers.get("WAC-Allow") ?? "", n = ((a = W(s, new RegExp(`${e}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
|
|
173
|
+
return T([
|
|
174
|
+
n.includes("read") && "read",
|
|
175
|
+
n.includes("write") && "write",
|
|
176
|
+
n.includes("append") && "append",
|
|
177
|
+
n.includes("control") && "control"
|
|
178
|
+
/* Control */
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function dt(r) {
|
|
183
|
+
const t = await m.compact(r, {});
|
|
184
|
+
return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
|
|
185
|
+
}
|
|
186
|
+
function V(r) {
|
|
187
|
+
return "@graph" in r;
|
|
188
|
+
}
|
|
189
|
+
const h = "anonymous://", R = h.length;
|
|
190
|
+
async function K(r, t) {
|
|
191
|
+
const e = {
|
|
192
|
+
headers: { Accept: "text/turtle" }
|
|
193
|
+
};
|
|
194
|
+
t != null && t.cache && (e.cache = t.cache);
|
|
195
|
+
try {
|
|
196
|
+
const n = await ((t == null ? void 0 : t.fetch) ?? window.fetch)(r, e);
|
|
197
|
+
if (n.status === 404) throw new w(r);
|
|
198
|
+
if ([401, 403].includes(n.status)) throw new v(r, n.status);
|
|
199
|
+
return {
|
|
200
|
+
body: await n.text(),
|
|
201
|
+
headers: n.headers
|
|
202
|
+
};
|
|
203
|
+
} catch (s) {
|
|
204
|
+
throw s instanceof v || s instanceof w ? s : new _(r, { cause: s });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function Z(r) {
|
|
208
|
+
const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => F(
|
|
209
|
+
T([
|
|
210
|
+
n.object.termType === "BlankNode" ? n.object.value : null,
|
|
211
|
+
n.subject.termType === "BlankNode" ? n.subject.value : null
|
|
212
|
+
]),
|
|
213
|
+
(c) => c.forEach((o) => (e[o] ?? (e[o] = /* @__PURE__ */ new Set())).add(a))
|
|
214
|
+
)).filter().unique();
|
|
215
|
+
for (const n of s) {
|
|
216
|
+
const a = e[n], c = z(
|
|
217
|
+
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
|
+
for (const o of a) {
|
|
220
|
+
const u = t[o], l = {
|
|
221
|
+
subject: u.subject,
|
|
222
|
+
object: u.object
|
|
223
|
+
};
|
|
224
|
+
for (const [$, I] of Object.entries(l))
|
|
225
|
+
I.termType !== "BlankNode" || I.value !== n || (l[$] = new O(c));
|
|
226
|
+
B(
|
|
227
|
+
t,
|
|
228
|
+
u,
|
|
229
|
+
new U(l.subject, u.predicate, l.object)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return t;
|
|
234
|
+
}
|
|
235
|
+
function M(r) {
|
|
236
|
+
return r.map((t) => " " + st(t)).sort().join(`
|
|
237
|
+
`);
|
|
238
|
+
}
|
|
239
|
+
function N(r) {
|
|
240
|
+
var t;
|
|
241
|
+
if ((t = r["@id"]) != null && t.startsWith("#")) {
|
|
242
|
+
r["@id"] = h + r["@id"];
|
|
243
|
+
for (const [e, s] of Object.entries(r))
|
|
244
|
+
typeof s != "object" || s === null || !("@id" in s) || N(r[e]);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function tt(r) {
|
|
248
|
+
for (const t of r)
|
|
249
|
+
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));
|
|
250
|
+
}
|
|
251
|
+
async function ht(r, t, e) {
|
|
252
|
+
e = e ?? window.fetch.bind(window);
|
|
253
|
+
const s = await y(t);
|
|
254
|
+
return await e(r, {
|
|
255
|
+
method: "PUT",
|
|
256
|
+
headers: { "Content-Type": "text/turtle" },
|
|
257
|
+
body: t
|
|
258
|
+
}), new A(r, s, new Headers({}));
|
|
259
|
+
}
|
|
260
|
+
async function C(r, t) {
|
|
261
|
+
const { body: e, headers: s } = await K(r, t), n = await y(e, { baseIRI: r });
|
|
262
|
+
return new A(r, n, s);
|
|
263
|
+
}
|
|
264
|
+
async function ft(r, t) {
|
|
265
|
+
try {
|
|
266
|
+
return await C(r, t);
|
|
267
|
+
} catch (e) {
|
|
268
|
+
if (!(e instanceof w)) throw e;
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
async function E(r, t) {
|
|
273
|
+
if (V(r))
|
|
274
|
+
return (await Promise.all(r["@graph"].map((n) => E(n, t)))).flat();
|
|
275
|
+
N(r);
|
|
276
|
+
const e = await m.toRDF(r, { base: t });
|
|
277
|
+
return tt(e), e;
|
|
278
|
+
}
|
|
279
|
+
async function pt(r, t) {
|
|
280
|
+
const e = await E(r, t);
|
|
281
|
+
return rt(e);
|
|
282
|
+
}
|
|
283
|
+
function wt(r) {
|
|
284
|
+
const t = nt(r);
|
|
285
|
+
return Object.entries(t).reduce((e, [s, n]) => {
|
|
286
|
+
const a = M(n);
|
|
287
|
+
return e.concat(`${s.toUpperCase()} DATA {
|
|
288
|
+
${a}
|
|
289
|
+
}`);
|
|
290
|
+
}, []).join(` ;
|
|
291
|
+
`);
|
|
292
|
+
}
|
|
293
|
+
function mt(r) {
|
|
294
|
+
const t = k(r);
|
|
295
|
+
return M(t);
|
|
296
|
+
}
|
|
297
|
+
function et(r, t = {}) {
|
|
298
|
+
const e = x({ baseIRI: t.baseIRI }), s = new j(e), n = {
|
|
299
|
+
quads: [],
|
|
300
|
+
containsRelativeIRIs: !1
|
|
301
|
+
};
|
|
302
|
+
return new Promise((a, c) => {
|
|
303
|
+
const o = s._resolveRelativeIRI;
|
|
304
|
+
s._resolveRelativeIRI = (...u) => (n.containsRelativeIRIs = !0, s._resolveRelativeIRI = o, s._resolveRelativeIRI(...u)), s.parse(r, (u, l) => {
|
|
305
|
+
if (u) {
|
|
306
|
+
c(
|
|
307
|
+
new P(t.baseIRI ?? null, g.Turtle, u.message)
|
|
308
|
+
);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
if (!l) {
|
|
312
|
+
a(n);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
n.quads.push(l);
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
async function rt(r) {
|
|
320
|
+
return {
|
|
321
|
+
"@graph": await m.fromRDF(r)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function gt(r) {
|
|
325
|
+
return new S().quadsToString(r);
|
|
326
|
+
}
|
|
327
|
+
function st(r) {
|
|
328
|
+
return new S().quadsToString([r]).slice(0, -1);
|
|
329
|
+
}
|
|
330
|
+
async function yt(r, t) {
|
|
331
|
+
try {
|
|
332
|
+
return !(await C(r, t)).isEmpty();
|
|
333
|
+
} catch {
|
|
334
|
+
return !1;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
async function It(r, t = {}) {
|
|
338
|
+
const e = q(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
339
|
+
return await Promise.all(
|
|
340
|
+
[...e].map(async (n) => {
|
|
341
|
+
const a = n[1].toLowerCase(), c = n[2];
|
|
342
|
+
s[a] = await y(c, t);
|
|
343
|
+
})
|
|
344
|
+
), s;
|
|
345
|
+
}
|
|
346
|
+
function nt(r, t = {}) {
|
|
347
|
+
const e = q(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
348
|
+
for (const n of e) {
|
|
349
|
+
const a = n[1].toLowerCase(), c = n[2];
|
|
350
|
+
s[a] = k(c, t);
|
|
351
|
+
}
|
|
352
|
+
return s;
|
|
353
|
+
}
|
|
354
|
+
async function y(r, t = {}) {
|
|
355
|
+
const { quads: e } = await et(r, t);
|
|
356
|
+
return e;
|
|
357
|
+
}
|
|
358
|
+
function k(r, t = {}) {
|
|
359
|
+
const e = x({ baseIRI: t.baseIRI }), s = new j(e);
|
|
360
|
+
try {
|
|
361
|
+
const n = s.parse(r);
|
|
362
|
+
return t.normalizeBlankNodes ? Z(n) : n;
|
|
363
|
+
} catch (n) {
|
|
364
|
+
throw new P(
|
|
365
|
+
t.baseIRI ?? null,
|
|
366
|
+
g.Turtle,
|
|
367
|
+
n.message ?? ""
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
async function bt(r, t, e) {
|
|
372
|
+
e = e ?? window.fetch.bind(window), await e(r, {
|
|
373
|
+
method: "PATCH",
|
|
374
|
+
headers: { "Content-Type": "application/sparql-update" },
|
|
375
|
+
body: t
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
export {
|
|
379
|
+
P as M,
|
|
380
|
+
_ as N,
|
|
381
|
+
X as S,
|
|
382
|
+
v as U,
|
|
383
|
+
st as a,
|
|
384
|
+
wt as b,
|
|
385
|
+
ht as c,
|
|
386
|
+
yt as d,
|
|
387
|
+
ft as e,
|
|
388
|
+
C as f,
|
|
389
|
+
g,
|
|
390
|
+
w as h,
|
|
391
|
+
pt as i,
|
|
392
|
+
E as j,
|
|
393
|
+
rt as k,
|
|
394
|
+
It as l,
|
|
395
|
+
y as m,
|
|
396
|
+
mt as n,
|
|
397
|
+
dt as o,
|
|
398
|
+
et as p,
|
|
399
|
+
gt as q,
|
|
400
|
+
V as r,
|
|
401
|
+
nt as s,
|
|
402
|
+
k as t,
|
|
403
|
+
bt as u,
|
|
404
|
+
lt as v,
|
|
405
|
+
d as w,
|
|
406
|
+
A as x,
|
|
407
|
+
Y as y,
|
|
408
|
+
H as z
|
|
409
|
+
};
|
|
410
|
+
//# sourceMappingURL=io-BiadF9_D.js.map
|