-
Notifications
You must be signed in to change notification settings - Fork 4
/
rdflib.ts
47 lines (36 loc) · 1.61 KB
/
rdflib.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { LowLevelStore } from "@ontologies/core";
import { NamedNode } from "./rdf";
import { SomeNode } from "./types";
/**
* Fetcher
*/
export interface RDFFetchOpts extends RequestInit {
fetch?: WindowOrWorkerGlobalScope["fetch"];
referringTerm?: NamedNode;
contentType?: string;
forceContentType?: string;
force?: boolean;
baseURI?: SomeNode | string;
proxyUsed?: boolean;
timeout?: number;
withCredentials?: boolean;
clearPreviousData?: boolean;
noMeta?: boolean;
noRDFa?: boolean;
}
export type RequestCallbackHandler = (uri: string | NamedNode, error?: Error) => boolean | undefined;
export type FetchSuccessCallback = (success: true, error: null, result: Response) => void;
export type FetchFailureCallback = (success: false, error: string, result: undefined) => void;
export interface Fetcher {
mediatypes: { [k: string]: { [k: string]: number } };
requested: { [k: string]: string | number | boolean };
// tslint:disable-next-line:no-misused-new - This is required to extend from the export of this file.
new (store: LowLevelStore, options: RDFFetchOpts): Fetcher;
addCallback(hook: string, callback: RequestCallbackHandler): void;
handleError(response: Response, docuri: string | NamedNode, options: RequestInit): Promise<any>;
// tslint:disable-next-line no-any
load(url: NamedNode[] | string[] | NamedNode | string, options: RDFFetchOpts): Promise<any>;
nowOrWhenFetched(uri: string | NamedNode,
options: RequestInit,
userCallback: FetchSuccessCallback | FetchFailureCallback): Promise<any>;
}