AWS SDK for JavaScript STS Client for Node.js, Browser and React Native, providing temporary security credentials and role assumption capabilities
92
Evaluation — 92%
↑ 1.05xAgent success when using this tile
A TypeScript service that processes AWS event messages with union-type payloads. The service needs to handle events where the payload can be one of several different types, validate the structure, and route to appropriate handlers.
TextMessage payload type @testBinaryMessage payload type @testErrorMessage payload type @testTextMessage events to the text handler @testBinaryMessage events to the binary handler @testErrorMessage events to the error handler @test@generates
The implementation should use AWS SDK v3's approach to handling union shapes in API responses. When processing messages, validate that exactly one union member is present and handle type discrimination appropriately.
/**
* Represents a text message payload
*/
export interface TextMessage {
text: string;
timestamp: Date;
}
/**
* Represents a binary message payload
*/
export interface BinaryMessage {
data: Uint8Array;
encoding: string;
}
/**
* Represents an error message payload
*/
export interface ErrorMessage {
code: string;
message: string;
}
/**
* Union type representing all possible message payloads
*/
export type MessagePayload =
| { TextMessage: TextMessage }
| { BinaryMessage: BinaryMessage }
| { ErrorMessage: ErrorMessage };
/**
* Represents an AWS event message
*/
export interface EventMessage {
eventId: string;
payload: MessagePayload;
}
/**
* Result of processing a message
*/
export interface ProcessingResult {
eventId: string;
type: 'text' | 'binary' | 'error';
processed: boolean;
}
/**
* Processes an AWS event message with union-type payload.
* Validates that exactly one union member is present and routes to the appropriate handler.
*
* @param event - The event message to process
* @returns Processing result with event ID, detected type, and success status
* @throws Error if the payload is invalid or contains multiple/no union members
*/
export function processEventMessage(event: EventMessage): ProcessingResult;Provides AWS SDK for JavaScript v3 capabilities including protocol handling and union shape validation patterns.
Install with Tessl CLI
npx tessl i tessl/npm-aws-sdk--client-stsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10