@rdfc/sparql-ingest-processor-ts 2.1.3 → 2.1.5

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.
@@ -159,7 +159,7 @@ export class SPARQLIngest extends Processor {
159
159
  if (this.config.graphStoreUrl) {
160
160
  try {
161
161
  const t0 = Date.now();
162
- await doSPARQLRequest(query, this.config, this.doSPARQLRequestLogger);
162
+ await doSPARQLRequest(query, this.config, this.logger);
163
163
  const reqTime = Date.now() - t0;
164
164
  if (this.config.measurePerformance) {
165
165
  this.requestsPerformance.push(reqTime);
@@ -185,7 +185,7 @@ export class SPARQLIngest extends Processor {
185
185
  }
186
186
  }
187
187
  else {
188
- await this.sparqlWriter.string(query.join("\n"));
188
+ await this.sparqlWriter.string(query.join(";\n"));
189
189
  }
190
190
  }
191
191
  }
@@ -193,7 +193,7 @@ export class SPARQLIngest extends Processor {
193
193
  if (this.config.operationMode === OperationMode.REPLICATION) {
194
194
  try {
195
195
  const t0 = Date.now();
196
- await doSPARQLRequest(this.memberBatch, this.config, this.doSPARQLRequestLogger);
196
+ await doSPARQLRequest(this.memberBatch, this.config, this.logger);
197
197
  const reqTime = Date.now() - t0;
198
198
  if (this.config.measurePerformance) {
199
199
  this.requestsPerformance.push(reqTime);
@@ -222,7 +222,7 @@ export class SPARQLIngest extends Processor {
222
222
  if (this.config.operationMode === OperationMode.REPLICATION && this.memberBatch.length > 0) {
223
223
  try {
224
224
  const t0 = Date.now();
225
- await doSPARQLRequest(this.memberBatch, this.config, this.doSPARQLRequestLogger);
225
+ await doSPARQLRequest(this.memberBatch, this.config, this.logger);
226
226
  const reqTime = Date.now() - t0;
227
227
  if (this.config.measurePerformance) {
228
228
  this.requestsPerformance.push(reqTime);
@@ -292,16 +292,16 @@ export class SPARQLIngest extends Processor {
292
292
  }
293
293
  }
294
294
  if (createStore.size > 0) {
295
- transactionQueryBuilder.push(CREATE(createStore, config.forVirtuoso).join("\n"));
295
+ transactionQueryBuilder.push(...CREATE(createStore, config.forVirtuoso));
296
296
  }
297
297
  if (updateStore.size > 0) {
298
- transactionQueryBuilder.push(UPDATE(updateStore, config.forVirtuoso).join("\n"));
298
+ transactionQueryBuilder.push(...UPDATE(updateStore, config.forVirtuoso));
299
299
  }
300
300
  if (deleteStore.size > 0) {
301
301
  deleteMembers.forEach(dm => {
302
- transactionQueryBuilder.push(DELETE(deleteStore, dm, config.memberShape).join("\n"));
302
+ transactionQueryBuilder.push(...DELETE(deleteStore, dm, config.memberShape));
303
303
  });
304
304
  }
305
- return transactionQueryBuilder.join("\n");
305
+ return transactionQueryBuilder.join(";\n");
306
306
  }
307
307
  }
@@ -1,8 +1,8 @@
1
- import { RDF, SHACL } from "@treecg/types";
1
+ import { SHACL } from "@treecg/types";
2
2
  import { Writer as N3Writer, Parser } from "n3";
3
3
  import { RdfStore } from "rdf-stores";
4
4
  import { DataFactory } from "rdf-data-factory";
5
- import { getObjects, getSubjects, splitStoreOnSize, splitStorePerNamedGraph } from "./Utils.js";
5
+ import { getObjects, splitStoreOnSize, splitStorePerNamedGraph } from "./Utils.js";
6
6
  const df = new DataFactory();
7
7
  export const CREATE = (store, forVirtuoso) => {
8
8
  const queries = [];
@@ -17,7 +17,7 @@ export const CREATE = (store, forVirtuoso) => {
17
17
  return df.quad(q.subject, q.predicate, q.object, df.defaultGraph());
18
18
  }))}
19
19
  ${graph.equals(df.defaultGraph()) ? "" : `}`}
20
- };
20
+ }
21
21
  `);
22
22
  });
23
23
  }
@@ -36,7 +36,7 @@ export const UPDATE = (store, forVirtuoso) => {
36
36
  }
37
37
  WHERE {
38
38
  ${formattedQuery[0]}
39
- };
39
+ }
40
40
  `];
41
41
  subStores.forEach((s, i) => {
42
42
  deleteInsertQuery.push(`
@@ -46,7 +46,7 @@ export const UPDATE = (store, forVirtuoso) => {
46
46
  return df.quad(q.subject, q.predicate, q.object, df.defaultGraph());
47
47
  }))}
48
48
  ${graph.equals(df.defaultGraph()) ? "" : `}`}
49
- };
49
+ }
50
50
  `);
51
51
  });
