From 7d1bb97aca5750bbac59418e4f1ceea8c145dc01 Mon Sep 17 00:00:00 2001 From: Oleksii Zghurskyi Date: Mon, 27 Oct 2025 20:08:27 +0200 Subject: [PATCH 1/2] Hide package API --- Package.swift | 5 +--- Sources/DLCCommon/Extensions/SQLiteRow.swift | 2 +- .../DLCCommon/Structures/RowCodingKey.swift | 10 +++---- .../DLCDecoder/Classes/MultiRowDecoder.swift | 28 ++++++++--------- .../DLCDecoder/Classes/SingleRowDecoder.swift | 30 +++++++++---------- .../DLCDecoder/Protocols/DateDecoder.swift | 2 +- Sources/DLCDecoder/Protocols/Decoder.swift | 2 +- .../Protocols/KeyCheckingDecoder.swift | 2 +- Sources/DLCDecoder/Protocols/RowDecoder.swift | 2 +- .../DLCDecoder/Protocols/ValueDecoder.swift | 2 +- .../DLCEncoder/Classes/MultiRowEncoder.swift | 30 +++++++++---------- .../DLCEncoder/Classes/SingleRowEncoder.swift | 30 +++++++++---------- .../DLCEncoder/Protocols/DateEncoder.swift | 2 +- Sources/DLCEncoder/Protocols/Encoder.swift | 2 +- Sources/DLCEncoder/Protocols/RowEncoder.swift | 2 +- .../DLCEncoder/Protocols/ValueEncoder.swift | 2 +- .../DataLiteCoder/Classes/DateDecoder.swift | 1 + 17 files changed, 76 insertions(+), 78 deletions(-) diff --git a/Package.swift b/Package.swift index cc2a91a..91a73fb 100644 --- a/Package.swift +++ b/Package.swift @@ -13,10 +13,7 @@ let package = Package( .library(name: "DataLiteCoder", targets: ["DataLiteCoder"]) ], dependencies: [ - .package( - url: "https://github.com/angd-dev/data-lite-core.git", - revision: "2b3ba846b06f865616787edfdb47f503317a0dc0" - ), + .package(url: "https://github.com/angd-dev/data-lite-core.git", from: "1.0.0"), .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0") ], targets: [ diff --git a/Sources/DLCCommon/Extensions/SQLiteRow.swift b/Sources/DLCCommon/Extensions/SQLiteRow.swift index e301be4..0215e02 100644 --- a/Sources/DLCCommon/Extensions/SQLiteRow.swift +++ b/Sources/DLCCommon/Extensions/SQLiteRow.swift @@ -1,7 +1,7 @@ import Foundation import DataLiteCore -public extension SQLiteRow { +package extension SQLiteRow { func contains(_ key: CodingKey) -> Bool { if let index = key.intValue { 0.. Bool { + package func decodeNil(for key: any CodingKey) throws -> Bool { let info = "Attempted to decode nil, but it's not supported for an array of rows." let context = DecodingError.Context( codingPath: codingPath + [key], @@ -36,11 +36,11 @@ public final class MultiRowDecoder: RowDecoder { throw DecodingError.dataCorrupted(context) } - public func decodeDate(for key: any CodingKey) throws -> Date { + package func decodeDate(for key: any CodingKey) throws -> Date { return try decode(Date.self, for: key) } - public func decode( + package func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { @@ -52,7 +52,7 @@ public final class MultiRowDecoder: RowDecoder { throw DecodingError.typeMismatch(type, context) } - public func decoder(for key: any CodingKey) throws -> any Decoder { + package func decoder(for key: any CodingKey) throws -> any Decoder { guard let index = key.intValue else { let info = "Expected an integer key, but found a non-integer key." let context = DecodingError.Context( @@ -69,7 +69,7 @@ public final class MultiRowDecoder: RowDecoder { ) } - public func container( + package func container( keyedBy type: Key.Type ) throws -> KeyedDecodingContainer { let info = "Expected a keyed container, but found an array of rows." @@ -83,14 +83,14 @@ public final class MultiRowDecoder: RowDecoder { ) } - public func unkeyedContainer() throws -> any UnkeyedDecodingContainer { + package func unkeyedContainer() throws -> any UnkeyedDecodingContainer { UnkeyedContainer( decoder: self, codingPath: codingPath ) } - public func singleValueContainer() throws -> any SingleValueDecodingContainer { + package func singleValueContainer() throws -> any SingleValueDecodingContainer { let info = "Expected a single value container, but found an array of rows." let context = DecodingError.Context( codingPath: codingPath, diff --git a/Sources/DLCDecoder/Classes/SingleRowDecoder.swift b/Sources/DLCDecoder/Classes/SingleRowDecoder.swift index 0c42603..76080e4 100644 --- a/Sources/DLCDecoder/Classes/SingleRowDecoder.swift +++ b/Sources/DLCDecoder/Classes/SingleRowDecoder.swift @@ -3,19 +3,19 @@ import DataLiteCore private import DLCCommon -public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { +package final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { // MARK: - Properties - public let dateDecoder: any DateDecoder - public let sqliteData: SQLiteRow - public let codingPath: [any CodingKey] - public let userInfo: [CodingUserInfoKey: Any] + package let dateDecoder: any DateDecoder + package let sqliteData: SQLiteRow + package let codingPath: [any CodingKey] + package let userInfo: [CodingUserInfoKey: Any] - public var count: Int? { sqliteData.count } + package var count: Int? { sqliteData.count } // MARK: Inits - public init( + package init( dateDecoder: any DateDecoder, sqliteData: SQLiteRow, codingPath: [any CodingKey], @@ -29,11 +29,11 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { // MARK: - Methods - public func contains(_ key: any CodingKey) -> Bool { + package func contains(_ key: any CodingKey) -> Bool { sqliteData.contains(key) } - public func decodeNil(for key: any CodingKey) throws -> Bool { + package func decodeNil(for key: any CodingKey) throws -> Bool { guard sqliteData.contains(key) else { let info = "No value associated with key \(key)." let context = DecodingError.Context( @@ -45,11 +45,11 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { return sqliteData[key] == .null } - public func decodeDate(for key: any CodingKey) throws -> Date { + package func decodeDate(for key: any CodingKey) throws -> Date { try dateDecoder.decode(from: self, for: key) } - public func decode( + package func decode( _ type: T.Type, for key: any CodingKey ) throws -> T { @@ -83,7 +83,7 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { return result } - public func decoder(for key: any CodingKey) throws -> any Decoder { + package func decoder(for key: any CodingKey) throws -> any Decoder { guard let data = sqliteData[key] else { let info = "No value associated with key \(key)." let context = DecodingError.Context( @@ -100,7 +100,7 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { ) } - public func container( + package func container( keyedBy type: Key.Type ) throws -> KeyedDecodingContainer { let allKeys = sqliteData.compactMap { (column, _) in @@ -114,14 +114,14 @@ public final class SingleRowDecoder: RowDecoder, KeyCheckingDecoder { return KeyedDecodingContainer(container) } - public func unkeyedContainer() throws -> any UnkeyedDecodingContainer { + package func unkeyedContainer() throws -> any UnkeyedDecodingContainer { UnkeyedContainer( decoder: self, codingPath: codingPath ) } - public func singleValueContainer() throws -> any SingleValueDecodingContainer { + package func singleValueContainer() throws -> any SingleValueDecodingContainer { let info = "Expected a single value container, but found a row value." let context = DecodingError.Context( codingPath: codingPath, diff --git a/Sources/DLCDecoder/Protocols/DateDecoder.swift b/Sources/DLCDecoder/Protocols/DateDecoder.swift index 57820ba..5a35fa7 100644 --- a/Sources/DLCDecoder/Protocols/DateDecoder.swift +++ b/Sources/DLCDecoder/Protocols/DateDecoder.swift @@ -1,6 +1,6 @@ import Foundation -public protocol DateDecoder { +package protocol DateDecoder { func decode(from decoder: any ValueDecoder) throws -> Date func decode(from decoder: any RowDecoder, for key: any CodingKey) throws -> Date } diff --git a/Sources/DLCDecoder/Protocols/Decoder.swift b/Sources/DLCDecoder/Protocols/Decoder.swift index 1a6c772..4d90341 100644 --- a/Sources/DLCDecoder/Protocols/Decoder.swift +++ b/Sources/DLCDecoder/Protocols/Decoder.swift @@ -1,6 +1,6 @@ import Foundation -public protocol Decoder: Swift.Decoder { +package protocol Decoder: Swift.Decoder { associatedtype SQLiteData var dateDecoder: any DateDecoder { get } diff --git a/Sources/DLCDecoder/Protocols/KeyCheckingDecoder.swift b/Sources/DLCDecoder/Protocols/KeyCheckingDecoder.swift index aeb4ffd..b4da553 100644 --- a/Sources/DLCDecoder/Protocols/KeyCheckingDecoder.swift +++ b/Sources/DLCDecoder/Protocols/KeyCheckingDecoder.swift @@ -1,5 +1,5 @@ import Foundation -public protocol KeyCheckingDecoder: Decoder { +package protocol KeyCheckingDecoder: Decoder { func contains(_ key: CodingKey) -> Bool } diff --git a/Sources/DLCDecoder/Protocols/RowDecoder.swift b/Sources/DLCDecoder/Protocols/RowDecoder.swift index b0d77bf..7e6e6c1 100644 --- a/Sources/DLCDecoder/Protocols/RowDecoder.swift +++ b/Sources/DLCDecoder/Protocols/RowDecoder.swift @@ -1,7 +1,7 @@ import Foundation import DataLiteCore -public protocol RowDecoder: Decoder { +package protocol RowDecoder: Decoder { var count: Int? { get } func decodeNil(for key: CodingKey) throws -> Bool diff --git a/Sources/DLCDecoder/Protocols/ValueDecoder.swift b/Sources/DLCDecoder/Protocols/ValueDecoder.swift index 4591052..cdc107d 100644 --- a/Sources/DLCDecoder/Protocols/ValueDecoder.swift +++ b/Sources/DLCDecoder/Protocols/ValueDecoder.swift @@ -1,7 +1,7 @@ import Foundation import DataLiteCore -public protocol ValueDecoder: Decoder { +package protocol ValueDecoder: Decoder { func decodeNil() -> Bool func decodeDate() throws -> Date func decode(_ type: T.Type) throws -> T diff --git a/Sources/DLCEncoder/Classes/MultiRowEncoder.swift b/Sources/DLCEncoder/Classes/MultiRowEncoder.swift index a297872..19f7175 100644 --- a/Sources/DLCEncoder/Classes/MultiRowEncoder.swift +++ b/Sources/DLCEncoder/Classes/MultiRowEncoder.swift @@ -3,20 +3,20 @@ import DataLiteCore private import DLCCommon -public final class MultiRowEncoder: RowEncoder { +package final class MultiRowEncoder: RowEncoder { // MARK: - Properties - public let dateEncoder: any DateEncoder - public let codingPath: [any CodingKey] - public let userInfo: [CodingUserInfoKey : Any] + package let dateEncoder: any DateEncoder + package let codingPath: [any CodingKey] + package let userInfo: [CodingUserInfoKey : Any] - public private(set) var sqliteData = [SQLiteRow]() + package private(set) var sqliteData = [SQLiteRow]() - public var count: Int { sqliteData.count } + package var count: Int { sqliteData.count } // MARK: - Inits - public init( + package init( dateEncoder: any DateEncoder, codingPath: [any CodingKey], userInfo: [CodingUserInfoKey : Any] @@ -28,7 +28,7 @@ public final class MultiRowEncoder: RowEncoder { // MARK: - Methods - public func set(_ value: Any, for key: any CodingKey) throws { + package func set(_ value: Any, for key: any CodingKey) throws { guard let value = value as? SQLiteRow else { let info = "Expected value of type \(SQLiteRow.self)" let context = EncodingError.Context( @@ -40,7 +40,7 @@ public final class MultiRowEncoder: RowEncoder { sqliteData.append(value) } - public func encodeNil(for key: any CodingKey) throws { + package func encodeNil(for key: any CodingKey) throws { let value = Optional.none as Any let info = "Attempted to encode nil, but it's not supported." let context = EncodingError.Context( @@ -50,7 +50,7 @@ public final class MultiRowEncoder: RowEncoder { throw EncodingError.invalidValue(value, context) } - public func encodeDate(_ date: Date, for key: any CodingKey) throws { + package func encodeDate(_ date: Date, for key: any CodingKey) throws { let info = "Attempted to encode Date, but it's not supported." let context = EncodingError.Context( codingPath: codingPath + [key], @@ -59,7 +59,7 @@ public final class MultiRowEncoder: RowEncoder { throw EncodingError.invalidValue(date, context) } - public func encode(_ value: T, for key: any CodingKey) throws { + package func encode(_ value: T, for key: any CodingKey) throws { let info = "Attempted to encode \(T.self), but it's not supported." let context = EncodingError.Context( codingPath: codingPath + [key], @@ -68,7 +68,7 @@ public final class MultiRowEncoder: RowEncoder { throw EncodingError.invalidValue(value, context) } - public func encoder(for key: any CodingKey) throws -> any Encoder { + package func encoder(for key: any CodingKey) throws -> any Encoder { SingleRowEncoder( dateEncoder: dateEncoder, codingPath: codingPath + [key], @@ -76,7 +76,7 @@ public final class MultiRowEncoder: RowEncoder { ) } - public func container( + package func container( keyedBy type: Key.Type ) -> KeyedEncodingContainer { let container = FailedEncodingContainer( @@ -85,11 +85,11 @@ public final class MultiRowEncoder: RowEncoder { return KeyedEncodingContainer(container) } - public func unkeyedContainer() -> any UnkeyedEncodingContainer { + package func unkeyedContainer() -> any UnkeyedEncodingContainer { UnkeyedContainer(encoder: self, codingPath: codingPath) } - public func singleValueContainer() -> any SingleValueEncodingContainer { + package func singleValueContainer() -> any SingleValueEncodingContainer { FailedEncodingContainer(codingPath: codingPath) } } diff --git a/Sources/DLCEncoder/Classes/SingleRowEncoder.swift b/Sources/DLCEncoder/Classes/SingleRowEncoder.swift index aed6573..d013eb8 100644 --- a/Sources/DLCEncoder/Classes/SingleRowEncoder.swift +++ b/Sources/DLCEncoder/Classes/SingleRowEncoder.swift @@ -3,20 +3,20 @@ import DataLiteCore private import DLCCommon -public final class SingleRowEncoder: RowEncoder { +package final class SingleRowEncoder: RowEncoder { // MARK: - Properties - public let dateEncoder: any DateEncoder - public let codingPath: [any CodingKey] - public let userInfo: [CodingUserInfoKey : Any] + package let dateEncoder: any DateEncoder + package let codingPath: [any CodingKey] + package let userInfo: [CodingUserInfoKey : Any] - public private(set) var sqliteData = SQLiteRow() + package private(set) var sqliteData = SQLiteRow() - public var count: Int { sqliteData.count } + package var count: Int { sqliteData.count } // MARK: - Inits - public init( + package init( dateEncoder: any DateEncoder, codingPath: [any CodingKey], userInfo: [CodingUserInfoKey : Any], @@ -28,7 +28,7 @@ public final class SingleRowEncoder: RowEncoder { // MARK: - Methods - public func set(_ value: Any, for key: any CodingKey) throws { + package func set(_ value: Any, for key: any CodingKey) throws { guard let value = value as? SQLiteValue else { let info = "The value does not match \(SQLiteValue.self)" let context = EncodingError.Context( @@ -40,19 +40,19 @@ public final class SingleRowEncoder: RowEncoder { sqliteData[key] = value } - public func encodeNil(for key: any CodingKey) throws { + package func encodeNil(for key: any CodingKey) throws { sqliteData[key] = .null } - public func encodeDate(_ date: Date, for key: any CodingKey) throws { + package func encodeDate(_ date: Date, for key: any CodingKey) throws { try dateEncoder.encode(date, for: key, to: self) } - public func encode(_ value: T, for key: any CodingKey) throws { + package func encode(_ value: T, for key: any CodingKey) throws { sqliteData[key] = value.sqliteValue } - public func encoder(for key: any CodingKey) throws -> any Encoder { + package func encoder(for key: any CodingKey) throws -> any Encoder { SingleValueEncoder( dateEncoder: dateEncoder, codingPath: codingPath + [key], @@ -60,7 +60,7 @@ public final class SingleRowEncoder: RowEncoder { ) } - public func container( + package func container( keyedBy type: Key.Type ) -> KeyedEncodingContainer { let container = KeyedContainer( @@ -69,11 +69,11 @@ public final class SingleRowEncoder: RowEncoder { return KeyedEncodingContainer(container) } - public func unkeyedContainer() -> any UnkeyedEncodingContainer { + package func unkeyedContainer() -> any UnkeyedEncodingContainer { FailedEncodingContainer(codingPath: codingPath) } - public func singleValueContainer() -> any SingleValueEncodingContainer { + package func singleValueContainer() -> any SingleValueEncodingContainer { FailedEncodingContainer(codingPath: codingPath) } } diff --git a/Sources/DLCEncoder/Protocols/DateEncoder.swift b/Sources/DLCEncoder/Protocols/DateEncoder.swift index 95bed11..31139ad 100644 --- a/Sources/DLCEncoder/Protocols/DateEncoder.swift +++ b/Sources/DLCEncoder/Protocols/DateEncoder.swift @@ -1,6 +1,6 @@ import Foundation -public protocol DateEncoder { +package protocol DateEncoder { func encode(_ date: Date, to encoder: any ValueEncoder) throws func encode(_ date: Date, for key: any CodingKey, to encoder: any RowEncoder) throws } diff --git a/Sources/DLCEncoder/Protocols/Encoder.swift b/Sources/DLCEncoder/Protocols/Encoder.swift index db3963b..2ff3630 100644 --- a/Sources/DLCEncoder/Protocols/Encoder.swift +++ b/Sources/DLCEncoder/Protocols/Encoder.swift @@ -1,6 +1,6 @@ import Foundation -public protocol Encoder: Swift.Encoder { +package protocol Encoder: Swift.Encoder { associatedtype SQLiteData var dateEncoder: any DateEncoder { get } diff --git a/Sources/DLCEncoder/Protocols/RowEncoder.swift b/Sources/DLCEncoder/Protocols/RowEncoder.swift index 16bff49..34da7c0 100644 --- a/Sources/DLCEncoder/Protocols/RowEncoder.swift +++ b/Sources/DLCEncoder/Protocols/RowEncoder.swift @@ -1,7 +1,7 @@ import Foundation import DataLiteCore -public protocol RowEncoder: Encoder { +package protocol RowEncoder: Encoder { var count: Int { get } func set(_ value: Any, for key: CodingKey) throws diff --git a/Sources/DLCEncoder/Protocols/ValueEncoder.swift b/Sources/DLCEncoder/Protocols/ValueEncoder.swift index 73d8924..28fb892 100644 --- a/Sources/DLCEncoder/Protocols/ValueEncoder.swift +++ b/Sources/DLCEncoder/Protocols/ValueEncoder.swift @@ -1,7 +1,7 @@ import Foundation import DataLiteCore -public protocol ValueEncoder: Encoder { +package protocol ValueEncoder: Encoder { func encodeNil() throws func encodeDate(_ date: Date) throws func encode(_ value: T) throws diff --git a/Sources/DataLiteCoder/Classes/DateDecoder.swift b/Sources/DataLiteCoder/Classes/DateDecoder.swift index f090134..48fd5fc 100644 --- a/Sources/DataLiteCoder/Classes/DateDecoder.swift +++ b/Sources/DataLiteCoder/Classes/DateDecoder.swift @@ -1,4 +1,5 @@ import Foundation + internal import DLCDecoder extension RowDecoder { From 66a77d008a490dcfe81d817a8f396610598374ac Mon Sep 17 00:00:00 2001 From: Oleksii Zghurskyi Date: Mon, 27 Oct 2025 20:23:49 +0200 Subject: [PATCH 2/2] Update readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 14ae5e8..1ee0be7 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ It is designed to be used alongside DataLiteCore, which manages low-level intera To add DataLiteCoder to your project, use Swift Package Manager (SPM). -> **Important:** The API of `DataLiteCoder` is currently unstable and may change without notice. It is **strongly recommended** to pin the dependency to a specific commit to ensure compatibility and avoid unexpected breakage when the API evolves. - ### Adding to an Xcode Project 1. Open your project in Xcode. @@ -38,7 +36,7 @@ import PackageDescription let package = Package( name: "YourProject", dependencies: [ - .package(url: "https://github.com/angd-dev/data-lite-coder.git", branch: "develop") + .package(url: "https://github.com/angd-dev/data-lite-coder.git", from: "1.0.0") ], targets: [ .target( @@ -53,7 +51,7 @@ let package = Package( ## Additional Resources -For more information and usage examples, see the [documentation](https://docs.angd.dev/?package=data-lite-coder&version=develop). +For more information and usage examples, see the [documentation](https://docs.angd.dev/?package=data-lite-coder&version=1.0.0). ## License