diff --git a/lib/hdt.d.ts b/lib/hdt.d.ts new file mode 100644 index 0000000..1b279c0 --- /dev/null +++ b/lib/hdt.d.ts @@ -0,0 +1,44 @@ +declare module "hdt" { + export interface Statement { + subject: string; + predicate: string; + object: string; + } + + export interface SearchTermsOpts { + limit?: number; + position?: "subject" | "predicate" | "object"; + prefix?: string; + } + + export interface SearchLiteralsOpts { + limit?: number; + offset?: number; + } + + export interface SearchLiteralsResult { + literals: string[]; + totalCount: number; + } + + export interface SearchTriplesOpts { + limit?: number; + offset?: number; + } + + export interface SearchResult { + triples: Statement[]; + totalCount: number; + hasExactCount: boolean; + } + + export interface Document { + searchTriples(sub?: string, pred?: string, obj?: string, opts?: SearchTriplesOpts): Promise; + countTriples(sub?: string, pred?: string, obj?: string): Promise; + searchLiterals(substring: string, opts?: SearchLiteralsOpts): Promise; + searchTerms(opts?: SearchTermsOpts): Promise; + close(): Promise; + } + + export function fromFile(filename: string): Promise; +} diff --git a/package.json b/package.json index 45ec916..8031d44 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "license": "LGPL-3.0", "main": "./lib/hdt", "bin": "./bin/hdt", + "types": "./lib/hdt.d.ts", "repository": { "type": "git", "url": "https://github.com/RubenVerborgh/HDT-Node.git"