mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Merge pull request #28197 from AlexeyMz/master
[sparqljs] Update to v2.1 (remove parser options, support CLEAR and DROP operations)
This commit is contained in:
Vendored
+42
-17
@@ -1,4 +1,4 @@
|
||||
// Type definitions for sparqljs 1.5
|
||||
// Type definitions for sparqljs 2.1
|
||||
// Project: https://github.com/RubenVerborgh/SPARQL.js
|
||||
// Definitions by: Alexey Morozov <https://github.com/AlexeyMz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -8,7 +8,6 @@ export const Parser: {
|
||||
new (
|
||||
prefixes?: { [prefix: string]: string },
|
||||
baseIRI?: string,
|
||||
options?: ParserOptions,
|
||||
): SparqlParser;
|
||||
};
|
||||
|
||||
@@ -16,11 +15,6 @@ export const Generator: {
|
||||
new (options?: GeneratorOptions): SparqlGenerator;
|
||||
};
|
||||
|
||||
export interface ParserOptions {
|
||||
/** @default true */
|
||||
collapseGroups?: boolean;
|
||||
}
|
||||
|
||||
export interface GeneratorOptions {
|
||||
allPrefixes?: boolean;
|
||||
}
|
||||
@@ -94,6 +88,7 @@ export type UpdateOperation = InsertDeleteOperation | ManagementOperation;
|
||||
|
||||
export interface InsertDeleteOperation {
|
||||
updateType: 'insert' | 'delete' | 'deletewhere' | 'insertdelete';
|
||||
graph?: string;
|
||||
insert?: Quads[];
|
||||
delete?: Quads[];
|
||||
where?: Pattern[];
|
||||
@@ -101,17 +96,47 @@ export interface InsertDeleteOperation {
|
||||
|
||||
export type Quads = BgpPattern | GraphQuads;
|
||||
|
||||
export interface ManagementOperation {
|
||||
type: 'load' | 'copy' | 'move' | 'add';
|
||||
export type ManagementOperation =
|
||||
| CopyMoveAddOperation
|
||||
| LoadOperation
|
||||
| CreateOperation
|
||||
| ClearDropOperation;
|
||||
|
||||
export interface CopyMoveAddOperation {
|
||||
type: 'copy' | 'move' | 'add';
|
||||
silent: boolean;
|
||||
source: string | {
|
||||
type: 'graph';
|
||||
default: boolean;
|
||||
};
|
||||
destination?: string | {
|
||||
type: 'graph';
|
||||
name: string;
|
||||
};
|
||||
source: GraphOrDefault;
|
||||
destination: GraphOrDefault;
|
||||
}
|
||||
|
||||
export interface LoadOperation {
|
||||
type: 'load';
|
||||
silent: boolean;
|
||||
source: string;
|
||||
destination: string | false;
|
||||
}
|
||||
|
||||
export interface CreateOperation {
|
||||
type: 'create';
|
||||
silent: boolean;
|
||||
graph: string;
|
||||
}
|
||||
|
||||
export interface ClearDropOperation {
|
||||
type: 'clear' | 'drop';
|
||||
silent: boolean;
|
||||
graph: GraphReference;
|
||||
}
|
||||
|
||||
export interface GraphOrDefault {
|
||||
type: 'graph';
|
||||
name?: string;
|
||||
default?: boolean;
|
||||
}
|
||||
|
||||
export interface GraphReference extends GraphOrDefault {
|
||||
named?: boolean;
|
||||
all?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,8 +26,7 @@ function officialExamples() {
|
||||
function advancedOptions() {
|
||||
const parser = new SparqlJs.Parser(
|
||||
{rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'},
|
||||
'http://example.com',
|
||||
{collapseGroups: true}
|
||||
'http://example.com'
|
||||
);
|
||||
const generator = new SparqlJs.Generator({allPrefixes: false});
|
||||
}
|
||||
@@ -122,3 +121,49 @@ function basicQueries() {
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Update query structure
|
||||
*/
|
||||
function updateQueries() {
|
||||
const bgp: SparqlJs.BgpPattern = {
|
||||
type: 'bgp',
|
||||
triples: [],
|
||||
};
|
||||
|
||||
const update: SparqlJs.Update = {
|
||||
type: 'update',
|
||||
prefixes: {
|
||||
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
||||
},
|
||||
updates: [
|
||||
{
|
||||
updateType: 'insertdelete',
|
||||
graph: 'http://example.com/foo',
|
||||
insert: [bgp],
|
||||
delete: [bgp],
|
||||
where: [],
|
||||
},
|
||||
{
|
||||
type: 'copy',
|
||||
silent: true,
|
||||
source: {
|
||||
type: 'graph',
|
||||
name: 'http://example.com/foo',
|
||||
},
|
||||
destination: {
|
||||
type: 'graph',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'clear',
|
||||
silent: false,
|
||||
graph: {
|
||||
type: 'graph',
|
||||
all: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user