Skip to content

v1.3.0

Compare
Choose a tag to compare
@Adedoyin-Emmanuel Adedoyin-Emmanuel released this 13 Feb 11:07
· 7 commits to main since this release

TsFluent v1.3.0 Release Notes ๐ŸŽ‰

Major Features ๐ŸŒŸ

Generic Context Support

  • Added TContext generic parameter to both Result and ResultAsync classes
  • Type-safe context handling in metadata and error objects
  • Improved type inference in chaining operations
  • Better IDE support with accurate type hints

Property-Based Access

  • Introduced direct property access for better developer experience:
    • result.errors instead of getErrors()
    • result.metadata instead of getMetadata()
    • Deprecated method-based access in favor of properties

Enhanced Error Handling

  • Improved error context preservation across transformations
  • Better retry information in AsyncUtils error context
  • Rich metadata support with timestamps and custom contexts

API Improvements

  • Enhanced ResultAsync.from() for better Promise handling
  • Improved AsyncUtils.tryAsync() with configurable retries and timeouts
  • Added comprehensive type safety across all operations

Breaking Changes โš ๏ธ

Deprecated Methods

  • getErrors() โ†’ use errors property instead
  • getMetadata() โ†’ use metadata property instead

Type Changes

  • ResultAsync.from<T>() now only accepts one generic type parameter
  • AsyncUtils.tryAsync<T>() simplified to one generic type parameter
  • Context types must extend Record<string, unknown>

New Features in Detail ๐Ÿ“

Result Class

// New context support
interface UserContext {
  userId: string;
  environment: "dev" | "prod";
}

const result = Result.ok<number, UserContext>(42)
  .withMetadata({
    context: {
      userId: "123",
      environment: "prod"
    }
  });

ResultAsync Class

// Improved Promise handling
const result = await ResultAsync.from<Response>(
  fetch("https://api.example.com/data")
);

// Type-safe metadata
result.withMetadata({
  context: {
    requestId: "123",
    endpoint: "/data"
  }
});

AsyncUtils

// Enhanced retry configuration
const result = await AsyncUtils.tryAsync(
  async () => {
    // async operation
  },
  3,    // maxAttempts
  1000, // delayMs
  2000  // timeoutMs
);

Bug Fixes ๐Ÿ›

  • Fixed type compatibility issues between Result and ResultAsync
  • Corrected metadata propagation in transformation methods
  • Resolved context type preservation in chaining operations
  • Fixed error context handling in retry operations

Performance Improvements โšก

  • Optimized error handling chain
  • Improved type inference performance
  • Better memory usage in retry operations

Documentation Updates ๐Ÿ“š

  • Added comprehensive examples for all new features
  • Updated API reference with accurate type information
  • Improved code samples with real-world use cases
  • Added detailed error handling scenarios

Migration Guide ๐Ÿ”„

Updating from v1.1.x

  1. Replace method calls with property access:

    // Old
    result.getErrors();
    result.getMetadata();
    
    // New
    result.errors;
    result.metadata;
  2. Update generic type parameters:

    // Old
    ResultAsync.from<T, Context>();
    
    // New
    ResultAsync.from<T>();
  3. Review context types:

    // Ensure context types extend Record<string, unknown>
    interface YourContext extends Record<string, unknown> {
      // your context properties
    }

Contributors ๐Ÿ‘ฅ

Special thanks to all contributors who helped make this release possible!

What's Next? ๐Ÿ”ฎ

We're planning several exciting features for upcoming releases:

  • Enhanced error categorization
  • More utility functions for common patterns
  • Additional convenience methods for error handling
  • Performance optimizations

Feedback and Support ๐Ÿ’ฌ

We welcome your feedback and contributions! Please:

License ๐Ÿ“„

TsFluent is released under the MIT License. See the LICENSE file for details.