UNPKG

4.24 kBTypeScriptView Raw
1import { Endpoint } from "./http";
2import { FinalizeHandler, FinalizeHandlerArguments, FinalizeHandlerOutput } from "./middleware";
3import { MetadataBearer } from "./response";
4/**
5 * A function that, given a TypedArray of bytes, can produce a string
6 * representation thereof.
7 *
8 * @example An encoder function that converts bytes to hexadecimal
9 * representation would return `'deadbeef'` when given `new
10 * Uint8Array([0xde, 0xad, 0xbe, 0xef])`.
11 */
12export interface Encoder {
13 (input: Uint8Array): string;
14}
15/**
16 * A function that, given a string, can derive the bytes represented by that
17 * string.
18 *
19 * @example A decoder function that converts bytes to hexadecimal
20 * representation would return `new Uint8Array([0xde, 0xad, 0xbe, 0xef])` when
21 * given the string `'deadbeef'`.
22 */
23export interface Decoder {
24 (input: string): Uint8Array;
25}
26/**
27 * A function that, when invoked, returns a promise that will be fulfilled with
28 * a value of type T.
29 *
30 * @example A function that reads credentials from shared SDK configuration
31 * files, assuming roles and collecting MFA tokens as necessary.
32 */
33export interface Provider<T> {
34 (): Promise<T>;
35}
36/**
37 * A function that, when invoked, returns a promise that will be fulfilled with
38 * a value of type T. It memoizes the result from the previous invocation
39 * instead of calling the underlying resources every time.
40 *
41 * You can force the provider to refresh the memoized value by invoke the
42 * function with optional parameter hash with `forceRefresh` boolean key and
43 * value `true`.
44 *
45 * @example A function that reads credentials from IMDS service that could
46 * return expired credentials. The SDK will keep using the expired credentials
47 * until an unretryable service error requiring a force refresh of the
48 * credentials.
49 */
50export interface MemoizedProvider<T> {
51 (options?: {
52 forceRefresh?: boolean;
53 }): Promise<T>;
54}
55/**
56 * A function that, given a request body, determines the
57 * length of the body. This is used to determine the Content-Length
58 * that should be sent with a request.
59 *
60 * @example A function that reads a file stream and calculates
61 * the size of the file.
62 */
63export interface BodyLengthCalculator {
64 (body: any): number | undefined;
65}
66/**
67 * Interface that specifies the retry behavior
68 */
69export interface RetryStrategy {
70 /**
71 * The retry mode describing how the retry strategy control the traffic flow.
72 */
73 mode?: string;
74 /**
75 * the retry behavior the will invoke the next handler and handle the retry accordingly.
76 * This function should also update the $metadata from the response accordingly.
77 * @see {@link ResponseMetadata}
78 */
79 retry: <Input extends object, Output extends MetadataBearer>(next: FinalizeHandler<Input, Output>, args: FinalizeHandlerArguments<Input>) => Promise<FinalizeHandlerOutput<Output>>;
80}
81/**
82 * Parses a URL in string form into an Endpoint object.
83 */
84export interface UrlParser {
85 (url: string): Endpoint;
86}
87/**
88 * Object containing regionalization information of
89 * AWS services.
90 */
91export interface RegionInfo {
92 hostname: string;
93 partition: string;
94 path?: string;
95 signingService?: string;
96 signingRegion?: string;
97}
98/**
99 * Options to pass when calling {@link RegionInfoProvider}
100 */
101export interface RegionInfoProviderOptions {
102 /**
103 * Enables IPv6/IPv4 dualstack endpoint.
104 * @default false
105 */
106 useDualstackEndpoint: boolean;
107 /**
108 * Enables FIPS compatible endpoints.
109 * @default false
110 */
111 useFipsEndpoint: boolean;
112}
113/**
114 * Function returns designated service's regionalization
115 * information from given region. Each service client
116 * comes with its regionalization provider. it serves
117 * to provide the default values of related configurations
118 */
119export interface RegionInfoProvider {
120 (region: string, options?: RegionInfoProviderOptions): Promise<RegionInfo | undefined>;
121}
122/**
123 * A tuple that represents an API name and optional version
124 * of a library built using the AWS SDK.
125 */
126export declare type UserAgentPair = [name: string, version?: string];
127/**
128 * User agent data that to be put into the request's user
129 * agent.
130 */
131export declare type UserAgent = UserAgentPair[];