🤖 Merge PR #58221 feat(new types): barnard59-validate-shacl by @tpluscode

* feat(new types): barnard59-validate-shacl

* chore: second author
This commit is contained in:
Tomasz Pluskiewicz
2022-01-17 17:11:54 +01:00
committed by GitHub
parent caad075d94
commit 9bef1e0792
6 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { NamedNode } from '@rdfjs/types';
import { shacl } from 'barnard59-validate-shacl';
import { Duplex, Readable } from "stream";
const shape: Readable = <any> {};
const shViolation: NamedNode = <any> {};
async function test() {
// shape only
let step: Duplex = await shacl(shape);
// minimal options
step = await shacl({
shape,
});
// full options
step = await shacl({
shape,
maxErrors: 0,
onViolation({ context, data, report }): boolean {
const arg = context.variables.get('arg');
if (data.size === 0) {
return false;
}
if (!report.conforms) {
return report.results.some(r => shViolation.equals(r.severity));
}
return false;
}
});
}

View File

@@ -0,0 +1,7 @@
// Type definitions for barnard59-validate-shacl 0.3
// Project: https://github.com/zazuko/barnard59-validate-shacl
// Definitions by: tpluscode <https://github.com/tpluscode>
// cristianvasquez <https://github.com/cristianvasquez>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export * from './validate';

View File

@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"rdf-js": "^4.0.2"
}
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"barnard59-validate-shacl-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }

View File

@@ -0,0 +1,19 @@
import { DatasetCore } from '@rdfjs/types';
import ValidationReport = require('rdf-validate-shacl/src/validation-report');
import { Context } from 'barnard59-core/lib/Pipeline';
import { Duplex, Readable } from 'stream';
export interface OnViolation {
context: Context;
data: DatasetCore;
report: ValidationReport;
}
interface Options {
shape: Readable;
maxErrors?: number;
onViolation?(arg: OnViolation): boolean;
}
export function shacl(arg: Readable | Options): Promise<Duplex>;
export {};