52
52
  queries.push(...deleteInsertQuery);
@@ -66,7 +66,7 @@ export const DELETE = (store, memberIRI, memberShape) => {
66
66
  ${deleteBuilder}
67
67
  } WHERE {
68
68
  ${whereBuilder}
69
- };
69
+ }
70
70
  `);
71
71
  }
72
72
  return queries;
@@ -123,36 +123,3 @@ function formatQuery(memberStore, memberIRI, memberShape, indexStart = 0) {
123
123
  return [queryBuilder.join("\n"), deleteQueryBuilder.join("\n")];
124
124
  }
125
125
  }
126
- function extractMainTargetClass(store) {
127
- const nodeShapes = getSubjects(store, RDF.terms.type, SHACL.terms.NodeShape, null);
128
- let mainNodeShape = null;
129
- if (nodeShapes && nodeShapes.length > 0) {
130
- for (const ns of nodeShapes) {
131
- const isNotReferenced = getSubjects(store, null, ns, null).length === 0;
132
- if (isNotReferenced) {
133
- if (!mainNodeShape) {
134
- mainNodeShape = ns;
135
- }
136
- else {
137
- throw new Error("There are multiple main node shapes in a given shape."
138
- + " Unrelated shapes must be given as separate member shapes");
139
- }
140
- }
141
- }
142
- if (mainNodeShape) {
143
- const tcq = getObjects(store, mainNodeShape, SHACL.terms.targetClass, null)[0];
144
- if (tcq) {
145
- return tcq;
146
- }
147
- else {
148
- throw new Error("No target class found in main SHACL Node Shapes");
149
- }
150
- }
151
- else {
152
- throw new Error("No main SHACL Node Shapes found in given member shape");
153
- }
154
- }
155
- else {
156
- throw new Error("No SHACL Node Shapes found in given member shape");
157
- }
158
- }
package/lib/Utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RdfStore } from "rdf-stores";
2
+ import { Logger } from "winston";
2
3
  import type { Term, Quad_Subject, Quad_Object, Quad, Quad_Graph } from "@rdfjs/types";
3
4
  import type { IngestConfig } from "./SPARQLIngest.js";
4
- import { Logger } from "winston";
5
5
  export declare function getSubjects(store: RdfStore, predicate: Term | null, object: Term | null, graph?: Term | null): Quad_Subject[];
6
6
  export declare function getObjects(store: RdfStore, subject: Term | null, predicate: Term | null, graph?: Term | null): Quad_Object[];
7
7
  export declare function splitStorePerNamedGraph(store: RdfStore): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdfc/sparql-ingest-processor-ts",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "SPARQL Update function to be within RDF-Connect pipelines",
5
5
  "author": "Julián Rojas",
6
6
  "contributors": [
@@ -40,8 +40,8 @@
40
40
  "@rdfjs/types": "^2.0.1",
41
41
  "@types/n3": "^1.26.1",
42
42
  "@types/node": "^25.2.2",
43
- "@typescript-eslint/eslint-plugin": "^8.54.0",
44
- "@typescript-eslint/parser": "^8.54.0",
43
+ "@typescript-eslint/eslint-plugin": "^8.55.0",
44
+ "@typescript-eslint/parser": "^8.55.0",
45
45
  "@vitest/coverage-v8": "^4.0.18",
46
46
  "eslint": "^9.39.2",
47
47
  "eslint-config-prettier": "^10.1.8",