@rdfc/sparql-ingest-processor-ts 2.1.1 → 2.1.3
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/README.md +5 -2
- package/lib/Utils.js +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,6 +46,8 @@ npm install @rdfc/sparql-ingest-processor-ts
|
|
|
46
46
|
<ingester> a rdfc:SPARQLIngest;
|
|
47
47
|
rdfc:memberStream <in>;
|
|
48
48
|
rdfc:ingestConfig [
|
|
49
|
+
rdfc:operationMode "Replication";
|
|
50
|
+
rdfc:memberBatchSize 500;
|
|
49
51
|
rdfc:memberShape "http://ex.org/Shape";
|
|
50
52
|
rdfc:changeSemantics [
|
|
51
53
|
rdfc:changeTypePath "http://ex.org/changeType";
|
|
@@ -83,6 +85,8 @@ npm install @rdfc/sparql-ingest-processor-ts
|
|
|
83
85
|
---
|
|
84
86
|
|
|
85
87
|
### Parameters of `rdfc:IngestConfig`:
|
|
88
|
+
- `rdfc:operationMode` (**string**, optional): Operation mode of the processor. Can be `Replication` or `Sync`. `Replication` mode uses the [SPARQL Graph Store Protocol](https://www.w3.org/TR/sparql11-http-rdf-update/) to ingest data directly into a triple store, which assumes that all received data is meant to be added. `Sync` mode uses the [SPARQL UPDATE specification](https://www.w3.org/TR/sparql11-update/) to ingest data via SPARQL queries, which allows for all CRUD operations.
|
|
89
|
+
- `rdfc:memberBatchSize` (**integer**, optional): Number of input records to batch together for ingestion when running in `Replication` mode.
|
|
86
90
|
- `rdfc:memberShape` (**string**, optional): SHACL shape used to guide query construction when payloads are incomplete.
|
|
87
91
|
- `rdfc:changeSemantics` (**rdfc:ChangeSemantics**, optional): Configures mapping between change types (create/update/delete) and SPARQL operations.
|
|
88
92
|
- `rdfc:targetNamedGraph` (**string**, optional): Force all operations into a specific named graph.
|
|
@@ -132,7 +136,6 @@ npm install @rdfc/sparql-ingest-processor-ts
|
|
|
132
136
|
|
|
133
137
|
## Notes
|
|
134
138
|
|
|
135
|
-
- Delete operations can be handled differently depending on how complete the input record is.
|
|
139
|
+
- Delete operations can be handled differently depending on how complete the input record is. A SHACL shape (`rdfc:memberShape`) can be provided to help identify deletion targets when payloads are incomplete.
|
|
136
140
|
- Transactions can buffer multiple input records and commit them together using `rdfc:transactionConfig`.
|
|
137
|
-
- A SHACL shape (`rdfc:memberShape`) can be provided to help identify deletion targets when payloads are incomplete.
|
|
138
141
|
|
package/lib/Utils.js
CHANGED
|
@@ -81,7 +81,11 @@ export async function doSPARQLRequest(query, config, logger) {
|
|
|
81
81
|
const timeout = config.measurePerformance?.queryTimeout || 1800;
|
|
82
82
|
if (query.length > 0 && typeof query[0] !== 'string') {
|
|
83
83
|
const quads = query;
|
|
84
|
-
|
|
84
|
+
let hasQuads = config.targetNamedGraph !== undefined;
|
|
85
|
+
if (quads.some(q => !q.graph.equals(df.defaultGraph()))) {
|
|
86
|
+
hasQuads = true;
|
|
87
|
+
}
|
|
88
|
+
const writer = new N3Writer({ format: hasQuads ? "N-Quads" : "N-Triples" });
|
|
85
89
|
const serialized = writer.quadsToString(quads);
|
|
86
90
|
const url = new URL(config.graphStoreUrl);
|
|
87
91
|
if (config.accessToken) {
|
|
@@ -92,7 +96,7 @@ export async function doSPARQLRequest(query, config, logger) {
|
|
|
92
96
|
const res = await fetch(url.toString(), {
|
|
93
97
|
method: "POST",
|
|
94
98
|
headers: {
|
|
95
|
-
'Content-Type': 'application/n-quads',
|
|
99
|
+
'Content-Type': hasQuads ? 'application/n-quads' : 'application/n-triples',
|
|
96
100
|
},
|
|
97
101
|
body: serialized,
|
|
98
102
|
dispatcher: new Agent({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdfc/sparql-ingest-processor-ts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "SPARQL Update function to be within RDF-Connect pipelines",
|
|
5
5
|
"author": "Julián Rojas",
|
|
6
6
|
"contributors": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@rdfc/js-runner": "^3.0.2",
|
|
40
40
|
"@rdfjs/types": "^2.0.1",
|
|
41
41
|
"@types/n3": "^1.26.1",
|
|
42
|
-
"@types/node": "^25.2.
|
|
42
|
+
"@types/node": "^25.2.2",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
|
44
44
|
"@typescript-eslint/parser": "^8.54.0",
|
|
45
45
|
"@vitest/coverage-v8": "^4.0.18",
|