UNPKG

1.63 kBTypeScriptView Raw
1import { Endpoint } from "./http";
2import { RequestHandler } from "./transfer";
3import { Decoder, Encoder, Provider } from "./util";
4/**
5 * Interface for object requires an Endpoint set.
6 */
7export interface EndpointBearer {
8 endpoint: Provider<Endpoint>;
9}
10export interface StreamCollector {
11 /**
12 * A function that converts a stream into an array of bytes.
13 *
14 * @param stream The low-level native stream from browser or Nodejs runtime
15 */
16 (stream: any): Promise<Uint8Array>;
17}
18/**
19 * Request and Response serde util functions and settings for AWS services
20 */
21export interface SerdeContext extends EndpointBearer {
22 base64Encoder: Encoder;
23 base64Decoder: Decoder;
24 utf8Encoder: Encoder;
25 utf8Decoder: Decoder;
26 streamCollector: StreamCollector;
27 requestHandler: RequestHandler<any, any>;
28 disableHostPrefix: boolean;
29}
30export interface RequestSerializer<Request, Context extends EndpointBearer = any> {
31 /**
32 * Converts the provided `input` into a request object
33 *
34 * @param input The user input to serialize.
35 *
36 * @param context Context containing runtime-specific util functions.
37 */
38 (input: any, context: Context): Promise<Request>;
39}
40export interface ResponseDeserializer<OutputType, ResponseType = any, Context = any> {
41 /**
42 * Converts the output of an operation into JavaScript types.
43 *
44 * @param output The HTTP response received from the service
45 *
46 * @param context context containing runtime-specific util functions.
47 */
48 (output: ResponseType, context: Context): Promise<OutputType>;
49}