CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-aws-sdk--client-sts

AWS SDK for JavaScript STS Client for Node.js, Browser and React Native, providing temporary security credentials and role assumption capabilities

92

1.05x

Evaluation92%

1.05x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-10/

AWS Event Message Processor

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.

Capabilities

Parse and validate event messages

  • It correctly parses event messages with TextMessage payload type @test
  • It correctly parses event messages with BinaryMessage payload type @test
  • It correctly parses event messages with ErrorMessage payload type @test
  • It throws an error when the event message contains an invalid union member @test

Route messages to appropriate handlers

  • It routes TextMessage events to the text handler @test
  • It routes BinaryMessage events to the binary handler @test
  • It routes ErrorMessage events to the error handler @test

Implementation

@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.

API

/**
 * 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;

Dependencies { .dependencies }

@aws-sdk/client-sts { .dependency }

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-sts

tile.json