Skip to content

2.0.0

Compare
Choose a tag to compare
@makoni makoni released this 31 Mar 17:35
· 6 commits to master since this release
be3176b

Version 2.0.0

This release significantly enhances the codebase by introducing support for Swift 6.0, adopting Swift Concurrency, updating dependencies, and improving overall code quality and documentation.

Major Updates

  • Swift Tool Version Update: Updated the minimum required Swift tools version to 6.0.
    - // swift-tools-version:5.8
    + // swift-tools-version:6.0

Documentation Updates

  • README:
    • Enhanced documentation for concurrency and compatibility with both Swift and Vapor versions.
    • Improved initialization examples and added instructions for avoiding hardcoded passwords.
    • Revised usage examples to reflect new API changes.

Codebase Enhancements

  • CouchDBClient: Updated to be an actor.
  • Client Initialization: Introduced a new configuration struct CouchDBClient.Config for cleaner initialization.
    let config = CouchDBClient.Config(
        couchProtocol: .http,
        couchHost: "127.0.0.1",
        couchPort: 5984,
        userName: "admin",
        userPassword: "yourPassword"
    )
    let couchDBClient = CouchDBClient(config: config)

Models and Protocol Updates

  • CouchDBRepresentable:
    • Changed _id to a non-optional property and added methods for updating document revisions.
    • Conformance to Sendable for thread safety.
    public protocol CouchDBRepresentable: Codable, Sendable {
        var _id: String { get }
        var _rev: String? { get }
        func updateRevision(_ newRevision: String) -> Self
    }
  • Error Handling:
    • Enhanced error models to conform to Sendable and added detailed documentation.
    public struct CouchDBError: Error, Codable, Sendable {
        public let error: String
        public let reason: String
    }
  • Responses:
    • Updated response models to conform to Sendable and added detailed documentation for properties.
    public struct CouchDBFindResponse<T: CouchDBRepresentable>: Codable, Sendable {
        let docs: [T]
        let bookmark: String?
    }

Test Updates

  • Unit Tests:
    • Updated tests to align with the new client initialization and document handling methods.
    struct ExpectedDoc: CouchDBRepresentable {
        var name: String
        var _id: String = NSUUID().uuidString
        var _rev: String?
        func updateRevision(_ newRevision: String) -> Self {
            return ExpectedDoc(name: name, _id: _id, _rev: newRevision)
        }
    }

Miscellaneous

  • Code Cleanup:
    • Removed unused imports and redundant code.
    • Improved code formatting and added missing documentation.