mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 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:
committed by
GitHub
parent
caad075d94
commit
9bef1e0792
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
7
types/barnard59-validate-shacl/index.d.ts
vendored
Normal file
7
types/barnard59-validate-shacl/index.d.ts
vendored
Normal 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';
|
||||
6
types/barnard59-validate-shacl/package.json
Normal file
6
types/barnard59-validate-shacl/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"rdf-js": "^4.0.2"
|
||||
}
|
||||
}
|
||||
23
types/barnard59-validate-shacl/tsconfig.json
Normal file
23
types/barnard59-validate-shacl/tsconfig.json
Normal 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"
|
||||
]
|
||||
}
|
||||
1
types/barnard59-validate-shacl/tslint.json
Normal file
1
types/barnard59-validate-shacl/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "@definitelytyped/dtslint/dt.json" }
|
||||
19
types/barnard59-validate-shacl/validate.d.ts
vendored
Normal file
19
types/barnard59-validate-shacl/validate.d.ts
vendored
Normal 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 {};
|
||||
Reference in New Issue
Block a user