forked from HydraCG/Heracles.ts
/
IHypermediaProcessor.ts
38 lines (35 loc) · 1.22 KB
/
IHypermediaProcessor.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
import { IHypermediaContainer } from "./DataModel/IHypermediaContainer";
import { IHydraClient } from "./IHydraClient";
import { IHypermediaProcessingOptions } from "./IHypermediaProcessingOptions";
import { Level } from "./Level";
/**
* Describes an abstract meta-data providing facility which translates from a raw {@link Response}
* to an abstract data model.
* @interface
*/
export interface IHypermediaProcessor {
/**
* Gets supported media types.
* @readonly
* @returns {Iterable<string>}
*/
readonly supportedMediaTypes: Iterable<string>;
/**
* Determines level of support of a this {@link IHypermediaProcessor} for given response.
* @param {Response} response Response to check support for.
* @returns {Level}
*/
supports(response: Response): Level;
/**
* Parses a given raw response.
* @param {Response} response Raw fetch response holding data to be parsed.
* @param {IHydraClient} client Hydra client.
* @param {IHypermediaProcessingOptions} options Optional additional processing options.
* @returns {Promise<IHypermediaContainer>}
*/
process(
response: Response,
client: IHydraClient,
options?: IHypermediaProcessingOptions
): Promise<IHypermediaContainer>;
}