Skip to content

Commit

Permalink
feat(types): add types to sdk stream utility mixin (#3779)
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZhengYP committed Jul 11, 2022
1 parent b272b15 commit f311cab
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/types/src/serde.ts
Expand Up @@ -52,3 +52,20 @@ export interface ResponseDeserializer<OutputType, ResponseType = any, Context =
*/
(output: ResponseType, context: Context): Promise<OutputType>;
}

/**
* The interface contains mix-in utility functions to transfer the runtime-specific
* stream implementation to specified format. Each stream can ONLY be transformed
* once.
*/
export interface SdkStreamMixin {
transformToByteArray: () => Promise<Uint8Array>;
transformToString: (encoding?: string) => Promise<string>;
transformToWebStream: () => ReadableStream;
}

/**
* The type describing a runtime-specific stream implementation with mix-in
* utility functions.
*/
export type SdkStream<BaseStream> = BaseStream & SdkStreamMixin;

0 comments on commit f311cab

Please sign in to comment.