v2.0.0
Release v2.0.0 — 2026-08-10
🚀 Highlights
Optional — a sentinel distinguishing "key absent" from an explicit null, for PATCH-style partial updates.
public readonly string|Optional $name;- A missing key resolves to
Optional::missing()— never a default, null, or a thrown error. - Nullable-optional (
string|Optional|null) still lets a present null clear the field. toArray()/toJson()/only()/except()/diff()/equals()omit a missing field unconditionally —from($dto->toArray())stays roundtrip-safe.definedOnly()for PATCH call sites:$model->update($data->definedOnly()).#[InferRules]inferssometimesinstead ofrequired/nullableforOptionalfields.- Works through nested
BaseData,#[DataCollection], and pairs naturally with#[WhenLoaded](an unloaded relation is already an absent key).
#[Hidden(except: [...])] — serialization groups/context. Hide a field by default and reveal it only in specific output contexts.
$dto->toArray(context: 'admin');- Each context compiles its own specialized serializer, cached separately — zero runtime branching.
- Propagates into nested
BaseData,#[DataCollection], and#[Flatten]fields. - Supported by
HasLaravelIntegration::toResponse()andPaginatedDataCollection.
jsonSchema() + TypeScript generation — describe a class's shape (JSON Schema draft 2020-12, or .d.ts) straight from the compiled metadata, no extra reflection.
OrderData::jsonSchema(): array— scalars, nullable, enums, nested$ref/$defs,#[DataCollection],#[Flatten],#[Hidden],Optional,#[Discriminator](oneOf).ProvidesJsonSchemaimplemented by every built-in cast.- Best-effort
#[Rules]/#[InferRules]→ JSON Schema constraint mapping. - New CLI
bin/sdo-typescriptand artisansdo:typescriptcommands generate.d.tsoutput alongside the existingsdo:warmdiscovery/config.
Support\TypeResolver::resolve()now returns a 3-tuple ([$nestedDataClass, $enumClass,$isOptional]) instead of 2.@internal, single call site (ClassMetaFactory).Support\SerializerCompilergained$contextualSerializersalongside$serializers.@internal,BaseData::toArray()already updated.
Full Changelog: v1.23.0...v2.0.0