v1.0.0-alpha.6
This release introduces powerful type-safe selection capabilities to the ORM and significantly improves the CLI’s schema parsing robustness.
✨ Features
Section titled “✨ Features”Type-Safe Select (UnrealORM)
Section titled “Type-Safe Select (UnrealORM)”The ORM now supports full type inference for specific field selections, including nested objects and computed fields.
import { typed } from 'unreal-orm';import { surql } from 'surrealdb';
// 1. Nested object selection with type inferenceconst posts = await Post.select({ select: { title: true, author: { name: true, email: true }, // Auto-expands record links metadata: { category: true } // Deep object selection }});// Result type: { title: string; author: { name: string; email: string }; metadata: { category: string } }[]
// 2. Computed fields with typed<T>() helperconst stats = await Post.select({ select: { title: true, commentCount: typed<number>(surql`count(<-comment)`) }});// Result type: { title: string; commentCount: number }[]
// 3. Type-safe OMITconst users = await User.select({ omit: { password: true, secret: true }});// Result type: Omit<User, 'password' | 'secret'>[]
// 4. SELECT VALUEconst names = await User.select({ value: 'name'});// Result type: string[]Improved Schema Parsing (UnrealCLI)
Section titled “Improved Schema Parsing (UnrealCLI)”The CLI’s schema parser has been enhanced to better handle real-world schemas and edge cases:
- READONLY Support: Correctly extracts
READONLYattributes from field definitions. - Robust Error Handling: Added try-catch blocks with user-friendly warnings instead of crashing on parse errors.
- Unsupported Feature Reporting: Explicitly warns about unsupported features like events, functions, and params instead of silently ignoring them.
- Mermaid Improvements: Warnings are now displayed in the
mermaidcommand output when parsing.surqlfiles. - Configuration Fix: The
-yflag now correctly defaults to using the config file unless explicit DB credentials are provided. - Cleanup: Removed the
/* Schema not inferred */comment from emptyField.object({})definitions.
📦 Package Updates
Section titled “📦 Package Updates”| Package | Version |
|---|---|
unreal-orm | 1.0.0-alpha.5 → 1.0.0-alpha.6 |
@unreal-orm/cli | 1.0.0-alpha.5 → 1.0.0-alpha.6 |