@lde/pipeline-shacl-sampler 0.7.3 → 0.7.4
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/sampleStages.d.ts +2 -25
- package/dist/sampleStages.d.ts.map +1 -1
- package/dist/sampleStages.js +2 -11
- package/package.json +2 -2
package/dist/sampleStages.d.ts
CHANGED
|
@@ -1,30 +1,8 @@
|
|
|
1
|
-
import { Stage, type StageOptions, type Validator } from '@lde/pipeline';
|
|
1
|
+
import { Stage, type NamespaceAlias, type StageOptions, type Validator } from '@lde/pipeline';
|
|
2
2
|
import type { NamedNode } from '@rdfjs/types';
|
|
3
3
|
import { type TargetShape } from './pathExtractor.js';
|
|
4
4
|
type OnInvalid = NonNullable<StageOptions['validation']>['onInvalid'];
|
|
5
|
-
|
|
6
|
-
* Declares that two namespaces should be treated as equivalent when
|
|
7
|
-
* sampling and validating, working around vocabularies that publish under
|
|
8
|
-
* both HTTP and HTTPS variants of the same IRI (notably schema.org).
|
|
9
|
-
*
|
|
10
|
-
* The sampler accepts subjects typed under the {@link alias} namespace in
|
|
11
|
-
* addition to the SHACL `sh:targetClass` IRI under {@link canonical}, and
|
|
12
|
-
* rewrites alias-namespace IRIs to canonical ones in the sampled quads
|
|
13
|
-
* before validation so SHACL `sh:targetClass` and `sh:path` patterns
|
|
14
|
-
* match.
|
|
15
|
-
*/
|
|
16
|
-
export interface NamespaceAlias {
|
|
17
|
-
/**
|
|
18
|
-
* The namespace declared in the SHACL shapes file (e.g.
|
|
19
|
-
* `https://schema.org/`).
|
|
20
|
-
*/
|
|
21
|
-
canonical: string;
|
|
22
|
-
/**
|
|
23
|
-
* The equivalent namespace that may appear in source data (e.g.
|
|
24
|
-
* `http://schema.org/`).
|
|
25
|
-
*/
|
|
26
|
-
alias: string;
|
|
27
|
-
}
|
|
5
|
+
export type { NamespaceAlias } from '@lde/pipeline';
|
|
28
6
|
/** Options for {@link shaclSampleStages}. */
|
|
29
7
|
export interface ShaclSampleStagesOptions {
|
|
30
8
|
/** URL or local path to the SHACL shapes file. */
|
|
@@ -128,5 +106,4 @@ export declare function buildSampleQuery(shape: TargetShape): string;
|
|
|
128
106
|
* producing vacuously-conformant reports.
|
|
129
107
|
*/
|
|
130
108
|
export declare function wrapValidatorWithAliasNormalization(inner: Validator, namespaceAliases: NamespaceAlias[]): Validator;
|
|
131
|
-
export {};
|
|
132
109
|
//# sourceMappingURL=sampleStages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampleStages.d.ts","sourceRoot":"","sources":["../src/sampleStages.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sampleStages.d.ts","sourceRoot":"","sources":["../src/sampleStages.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EAIL,KAAK,cAAc,EACnB,KAAK,YAAY,EAGjB,KAAK,SAAS,EACf,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,SAAS,EAAQ,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAI3E,KAAK,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AAEtE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,KAAK,MAAM,CAAC;CACvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,KAAK,EAAE,CAAC,CAkClB;AA6BD,qDAAqD;AACrD,MAAM,WAAW,2BAA2B;IAC1C,uCAAuC;IACvC,WAAW,EAAE,SAAS,CAAC;IACvB,kFAAkF;IAClF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,cAAc,EAAE,CAAC;IACpC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,yBAAyB,CAAC,EACxC,WAAW,EACX,aAAa,EACb,UAAU,EACV,gBAAqB,EACrB,aAAa,GACd,EAAE,2BAA2B,GAAG,MAAM,CAYtC;AAsBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAuB3D;AAED;;;;;;GAMG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,SAAS,EAChB,gBAAgB,EAAE,cAAc,EAAE,GACjC,SAAS,CAeX"}
|
package/dist/sampleStages.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Stage, SparqlConstructReader, SparqlItemSelector, } from '@lde/pipeline';
|
|
1
|
+
import { aliasVariants, Stage, SparqlConstructReader, SparqlItemSelector, } from '@lde/pipeline';
|
|
2
2
|
import { assertSafeIri } from '@lde/dataset';
|
|
3
3
|
import { DataFactory } from 'n3';
|
|
4
4
|
import { extractTargetShapes } from './pathExtractor.js';
|
|
@@ -86,16 +86,7 @@ function buildTypePattern(targetClass, namespaceAliases) {
|
|
|
86
86
|
return `?s a ?type . FILTER(?type IN (${iriList}))`;
|
|
87
87
|
}
|
|
88
88
|
function expandTargetClass(targetClass, namespaceAliases) {
|
|
89
|
-
|
|
90
|
-
for (const { canonical, alias } of namespaceAliases) {
|
|
91
|
-
if (iri.startsWith(canonical)) {
|
|
92
|
-
return [iri, alias + iri.slice(canonical.length)];
|
|
93
|
-
}
|
|
94
|
-
if (iri.startsWith(alias)) {
|
|
95
|
-
return [iri, canonical + iri.slice(alias.length)];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return [iri];
|
|
89
|
+
return aliasVariants(targetClass.value, namespaceAliases);
|
|
99
90
|
}
|
|
100
91
|
export function buildSampleQuery(shape) {
|
|
101
92
|
for (const chain of shape.pathChains) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/pipeline-shacl-sampler",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Per-class sampling stages for @lde/pipeline, derived from SHACL shapes",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@lde/dataset": "^0.7.8",
|
|
36
|
-
"@lde/pipeline": "^0.33.
|
|
36
|
+
"@lde/pipeline": "^0.33.4"
|
|
37
37
|
}
|
|
38
38
|
}
|