@lde/pipeline 0.16.0 → 0.17.1
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.
|
@@ -4,19 +4,35 @@ import { type DistributionResolver, NoDistributionAvailable, ResolvedDistributio
|
|
|
4
4
|
export interface ImportResolverOptions {
|
|
5
5
|
importer: Importer;
|
|
6
6
|
server: SparqlServer;
|
|
7
|
+
/**
|
|
8
|
+
* Controls how a dataset's distribution is selected.
|
|
9
|
+
*
|
|
10
|
+
* - `'sparql'` (default) — use a dataset's own SPARQL endpoint when one is
|
|
11
|
+
* available; fall back to importing a data dump only when no endpoint
|
|
12
|
+
* responds.
|
|
13
|
+
* - `'import'` — always import a data dump into a local SPARQL server,
|
|
14
|
+
* even when the dataset advertises a working SPARQL endpoint. Useful when
|
|
15
|
+
* the remote endpoint is too slow or unreliable.
|
|
16
|
+
*
|
|
17
|
+
* In both modes the inner resolver still runs so that probe results are
|
|
18
|
+
* collected for reporting and the dataset knowledge graph.
|
|
19
|
+
*/
|
|
20
|
+
strategy?: 'sparql' | 'import';
|
|
7
21
|
}
|
|
8
22
|
/**
|
|
9
|
-
* A {@link DistributionResolver} decorator that adds
|
|
23
|
+
* A {@link DistributionResolver} decorator that adds data-dump import logic.
|
|
10
24
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
25
|
+
* Wraps an inner resolver (typically {@link SparqlDistributionResolver}) and
|
|
26
|
+
* adds the ability to import a data dump into a local SPARQL server. The
|
|
27
|
+
* {@link ImportResolverOptions.strategy | strategy} option controls whether the
|
|
28
|
+
* inner resolver's SPARQL endpoint is preferred or bypassed.
|
|
14
29
|
*/
|
|
15
30
|
export declare class ImportResolver implements DistributionResolver {
|
|
16
31
|
private readonly inner;
|
|
17
32
|
private readonly options;
|
|
18
33
|
constructor(inner: DistributionResolver, options: ImportResolverOptions);
|
|
19
34
|
resolve(...args: Parameters<DistributionResolver['resolve']>): Promise<ResolvedDistribution | NoDistributionAvailable>;
|
|
35
|
+
private importDataset;
|
|
20
36
|
cleanup(): Promise<void>;
|
|
21
37
|
}
|
|
22
38
|
//# sourceMappingURL=importResolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importResolver.d.ts","sourceRoot":"","sources":["../../src/distribution/importResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"importResolver.d.ts","sourceRoot":"","sources":["../../src/distribution/importResolver.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,YAAW,oBAAoB;IAEvD,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,qBAAqB;IAG3C,OAAO,CACX,GAAG,IAAI,EAAE,UAAU,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,GACnD,OAAO,CAAC,oBAAoB,GAAG,uBAAuB,CAAC;YAgB5C,aAAa;IAgCrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
|
|
@@ -2,11 +2,12 @@ import { Distribution } from '@lde/dataset';
|
|
|
2
2
|
import { ImportFailed, ImportSuccessful } from '@lde/sparql-importer';
|
|
3
3
|
import { NoDistributionAvailable, ResolvedDistribution, } from './resolver.js';
|
|
4
4
|
/**
|
|
5
|
-
* A {@link DistributionResolver} decorator that adds
|
|
5
|
+
* A {@link DistributionResolver} decorator that adds data-dump import logic.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Wraps an inner resolver (typically {@link SparqlDistributionResolver}) and
|
|
8
|
+
* adds the ability to import a data dump into a local SPARQL server. The
|
|
9
|
+
* {@link ImportResolverOptions.strategy | strategy} option controls whether the
|
|
10
|
+
* inner resolver's SPARQL endpoint is preferred or bypassed.
|
|
10
11
|
*/
|
|
11
12
|
export class ImportResolver {
|
|
12
13
|
inner;
|
|
@@ -16,19 +17,26 @@ export class ImportResolver {
|
|
|
16
17
|
this.options = options;
|
|
17
18
|
}
|
|
18
19
|
async resolve(...args) {
|
|
20
|
+
const [dataset] = args;
|
|
19
21
|
const result = await this.inner.resolve(...args);
|
|
20
|
-
|
|
22
|
+
// 'sparql' strategy (default): use SPARQL endpoint if inner found one.
|
|
23
|
+
if (this.options.strategy !== 'import' &&
|
|
24
|
+
result instanceof ResolvedDistribution) {
|
|
21
25
|
return result;
|
|
22
|
-
|
|
26
|
+
}
|
|
27
|
+
// Either 'import' strategy or inner found nothing: import a data dump.
|
|
28
|
+
return this.importDataset(dataset, result.probeResults);
|
|
29
|
+
}
|
|
30
|
+
async importDataset(dataset, probeResults) {
|
|
23
31
|
const importStart = Date.now();
|
|
24
32
|
const importResult = await this.options.importer.import(dataset);
|
|
25
33
|
if (importResult instanceof ImportSuccessful) {
|
|
26
34
|
await this.options.server.start();
|
|
27
35
|
const distribution = Distribution.sparql(this.options.server.queryEndpoint, importResult.identifier);
|
|
28
36
|
distribution.subjectFilter = importResult.distribution.subjectFilter;
|
|
29
|
-
return new ResolvedDistribution(distribution,
|
|
37
|
+
return new ResolvedDistribution(distribution, probeResults, importResult.distribution, Date.now() - importStart);
|
|
30
38
|
}
|
|
31
|
-
return new NoDistributionAvailable(dataset, 'No SPARQL endpoint or importable data dump available',
|
|
39
|
+
return new NoDistributionAvailable(dataset, 'No SPARQL endpoint or importable data dump available', probeResults, importResult instanceof ImportFailed ? importResult : undefined);
|
|
32
40
|
}
|
|
33
41
|
async cleanup() {
|
|
34
42
|
await this.options.server.stop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/pipeline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
6
6
|
"directory": "packages/pipeline"
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"!**/*.tsbuildinfo"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lde/dataset": "0.7.
|
|
27
|
-
"@lde/dataset-registry-client": "0.7.
|
|
28
|
-
"@lde/sparql-importer": "0.3.
|
|
26
|
+
"@lde/dataset": "0.7.1",
|
|
27
|
+
"@lde/dataset-registry-client": "0.7.3",
|
|
28
|
+
"@lde/sparql-importer": "0.3.1",
|
|
29
29
|
"@lde/sparql-server": "0.4.10",
|
|
30
30
|
"@rdfjs/types": "^2.0.1",
|
|
31
31
|
"@traqula/generator-sparql-1-1": "^1.0.3",
|