@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.508449b33de64b0bcade86b642c9793381434231
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chai.d.ts +31 -0
- package/dist/chai.js +23 -0
- package/dist/chai.js.map +1 -0
- package/dist/helpers-DGXMj9cx.js +107 -0
- package/dist/helpers-DGXMj9cx.js.map +1 -0
- package/dist/io-wCcrq4b9.js +401 -0
- package/dist/io-wCcrq4b9.js.map +1 -0
- package/dist/noeldemartin-solid-utils.d.ts +61 -65
- package/dist/noeldemartin-solid-utils.js +224 -0
- package/dist/noeldemartin-solid-utils.js.map +1 -0
- 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 +67 -63
- 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/auth.test.ts +221 -0
- package/src/helpers/auth.ts +28 -27
- package/src/helpers/identifiers.test.ts +76 -0
- package/src/helpers/identifiers.ts +14 -17
- package/src/helpers/index.ts +0 -1
- package/src/helpers/interop.ts +23 -16
- package/src/helpers/io.test.ts +228 -0
- package/src/helpers/io.ts +57 -77
- package/src/helpers/jsonld.ts +6 -6
- package/src/helpers/vocabs.ts +3 -6
- package/src/helpers/wac.test.ts +64 -0
- package/src/helpers/wac.ts +10 -6
- package/src/index.ts +4 -0
- package/src/models/SolidDocument.test.ts +77 -0
- package/src/models/SolidDocument.ts +14 -18
- package/src/models/SolidStore.ts +22 -12
- package/src/models/SolidThing.ts +5 -7
- package/src/models/index.ts +2 -0
- package/src/{helpers/testing.ts → testing/helpers.ts} +24 -27
- package/src/testing/hepers.test.ts +329 -0
- package/src/testing/index.ts +1 -2
- 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/.github/workflows/ci.yml +0 -16
- package/.nvmrc +0 -1
- package/CHANGELOG.md +0 -70
- package/dist/noeldemartin-solid-utils.cjs.js +0 -2
- package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
- package/dist/noeldemartin-solid-utils.esm.js +0 -2
- package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
- package/dist/noeldemartin-solid-utils.umd.js +0 -90
- package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
- package/noeldemartin.config.js +0 -9
- package/src/main.ts +0 -5
- package/src/plugins/chai/assertions.ts +0 -40
- package/src/plugins/chai/index.ts +0 -5
- package/src/plugins/cypress/types.d.ts +0 -15
- package/src/plugins/index.ts +0 -2
- package/src/plugins/jest/index.ts +0 -5
- package/src/plugins/jest/matchers.ts +0 -65
- package/src/plugins/jest/types.d.ts +0 -14
- package/src/testing/ResponseStub.ts +0 -46
- package/src/testing/mocking.ts +0 -33
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-DGXMj9cx.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-wCcrq4b9.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-DGXMj9cx.js.map
|
|
@@ -0,0 +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":"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"}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var k = (r, t, e) => t in r ? E(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var i = (r, t, e) => k(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import w from "jsonld";
|
|
5
|
+
import $ from "md5";
|
|
6
|
+
import { JSError as h, parseDate as f, stringMatch as Q, arrayFilter as v, objectWithoutEmpty as T, stringMatchAll as x, arr as b, tap as L, arrayReplace as F } from "@noeldemartin/utils";
|
|
7
|
+
import { Parser as q, Writer as S, BlankNode as W, Quad as z } from "n3";
|
|
8
|
+
function B(r, t, e) {
|
|
9
|
+
return r ? `Malformed ${t} document found at ${r} - ${e}` : `Malformed ${t} document - ${e}`;
|
|
10
|
+
}
|
|
11
|
+
var m = /* @__PURE__ */ ((r) => (r.Turtle = "Turtle", r))(m || {});
|
|
12
|
+
class P extends h {
|
|
13
|
+
constructor(e, s, n) {
|
|
14
|
+
super(B(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 U extends h {
|
|
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 p extends h {
|
|
29
|
+
constructor(e) {
|
|
30
|
+
super(`Document with '${e}' url not found`);
|
|
31
|
+
i(this, "url");
|
|
32
|
+
this.url = e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function O(r, t) {
|
|
36
|
+
return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${r}`;
|
|
37
|
+
}
|
|
38
|
+
class R extends h {
|
|
39
|
+
constructor(e, s) {
|
|
40
|
+
super(O(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 j = {
|
|
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 ct(r, t) {
|
|
62
|
+
j[r] = t;
|
|
63
|
+
}
|
|
64
|
+
function l(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 = j[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 J {
|
|
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 === l(t))) == null ? void 0 : e.object.value;
|
|
85
|
+
}
|
|
86
|
+
values(t) {
|
|
87
|
+
return this.quads.filter((e) => e.predicate.value === l(t)).map((e) => e.object.value);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class _ {
|
|
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 J(t, e);
|
|
120
|
+
}
|
|
121
|
+
expandIRI(t) {
|
|
122
|
+
return l(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 G = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(G || {});
|
|
129
|
+
class D extends _ {
|
|
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, l("rdf:type"), l("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 f(this.headers.get("last-modified")) ?? f((e = this.statement(this.url, "purl:modified")) == null ? void 0 : e.object.value) ?? this.getLatestDocumentDate() ?? null;
|
|
162
|
+
}
|
|
163
|
+
expandIRI(e) {
|
|
164
|
+
return l(e, { defaultPrefix: this.url });
|
|
165
|
+
}
|
|
166
|
+
getLatestDocumentDate() {
|
|
167
|
+
const e = [...this.statements(void 0, "purl:modified"), ...this.statements(void 0, "purl:created")].map((s) => f(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 = Q(s, new RegExp(`${e}="([^"]+)"`))) == null ? void 0 : a[1]) ?? "";
|
|
173
|
+
return v([
|
|
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 w.compact(r, {});
|
|
184
|
+
return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
|
|
185
|
+
}
|
|
186
|
+
function H(r) {
|
|
187
|
+
return "@graph" in r;
|
|
188
|
+
}
|
|
189
|
+
const g = "anonymous://", X = g.length;
|
|
190
|
+
async function Y(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 p(r);
|
|
198
|
+
if ([401, 403].includes(n.status)) throw new R(r, n.status);
|
|
199
|
+
return {
|
|
200
|
+
body: await n.text(),
|
|
201
|
+
headers: n.headers
|
|
202
|
+
};
|
|
203
|
+
} catch (s) {
|
|
204
|
+
throw s instanceof R || s instanceof p ? s : new U(r, { cause: s });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function V(r) {
|
|
208
|
+
const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => L(
|
|
209
|
+
v([
|
|
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 = $(
|
|
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], d = {
|
|
221
|
+
subject: u.subject,
|
|
222
|
+
object: u.object
|
|
223
|
+
};
|
|
224
|
+
for (const [C, y] of Object.entries(d))
|
|
225
|
+
y.termType !== "BlankNode" || y.value !== n || (d[C] = new W(c));
|
|
226
|
+
F(
|
|
227
|
+
t,
|
|
228
|
+
u,
|
|
229
|
+
new z(d.subject, u.predicate, d.object)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return t;
|
|
234
|
+
}
|
|
235
|
+
function A(r) {
|
|
236
|
+
return r.map((t) => " " + rt(t)).sort().join(`
|
|
237
|
+
`);
|
|
238
|
+
}
|
|
239
|
+
function K(r) {
|
|
240
|
+
var t;
|
|
241
|
+
(t = r["@id"]) != null && t.startsWith("#") && (r["@id"] = g + r["@id"]);
|
|
242
|
+
}
|
|
243
|
+
function Z(r) {
|
|
244
|
+
for (const t of r)
|
|
245
|
+
t.subject.value.startsWith(g) && (t.subject.value = t.subject.value.slice(X));
|
|
246
|
+
}
|
|
247
|
+
async function lt(r, t, e) {
|
|
248
|
+
e = e ?? window.fetch.bind(window);
|
|
249
|
+
const s = await I(t);
|
|
250
|
+
return await e(r, {
|
|
251
|
+
method: "PUT",
|
|
252
|
+
headers: { "Content-Type": "text/turtle" },
|
|
253
|
+
body: t
|
|
254
|
+
}), new D(r, s, new Headers({}));
|
|
255
|
+
}
|
|
256
|
+
async function M(r, t) {
|
|
257
|
+
const { body: e, headers: s } = await Y(r, t), n = await I(e, { baseIRI: r });
|
|
258
|
+
return new D(r, n, s);
|
|
259
|
+
}
|
|
260
|
+
async function ht(r, t) {
|
|
261
|
+
try {
|
|
262
|
+
return await M(r, t);
|
|
263
|
+
} catch (e) {
|
|
264
|
+
if (!(e instanceof p)) throw e;
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async function tt(r, t) {
|
|
269
|
+
if (H(r))
|
|
270
|
+
return (await Promise.all(r["@graph"].map((n) => tt(n, t)))).flat();
|
|
271
|
+
K(r);
|
|
272
|
+
const e = await w.toRDF(r, { base: t });
|
|
273
|
+
return Z(e), e;
|
|
274
|
+
}
|
|
275
|
+
function ft(r) {
|
|
276
|
+
const t = st(r);
|
|
277
|
+
return Object.entries(t).reduce((e, [s, n]) => {
|
|
278
|
+
const a = A(n);
|
|
279
|
+
return e.concat(`${s.toUpperCase()} DATA {
|
|
280
|
+
${a}
|
|
281
|
+
}`);
|
|
282
|
+
}, []).join(` ;
|
|
283
|
+
`);
|
|
284
|
+
}
|
|
285
|
+
function pt(r) {
|
|
286
|
+
const t = N(r);
|
|
287
|
+
return A(t);
|
|
288
|
+
}
|
|
289
|
+
function et(r, t = {}) {
|
|
290
|
+
const e = T({ baseIRI: t.baseIRI }), s = new q(e), n = {
|
|
291
|
+
quads: [],
|
|
292
|
+
containsRelativeIRIs: !1
|
|
293
|
+
};
|
|
294
|
+
return new Promise((a, c) => {
|
|
295
|
+
const o = s._resolveRelativeIRI;
|
|
296
|
+
s._resolveRelativeIRI = (...u) => (n.containsRelativeIRIs = !0, s._resolveRelativeIRI = o, s._resolveRelativeIRI(...u)), s.parse(r, (u, d) => {
|
|
297
|
+
if (u) {
|
|
298
|
+
c(
|
|
299
|
+
new P(t.baseIRI ?? null, m.Turtle, u.message)
|
|
300
|
+
);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (!d) {
|
|
304
|
+
a(n);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
n.quads.push(d);
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async function wt(r) {
|
|
312
|
+
return {
|
|
313
|
+
"@graph": await w.fromRDF(r)
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function mt(r) {
|
|
317
|
+
return new S().quadsToString(r);
|
|
318
|
+
}
|
|
319
|
+
function rt(r) {
|
|
320
|
+
return new S().quadsToString([r]).slice(0, -1);
|
|
321
|
+
}
|
|
322
|
+
async function gt(r, t) {
|
|
323
|
+
try {
|
|
324
|
+
return !(await M(r, t)).isEmpty();
|
|
325
|
+
} catch {
|
|
326
|
+
return !1;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async function It(r, t = {}) {
|
|
330
|
+
const e = x(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
331
|
+
return await Promise.all(
|
|
332
|
+
[...e].map(async (n) => {
|
|
333
|
+
const a = n[1].toLowerCase(), c = n[2];
|
|
334
|
+
s[a] = await I(c, t);
|
|
335
|
+
})
|
|
336
|
+
), s;
|
|
337
|
+
}
|
|
338
|
+
function st(r, t = {}) {
|
|
339
|
+
const e = x(r, /(\w+) DATA {([^}]+)}/g), s = {};
|
|
340
|
+
for (const n of e) {
|
|
341
|
+
const a = n[1].toLowerCase(), c = n[2];
|
|
342
|
+
s[a] = N(c, t);
|
|
343
|
+
}
|
|
344
|
+
return s;
|
|
345
|
+
}
|
|
346
|
+
async function I(r, t = {}) {
|
|
347
|
+
const { quads: e } = await et(r, t);
|
|
348
|
+
return e;
|
|
349
|
+
}
|
|
350
|
+
function N(r, t = {}) {
|
|
351
|
+
const e = T({ baseIRI: t.baseIRI }), s = new q(e);
|
|
352
|
+
try {
|
|
353
|
+
const n = s.parse(r);
|
|
354
|
+
return t.normalizeBlankNodes ? V(n) : n;
|
|
355
|
+
} catch (n) {
|
|
356
|
+
throw new P(
|
|
357
|
+
t.baseIRI ?? null,
|
|
358
|
+
m.Turtle,
|
|
359
|
+
n.message ?? ""
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async function yt(r, t, e) {
|
|
364
|
+
e = e ?? window.fetch.bind(window), await e(r, {
|
|
365
|
+
method: "PATCH",
|
|
366
|
+
headers: { "Content-Type": "application/sparql-update" },
|
|
367
|
+
body: t
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
export {
|
|
371
|
+
P as M,
|
|
372
|
+
U as N,
|
|
373
|
+
_ as S,
|
|
374
|
+
R as U,
|
|
375
|
+
rt as a,
|
|
376
|
+
ft as b,
|
|
377
|
+
lt as c,
|
|
378
|
+
gt as d,
|
|
379
|
+
ht as e,
|
|
380
|
+
M as f,
|
|
381
|
+
m as g,
|
|
382
|
+
p as h,
|
|
383
|
+
wt as i,
|
|
384
|
+
tt as j,
|
|
385
|
+
It as k,
|
|
386
|
+
I as l,
|
|
387
|
+
dt as m,
|
|
388
|
+
pt as n,
|
|
389
|
+
H as o,
|
|
390
|
+
et as p,
|
|
391
|
+
mt as q,
|
|
392
|
+
ct as r,
|
|
393
|
+
st as s,
|
|
394
|
+
N as t,
|
|
395
|
+
yt as u,
|
|
396
|
+
l as v,
|
|
397
|
+
D as w,
|
|
398
|
+
G as x,
|
|
399
|
+
J as y
|
|
400
|
+
};
|
|
401
|
+
//# sourceMappingURL=io-wCcrq4b9.js.map
|