1 | import { Fetcher, FetchMiddleware } from './http/fetcher';
|
2 | import Resource from './resource';
|
3 | import { State, StateFactory } from './state';
|
4 | import { LinkVariables } from './link';
|
5 | import { FollowPromiseOne } from './follow-promise';
|
6 | import { StateCache } from './cache';
|
7 | export default class Client {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 | bookmarkUri: string;
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | contentTypeMap: {
|
24 | [mimeType: string]: [StateFactory<any>, string];
|
25 | };
|
26 | |
27 |
|
28 |
|
29 | cache: StateCache;
|
30 | |
31 |
|
32 |
|
33 |
|
34 | resources: Map<string, Resource>;
|
35 | |
36 |
|
37 |
|
38 |
|
39 | fetcher: Fetcher;
|
40 | constructor(bookmarkUri: string);
|
41 | /**
|
42 | * Follows a relationship, based on its reltype. For example, this might be
|
43 | * 'alternate', 'item', 'edit' or a custom url-based one.
|
44 | *
|
45 | * This function can also follow templated uris. You can specify uri
|
46 | * variables in the optional variables argument.
|
47 | */
|
48 | follow<TFollowedResource = any>(rel: string, variables?: LinkVariables): FollowPromiseOne<TFollowedResource>;
|
49 | /**
|
50 | * Returns a resource by its uri.
|
51 | *
|
52 | * This function doesn't do any HTTP requests. The uri is optional. If it's
|
53 | * not specified, it will return the bookmark resource.
|
54 | *
|
55 | * If a relative uri is passed, it will be resolved based on the bookmark
|
56 | * uri.
|
57 | *
|
58 | * @example
|
59 | * const res = ketting.go('https:
|
60 | * @example
|
61 | * const res = ketting.go<Author>('/users/1');
|
62 | * @example
|
63 | * const res = ketting.go();
|
64 | */
|
65 | go<TResource = any>(uri?: string): Resource<TResource>;
|
66 | |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | use(middleware: FetchMiddleware, origin?: string): void;
|
74 | |
75 |
|
76 |
|
77 | clearCache(): void;
|
78 | |
79 |
|
80 |
|
81 | getStateForResponse(uri: string, response: Response): Promise<State>;
|
82 | |
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 | cacheState(state: State): void;
|
89 | private acceptHeader;
|
90 | private cacheExpireHandler;
|
91 | }
|
92 |
|
\ | No newline at end of file |