@@ -5,10 +5,8 @@ import {
5
5
} from "rdflib" ;
6
6
7
7
import {
8
- DataProcessor ,
9
8
DataProcessorOpts ,
10
- emptyRequest ,
11
- } from "./processor/DataProcessor" ;
9
+ } from "./types" ;
12
10
import {
13
11
DataTuple ,
14
12
EmptyRequestStatus ,
@@ -18,31 +16,16 @@ import {
18
16
SomeNode ,
19
17
} from "./types" ;
20
18
21
- export interface LinkedDataAPIOpts {
22
- dataProcessorOpts ?: DataProcessorOpts ;
23
- processor ?: DataProcessor ;
24
- }
25
-
26
- export class LinkedDataAPI {
27
- private processor : DataProcessor ;
28
-
29
- public constructor ( opts : LinkedDataAPIOpts ) {
30
- this . processor = opts . processor || new DataProcessor ( opts . dataProcessorOpts ) ;
31
- }
32
-
33
- public execActionByIRI ( subject : NamedNode , dataTuple : DataTuple ) : Promise < LinkedActionResponse > {
34
- return this . processor . execActionByIRI ( subject , dataTuple ) ;
35
- }
19
+ export interface LinkedDataAPI {
20
+ execActionByIRI ( subject : NamedNode , dataTuple : DataTuple ) : Promise < LinkedActionResponse > ;
36
21
37
22
/**
38
23
* Loads a resource from the {iri}.
39
24
* @param iri The SomeNode of the resource
40
25
* @return The response from the server, or an response object from
41
26
* the extension
42
27
*/
43
- public fetchResource ( iri : NamedNode ) : Promise < Response | object > {
44
- return this . processor . fetchResource ( iri ) ;
45
- }
28
+ fetchResource ( iri : NamedNode ) : Promise < Response | object > ;
46
29
47
30
/**
48
31
* Gets an entity by its SomeNode.
@@ -53,9 +36,7 @@ export class LinkedDataAPI {
53
36
* @param opts The options for fetch-/processing the resource.
54
37
* @return A promise with the resulting entity
55
38
*/
56
- public getEntity ( iri : NamedNode , opts ?: FetchOpts ) : Promise < Statement [ ] > {
57
- return this . processor . getEntity ( iri , opts ) ;
58
- }
39
+ getEntity ( iri : NamedNode , opts ?: FetchOpts ) : Promise < Statement [ ] > ;
59
40
60
41
/**
61
42
* Retrieve the (network) status for a resource.
@@ -74,28 +55,22 @@ export class LinkedDataAPI {
74
55
* @param {SomeNode } iri The resource to get the status on.
75
56
* @return {EmptyRequestStatus | FulfilledRequestStatus }
76
57
*/
77
- public getStatus ( iri : SomeNode ) : EmptyRequestStatus | FulfilledRequestStatus {
78
- if ( iri . termType === "BlankNode" ) {
79
- return emptyRequest as EmptyRequestStatus ;
80
- }
81
-
82
- return this . processor . getStatus ( iri ) ;
83
- }
58
+ getStatus ( iri : SomeNode ) : EmptyRequestStatus | FulfilledRequestStatus ;
84
59
85
60
/** Register a transformer so it can be used to interact with API's. */
86
- public registerTransformer ( processor : ResponseTransformer ,
87
- mediaType : string | string [ ] ,
88
- acceptValue : number ) : void {
89
- const mediaTypes : string [ ] = Array . isArray ( mediaType ) ? mediaType : [ mediaType ] ;
90
- this . processor . registerTransformer ( processor , mediaTypes , acceptValue ) ;
91
- }
61
+ registerTransformer ( processor : ResponseTransformer ,
62
+ mediaType : string | string [ ] ,
63
+ acceptValue : number ) : void ;
92
64
93
65
/**
94
66
* Overrides the `Accept` value for when a certain host doesn't respond well to multiple values.
95
67
* @param origin The iri of the origin for the requests.
96
68
* @param acceptValue The value to use for the `Accept` header.
97
69
*/
98
- public setAcceptForHost ( origin : string , acceptValue : string ) : void {
99
- this . processor . setAcceptForHost ( origin , acceptValue ) ;
100
- }
70
+ setAcceptForHost ( origin : string , acceptValue : string ) : void ;
101
71
}
72
+
73
+ declare var LinkedDataAPI : {
74
+ new ( opts ?: DataProcessorOpts ) : any ;
75
+ ( ) : any ;
76
+ } ;
0 commit comments