Skip to content

Commit

Permalink
Merge pull request #53 from rubensworks/fix/ts
Browse files Browse the repository at this point in the history
Migrate typings to @rdfjs/types
  • Loading branch information
RubenVerborgh authored Mar 25, 2024
2 parents 98c43c5 + b03dd38 commit b979292
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 75 deletions.
90 changes: 47 additions & 43 deletions lib/hdt.d.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
import * as RDF from "rdf-js";

declare module "hdt" {
export interface SearchTermsOpts {
limit?: number;
position?: "subject" | "predicate" | "object";
prefix?: string;
subject?: string; // mutually exclusive with prefix and prioritized
object?: string, // mutually exclusive with prefix and prioritized
}

export interface SearchLiteralsOpts {
limit?: number;
offset?: number;
}

export interface SearchLiteralsResult {
literals: RDF.Literal[];
totalCount: number;
}

export interface SearchTriplesOpts {
limit?: number;
offset?: number;
}

export interface SearchResult {
triples: RDF.Quad[];
totalCount: number;
hasExactCount: boolean;
}

export interface Document {
searchTriples(sub?: RDF.Term, pred?: RDF.Term, obj?: RDF.Term, opts?: SearchTriplesOpts): Promise<SearchResult>;
countTriples(sub?: RDF.Term, pred?: RDF.Term, obj?: RDF.Term): Promise<SearchResult>;
searchLiterals(substring: string, opts?: SearchLiteralsOpts): Promise<SearchLiteralsResult>;
searchTerms(opts?: SearchTermsOpts): Promise<string[]>;
close(): Promise<void>;
readHeader(): Promise<string>;
changeHeader(triples:string, outputFile:string): Promise<Document>;
}

export function fromFile(filename: string, opts?: { dataFactory?: RDF.DataFactory }): Promise<Document>;
import * as RDF from "@rdfjs/types";

export interface SearchTermsOpts {
limit?: number;
position?: "subject" | "predicate" | "object";
prefix?: string;
subject?: string; // mutually exclusive with prefix and prioritized
object?: string, // mutually exclusive with prefix and prioritized
}

export interface SearchLiteralsOpts {
limit?: number;
offset?: number;
}

export interface SearchLiteralsResult {
literals: RDF.Literal[];
totalCount: number;
}

export interface SearchTriplesOpts {
limit?: number;
offset?: number;
}

export interface SearchResult {
triples: RDF.Quad[];
totalCount: number;
hasExactCount: boolean;
}

export interface Document {
searchTriples(sub?: RDF.Term, pred?: RDF.Term, obj?: RDF.Term, opts?: SearchTriplesOpts): Promise<SearchResult>;

countTriples(sub?: RDF.Term, pred?: RDF.Term, obj?: RDF.Term): Promise<SearchResult>;

searchLiterals(substring: string, opts?: SearchLiteralsOpts): Promise<SearchLiteralsResult>;

searchTerms(opts?: SearchTermsOpts): Promise<string[]>;

close(): Promise<void>;

readHeader(): Promise<string>;

changeHeader(triples: string, outputFile: string): Promise<Document>;
}

export function fromFile(filename: string, opts?: { dataFactory?: RDF.DataFactory }): Promise<Document>;
202 changes: 172 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
},
"dependencies": {
"minimist": "^1.1.0",
"n3": "^1.3.5",
"n3": "^1.17.3",
"nan": "^2.19.0",
"rdf-string": "^1.3.1"
"rdf-string": "^1.6.3"
},
"devDependencies": {
"eslint": "^5.3.0",
Expand Down

0 comments on commit b979292

Please sign in to comment.