From aa2b0a217269a51d5939d3e9b44d56b5215b7858 Mon Sep 17 00:00:00 2001 From: Richard Piazza Date: Sat, 21 Mar 2026 14:11:52 -0500 Subject: [PATCH] Updated Dependencies; Addressed Some Deprecations --- Package.resolved | 26 ++-------- Package.swift | 28 ++++++----- Sources/TranslationCatalog/Catalog.swift | 18 +++---- Sources/TranslationCatalog/CatalogError.swift | 6 +-- Sources/TranslationCatalog/CatalogQuery.swift | 2 +- .../TranslationCatalog/CatalogUpdate.swift | 2 +- .../CoreDataCatalog.swift | 4 +- .../FilesystemContainer.swift | 18 +++---- .../ExpressionImporter.swift | 14 +++--- Sources/TranslationCatalogIO/FileFormat.swift | 2 + .../KeyHierarchy+Syntax.swift | 2 + .../TranslationCatalogIO/MarkdownTable.swift | 2 + .../Entities/ExpressionEntity.swift | 16 +++---- .../Entities/ProjectEntity.swift | 6 +-- .../Entities/ProjectExpressionEntity.swift | 4 +- .../Entities/TranslationEntity.swift | 16 +++---- .../SQLiteCatalog.swift | 18 +++---- .../SQLiteStatement+Expression.swift | 30 ++++++------ .../SQLiteStatement+Project.swift | 4 +- .../SQLiteStatement+ProjectExpression.swift | 4 +- .../SQLiteStatement+Translation.swift | 14 +++--- Sources/localizer/Catalog+Export.swift | 2 +- Sources/localizer/Catalog+Syntax.swift | 2 +- Sources/localizer/Catalog.swift | 4 +- Sources/localizer/Configuration.swift | 3 +- .../Extensions/FileFormat+localizer.swift | 1 + .../Extensions/Catalog+DeleteAssertions.swift | 20 ++++---- .../Extensions/Catalog+InsertAssertions.swift | 20 ++++---- .../Extensions/Catalog+UpdateAssertions.swift | 48 +++++++++---------- 29 files changed, 166 insertions(+), 170 deletions(-) diff --git a/Package.resolved b/Package.resolved index 3593e8e..c2b802b 100644 --- a/Package.resolved +++ b/Package.resolved @@ -9,15 +9,6 @@ "version" : "0.5.0" } }, - { - "identity" : "htmlstring", - "kind" : "remoteSourceControl", - "location" : "https://github.com/alexisakers/HTMLString.git", - "state" : { - "revision" : "04613a3b0f40a91e554b5174c0a10657f1a26357", - "version" : "6.0.1" - } - }, { "identity" : "localesupport", "kind" : "remoteSourceControl", @@ -32,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/stephencelis/SQLite.swift.git", "state" : { - "revision" : "392dd6058624d9f6c5b4c769d165ddd8c7293394", - "version" : "0.15.4" + "revision" : "964c300fb0736699ce945c9edb56ecd62eba27a3", + "version" : "0.16.0" } }, { @@ -50,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-argument-parser", "state" : { - "revision" : "011f0c765fb46d9cac61bca19be0527e99c98c8b", - "version" : "1.5.1" + "revision" : "626b5b7b2f45e1b0b1c6f4a309296d1d21d7311b", + "version" : "1.7.1" } }, { @@ -72,15 +63,6 @@ "version" : "509.1.1" } }, - { - "identity" : "swift-toolchain-sqlite", - "kind" : "remoteSourceControl", - "location" : "https://github.com/swiftlang/swift-toolchain-sqlite", - "state" : { - "revision" : "b626d3002773b1a1304166643e7f118f724b2132", - "version" : "1.0.4" - } - }, { "identity" : "xmlcoder", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index cd8cea5..3ae6ab0 100644 --- a/Package.swift +++ b/Package.swift @@ -12,9 +12,9 @@ let package = Package( .iOS(.v16), .tvOS(.v16), .watchOS(.v9), + .visionOS(.v1), ], products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "TranslationCatalog", targets: [ @@ -31,16 +31,13 @@ let package = Package( ), ], dependencies: [ - // Dependencies declare other packages that this package depends on. - // .package(url: /* package url */, from: "1.0.0"), .package(url: "https://github.com/richardpiazza/LocaleSupport.git", from: "0.8.1"), - .package(url: "https://github.com/richardpiazza/Statement.git", .upToNextMajor(from: "0.8.1")), - .package(url: "https://github.com/richardpiazza/CoreDataPlus.git", .upToNextMajor(from: "0.5.0")), - .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMajor(from: "1.5.1")), - .package(url: "https://github.com/apple/swift-syntax.git", .upToNextMajor(from: "509.0.0")), - .package(url: "https://github.com/CoreOffice/XMLCoder.git", .upToNextMajor(from: "0.17.1")), - .package(url: "https://github.com/alexisakers/HTMLString.git", .upToNextMajor(from: "6.0.0")), - .package(url: "https://github.com/stephencelis/SQLite.swift.git", .upToNextMajor(from: "0.15.4")), + .package(url: "https://github.com/richardpiazza/Statement.git", from: "0.8.1"), + .package(url: "https://github.com/richardpiazza/CoreDataPlus.git", from: "0.5.0"), + .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.7.1"), + .package(url: "https://github.com/apple/swift-syntax.git", from: "509.0.0"), + .package(url: "https://github.com/CoreOffice/XMLCoder.git", from: "0.17.1"), + .package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.16.0"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. @@ -65,7 +62,6 @@ let package = Package( dependencies: [ "TranslationCatalog", .product(name: "XMLCoder", package: "XMLCoder"), - .product(name: "HTMLString", package: "HTMLString"), .product(name: "SwiftSyntax", package: "swift-syntax"), .product(name: "SwiftSyntaxBuilder", package: "swift-syntax"), .product(name: "LocaleSupport", package: "LocaleSupport"), @@ -119,3 +115,13 @@ let package = Package( ], swiftLanguageVersions: [.v5] ) + +for target in package.targets { + var settings = target.swiftSettings ?? [] + settings.append(contentsOf: [ + .enableUpcomingFeature("ExistentialAny"), + .enableUpcomingFeature("MemberImportVisibility"), + .enableUpcomingFeature("StrictConcurrency=complete"), + ]) + target.swiftSettings = settings +} diff --git a/Sources/TranslationCatalog/Catalog.swift b/Sources/TranslationCatalog/Catalog.swift index 6f31f14..135a492 100644 --- a/Sources/TranslationCatalog/Catalog.swift +++ b/Sources/TranslationCatalog/Catalog.swift @@ -9,7 +9,7 @@ public protocol Catalog { /// Retrieve all `Project`s that match the provided query parameters /// /// - parameter query: Parameters that filter the results - func projects(matching query: CatalogQuery) throws -> [Project] + func projects(matching query: any CatalogQuery) throws -> [Project] /// Retrieve a single project for the provided identifier. /// /// - parameter id: The unique identifier for the `Project` @@ -17,7 +17,7 @@ public protocol Catalog { /// Retrieves the first `Project` matching the query /// /// - parameter query: Parameters that filter the results - func project(matching query: CatalogQuery) throws -> Project + func project(matching query: any CatalogQuery) throws -> Project /// Inserts a `Project` into the catalog. /// /// - parameter project: The entity to insert. @@ -27,7 +27,7 @@ public protocol Catalog { /// /// - parameter id: The unique identifier for the `Project` /// - parameter action: The update to perform on the entity matching the provided id. - func updateProject(_ id: Project.ID, action: CatalogUpdate) throws + func updateProject(_ id: Project.ID, action: any CatalogUpdate) throws /// Removes a `Project` from the catalog. /// /// This should remove the `Project` only. Any `Expression`s that were linked to the project should remain intact, as expressions @@ -39,15 +39,15 @@ public protocol Catalog { // MARK: - Expression func expressions() throws -> [Expression] - func expressions(matching query: CatalogQuery) throws -> [Expression] + func expressions(matching query: any CatalogQuery) throws -> [Expression] func expression(_ id: Expression.ID) throws -> Expression - func expression(matching query: CatalogQuery) throws -> Expression + func expression(matching query: any CatalogQuery) throws -> Expression /// Insert a `Expression` into the catalog. /// /// - parameter expression: The entity to insert. /// - returns The unique identifier created for the new entity. @discardableResult func createExpression(_ expression: Expression) throws -> Expression.ID - func updateExpression(_ id: Expression.ID, action: CatalogUpdate) throws + func updateExpression(_ id: Expression.ID, action: any CatalogUpdate) throws /// Remove a `Expression` from the catalog. /// /// When removed, the `Translation`s linked to the expression should be removed - as well as - any references that @@ -59,9 +59,9 @@ public protocol Catalog { // MARK: - Translation func translations() throws -> [Translation] - func translations(matching query: CatalogQuery) throws -> [Translation] + func translations(matching query: any CatalogQuery) throws -> [Translation] func translation(_ id: Translation.ID) throws -> Translation - func translation(matching query: CatalogQuery) throws -> Translation + func translation(matching query: any CatalogQuery) throws -> Translation /// Insert a `Translation` into the catalog. /// /// - parameter translation: The entity to insert. @@ -71,7 +71,7 @@ public protocol Catalog { /// /// - parameter id: The unique identifier for the `Translation`. /// - parameter action: The update to perform on the entity matching the provided id. - func updateTranslation(_ id: Translation.ID, action: CatalogUpdate) throws + func updateTranslation(_ id: Translation.ID, action: any CatalogUpdate) throws /// Remove a `Translation` from the catalog. /// /// - parameter id: The unique identifier for the `Translation`. diff --git a/Sources/TranslationCatalog/CatalogError.swift b/Sources/TranslationCatalog/CatalogError.swift index be3727d..05f7d38 100644 --- a/Sources/TranslationCatalog/CatalogError.swift +++ b/Sources/TranslationCatalog/CatalogError.swift @@ -1,5 +1,5 @@ public enum CatalogError: Error { - case badQuery(CatalogQuery) + case badQuery(any CatalogQuery) case dataTypeConversion(String? = nil) case expressionExistingWithId(Expression.ID, Expression) case expressionExistingWithKey(String, Expression) @@ -9,6 +9,6 @@ public enum CatalogError: Error { case translationExistingWithId(Translation.ID, Translation) case translationExistingWithValue(String, Translation) case translationId(Translation.ID) - case unhandledQuery(CatalogQuery) - case unhandledUpdate(CatalogUpdate) + case unhandledQuery(any CatalogQuery) + case unhandledUpdate(any CatalogUpdate) } diff --git a/Sources/TranslationCatalog/CatalogQuery.swift b/Sources/TranslationCatalog/CatalogQuery.swift index c834b03..bc427ed 100644 --- a/Sources/TranslationCatalog/CatalogQuery.swift +++ b/Sources/TranslationCatalog/CatalogQuery.swift @@ -1,7 +1,7 @@ import Foundation /// Associated parameters for performing query operations -public protocol CatalogQuery {} +public protocol CatalogQuery: Sendable {} public enum GenericProjectQuery: CatalogQuery { case id(Project.ID) diff --git a/Sources/TranslationCatalog/CatalogUpdate.swift b/Sources/TranslationCatalog/CatalogUpdate.swift index a5f92bd..8a9ebcd 100644 --- a/Sources/TranslationCatalog/CatalogUpdate.swift +++ b/Sources/TranslationCatalog/CatalogUpdate.swift @@ -1,7 +1,7 @@ import Foundation /// Associated parameters when performing update operations -public protocol CatalogUpdate {} +public protocol CatalogUpdate: Sendable {} public enum GenericProjectUpdate: CatalogUpdate { case name(String) diff --git a/Sources/TranslationCatalogCoreData/CoreDataCatalog.swift b/Sources/TranslationCatalogCoreData/CoreDataCatalog.swift index e873e98..357a8e6 100644 --- a/Sources/TranslationCatalogCoreData/CoreDataCatalog.swift +++ b/Sources/TranslationCatalogCoreData/CoreDataCatalog.swift @@ -1,8 +1,8 @@ #if canImport(CoreData) -import CoreData +@preconcurrency import CoreData import CoreDataPlus import Foundation -import TranslationCatalog +@preconcurrency import TranslationCatalog public class CoreDataCatalog: TranslationCatalog.Catalog { diff --git a/Sources/TranslationCatalogFilesystem/FilesystemContainer.swift b/Sources/TranslationCatalogFilesystem/FilesystemContainer.swift index d332168..b747afa 100644 --- a/Sources/TranslationCatalogFilesystem/FilesystemContainer.swift +++ b/Sources/TranslationCatalogFilesystem/FilesystemContainer.swift @@ -137,7 +137,7 @@ extension FilesystemContainer { } } - public func projects(matching query: CatalogQuery) throws -> [Project] { + public func projects(matching query: any CatalogQuery) throws -> [Project] { let documents: [ProjectDocument] switch query { @@ -158,7 +158,7 @@ extension FilesystemContainer { try project(matching: GenericProjectQuery.id(id)) } - public func project(matching query: CatalogQuery) throws -> Project { + public func project(matching query: any CatalogQuery) throws -> Project { let document: ProjectDocument switch query { @@ -212,7 +212,7 @@ extension FilesystemContainer { return id } - public func updateProject(_ id: Project.ID, action: CatalogUpdate) throws { + public func updateProject(_ id: Project.ID, action: any CatalogUpdate) throws { guard let index = projectDocuments.firstIndex(where: { $0.id == id }) else { throw CatalogError.projectId(id) } @@ -249,7 +249,7 @@ extension FilesystemContainer { } } - public func expressions(matching query: CatalogQuery) throws -> [TranslationCatalog.Expression] { + public func expressions(matching query: any CatalogQuery) throws -> [TranslationCatalog.Expression] { switch query { case GenericExpressionQuery.projectId(let projectId): return try project(projectId).expressions @@ -359,7 +359,7 @@ extension FilesystemContainer { try expression(matching: GenericExpressionQuery.id(id)) } - public func expression(matching query: CatalogQuery) throws -> TranslationCatalog.Expression { + public func expression(matching query: any CatalogQuery) throws -> TranslationCatalog.Expression { let document: ExpressionDocument switch query { @@ -423,7 +423,7 @@ extension FilesystemContainer { return id } - public func updateExpression(_ id: TranslationCatalog.Expression.ID, action: CatalogUpdate) throws { + public func updateExpression(_ id: TranslationCatalog.Expression.ID, action: any CatalogUpdate) throws { guard let index = expressionDocuments.firstIndex(where: { $0.id == id }) else { throw CatalogError.expressionId(id) } @@ -493,7 +493,7 @@ extension FilesystemContainer { } } - public func translations(matching query: CatalogQuery) throws -> [Translation] { + public func translations(matching query: any CatalogQuery) throws -> [Translation] { var documents: [TranslationDocument] switch query { @@ -532,7 +532,7 @@ extension FilesystemContainer { try translation(matching: GenericTranslationQuery.id(id)) } - public func translation(matching query: CatalogQuery) throws -> Translation { + public func translation(matching query: any CatalogQuery) throws -> Translation { switch query { case GenericTranslationQuery.id(let uuid): guard let document = translationDocuments.first(where: { $0.id == uuid }) else { @@ -589,7 +589,7 @@ extension FilesystemContainer { return id } - public func updateTranslation(_ id: Translation.ID, action: CatalogUpdate) throws { + public func updateTranslation(_ id: Translation.ID, action: any CatalogUpdate) throws { guard let index = translationDocuments.firstIndex(where: { $0.id == id }) else { throw CatalogError.translationId(id) } diff --git a/Sources/TranslationCatalogIO/ExpressionImporter.swift b/Sources/TranslationCatalogIO/ExpressionImporter.swift index b8551bf..4a92945 100644 --- a/Sources/TranslationCatalogIO/ExpressionImporter.swift +++ b/Sources/TranslationCatalogIO/ExpressionImporter.swift @@ -6,10 +6,10 @@ public class ExpressionImporter { public enum Operation: CustomStringConvertible { case createdExpression(TranslationCatalog.Expression) case skippedExpression(TranslationCatalog.Expression) - case failedExpression(TranslationCatalog.Expression, Error) + case failedExpression(TranslationCatalog.Expression, any Error) case createdTranslation(Translation) case skippedTranslation(Translation) - case failedTranslation(Translation, Error) + case failedTranslation(Translation, any Error) public var description: String { switch self { @@ -29,10 +29,10 @@ public class ExpressionImporter { } } - private let catalog: Catalog + private let catalog: any Catalog private let sequence = AsyncStream.makeStream(of: Operation.self) - public init(catalog: Catalog) { + public init(catalog: any Catalog) { self.catalog = catalog } @@ -55,7 +55,7 @@ public class ExpressionImporter { sequence.continuation.finish() } - private func importExpression(_ expression: TranslationCatalog.Expression, into catalog: Catalog) { + private func importExpression(_ expression: TranslationCatalog.Expression, into catalog: any Catalog) { do { try catalog.createExpression(expression) sequence.continuation.yield(.createdExpression(expression)) @@ -67,7 +67,7 @@ public class ExpressionImporter { } } - private func importTranslations(_ expression: TranslationCatalog.Expression, into catalog: Catalog) { + private func importTranslations(_ expression: TranslationCatalog.Expression, into catalog: any Catalog) { guard let id = try? catalog.expression(matching: GenericExpressionQuery.key(expression.key)).id else { return } @@ -82,7 +82,7 @@ public class ExpressionImporter { } } - private func importTranslation(_ translation: Translation, into catalog: Catalog) { + private func importTranslation(_ translation: Translation, into catalog: any Catalog) { do { try catalog.createTranslation(translation) sequence.continuation.yield(.createdTranslation(translation)) diff --git a/Sources/TranslationCatalogIO/FileFormat.swift b/Sources/TranslationCatalogIO/FileFormat.swift index a4cecbf..c911525 100644 --- a/Sources/TranslationCatalogIO/FileFormat.swift +++ b/Sources/TranslationCatalogIO/FileFormat.swift @@ -1,3 +1,5 @@ +import Foundation + /// Known/handled file types of expression/translation lists. public enum FileFormat: CaseIterable { /// Android-compatible XML format diff --git a/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift b/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift index f1c513a..278bfb8 100644 --- a/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift +++ b/Sources/TranslationCatalogIO/KeyHierarchy+Syntax.swift @@ -1,4 +1,6 @@ import Foundation +import LocaleSupport +import SwiftBasicFormat import SwiftSyntax import SwiftSyntaxBuilder import TranslationCatalog diff --git a/Sources/TranslationCatalogIO/MarkdownTable.swift b/Sources/TranslationCatalogIO/MarkdownTable.swift index 88c3df1..07d1b4e 100644 --- a/Sources/TranslationCatalogIO/MarkdownTable.swift +++ b/Sources/TranslationCatalogIO/MarkdownTable.swift @@ -1,3 +1,5 @@ +import Foundation + /// Creates a markdown formatted table when printed. public class MarkdownTable: CustomStringConvertible { diff --git a/Sources/TranslationCatalogSQLite/Entities/ExpressionEntity.swift b/Sources/TranslationCatalogSQLite/Entities/ExpressionEntity.swift index d743949..1aea08c 100644 --- a/Sources/TranslationCatalogSQLite/Entities/ExpressionEntity.swift +++ b/Sources/TranslationCatalogSQLite/Entities/ExpressionEntity.swift @@ -32,14 +32,14 @@ extension ExpressionEntity { extension ExpressionEntity { static let entity = ExpressionEntity() - static var id: Attribute { entity["id"]! } - static var uuid: Attribute { entity["uuid"]! } - static var key: Attribute { entity["key"]! } - static var name: Attribute { entity["name"]! } - static var defaultLanguage: Attribute { entity["default_language"]! } - static var defaultValue: Attribute { entity["default_value"]! } - static var context: Attribute { entity["context"]! } - static var feature: Attribute { entity["feature"]! } + static var id: any Attribute { entity["id"]! } + static var uuid: any Attribute { entity["uuid"]! } + static var key: any Attribute { entity["key"]! } + static var name: any Attribute { entity["name"]! } + static var defaultLanguage: any Attribute { entity["default_language"]! } + static var defaultValue: any Attribute { entity["default_value"]! } + static var context: any Attribute { entity["context"]! } + static var feature: any Attribute { entity["feature"]! } init(_ expression: TranslationCatalog.Expression) { uuid = expression.id.uuidString diff --git a/Sources/TranslationCatalogSQLite/Entities/ProjectEntity.swift b/Sources/TranslationCatalogSQLite/Entities/ProjectEntity.swift index 58cad15..f831e42 100644 --- a/Sources/TranslationCatalogSQLite/Entities/ProjectEntity.swift +++ b/Sources/TranslationCatalogSQLite/Entities/ProjectEntity.swift @@ -16,9 +16,9 @@ struct ProjectEntity: Entity, Identifiable { extension ProjectEntity { static let entity = ProjectEntity() - static var id: Attribute { entity["id"]! } - static var uuid: Attribute { entity["uuid"]! } - static var name: Attribute { entity["name"]! } + static var id: any Attribute { entity["id"]! } + static var uuid: any Attribute { entity["uuid"]! } + static var name: any Attribute { entity["name"]! } init(_ project: Project) { uuid = project.id.uuidString diff --git a/Sources/TranslationCatalogSQLite/Entities/ProjectExpressionEntity.swift b/Sources/TranslationCatalogSQLite/Entities/ProjectExpressionEntity.swift index effb6e5..de120f6 100644 --- a/Sources/TranslationCatalogSQLite/Entities/ProjectExpressionEntity.swift +++ b/Sources/TranslationCatalogSQLite/Entities/ProjectExpressionEntity.swift @@ -13,6 +13,6 @@ struct ProjectExpressionEntity: Entity { extension ProjectExpressionEntity { static let entity = ProjectExpressionEntity() - static var projectID: Attribute { entity["project_id"]! } - static var expressionID: Attribute { entity["expression_id"]! } + static var projectID: any Attribute { entity["project_id"]! } + static var expressionID: any Attribute { entity["expression_id"]! } } diff --git a/Sources/TranslationCatalogSQLite/Entities/TranslationEntity.swift b/Sources/TranslationCatalogSQLite/Entities/TranslationEntity.swift index 6c6cccf..2b1e82c 100644 --- a/Sources/TranslationCatalogSQLite/Entities/TranslationEntity.swift +++ b/Sources/TranslationCatalogSQLite/Entities/TranslationEntity.swift @@ -26,14 +26,14 @@ struct TranslationEntity: Entity { extension TranslationEntity { static let entity = TranslationEntity() - static var id: Attribute { entity["id"]! } - static var uuid: Attribute { entity["uuid"]! } - static var expressionID: Attribute { entity["expression_id"]! } - static var language: Attribute { entity["language_code"]! } - static var script: Attribute { entity["script_code"]! } - static var region: Attribute { entity["region_code"]! } - static var value: Attribute { entity["value"]! } - static var stateRawValue: Attribute { entity["state_raw_value"]! } + static var id: any Attribute { entity["id"]! } + static var uuid: any Attribute { entity["uuid"]! } + static var expressionID: any Attribute { entity["expression_id"]! } + static var language: any Attribute { entity["language_code"]! } + static var script: any Attribute { entity["script_code"]! } + static var region: any Attribute { entity["region_code"]! } + static var value: any Attribute { entity["value"]! } + static var stateRawValue: any Attribute { entity["state_raw_value"]! } init(_ translation: TranslationCatalog.Translation) { uuid = translation.id.uuidString diff --git a/Sources/TranslationCatalogSQLite/SQLiteCatalog.swift b/Sources/TranslationCatalogSQLite/SQLiteCatalog.swift index 5e09236..a17acfc 100644 --- a/Sources/TranslationCatalogSQLite/SQLiteCatalog.swift +++ b/Sources/TranslationCatalogSQLite/SQLiteCatalog.swift @@ -28,7 +28,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { return try db.projectEntities(statement: statement).map { try $0.project() } } - public func projects(matching query: CatalogQuery) throws -> [Project] { + public func projects(matching query: any CatalogQuery) throws -> [Project] { switch query { case ProjectQuery.hierarchy: var output: [Project] = [] @@ -64,7 +64,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { try project(matching: GenericProjectQuery.id(id)) } - public func project(matching query: CatalogQuery) throws -> Project { + public func project(matching query: any CatalogQuery) throws -> Project { switch query { case ProjectQuery.primaryKey(let id): guard let entity = try db.projectEntity(statement: renderStatement(.selectProject(withID: id))) else { @@ -112,7 +112,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { return id } - public func updateProject(_ id: Project.ID, action: CatalogUpdate) throws { + public func updateProject(_ id: Project.ID, action: any CatalogUpdate) throws { guard let entity = try db.projectEntity(statement: renderStatement(.selectProject(withID: id))) else { throw CatalogError.projectId(id) } @@ -154,7 +154,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { try db.expressionEntities(statement: renderStatement(.selectAllFromExpression)).map { try $0.expression() } } - public func expressions(matching query: CatalogQuery) throws -> [TranslationCatalog.Expression] { + public func expressions(matching query: any CatalogQuery) throws -> [TranslationCatalog.Expression] { switch query { case ExpressionQuery.hierarchy: var output: [TranslationCatalog.Expression] = [] @@ -210,7 +210,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { try expression(matching: GenericExpressionQuery.id(id)) } - public func expression(matching query: CatalogQuery) throws -> TranslationCatalog.Expression { + public func expression(matching query: any CatalogQuery) throws -> TranslationCatalog.Expression { switch query { case ExpressionQuery.primaryKey(let id): guard let entity = try db.expressionEntity(statement: renderStatement(.selectExpression(withID: id))) else { @@ -274,7 +274,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { return id } - public func updateExpression(_ id: TranslationCatalog.Expression.ID, action: CatalogUpdate) throws { + public func updateExpression(_ id: TranslationCatalog.Expression.ID, action: any CatalogUpdate) throws { guard let entity = try? db.expressionEntity(statement: renderStatement(.selectExpression(withID: id))) else { throw CatalogError.expressionId(id) } @@ -353,7 +353,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { return output } - public func translations(matching query: CatalogQuery) throws -> [TranslationCatalog.Translation] { + public func translations(matching query: any CatalogQuery) throws -> [TranslationCatalog.Translation] { switch query { case GenericTranslationQuery.expressionId(let expressionUUID): guard let expressionEntity = try db.expressionEntity(statement: renderStatement(.selectExpression(withID: expressionUUID))) else { @@ -385,7 +385,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { try translation(matching: GenericTranslationQuery.id(id)) } - public func translation(matching query: CatalogQuery) throws -> TranslationCatalog.Translation { + public func translation(matching query: any CatalogQuery) throws -> TranslationCatalog.Translation { let entity: TranslationEntity switch query { @@ -463,7 +463,7 @@ public class SQLiteCatalog: TranslationCatalog.Catalog { return id } - public func updateTranslation(_ id: TranslationCatalog.Translation.ID, action: CatalogUpdate) throws { + public func updateTranslation(_ id: TranslationCatalog.Translation.ID, action: any CatalogUpdate) throws { guard let entity = try? db.translationEntity(statement: renderStatement(.selectTranslation(withID: id))) else { throw CatalogError.translationId(id) } diff --git a/Sources/TranslationCatalogSQLite/SQLiteStatement+Expression.swift b/Sources/TranslationCatalogSQLite/SQLiteStatement+Expression.swift index a6cc68c..b821b7c 100644 --- a/Sources/TranslationCatalogSQLite/SQLiteStatement+Expression.swift +++ b/Sources/TranslationCatalogSQLite/SQLiteStatement+Expression.swift @@ -271,13 +271,13 @@ extension SQLiteStatement { .column(ExpressionEntity.feature) ), .VALUES( - .value(expression.uuid as DataTypeConvertible), - .value(expression.key as DataTypeConvertible), - .value(expression.name as DataTypeConvertible), - .value(expression.defaultLanguage as DataTypeConvertible), - .value(expression.defaultValue as DataTypeConvertible), - .value(expression.context as DataTypeConvertible), - .value(expression.feature as DataTypeConvertible) + .value(expression.uuid as any DataTypeConvertible), + .value(expression.key as any DataTypeConvertible), + .value(expression.name as any DataTypeConvertible), + .value(expression.defaultLanguage as any DataTypeConvertible), + .value(expression.defaultValue as any DataTypeConvertible), + .value(expression.context as any DataTypeConvertible), + .value(expression.feature as any DataTypeConvertible) ) ) } @@ -292,7 +292,7 @@ extension SQLiteStatement { .SET( .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.key), - .value(key as DataTypeConvertible), + .value(key as any DataTypeConvertible), ]) ), .WHERE( @@ -309,7 +309,7 @@ extension SQLiteStatement { .SET( .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.name), - .value(name as DataTypeConvertible), + .value(name as any DataTypeConvertible), ]) ), .WHERE( @@ -326,7 +326,7 @@ extension SQLiteStatement { .SET( .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.defaultLanguage), - .value(defaultLanguage.identifier as DataTypeConvertible), + .value(defaultLanguage.identifier as any DataTypeConvertible), ]) ), .WHERE( @@ -343,7 +343,7 @@ extension SQLiteStatement { .SET( .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.defaultValue), - .value(defaultValue as DataTypeConvertible), + .value(defaultValue as any DataTypeConvertible), ]) ), .WHERE( @@ -361,11 +361,11 @@ extension SQLiteStatement { .unwrap(context, transform: { value in .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.context), - .value(value as DataTypeConvertible), + .value(value as any DataTypeConvertible), ]) }, else: .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.context), - .value(context as DataTypeConvertible), + .value(context as any DataTypeConvertible), ]) ) ), @@ -386,13 +386,13 @@ extension SQLiteStatement { transform: { value in .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.feature), - .value(value as DataTypeConvertible), + .value(value as any DataTypeConvertible), ]) }, else: .comparison(op: .equal, segments: [ Segment.column(ExpressionEntity.feature), - .value(feature as DataTypeConvertible), + .value(feature as any DataTypeConvertible), ]) ) ), diff --git a/Sources/TranslationCatalogSQLite/SQLiteStatement+Project.swift b/Sources/TranslationCatalogSQLite/SQLiteStatement+Project.swift index 0d8e979..f1a35be 100644 --- a/Sources/TranslationCatalogSQLite/SQLiteStatement+Project.swift +++ b/Sources/TranslationCatalogSQLite/SQLiteStatement+Project.swift @@ -121,8 +121,8 @@ extension SQLiteStatement { .column(ProjectEntity.name) ), .VALUES( - .value(project.uuid as DataTypeConvertible), - .value(project.name as DataTypeConvertible) + .value(project.uuid as any DataTypeConvertible), + .value(project.name as any DataTypeConvertible) ) ) } diff --git a/Sources/TranslationCatalogSQLite/SQLiteStatement+ProjectExpression.swift b/Sources/TranslationCatalogSQLite/SQLiteStatement+ProjectExpression.swift index faa1698..6e71f4d 100644 --- a/Sources/TranslationCatalogSQLite/SQLiteStatement+ProjectExpression.swift +++ b/Sources/TranslationCatalogSQLite/SQLiteStatement+ProjectExpression.swift @@ -43,8 +43,8 @@ extension SQLiteStatement { .column(ProjectExpressionEntity.expressionID) ), .VALUES( - .value(projectID as DataTypeConvertible), - .value(expressionID as DataTypeConvertible) + .value(projectID as any DataTypeConvertible), + .value(expressionID as any DataTypeConvertible) ) ) } diff --git a/Sources/TranslationCatalogSQLite/SQLiteStatement+Translation.swift b/Sources/TranslationCatalogSQLite/SQLiteStatement+Translation.swift index 86fe87f..827dc3b 100644 --- a/Sources/TranslationCatalogSQLite/SQLiteStatement+Translation.swift +++ b/Sources/TranslationCatalogSQLite/SQLiteStatement+Translation.swift @@ -200,13 +200,13 @@ extension SQLiteStatement { .column(TranslationEntity.stateRawValue) ), .VALUES( - .value(translation.uuid as DataTypeConvertible), - .value(translation.expressionID as DataTypeConvertible), - .value(translation.language as DataTypeConvertible), - .value(translation.region as DataTypeConvertible), - .value(translation.value as DataTypeConvertible), - .value(translation.script as DataTypeConvertible), - .value(translation.stateRawValue as DataTypeConvertible) + .value(translation.uuid as any DataTypeConvertible), + .value(translation.expressionID as any DataTypeConvertible), + .value(translation.language as any DataTypeConvertible), + .value(translation.region as any DataTypeConvertible), + .value(translation.value as any DataTypeConvertible), + .value(translation.script as any DataTypeConvertible), + .value(translation.stateRawValue as any DataTypeConvertible) ) ) } diff --git a/Sources/localizer/Catalog+Export.swift b/Sources/localizer/Catalog+Export.swift index e61e702..e004058 100644 --- a/Sources/localizer/Catalog+Export.swift +++ b/Sources/localizer/Catalog+Export.swift @@ -62,7 +62,7 @@ extension Catalog { } func queryExpressions( - from catalog: TranslationCatalog.Catalog, + from catalog: any TranslationCatalog.Catalog, using storage: Storage, projectId: Project.ID? ) throws -> [TranslationCatalog.Expression] { diff --git a/Sources/localizer/Catalog+Syntax.swift b/Sources/localizer/Catalog+Syntax.swift index 8729f45..083979e 100644 --- a/Sources/localizer/Catalog+Syntax.swift +++ b/Sources/localizer/Catalog+Syntax.swift @@ -7,7 +7,7 @@ import TranslationCatalogIO extension Catalog { struct Syntax: CatalogCommand { - static var configuration: CommandConfiguration = CommandConfiguration( + static let configuration: CommandConfiguration = CommandConfiguration( commandName: "syntax", abstract: "Create a enumerated syntax tree.", discussion: """ diff --git a/Sources/localizer/Catalog.swift b/Sources/localizer/Catalog.swift index 61ced84..c2cac98 100644 --- a/Sources/localizer/Catalog.swift +++ b/Sources/localizer/Catalog.swift @@ -41,7 +41,7 @@ protocol CatalogCommand: AsyncParsableCommand { } extension CatalogCommand { - func catalog() throws -> TranslationCatalog.Catalog { + func catalog() throws -> any TranslationCatalog.Catalog { let url = switch storage { #if os(macOS) case .coreData: @@ -65,7 +65,7 @@ extension CatalogCommand { } } - let catalog: TranslationCatalog.Catalog + let catalog: any TranslationCatalog.Catalog switch storage { #if os(macOS) diff --git a/Sources/localizer/Configuration.swift b/Sources/localizer/Configuration.swift index 5e9e9ac..bc023ea 100644 --- a/Sources/localizer/Configuration.swift +++ b/Sources/localizer/Configuration.swift @@ -1,4 +1,5 @@ import Foundation +import TranslationCatalog struct Configuration: Codable { var defaultLanguageCode: Locale.LanguageCode @@ -11,7 +12,7 @@ struct Configuration: Codable { defaultStorage = .default } - init(from decoder: Decoder) throws { + init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) defaultLanguageCode = try container.decodeIfPresent(Locale.LanguageCode.self, forKey: .defaultLanguageCode) ?? .default defaultRegionCode = try container.decodeIfPresent(Locale.Region.self, forKey: .defaultRegionCode) ?? .default diff --git a/Sources/localizer/Extensions/FileFormat+localizer.swift b/Sources/localizer/Extensions/FileFormat+localizer.swift index de64a64..1695d06 100644 --- a/Sources/localizer/Extensions/FileFormat+localizer.swift +++ b/Sources/localizer/Extensions/FileFormat+localizer.swift @@ -1,4 +1,5 @@ import ArgumentParser +import Foundation import TranslationCatalogIO extension FileFormat: ExpressibleByArgument { diff --git a/Tests/TranslationCatalogTests/Extensions/Catalog+DeleteAssertions.swift b/Tests/TranslationCatalogTests/Extensions/Catalog+DeleteAssertions.swift index 501456a..38e465d 100644 --- a/Tests/TranslationCatalogTests/Extensions/Catalog+DeleteAssertions.swift +++ b/Tests/TranslationCatalogTests/Extensions/Catalog+DeleteAssertions.swift @@ -7,13 +7,13 @@ extension Catalog { let projectId = UUID(uuidString: "06937A10-2E46-4FFD-A2E7-60A3F03ED007")! let project = Project(id: projectId, name: "Example Project") - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createProject(project) let projects = try catalog.projects() XCTAssertEqual(projects.count, 1) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let projects = try catalog.projects() XCTAssertEqual(projects.count, 0) } @@ -33,13 +33,13 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 1) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 0) } @@ -68,14 +68,14 @@ extension Catalog { state: .translated ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) try catalog.createTranslation(translation) let translations = try catalog.translations() XCTAssertEqual(translations.count, 1) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let translations = try catalog.translations() XCTAssertEqual(translations.count, 0) } @@ -104,7 +104,7 @@ extension Catalog { state: .translated ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) try catalog.createTranslation(translation) let expressions = try catalog.expressions() @@ -113,7 +113,7 @@ extension Catalog { XCTAssertEqual(translations.count, 1) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 0) let translations = try catalog.translations() @@ -137,7 +137,7 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createProject(project) try catalog.createExpression(expression) try catalog.updateProject(projectId, action: GenericProjectUpdate.linkExpression(expressionId)) @@ -147,7 +147,7 @@ extension Catalog { XCTAssertEqual(expressions.count, 1) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let projects = try catalog.projects() XCTAssertEqual(projects.count, 0) let expressions = try catalog.expressions() diff --git a/Tests/TranslationCatalogTests/Extensions/Catalog+InsertAssertions.swift b/Tests/TranslationCatalogTests/Extensions/Catalog+InsertAssertions.swift index 054be27..f47adb4 100644 --- a/Tests/TranslationCatalogTests/Extensions/Catalog+InsertAssertions.swift +++ b/Tests/TranslationCatalogTests/Extensions/Catalog+InsertAssertions.swift @@ -7,12 +7,12 @@ extension Catalog { let projectId = UUID(uuidString: "64BBF2A8-0423-4545-B3E1-4A373F6359AF")! let project = Project(id: projectId, name: "Project 1") - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { let projects = try catalog.projects() XCTAssertEqual(projects.count, 0) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let projects = try catalog.projects() XCTAssertEqual(projects.count, 1) let entity = try XCTUnwrap(projects.first) @@ -37,12 +37,12 @@ extension Catalog { feature: "Settings" ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 0) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 1) let entity = try XCTUnwrap(expressions.first) @@ -81,13 +81,13 @@ extension Catalog { state: .translated ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) let translations = try catalog.translations() XCTAssertEqual(translations.count, 0) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let translations = try catalog.translations() XCTAssertEqual(translations.count, 1) let entity = try XCTUnwrap(translations.first) @@ -118,14 +118,14 @@ extension Catalog { let projectId = UUID(uuidString: "CB3900B9-C4A8-4953-9CF7-C737323954E9")! let project = Project(id: projectId, name: "", expressions: [expression]) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { let projects = try catalog.projects() XCTAssertEqual(projects.count, 0) let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 0) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 1) let projects = try catalog.projects() @@ -161,14 +161,14 @@ extension Catalog { translations: [translation] ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 0) let translations = try catalog.translations() XCTAssertEqual(translations.count, 0) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions() XCTAssertEqual(expressions.count, 1) let translations = try catalog.translations() diff --git a/Tests/TranslationCatalogTests/Extensions/Catalog+UpdateAssertions.swift b/Tests/TranslationCatalogTests/Extensions/Catalog+UpdateAssertions.swift index 376a73d..e209017 100644 --- a/Tests/TranslationCatalogTests/Extensions/Catalog+UpdateAssertions.swift +++ b/Tests/TranslationCatalogTests/Extensions/Catalog+UpdateAssertions.swift @@ -7,11 +7,11 @@ extension Catalog { let id = UUID(uuidString: "2CF3BCAD-18A6-4839-9A26-3A3D1348156C")! let project = Project(id: id, name: "Example 1") - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createProject(project) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.project(id) XCTAssertEqual(entity.name, "Example-2") } @@ -33,12 +33,12 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createProject(project) try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions(matching: GenericExpressionQuery.projectId(projectId)) XCTAssertEqual(expressions.count, 1) } @@ -60,11 +60,11 @@ extension Catalog { ) let project = Project(id: projectId, name: "Project", expressions: [expression]) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createProject(project) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let expressions = try catalog.expressions(matching: GenericExpressionQuery.projectId(projectId)) XCTAssertEqual(expressions.count, 0) } @@ -84,11 +84,11 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.expression(expressionId) XCTAssertEqual(entity.key, "KEY_ONE") } @@ -108,11 +108,11 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.expression(expressionId) XCTAssertEqual(entity.name, "Example") } @@ -132,11 +132,11 @@ extension Catalog { languageCode: .english ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.expression(expressionId) XCTAssertEqual(entity.defaultLanguageCode, .french) } @@ -173,13 +173,13 @@ extension Catalog { context: "Common" ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression1) try catalog.createExpression(expression2) try catalog.createExpression(expression3) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { var entity = try catalog.expression(id1) XCTAssertEqual(entity.context, "Common") entity = try catalog.expression(id2) @@ -222,13 +222,13 @@ extension Catalog { feature: "Common" ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression1) try catalog.createExpression(expression2) try catalog.createExpression(expression3) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { var entity = try catalog.expression(id1) XCTAssertEqual(entity.feature, "Common") entity = try catalog.expression(id2) @@ -265,11 +265,11 @@ extension Catalog { translations: [translation] ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.translation(translationId) XCTAssertEqual(entity.language, .french) } @@ -320,11 +320,11 @@ extension Catalog { translations: [t1, t2, t3] ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { var entity = try catalog.translation(id1) XCTAssertEqual(entity.script, .devanagari) entity = try catalog.translation(id2) @@ -378,11 +378,11 @@ extension Catalog { translations: [t1, t2, t3] ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { var entity = try catalog.translation(id1) XCTAssertEqual(entity.region, .australia) entity = try catalog.translation(id2) @@ -417,11 +417,11 @@ extension Catalog { translations: [translation] ) - func preConditions(catalog: Catalog) throws { + func preConditions(catalog: any Catalog) throws { try catalog.createExpression(expression) } - func postConditions(catalog: Catalog) throws { + func postConditions(catalog: any Catalog) throws { let entity = try catalog.translation(translationId) XCTAssertEqual(entity.value, "Updated") }