v0.4.0
What's new
Cast enum
Replaces raw string literals in cast declarations with named constants — full IDE autocomplete and no risk of typos:
import { Cast } from '@wrsouza/orion';
// before
@casts({ isActive: 'boolean', bornAt: 'date', price: 'decimal:2' })
// now
@casts({ isActive: Cast.Boolean, bornAt: Cast.Date, price: Cast.Decimal(2) })Available values: Cast.Number, Cast.String, Cast.Boolean, Cast.Json, Cast.Date, Cast.Array, Cast.Hashed, Cast.Encrypted, Cast.EncryptedArray, Cast.EncryptedJson, Cast.ImmutableDate, Cast.ImmutableDatetime, Cast.JsonUnicode, Cast.AsStringable, Cast.Decimal(n).
@cast() — property decorator
Declare the cast directly on the field, alongside @map():
export class User extends Model {
@map('is_active')
@cast(Cast.Boolean)
declare isActive: boolean;
@map('born_at')
@cast(Cast.Date)
declare bornAt: Date;
@cast(MoneyCast) // custom cast class also accepted
declare balance: Money;
}Property-level declarations are merged on top of class-level @casts({}) — the property decorator wins on conflict.
@hidden() — property decorator
@hidden now works as a property decorator in addition to the existing class decorator form:
// class (unchanged)
@hidden(['password', 'remember_token'])
class User extends Model {}
// property (new)
class User extends Model {
@hidden()
declare password: string;
}