@noeldemartin/solid-utils 0.6.0-next.956cbec11a55691bab3170059fa908865d683e20 → 0.6.0-next.9e5255c1e3f28414be67ade1f4aadbbbd1211cb2

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 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-Bxz7F0sw.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
@@ -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-vm3EKQZf.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-Bxz7F0sw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers-Bxz7F0sw.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,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,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,24 +1,24 @@
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);
1
+ var k = Object.defineProperty;
2
+ var $ = (r, t, e) => t in r ? k(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var i = (r, t, e) => $(r, typeof t != "symbol" ? t + "" : t, e);
4
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) {
5
+ import L 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 z, arrayReplace as F } from "@noeldemartin/utils";
7
+ import { Parser as q, Writer as S, BlankNode as W, Quad as B } from "n3";
8
+ function U(r, t, e) {
9
9
  return r ? `Malformed ${t} document found at ${r} - ${e}` : `Malformed ${t} document - ${e}`;
10
10
  }
11
11
  var m = /* @__PURE__ */ ((r) => (r.Turtle = "Turtle", r))(m || {});
12
12
  class P extends h {
13
13
  constructor(e, s, n) {
14
- super(B(e, s, n));
14
+ super(U(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 U extends h {
21
+ class O extends h {
22
22
  constructor(e, s) {
23
23
  super(`Request failed trying to fetch ${e}`, s);
24
24
  i(this, "url");
@@ -32,12 +32,12 @@ class p extends h {
32
32
  this.url = e;
33
33
  }
34
34
  }
35
- function O(r, t) {
35
+ function J(r, t) {
36
36
  return `Unauthorized${t === 403 ? " (Forbidden)" : ""}: ${r}`;
37
37
  }
38
38
  class R extends h {
39
39
  constructor(e, s) {
40
- super(O(e, s));
40
+ super(J(e, s));
41
41
  i(this, "url");
42
42
  i(this, "responseStatus");
43
43
  this.url = e, this.responseStatus = s;
@@ -58,7 +58,7 @@ const j = {
58
58
  solid: "http://www.w3.org/ns/solid/terms#",
59
59
  vcard: "http://www.w3.org/2006/vcard/ns#"
60
60
  };
61
- function ct(r, t) {
61
+ function dt(r, t) {
62
62
  j[r] = t;
63
63
  }
64
64
  function l(r, t = {}) {
@@ -73,7 +73,7 @@ function l(r, t = {}) {
73
73
  if (!t.defaultPrefix) throw new Error(`Can't expand IRI without a default prefix: '${r}'`);
74
74
  return t.defaultPrefix + e;
75
75
  }
76
- class J {
76
+ class _ {
77
77
  constructor(t, e) {
78
78
  i(this, "url");
79
79
  i(this, "quads");
@@ -87,7 +87,7 @@ class J {
87
87
  return this.quads.filter((e) => e.predicate.value === l(t)).map((e) => e.object.value);
88
88
  }
89
89
  }
90
- class _ {
90
+ class G {
91
91
  constructor(t = []) {
92
92
  i(this, "quads");
93
93
  this.quads = t;
@@ -116,7 +116,7 @@ class _ {
116
116
  }
117
117
  getThing(t) {
118
118
  const e = this.statements(t);
119
- return new J(t, e);
119
+ return new _(t, e);
120
120
  }
121
121
  expandIRI(t) {
122
122
  return l(t);
@@ -125,8 +125,8 @@ class _ {
125
125
  return typeof e == "string" ? this.expandIRI(e) === t.value : t.termType === t.termType && t.value === e.value;
126
126
  }
127
127
  }
128
- var G = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(G || {});
129
- class D extends _ {
128
+ var H = /* @__PURE__ */ ((r) => (r.Read = "read", r.Write = "write", r.Append = "append", r.Control = "control", r))(H || {});
129
+ class D extends G {
130
130
  constructor(e, s, n) {
131
131
  super(s);
132
132
  i(this, "url");
@@ -179,15 +179,15 @@ class D extends _ {
179
179
  ]);
180
180
  }
181
181
  }
182
- async function dt(r) {
182
+ async function lt(r) {
183
183
  const t = await w.compact(r, {});
184
184
  return "@graph" in t ? t : "@id" in t ? { "@graph": [t] } : { "@graph": [] };
185
185
  }
186
- function H(r) {
186
+ function X(r) {
187
187
  return "@graph" in r;
188
188
  }
189
- const g = "anonymous://", X = g.length;
190
- async function Y(r, t) {
189
+ const g = "anonymous://", Y = g.length;
190
+ async function V(r, t) {
191
191
  const e = {
192
192
  headers: { Accept: "text/turtle" }
193
193
  };
@@ -201,11 +201,11 @@ async function Y(r, t) {
201
201
  headers: n.headers
202
202
  };
203
203
  } catch (s) {
204
- throw s instanceof R || s instanceof p ? s : new U(r, { cause: s });
204
+ throw s instanceof R || s instanceof p ? s : new O(r, { cause: s });
205
205
  }
206
206
  }
207
- function V(r) {
208
- const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => L(
207
+ function K(r) {
208
+ const t = r.slice(0), e = {}, s = b(r).flatMap((n, a) => z(
209
209
  v([
210
210
  n.object.termType === "BlankNode" ? n.object.value : null,
211
211
  n.subject.termType === "BlankNode" ? n.subject.value : null
@@ -213,7 +213,7 @@ function V(r) {
213
213
  (c) => c.forEach((o) => (e[o] ?? (e[o] = /* @__PURE__ */ new Set())).add(a))
214
214
  )).filter().unique();
215
215
  for (const n of s) {
216
- const a = e[n], c = $(
216
+ const a = e[n], c = L(
217
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
218
  );
219
219
  for (const o of a) {
@@ -221,30 +221,30 @@ function V(r) {
221
221
  subject: u.subject,
222
222
  object: u.object
223
223
  };
224
- for (const [C, y] of Object.entries(d))
225
- y.termType !== "BlankNode" || y.value !== n || (d[C] = new W(c));
224
+ for (const [E, y] of Object.entries(d))
225
+ y.termType !== "BlankNode" || y.value !== n || (d[E] = new W(c));
226
226
  F(
227
227
  t,
228
228
  u,
229
- new z(d.subject, u.predicate, d.object)
229
+ new B(d.subject, u.predicate, d.object)
230
230
  );
231
231
  }
232
232
  }
233
233
  return t;
234
234
  }
235
235
  function A(r) {
236
- return r.map((t) => " " + rt(t)).sort().join(`
236
+ return r.map((t) => " " + st(t)).sort().join(`
237
237
  `);
238
238
  }
239
- function K(r) {
239
+ function Z(r) {
240
240
  var t;
241
241
  (t = r["@id"]) != null && t.startsWith("#") && (r["@id"] = g + r["@id"]);
242
242
  }
243
- function Z(r) {
243
+ function tt(r) {
244
244
  for (const t of r)
245
- t.subject.value.startsWith(g) && (t.subject.value = t.subject.value.slice(X));
245
+ t.subject.value.startsWith(g) && (t.subject.value = t.subject.value.slice(Y));
246
246
  }
247
- async function lt(r, t, e) {
247
+ async function ht(r, t, e) {
248
248
  e = e ?? window.fetch.bind(window);
249
249
  const s = await I(t);
250
250
  return await e(r, {
@@ -254,10 +254,10 @@ async function lt(r, t, e) {
254
254
  }), new D(r, s, new Headers({}));
255
255
  }
256
256
  async function M(r, t) {
257
- const { body: e, headers: s } = await Y(r, t), n = await I(e, { baseIRI: r });
257
+ const { body: e, headers: s } = await V(r, t), n = await I(e, { baseIRI: r });
258
258
  return new D(r, n, s);
259
259
  }
260
- async function ht(r, t) {
260
+ async function ft(r, t) {
261
261
  try {
262
262
  return await M(r, t);
263
263
  } catch (e) {
@@ -265,15 +265,19 @@ async function ht(r, t) {
265
265
  return null;
266
266
  }
267
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);
268
+ async function N(r, t) {
269
+ if (X(r))
270
+ return (await Promise.all(r["@graph"].map((n) => N(n, t)))).flat();
271
+ Z(r);
272
272
  const e = await w.toRDF(r, { base: t });
273
- return Z(e), e;
273
+ return tt(e), e;
274
+ }
275
+ async function pt(r, t) {
276
+ const e = await N(r, t);
277
+ return rt(e);
274
278
  }
275
- function ft(r) {
276
- const t = st(r);
279
+ function wt(r) {
280
+ const t = nt(r);
277
281
  return Object.entries(t).reduce((e, [s, n]) => {
278
282
  const a = A(n);
279
283
  return e.concat(`${s.toUpperCase()} DATA {
@@ -282,8 +286,8 @@ ${a}
282
286
  }, []).join(` ;
283
287
  `);
284
288
  }
285
- function pt(r) {
286
- const t = N(r);
289
+ function mt(r) {
290
+ const t = C(r);
287
291
  return A(t);
288
292
  }
289
293
  function et(r, t = {}) {
@@ -308,25 +312,25 @@ function et(r, t = {}) {
308
312
  });
309
313
  });
310
314
  }
311
- async function wt(r) {
315
+ async function rt(r) {
312
316
  return {
313
317
  "@graph": await w.fromRDF(r)
314
318
  };
315
319
  }
316
- function mt(r) {
320
+ function gt(r) {
317
321
  return new S().quadsToString(r);
318
322
  }
319
- function rt(r) {
323
+ function st(r) {
320
324
  return new S().quadsToString([r]).slice(0, -1);
321
325
  }
322
- async function gt(r, t) {
326
+ async function It(r, t) {
323
327
  try {
324
328
  return !(await M(r, t)).isEmpty();
325
329
  } catch {
326
330
  return !1;
327
331
  }
328
332
  }
329
- async function It(r, t = {}) {
333
+ async function yt(r, t = {}) {
330
334
  const e = x(r, /(\w+) DATA {([^}]+)}/g), s = {};
331
335
  return await Promise.all(
332
336
  [...e].map(async (n) => {
@@ -335,11 +339,11 @@ async function It(r, t = {}) {
335
339
  })
336
340
  ), s;
337
341
  }
338
- function st(r, t = {}) {
342
+ function nt(r, t = {}) {
339
343
  const e = x(r, /(\w+) DATA {([^}]+)}/g), s = {};
340
344
  for (const n of e) {
341
345
  const a = n[1].toLowerCase(), c = n[2];
342
- s[a] = N(c, t);
346
+ s[a] = C(c, t);
343
347
  }
344
348
  return s;
345
349
  }
@@ -347,11 +351,11 @@ async function I(r, t = {}) {
347
351
  const { quads: e } = await et(r, t);
348
352
  return e;
349
353
  }
350
- function N(r, t = {}) {
354
+ function C(r, t = {}) {
351
355
  const e = T({ baseIRI: t.baseIRI }), s = new q(e);
352
356
  try {
353
357
  const n = s.parse(r);
354
- return t.normalizeBlankNodes ? V(n) : n;
358
+ return t.normalizeBlankNodes ? K(n) : n;
355
359
  } catch (n) {
356
360
  throw new P(
357
361
  t.baseIRI ?? null,
@@ -360,7 +364,7 @@ function N(r, t = {}) {
360
364
  );
361
365
  }
362
366
  }
363
- async function yt(r, t, e) {
367
+ async function bt(r, t, e) {
364
368
  e = e ?? window.fetch.bind(window), await e(r, {
365
369
  method: "PATCH",
366
370
  headers: { "Content-Type": "application/sparql-update" },
@@ -369,33 +373,34 @@ async function yt(r, t, e) {
369
373
  }
370
374
  export {
371
375
  P as M,
372
- U as N,
373
- _ as S,
376
+ O as N,
377
+ G as S,
374
378
  R as U,
375
- ht as a,
376
- m as b,
377
- lt as c,
378
- p as d,
379
- pt as e,
379
+ st as a,
380
+ wt as b,
381
+ ht as c,
382
+ It as d,
383
+ ft as e,
380
384
  M as f,
381
- mt as g,
382
- rt as h,
383
- It as i,
384
- tt as j,
385
- st as k,
386
- N as l,
387
- dt as m,
388
- ft as n,
389
- H as o,
385
+ m as g,
386
+ p as h,
387
+ pt as i,
388
+ N as j,
389
+ rt as k,
390
+ yt as l,
391
+ I as m,
392
+ mt as n,
393
+ lt as o,
390
394
  et as p,
391
- wt as q,
392
- ct as r,
393
- gt as s,
394
- I as t,
395
- yt as u,
396
- l as v,
397
- D as w,
398
- G as x,
399
- J as y
395
+ gt as q,
396
+ X as r,
397
+ nt as s,
398
+ C as t,
399
+ bt as u,
400
+ dt as v,
401
+ l as w,
402
+ D as x,
403
+ H as y,
404
+ _ as z
400
405
  };
401
- //# sourceMappingURL=io-CMHtz5bu.js.map
406
+ //# sourceMappingURL=io-vm3EKQZf.js.map