/** * Test Data Builders * * Provides factory functions for creating test data used across * integration tests. This eliminates repetitive data creation and * ensures consistent test fixtures. * * Usage: * import { * createTestItem, * createTestItems, * createBatchWriteRequest * } from './utilities/test-data-builders' * * const item = createTestItem({ pk: 'user-1', sk: 'profile' }) * const items = createTestItems(100) */ import type { AttributeValue } from '@aws-sdk/client-dynamodb'; /** * Basic DynamoDB item structure */ export interface TestItem { pk: string; sk: string; [key: string]: unknown; } /** * Options for creating test items */ export interface CreateTestItemOptions { pk?: string; sk?: string; data?: Record; withTimestamp?: boolean; withVersion?: number; } /** * Creates a single test item */ export declare function createTestItem(options?: CreateTestItemOptions): TestItem; /** * Creates multiple test items with sequential IDs */ export declare function createTestItems(count: number, options?: { pkPrefix?: string; skPrefix?: string; dataGenerator?: (index: number) => Record; withTimestamp?: boolean; withVersion?: boolean; }): TestItem[]; /** * Creates a marshalled DynamoDB item */ export declare function createMarshalledItem(options?: CreateTestItemOptions): Record; /** * Creates multiple marshalled DynamoDB items */ export declare function createMarshalledItems(count: number, options?: Parameters[1]): Record[]; /** * Creates a DynamoDB key object */ export declare function createKey(pk: string, sk: string): Record; /** * Creates multiple DynamoDB keys */ export declare function createKeys(items: Array<{ pk: string; sk: string; }>): Record[]; /** * DynamoDB batch size limit */ export declare const DYNAMODB_BATCH_SIZE = 25; /** * Creates a BatchWriteItem request structure for DynamoDB */ export declare function createBatchWriteRequest(tableName: string, items: TestItem[]): { RequestItems: { [tableName: string]: Array<{ PutRequest: { Item: Record; }; }>; }; }; /** * Creates a BatchGetItem request structure for DynamoDB */ export declare function createBatchGetRequest(tableName: string, keys: Array<{ pk: string; sk: string; }>): { RequestItems: { [tableName: string]: { Keys: Record[]; }; }; }; /** * Splits items into batches of the specified size */ export declare function splitIntoBatches(items: T[], batchSize?: number): T[][]; /** * Creates test content for S3 objects */ export declare function createS3Content(options?: { type?: 'text' | 'json' | 'binary'; size?: number; data?: unknown; }): Buffer; /** * Creates S3 object metadata */ export declare function createS3Metadata(options?: { contentType?: string; customMetadata?: Record; }): { ContentType: string; Metadata?: Record; }; /** * Creates an SQS message body */ export declare function createSQSMessageBody>(data: T): string; /** * Creates multiple SQS message entries for batch operations */ export declare function createSQSBatchEntries(messages: Array<{ id: string; body: unknown; delaySeconds?: number; messageAttributes?: Record; }>): Array<{ Id: string; MessageBody: string; DelaySeconds?: number; MessageAttributes?: Record; }>; /** * Creates an SNS message for publishing */ export declare function createSNSMessage(options: { subject?: string; message: unknown; messageAttributes?: Record; }): { Subject?: string; Message: string; MessageAttributes?: Record; }; /** * Creates Step Functions execution input */ export declare function createSFNInput>(data: T): string; /** * Creates a Step Functions execution name */ export declare function createSFNExecutionName(prefix?: string): string; /** * Creates a random string of specified length */ export declare function createRandomString(length: number): string; /** * Creates test data with nested structures */ export declare function createNestedTestData(depth: number, breadth?: number): Record; /** * Creates test data with various JavaScript types */ export declare function createMixedTypeTestData(): Record; /** * Creates large test data for performance/memory tests */ export declare function createLargeTestData(options?: { itemCount?: number; stringLength?: number; includeNested?: boolean; }): Record; /** * Unmarshalls a DynamoDB item to a plain JavaScript object */ export declare function unmarshallItem>(item: Record): T; /** * Unmarshalls multiple DynamoDB items */ export declare function unmarshallItems>(items: Record[]): T[]; /** * Re-export for convenience */ export { marshall, unmarshall } from '@aws-sdk/util-dynamodb';