Repository navigation
Releases
Releases · kylehughes/swift-versioned-models
v1.0.0
Initial release of VersionedModels, a zero-dependency Swift 6 library for migrating models across schema versions in memory and decoding older persisted Codable payloads forward to your current model type.
Highlights
- Format-agnostic migration core:
ModelVersionandVersionablelink each model type to its immediate predecessor at compile time with single-pass forward migration (migrate(from:),migrated(to:),canMigrate(from:),canMigrate(fromVersion:),canMigrate(to:)) and noCodablerequirement. - Additive
Codablepersistence and pluggable wire shapes:DecodableVersionable,CodableVersionable,VersionedPayload, andVersionedPayloadFormatvalidate the stored rawUIntversion before reading the model payload. Ships with built-inVersionedEnvelope({"version": 1, "model": {...}}),FlattenedVersionedPayload, andUnkeyedVersionedPayload, plusKeyedVersionedPayloadFormat,FlattenedVersionedPayloadFormat,VersionedModelDecoder, andKeyedDecodingContainer/KeyedEncodingContainerversioned helpers. - Chain validation and clear errors:
validateMigrationChain(scope:)(.allVersions,.upToCurrentVersion,.from(_:),.range(from:through:),.excluding(_:)) andreachableVersions()throw typedVersionMigrationError<Version>, andvalidateVersion(rawValue:)throws typedVersionedPayloadDecodingError. - Platform support: Pure Swift standard library (no
Foundationor external dependencies) targeting Swift 6.4+ on iOS 16.0+, macOS 13.0+, tvOS 16.0+, visionOS 1.0+, and watchOS 9.0+.