From d51d1c98efa1edc5a0d2d2474ea67aa419a66c8b Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 18 Oct 2017 15:26:20 +0900 Subject: [PATCH] Update n3 store and util types --- types/n3/index.d.ts | 51 ++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/types/n3/index.d.ts b/types/n3/index.d.ts index 4621336998..75c2318743 100644 --- a/types/n3/index.d.ts +++ b/types/n3/index.d.ts @@ -86,7 +86,7 @@ export type ErrorCallback = (err: Error, result: any) => void; export type QuadCallback = (result: Quad) => void; export type QuadPredicate = (result: Quad) => boolean; -export type OTerm = string | null; +export type OString = string | RDF.Term | null; export type OIRI = RDF.Term | null; export type Logger = (message?: any, ...optionalParams: any[]) => void; @@ -155,7 +155,7 @@ export interface N3StreamWriter extends N3Writer { } export interface N3Store { - size: number; + readonly size: number; addTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; addTriple(quad: RDF.Quad): void; addTriples(quads: RDF.Quad[]): void; @@ -164,31 +164,31 @@ export interface N3Store { removeTriple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void; removeTriple(quad: RDF.Quad): void; removeTriples(quads: RDF.Quad[]): void; - getTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): Quad[]; - getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): Quad[]; - countTriples(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number; + getTriples(subject: OString, predicate: OString, object: OString | OString[], graph: OString): Quad[]; + getTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI | OIRI[], graph: OIRI): Quad[]; + countTriples(subject: OString, predicate: OString, object: OString, graph: OString): number; countTriplesByIRI(subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): number; - forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void; + forEach(callback: QuadCallback, subject: OString, predicate: OString, object: OString, graph: OString): void; forEachByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): void; - every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + every(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; everyByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean; + some(callback: QuadPredicate, subject: OString, predicate: OString, object: OString, graph: OString): boolean; someByIRI(callback: QuadPredicate, subject: OIRI, predicate: OIRI, object: OIRI, graph: OIRI): boolean; - getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getSubjects(predicate: OString, object: OString, graph: OString): RDF.Term[]; getSubjectsByIRI(predicate: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void; + forSubjects(callback: QuadCallback, predicate: OString, object: OString, graph: OString): void; forSubjectsByIRI(callback: QuadCallback, predicate: OIRI, object: OIRI, graph: OIRI): void; - getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[]; + getPredicates(subject: OString, object: OString, graph: OString): RDF.Term[]; getPredicatesByIRI(subject: OIRI, object: OIRI, graph: OIRI): RDF.Term[]; - forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void; + forPredicates(callback: QuadCallback, subject: OString, object: OString, graph: OString): void; forPredicatesByIRI(callback: QuadCallback, subject: OIRI, object: OIRI, graph: OIRI): void; - getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[]; + getObjects(subject: OString, predicate: OString, graph: OString): RDF.Term[]; getObjectsByIRI(subject: OIRI, predicate: OIRI, graph: OIRI): RDF.Term[]; - forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void; + forObjects(callback: QuadCallback, subject: OString, predicate: OString, graph: OString): void; forObjectsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, graph: OIRI): void; - getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[]; + getGraphs(subject: OString, predicate: OString, object: OString): RDF.Term[]; getGraphsByIRI(subject: OIRI, predicate: OIRI, object: OIRI): RDF.Term[]; - forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void; + forGraphs(callback: QuadCallback, subject: OString, predicate: OString, object: OString): void; forGraphsByIRI(callback: QuadCallback, subject: OIRI, predicate: OIRI, object: OIRI): void; createBlankNode(suggestedName: string): BlankNode; } @@ -199,14 +199,17 @@ export interface StoreOptions { } export namespace Util { - function createLiteral(value: any, type?: string): string; + function createLiteral(value: any, type?: string): Literal; + function createIRI(iri: string): NamedNode; - function isIRI(value: string): boolean; - function isLiteral(value: string): boolean; - function getLiteralValue(value: string): string; - function getLiteralLanguage(value: string): string; - function getLiteralType(value: string): string; - function isBlank(value: string): boolean; + function isIRI(value: RDF.Term | null): boolean; + function isLiteral(value: RDF.Term | null): boolean; + function isBlank(value: RDF.Term | null): boolean; + function isDefaultGraph(value: RDF.Term | null): boolean; + function inDefaultGraph(value: RDF.Quad): boolean; + function getLiteralValue(value: RDF.Literal): string; + function getLiteralLanguage(value: RDF.Literal): string; + function getLiteralType(value: RDF.Literal): RDF.NamedNode; function isPrefixedName(name: string): boolean; - function expandPrefixedName(name: string, prefixes: Prefixes): string; + function expandPrefixedName(name: string, prefixes: Prefixes): string | RDF.NamedNode; }