@pod-os/core 0.31.0-rc.0f398fa.0 → 0.31.0-rc.26940ee.0

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/index.js CHANGED
@@ -28261,23 +28261,22 @@ var Fetcher = class _Fetcher {
28261
28261
  linkData(originalUri, rel2, uri6, why, reverse) {
28262
28262
  if (!uri6) return;
28263
28263
  let kb = this.store;
28264
- let predicate4;
28265
28264
  let obj = kb.rdfFactory.namedNode(join(uri6, originalUri.value));
28265
+ let predicates;
28266
28266
  if (rel2 === "alternate" || rel2 === "seeAlso" || rel2 === "meta" || rel2 === "describedby") {
28267
28267
  if (obj.value === originalUri.value) {
28268
28268
  return;
28269
28269
  }
28270
- predicate4 = this.ns.rdfs("seeAlso");
28270
+ predicates = [kb.rdfFactory.namedNode(this.ianaLinkRelation(rel2)), this.ns.rdfs("seeAlso")];
28271
28271
  } else if (rel2 === "type") {
28272
- predicate4 = kb.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
28272
+ predicates = [kb.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")];
28273
28273
  } else {
28274
- predicate4 = kb.rdfFactory.namedNode(join(encodeURIComponent(rel2), "http://www.iana.org/assignments/link-relations/"));
28275
- }
28276
- if (reverse) {
28277
- kb.add(obj, predicate4, originalUri, why);
28278
- } else {
28279
- kb.add(originalUri, predicate4, obj, why);
28274
+ predicates = [kb.rdfFactory.namedNode(this.ianaLinkRelation(rel2))];
28280
28275
  }
28276
+ kb.addAll(predicates.map((predicate4) => reverse ? kb.rdfFactory.quad(obj, predicate4, originalUri, why) : kb.rdfFactory.quad(originalUri, predicate4, obj, why)));
28277
+ }
28278
+ ianaLinkRelation(rel2) {
28279
+ return join(encodeURIComponent(rel2), "http://www.iana.org/assignments/link-relations/");
28281
28280
  }
28282
28281
  parseLinkHeader(linkHeader, originalUri, reqNode) {
28283
28282
  if (!linkHeader) {
package/lib/index.js CHANGED
@@ -36698,23 +36698,22 @@ var PodOS = (() => {
36698
36698
  linkData(originalUri, rel2, uri6, why, reverse) {
36699
36699
  if (!uri6) return;
36700
36700
  let kb = this.store;
36701
- let predicate4;
36702
36701
  let obj = kb.rdfFactory.namedNode(join(uri6, originalUri.value));
36702
+ let predicates;
36703
36703
  if (rel2 === "alternate" || rel2 === "seeAlso" || rel2 === "meta" || rel2 === "describedby") {
36704
36704
  if (obj.value === originalUri.value) {
36705
36705
  return;
36706
36706
  }
36707
- predicate4 = this.ns.rdfs("seeAlso");
36707
+ predicates = [kb.rdfFactory.namedNode(this.ianaLinkRelation(rel2)), this.ns.rdfs("seeAlso")];
36708
36708
  } else if (rel2 === "type") {
36709
- predicate4 = kb.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
36709
+ predicates = [kb.rdfFactory.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")];
36710
36710
  } else {
36711
- predicate4 = kb.rdfFactory.namedNode(join(encodeURIComponent(rel2), "http://www.iana.org/assignments/link-relations/"));
36712
- }
36713
- if (reverse) {
36714
- kb.add(obj, predicate4, originalUri, why);
36715
- } else {
36716
- kb.add(originalUri, predicate4, obj, why);
36711
+ predicates = [kb.rdfFactory.namedNode(this.ianaLinkRelation(rel2))];
36717
36712
  }
36713
+ kb.addAll(predicates.map((predicate4) => reverse ? kb.rdfFactory.quad(obj, predicate4, originalUri, why) : kb.rdfFactory.quad(originalUri, predicate4, obj, why)));
36714
+ }
36715
+ ianaLinkRelation(rel2) {
36716
+ return join(encodeURIComponent(rel2), "http://www.iana.org/assignments/link-relations/");
36718
36717
  }
36719
36718
  parseLinkHeader(linkHeader, originalUri, reqNode) {
36720
36719
  if (!linkHeader) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pod-os/core",
3
3
  "description": "Core module of PodOS",
4
- "version": "0.31.0-rc.0f398fa.0",
4
+ "version": "0.31.0-rc.26940ee.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./types/index.d.ts",
@@ -21,8 +21,8 @@
21
21
  "node": ">=18.0.0"
22
22
  },
23
23
  "scripts": {
24
- "test": "jest",
25
- "test:watch": "jest --watch",
24
+ "test": "vitest --watch=false",
25
+ "test:watch": "vitest",
26
26
  "typecheck": "tsc --noEmit",
27
27
  "lint": "eslint ./src",
28
28
  "build:bundle": "rimraf lib && node esbuild/build-bundle.mjs",
@@ -49,8 +49,6 @@
49
49
  "@types/sparqljs": "^3.1.12",
50
50
  "esbuild": "^0.28.0",
51
51
  "eslint": "^10.0.0",
52
- "jest": "^30.4.2",
53
- "jest-when": "^4.0.3",
54
52
  "npm-run-all": "^4.1.5",
55
53
  "prettier": "^3.8.3",
56
54
  "rimraf": "^6.1.3",
@@ -58,7 +56,9 @@
58
56
  "typedoc": "^0.28.19",
59
57
  "typedoc-plugin-markdown": "^4.11.0",
60
58
  "typescript": "^6.0.3",
61
- "typescript-eslint": "^8.59.4"
59
+ "typescript-eslint": "^8.59.4",
60
+ "vitest": "^4.1.8",
61
+ "vitest-when": "^0.10.0"
62
62
  },
63
63
  "dependencies": {
64
64
  "@solid-data-modules/rdflib-utils": "^0.6.0",
@@ -68,7 +68,7 @@
68
68
  "mime": "^4.1.0",
69
69
  "neverthrow": "^8.2.0",
70
70
  "rdf-namespaces": "^1.17.0",
71
- "rdflib": "2.3.9",
71
+ "rdflib": "2.4.0",
72
72
  "rxjs": "^7.8.2",
73
73
  "slugify": "^1.6.9",
74
74
  "url": "^0.11.4",
@@ -1,2 +1,2 @@
1
- import { AuthenticatedFetch } from "./authentication";
2
- export declare function thenSparqlUpdateIsSentToUrl(fetchMock: jest.Mock<AuthenticatedFetch>, url: string, query: string): void;
1
+ import { Mock } from "vitest";
2
+ export declare function thenSparqlUpdateIsSentToUrl(fetchMock: Mock, url: string, query: string): void;
@@ -0,0 +1,8 @@
1
+ import { Mock } from "vitest";
2
+ /**
3
+ * Expect that a PATCH request has been performed
4
+ * @param authenticatedFetch - A mocked fetch function
5
+ * @param url - The expected URL to PATCH
6
+ * @param expectedBody - The expected request body
7
+ */
8
+ export declare function expectPatchRequest(authenticatedFetch: Mock, url: string, expectedBody: string): void;
@@ -0,0 +1,2 @@
1
+ export * from "./expectRequests.js";
2
+ export * from "./mockResponses.js";
@@ -0,0 +1,24 @@
1
+ import { Mock } from "vitest";
2
+ /**
3
+ * Mock a turtle document at the given URL
4
+ * @param fetch - A mocked fetch function
5
+ * @param url - The URL to mock
6
+ * @param ttl - The mocked turtle file content
7
+ * @param additionalHeaders - Additional headers to include in the response
8
+ */
9
+ export declare function mockTurtleDocument(fetch: Mock, url: string, ttl: string, additionalHeaders?: Record<string, string>): void;
10
+ /**
11
+ * Mock a LDP container at the given URL
12
+ * @param fetch - A mocked fetch function
13
+ * @param url - The URL to mock
14
+ * @param contains - List of URLs of documents contained in this container
15
+ * @param moreTurtle - Additional turtle to include into the response
16
+ * @param additionalHeaders - Additional headers to include in the response
17
+ */
18
+ export declare function mockLdpContainer(fetch: Mock, url: string, contains?: string[], moreTurtle?: string, additionalHeaders?: Record<string, string>): void;
19
+ /**
20
+ * Mock a 404 - Not Found response for the given URL
21
+ * @param fetch - A mocked fetch function
22
+ * @param url - The URL to mock
23
+ */
24
+ export declare function mockNotFound(fetch: Mock, url: string): void;
@@ -0,0 +1 @@
1
+ export {};