@lde/pipeline 0.28.5 → 0.28.6
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 +21 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/{provenance.d.ts → plugin/provenance.d.ts} +2 -2
- package/dist/plugin/provenance.d.ts.map +1 -0
- package/dist/plugin/schemaOrgNormalization.d.ts +13 -0
- package/dist/plugin/schemaOrgNormalization.d.ts.map +1 -0
- package/dist/plugin/schemaOrgNormalization.js +33 -0
- package/package.json +5 -5
- package/dist/provenance.d.ts.map +0 -1
- /package/dist/{provenance.js → plugin/provenance.js} +0 -0
package/README.md
CHANGED
|
@@ -225,6 +225,27 @@ Writes generated quads to a destination:
|
|
|
225
225
|
- `SparqlUpdateWriter` — writes to a SPARQL endpoint via UPDATE queries
|
|
226
226
|
- `FileWriter` — writes to local files
|
|
227
227
|
|
|
228
|
+
### Plugins
|
|
229
|
+
|
|
230
|
+
Plugins hook into the pipeline lifecycle via the `PipelinePlugin` interface. Register them in the `plugins` array when constructing a `Pipeline`.
|
|
231
|
+
|
|
232
|
+
#### `provenancePlugin()`
|
|
233
|
+
|
|
234
|
+
Appends [PROV-O](https://www.w3.org/TR/prov-o/) provenance quads (`prov:Entity`, `prov:Activity`, `prov:startedAtTime`, `prov:endedAtTime`) to every stage’s output.
|
|
235
|
+
|
|
236
|
+
#### `schemaOrgNormalizationPlugin()`
|
|
237
|
+
|
|
238
|
+
Normalizes `http://schema.org/` to `https://schema.org/` in `void:class` and `void:property` quad objects, so downstream consumers can rely on a single canonical namespace. `void:vocabulary` quads are left unchanged so consumers can see which namespace the source dataset actually uses.
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
import { schemaOrgNormalizationPlugin, provenancePlugin } from '@lde/pipeline';
|
|
242
|
+
|
|
243
|
+
new Pipeline({
|
|
244
|
+
// ...
|
|
245
|
+
plugins: [schemaOrgNormalizationPlugin(), provenancePlugin()],
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
228
249
|
## Usage
|
|
229
250
|
|
|
230
251
|
```typescript
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export * from './stageOutputResolver.js';
|
|
|
9
9
|
export * from './sparql/index.js';
|
|
10
10
|
export * from './distribution/index.js';
|
|
11
11
|
export * from './writer/index.js';
|
|
12
|
-
export * from './provenance.js';
|
|
12
|
+
export * from './plugin/provenance.js';
|
|
13
|
+
export * from './plugin/schemaOrgNormalization.js';
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export * from './stageOutputResolver.js';
|
|
|
9
9
|
export * from './sparql/index.js';
|
|
10
10
|
export * from './distribution/index.js';
|
|
11
11
|
export * from './writer/index.js';
|
|
12
|
-
export * from './provenance.js';
|
|
12
|
+
export * from './plugin/provenance.js';
|
|
13
|
+
export * from './plugin/schemaOrgNormalization.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { QuadTransform } from '
|
|
2
|
-
import type { PipelinePlugin } from '
|
|
1
|
+
import type { QuadTransform } from '../stage.js';
|
|
2
|
+
import type { PipelinePlugin } from '../pipeline.js';
|
|
3
3
|
/** QuadTransform that appends PROV-O provenance quads. */
|
|
4
4
|
export declare const provenanceTransform: QuadTransform;
|
|
5
5
|
/** Pipeline plugin that appends PROV-O provenance to every stage's output. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../../src/plugin/provenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAkBrD,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,EAAE,aACgC,CAAC;AAEnE,8EAA8E;AAC9E,wBAAgB,gBAAgB,IAAI,cAAc,CAKjD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { QuadTransform } from '../stage.js';
|
|
2
|
+
import type { PipelinePlugin } from '../pipeline.js';
|
|
3
|
+
/** QuadTransform that normalizes `http://schema.org/` to `https://schema.org/` in `void:class` and `void:property` objects. */
|
|
4
|
+
export declare const schemaOrgNormalizationTransform: QuadTransform;
|
|
5
|
+
/**
|
|
6
|
+
* Pipeline plugin that normalizes `http://schema.org/` to `https://schema.org/`
|
|
7
|
+
* in `void:class` and `void:property` quad objects.
|
|
8
|
+
*
|
|
9
|
+
* `void:vocabulary` quads are left unchanged so consumers can see which
|
|
10
|
+
* namespace the source dataset actually uses.
|
|
11
|
+
*/
|
|
12
|
+
export declare function schemaOrgNormalizationPlugin(): PipelinePlugin;
|
|
13
|
+
//# sourceMappingURL=schemaOrgNormalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaOrgNormalization.d.ts","sourceRoot":"","sources":["../../src/plugin/schemaOrgNormalization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAYrD,+HAA+H;AAC/H,eAAO,MAAM,+BAA+B,EAAE,aACnB,CAAC;AAE5B;;;;;;GAMG;AACH,wBAAgB,4BAA4B,IAAI,cAAc,CAK7D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DataFactory } from 'n3';
|
|
2
|
+
const { namedNode, quad } = DataFactory;
|
|
3
|
+
const VOID_CLASS = namedNode('http://rdfs.org/ns/void#class');
|
|
4
|
+
const VOID_PROPERTY = namedNode('http://rdfs.org/ns/void#property');
|
|
5
|
+
const HTTP_SCHEMA_ORG = 'http://schema.org/';
|
|
6
|
+
const HTTPS_SCHEMA_ORG = 'https://schema.org/';
|
|
7
|
+
/** QuadTransform that normalizes `http://schema.org/` to `https://schema.org/` in `void:class` and `void:property` objects. */
|
|
8
|
+
export const schemaOrgNormalizationTransform = (quads) => normalizeSchemaOrg(quads);
|
|
9
|
+
/**
|
|
10
|
+
* Pipeline plugin that normalizes `http://schema.org/` to `https://schema.org/`
|
|
11
|
+
* in `void:class` and `void:property` quad objects.
|
|
12
|
+
*
|
|
13
|
+
* `void:vocabulary` quads are left unchanged so consumers can see which
|
|
14
|
+
* namespace the source dataset actually uses.
|
|
15
|
+
*/
|
|
16
|
+
export function schemaOrgNormalizationPlugin() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'schema-org-normalization',
|
|
19
|
+
beforeStageWrite: schemaOrgNormalizationTransform,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function* normalizeSchemaOrg(quads) {
|
|
23
|
+
for await (const q of quads) {
|
|
24
|
+
if ((q.predicate.equals(VOID_CLASS) || q.predicate.equals(VOID_PROPERTY)) &&
|
|
25
|
+
q.object.termType === 'NamedNode' &&
|
|
26
|
+
q.object.value.startsWith(HTTP_SCHEMA_ORG)) {
|
|
27
|
+
yield quad(q.subject, q.predicate, namedNode(HTTPS_SCHEMA_ORG + q.object.value.slice(HTTP_SCHEMA_ORG.length)), q.graph);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
yield q;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/pipeline",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
6
6
|
"directory": "packages/pipeline"
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"@lde/sparql-importer": "0.6.0",
|
|
30
30
|
"@lde/sparql-server": "0.4.10",
|
|
31
31
|
"@rdfjs/types": "^2.0.1",
|
|
32
|
-
"@traqula/generator-sparql-1-1": "^1.0.
|
|
33
|
-
"@traqula/parser-sparql-1-1": "^1.0.
|
|
34
|
-
"@traqula/rules-sparql-1-1": "^1.0.
|
|
32
|
+
"@traqula/generator-sparql-1-1": "^1.0.4",
|
|
33
|
+
"@traqula/parser-sparql-1-1": "^1.0.4",
|
|
34
|
+
"@traqula/rules-sparql-1-1": "^1.0.4",
|
|
35
35
|
"fetch-sparql-endpoint": "^7.1.0",
|
|
36
36
|
"filenamify-url": "^4.0.0",
|
|
37
37
|
"is-network-error": "^1.3.1",
|
|
38
38
|
"n3": "^2.0.1",
|
|
39
|
-
"p-retry": "^
|
|
39
|
+
"p-retry": "^8.0.0",
|
|
40
40
|
"rdf-string": "^2.0.1",
|
|
41
41
|
"tslib": "^2.3.0"
|
|
42
42
|
}
|
package/dist/provenance.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provenance.d.ts","sourceRoot":"","sources":["../src/provenance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAkBpD,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,EAAE,aACgC,CAAC;AAEnE,8EAA8E;AAC9E,wBAAgB,gBAAgB,IAAI,cAAc,CAKjD"}
|
|
File without changes
|