Skip to content

v2.0.0

Choose a tag to compare

@yuriizee yuriizee released this 10 Aug 09:33
· 2 commits to v2 since this release

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] infers sometimes instead of required/nullable for Optional fields.
  • Works through nested BaseData, #[DataCollection], and pairs naturally with #[WhenLoaded] (an unloaded relation is already an absent key).

📖 Optional — Absent vs Null

#[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() and PaginatedDataCollection.

📖 #[Hidden]

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).
  • ProvidesJsonSchema implemented by every built-in cast.
  • Best-effort #[Rules] / #[InferRules] → JSON Schema constraint mapping.
  • New CLI bin/sdo-typescript and artisan sdo:typescript commands generate .d.ts output alongside the existing sdo:warm discovery/config.

📖 Schema Generation


⚠️ Breaking changes (internal API only — no consumer-facing impact)

  • Support\TypeResolver::resolve() now returns a 3-tuple ([$nestedDataClass, $enumClass,$isOptional]) instead of 2. @internal, single call site (ClassMetaFactory).
  • Support\SerializerCompiler gained $contextualSerializers alongside $serializers. @internal, BaseData::toArray() already updated.

Full Changelog: v1.23.0...v2.0.0