From 46df6c195ec969f2191942bcdf484e431b6666fc Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 12 Nov 2026 14:49:50 +0700 Subject: [PATCH 1/3] perf(macos): ship smaller binaries: no exports, one lease chain, no duplicate helpers or unused clients --- .claude/rules/plugin-system.md | 2 +- apple/Configs/NoExportedSymbols.exp | 2 + apple/Packages/TableProCore/Package.swift | 39 +++- .../Config/FirebaseConnectionSettings.swift | 1 + .../Firestore/FirestoreCellCodec.swift | 1 + .../Firestore/FirestoreClient.swift | 1 + .../Firestore/FirestoreDocument.swift | 1 + .../Firestore/FirestoreDocumentJSON.swift | 1 + .../Firestore/FirestoreQuery.swift | 73 +------- .../Firestore/FirestoreValue.swift | 1 + .../RealtimeDatabaseClient.swift | 1 + .../RealtimeDatabaseQuery.swift | 1 + .../RealtimeDatabaseRows.swift | 33 +--- .../Wire/FirebaseTransport.swift | 1 + .../RealtimeDatabasePath.swift | 33 ++++ .../Wire/FirebaseBrowseSpec.swift | 73 ++++++++ .../Wire/FirebaseJSON.swift | 2 +- .../Wire/FirebaseStatement.swift | 6 +- .../TableProProcess}/DescriptorRead.swift | 2 + .../TableProProcess}/DescriptorWrite.swift | 2 + .../QdrantConnectionSettings.swift | 1 + .../QdrantFilterBuilder.swift | 15 +- .../QdrantPoint.swift | 1 + .../QdrantRowWrites.swift | 23 +-- .../QdrantSchema.swift | 1 + .../TableProQdrantClient/QdrantSortPlan.swift | 27 +++ .../QdrantValue.swift | 1 + .../Wire/QdrantClient.swift | 1 + .../Wire/QdrantScrollPager.swift | 0 .../Wire/QdrantSortedPager.swift | 1 + .../Wire/QdrantTransport.swift | 2 - .../TableProQdrantCore/QdrantBrowse.swift | 25 --- .../TableProQdrantCore/QdrantFilterSpec.swift | 15 ++ .../QdrantInsertCheck.swift | 21 +++ .../WeaviateAuth.swift | 1 + .../WeaviateFilterBuilder.swift | 46 +---- .../WeaviateGraphQL+Query.swift | 73 ++++++++ .../WeaviateObjectCodec.swift | 1 + .../WeaviateOperations.swift | 2 +- .../WeaviatePathEncoding.swift | 0 .../WeaviateStatementGenerator.swift | 174 ++++++++++++++++++ .../Wire/WeaviateClient.swift | 1 + .../Wire/WeaviateObjectPages.swift | 1 + .../Wire/WeaviateTransport.swift | 1 + .../WeaviateGraphQL.swift | 69 ------- .../TableProWeaviateCore/WeaviateQuery.swift | 172 ----------------- .../WeaviateValueKind.swift | 46 +++++ .../FirebaseConnectionSettingsTests.swift | 1 + .../FirebaseStatementTests.swift | 1 + .../DescriptorReadTests.swift | 4 +- .../DescriptorWriteTests.swift | 4 +- .../QdrantClientTests.swift | 1 + .../QdrantConsoleTests.swift | 1 + .../QdrantFilterBuilderTests.swift | 1 + .../QdrantRowWriteTests.swift | 1 + .../QdrantSchemaTests.swift | 1 + .../QdrantTestSupport.swift | 1 + .../WeaviateTunneledTrustTests.swift | 2 +- apple/Packages/TableProEditor/Package.swift | 7 +- apple/Packages/TableProMacCore/Package.swift | 4 +- .../openapi-generator-config.yaml | 10 + .../CLILiveEnvironment.swift | 1 - .../TableProMCP/Bridge/BridgeProxy.swift | 2 +- .../Identity/MCPClientIdentity.swift | 3 +- .../Transport/MCPBridgeLogger.swift | 2 +- .../Transport/BridgeStdoutTests.swift | 2 +- .../MCPStderrBridgeLoggerTests.swift | 2 +- .../FirebaseCredentialFactory.swift | 1 + .../FirebaseDriverPlugin/FirebasePlugin.swift | 1 + .../FirebasePluginDriver+Editing.swift | 1 + .../FirebasePluginDriver+Execution.swift | 1 + .../FirebasePluginDriver+Metadata.swift | 1 + .../FirebasePluginDriver.swift | 1 + .../QdrantDriverPlugin/QdrantPlugin.swift | 1 + .../QdrantPluginDriver+Execution.swift | 1 + .../QdrantPluginDriver+Metadata.swift | 1 + .../QdrantPluginDriver.swift | 1 + .../QdrantURLSessionTransport.swift | 1 + .../WeaviateDriverPlugin/WeaviatePlugin.swift | 1 + .../WeaviatePluginDriver+Execution.swift | 1 + .../WeaviatePluginDriver+Metadata.swift | 1 + .../WeaviatePluginDriver.swift | 1 + .../cockroachdb-icon.imageset/cockroachdb.svg | 2 +- .../snowflake-icon.imageset/snowflake.svg | 2 +- .../starrocks-icon.imageset/starrocks.svg | 2 +- apple/TablePro/CLI/BridgeMain.swift | 2 +- .../Core/Database/CLIToolVersionProbe.swift | 1 - .../DatabaseManager+ScopedDriver.swift | 72 +++++++- apple/TablePro/Core/Process/PipeReader.swift | 2 +- .../ConnectionScriptRunner.swift | 1 - .../Core/Process/PipeReaderTests.swift | 2 +- .../ProcessNativeDumpRunnerTests.swift | 2 +- apple/project.yml | 15 +- apple/scripts/probes/check-qdrant.sh | 11 +- apple/scripts/probes/qdrant-probe.swift | 3 +- 95 files changed, 678 insertions(+), 502 deletions(-) create mode 100644 apple/Configs/NoExportedSymbols.exp rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Config/FirebaseConnectionSettings.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreCellCodec.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreClient.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreDocument.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreDocumentJSON.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreQuery.swift (84%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Firestore/FirestoreValue.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/RealtimeDatabase/RealtimeDatabaseClient.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/RealtimeDatabase/RealtimeDatabaseQuery.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/RealtimeDatabase/RealtimeDatabaseRows.swift (77%) rename apple/Packages/TableProCore/Sources/{TableProFirebaseCore => TableProFirebaseClient}/Wire/FirebaseTransport.swift (98%) create mode 100644 apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabasePath.swift create mode 100644 apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseBrowseSpec.swift rename apple/Packages/{TableProMacCore/Sources/TableProUtilities/Process => TableProCore/Sources/TableProProcess}/DescriptorRead.swift (98%) rename apple/Packages/{TableProMacCore/Sources/TableProUtilities/Process => TableProCore/Sources/TableProProcess}/DescriptorWrite.swift (97%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantConnectionSettings.swift (98%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantFilterBuilder.swift (96%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantPoint.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantRowWrites.swift (89%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantSchema.swift (99%) create mode 100644 apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSortPlan.swift rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/QdrantValue.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/Wire/QdrantClient.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/Wire/QdrantScrollPager.swift (100%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/Wire/QdrantSortedPager.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProQdrantCore => TableProQdrantClient}/Wire/QdrantTransport.swift (85%) create mode 100644 apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterSpec.swift create mode 100644 apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantInsertCheck.swift rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/WeaviateAuth.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/WeaviateFilterBuilder.swift (90%) create mode 100644 apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateGraphQL+Query.swift rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/WeaviateObjectCodec.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/WeaviateOperations.swift (98%) rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/WeaviatePathEncoding.swift (100%) create mode 100644 apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateStatementGenerator.swift rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/Wire/WeaviateClient.swift (99%) rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/Wire/WeaviateObjectPages.swift (98%) rename apple/Packages/TableProCore/Sources/{TableProWeaviateCore => TableProWeaviateClient}/Wire/WeaviateTransport.swift (99%) create mode 100644 apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateValueKind.swift rename apple/Packages/{TableProMacCore/Tests/TableProUtilitiesTests/Process => TableProCore/Tests/TableProProcessTests}/DescriptorReadTests.swift (98%) rename apple/Packages/{TableProMacCore/Tests/TableProUtilitiesTests/Process => TableProCore/Tests/TableProProcessTests}/DescriptorWriteTests.swift (97%) rename apple/Packages/TableProCore/Tests/{TableProWeaviateCoreTests => TableProWeaviateClientTests}/WeaviateTunneledTrustTests.swift (98%) diff --git a/.claude/rules/plugin-system.md b/.claude/rules/plugin-system.md index e61ec10314..dc90c8595e 100644 --- a/.claude/rules/plugin-system.md +++ b/.claude/rules/plugin-system.md @@ -37,7 +37,7 @@ TableProPluginKit is built with Library Evolution, so an already-built plugin ke ## One PluginKit per process - R1 (the rule is in `apple/AGENTS.md`, Invariants that apply everywhere): a plugin that linked a package product depending on the `TableProPluginKit` package would carry its own copy of PluginKit's types, and the host's casts across that boundary fail. Products a plugin and the iOS app share stay PluginKit-free for that reason. -- The R1 check runs per binary (each plugin, each plugin test bundle, the app) and must print nothing: +- The R1 check runs per binary (each plugin, each plugin test bundle, the app) and must print nothing. A Release binary keeps no symbols, so run it on a Debug build, or on the dSYM's `Contents/Resources/DWARF/` for a Release one: ```bash nm -m "$BIN" | grep -v undefined | grep -E '_\$s17TableProPluginKit[0-9A-Za-z_]*Mn$' \ diff --git a/apple/Configs/NoExportedSymbols.exp b/apple/Configs/NoExportedSymbols.exp new file mode 100644 index 0000000000..058f29f449 --- /dev/null +++ b/apple/Configs/NoExportedSymbols.exp @@ -0,0 +1,2 @@ +# Exports nothing. dyld finds main through LC_MAIN and a plugin's principal class through the Objective-C runtime, +# and nothing binds to these binaries' symbols, so every public package symbol would only be a dead-strip root. diff --git a/apple/Packages/TableProCore/Package.swift b/apple/Packages/TableProCore/Package.swift index a59c9a69de..ecf8b7d0dd 100644 --- a/apple/Packages/TableProCore/Package.swift +++ b/apple/Packages/TableProCore/Package.swift @@ -36,10 +36,13 @@ let package = Package( .library(name: "TableProGoogleCloud", targets: ["TableProGoogleCloud"]), .library(name: "TableProSpannerCore", targets: ["TableProSpannerCore"]), .library(name: "TableProWeaviateCore", targets: ["TableProWeaviateCore"]), + .library(name: "TableProWeaviateClient", targets: ["TableProWeaviateClient"]), .library(name: "TableProQdrantCore", targets: ["TableProQdrantCore"]), + .library(name: "TableProQdrantClient", targets: ["TableProQdrantClient"]), .library(name: "TableProInfluxDBCore", targets: ["TableProInfluxDBCore"]), .library(name: "TableProNeo4jCore", targets: ["TableProNeo4jCore"]), .library(name: "TableProFirebaseCore", targets: ["TableProFirebaseCore"]), + .library(name: "TableProFirebaseClient", targets: ["TableProFirebaseClient"]), .library(name: "TableProBigtableCore", targets: ["TableProBigtableCore"]), .library(name: "TableProNumberFormatting", targets: ["TableProNumberFormatting"]), .library(name: "TableProDocumentPath", targets: ["TableProDocumentPath"]), @@ -205,12 +208,25 @@ let package = Package( dependencies: [], path: "Sources/TableProWeaviateCore" ), + // Only the plugin links this; the app tiers statements with TableProWeaviateCore alone. + .target( + name: "TableProWeaviateClient", + dependencies: ["TableProWeaviateCore"], + path: "Sources/TableProWeaviateClient" + ), .target( name: "TableProQdrantCore", dependencies: [], path: "Sources/TableProQdrantCore", swiftSettings: pluginCoreSettings ), + // Only the plugin links this; the app tiers statements with TableProQdrantCore alone. + .target( + name: "TableProQdrantClient", + dependencies: ["TableProQdrantCore"], + path: "Sources/TableProQdrantClient", + swiftSettings: pluginCoreSettings + ), .target( name: "TableProInfluxDBCore", dependencies: [], @@ -228,9 +244,15 @@ let package = Package( ), .target( name: "TableProFirebaseCore", - dependencies: ["TableProGoogleCloud"], + dependencies: [], path: "Sources/TableProFirebaseCore" ), + // Only the plugin links this; the app tiers statements with TableProFirebaseCore alone. + .target( + name: "TableProFirebaseClient", + dependencies: ["TableProFirebaseCore", "TableProGoogleCloud"], + path: "Sources/TableProFirebaseClient" + ), .target( name: "TableProR2SQLCore", dependencies: ["TableProSQLQuoting"], @@ -252,7 +274,8 @@ let package = Package( dependencies: [], path: "Sources/TableProSQLQuoting" ), - // Starts every child process outside PluginKit. Foundation only, so it builds on Linux too. + // Starts every child process outside PluginKit and reads and writes its descriptors. Foundation only, with the + // descriptor code behind canImport(Darwin), so it builds on Linux too. .target( name: "TableProProcess", dependencies: [], @@ -388,13 +411,13 @@ let package = Package( path: "Tests/TableProNeo4jCoreTests" ), .testTarget( - name: "TableProWeaviateCoreTests", - dependencies: ["TableProWeaviateCore", "TableProTLSTestFixtures"], - path: "Tests/TableProWeaviateCoreTests" + name: "TableProWeaviateClientTests", + dependencies: ["TableProWeaviateClient", "TableProTLSTestFixtures"], + path: "Tests/TableProWeaviateClientTests" ), .testTarget( name: "TableProFirebaseCoreTests", - dependencies: ["TableProFirebaseCore", "TableProGoogleCloud"], + dependencies: ["TableProFirebaseCore", "TableProFirebaseClient", "TableProGoogleCloud"], path: "Tests/TableProFirebaseCoreTests" ), .testTarget( @@ -409,7 +432,7 @@ let package = Package( ), .testTarget( name: "TableProQdrantCoreTests", - dependencies: ["TableProQdrantCore"], + dependencies: ["TableProQdrantCore", "TableProQdrantClient"], path: "Tests/TableProQdrantCoreTests", swiftSettings: pluginCoreSettings ), @@ -514,7 +537,7 @@ let package = Package( ), .testTarget( name: "TableProProcessTests", - dependencies: ["TableProProcess"], + dependencies: ["TableProProcess", "TableProTestSupport"], path: "Tests/TableProProcessTests" ), .testTarget( diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Config/FirebaseConnectionSettings.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Config/FirebaseConnectionSettings.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Config/FirebaseConnectionSettings.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Config/FirebaseConnectionSettings.swift index b76179a1c6..bfa9318339 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Config/FirebaseConnectionSettings.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Config/FirebaseConnectionSettings.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore public enum FirebaseFieldID { public static let authMethod = "fbAuthMethod" diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreCellCodec.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreCellCodec.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreCellCodec.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreCellCodec.swift index 7a911cec8f..668f0cbc0f 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreCellCodec.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreCellCodec.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore /// The grid only holds text, so an edit is read by the type the field already had: a string field /// stays a string even when the new text looks like a number. diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreClient.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreClient.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreClient.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreClient.swift index 94014f42c6..cfeb8c381c 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreClient.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreClient.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore import TableProGoogleCloud public final class FirestoreClient: @unchecked Sendable { diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocument.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocument.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocument.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocument.swift index f810394b4c..60f3877559 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocument.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocument.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore public struct FirestoreDocument: Sendable, Equatable { /// Relative to `.../documents`, such as `users/alice`. diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocumentJSON.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocumentJSON.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocumentJSON.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocumentJSON.swift index 4a6ef31fe0..ba6c0f1f38 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreDocumentJSON.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreDocumentJSON.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore /// Types JSON has no word for are single-key objects such as `{"$timestamp": "..."}`. `$double` /// marks a double with no fraction, and `$map` wraps a real map whose only key is one of the tags. diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreQuery.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreQuery.swift similarity index 84% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreQuery.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreQuery.swift index be24f39373..49d3149337 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreQuery.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreQuery.swift @@ -1,76 +1,5 @@ import Foundation - -public struct FirebaseFilterSpec: Codable, Sendable, Equatable { - public let column: String - public let op: String - public let value: String - public let secondValue: String? - - public init(column: String, op: String, value: String, secondValue: String? = nil) { - self.column = column - self.op = op - self.value = value - self.secondValue = secondValue - } - - /// The host sends BETWEEN as `value: "lower,upper"` with the upper bound again in `secondValue`, - /// so the lower bound is `value` without that suffix, whatever commas the bounds hold. - public var betweenBounds: (lower: String, upper: String)? { - guard let upper = secondValue else { - let parts = FirebaseScalars.split(value, separator: ",", omittingEmpty: false) - return parts.count == 2 ? (parts[0], parts[1]) : nil - } - let suffix = Array(("," + upper).unicodeScalars) - let scalars = Array(value.unicodeScalars) - guard scalars.count >= suffix.count, Array(scalars.suffix(suffix.count)) == suffix else { - return (value, upper) - } - var lower = String.UnicodeScalarView() - lower.append(contentsOf: scalars.dropLast(suffix.count)) - return (String(lower), upper) - } -} - -public struct FirebaseSortSpec: Codable, Sendable, Equatable { - public let column: String - public let ascending: Bool - - public init(column: String, ascending: Bool) { - self.column = column - self.ascending = ascending - } -} - -/// Turned into a query only when it runs, because filter values are typed by the fields the -/// collection was last seen holding. -public struct FirebaseBrowseSpec: Codable, Sendable, Equatable { - public let table: String - public let filters: [FirebaseFilterSpec] - public let logicMode: String - public let sorts: [FirebaseSortSpec] - public let limit: Int - public let offset: Int - - public init( - table: String, - filters: [FirebaseFilterSpec] = [], - logicMode: String = "AND", - sorts: [FirebaseSortSpec] = [], - limit: Int, - offset: Int - ) { - self.table = table - self.filters = filters - self.logicMode = logicMode - self.sorts = sorts - self.limit = limit - self.offset = offset - } - - public var usesOr: Bool { - logicMode.uppercased() == "OR" - } -} +import TableProFirebaseCore /// A table in the sidebar is either a collection path (`users`, `users/alice/orders`) or a /// collection group, `*/orders`, which is every `orders` collection at any depth. diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreValue.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreValue.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreValue.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreValue.swift index a79f4d27b8..929c75bac9 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Firestore/FirestoreValue.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Firestore/FirestoreValue.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore public indirect enum FirestoreValue: Sendable, Hashable { case null diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseClient.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseClient.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseClient.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseClient.swift index dd77ec8e1e..3d7d9acfbc 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseClient.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseClient.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore import TableProGoogleCloud public final class RealtimeDatabaseClient: @unchecked Sendable { diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseQuery.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseQuery.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseQuery.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseQuery.swift index 5af5a6c63b..ea7c9d1dd4 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseQuery.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseQuery.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore /// The REST API has no offset, so a page asks the server for the first `offset + limit` children in /// its order and drops the leading `offset` here. diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseRows.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseRows.swift similarity index 77% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseRows.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseRows.swift index 6fcc4b9fc7..91935022c2 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabaseRows.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/RealtimeDatabase/RealtimeDatabaseRows.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore public struct RealtimeDatabaseRowSet: Sendable, Equatable { public let columns: [String] @@ -99,35 +100,3 @@ public enum RealtimeDatabaseCell { } } } - -public enum RealtimeDatabasePath { - /// Characters the Realtime Database refuses in a key; checked before a write so the error - /// names the key instead of coming back as a bare 400. - static let forbidden = CharacterSet(charactersIn: ".#$[]/").union(.controlCharacters) - - public static func normalized(_ path: String) -> String { - FirebaseScalars.split(path, separator: "/").joined(separator: "/") - } - - /// An empty key stands for the node itself, which is how a node holding a plain value shows. - public static func join(_ parent: String, _ key: String) -> String { - let base = normalized(parent) - guard !key.isEmpty else { return base } - return base.isEmpty ? key : base + "/" + key - } - - /// The `$key` of the row a node holding a plain value shows as. A key cannot hold `/`, so this - /// can never name a child. - public static func nodeKey(_ path: String) -> String { - "/" + normalized(path) - } - - public static func validateKey(_ key: String) throws { - guard !key.isEmpty, key.rangeOfCharacter(from: forbidden) == nil, key.utf8.count <= 768 else { - throw FirebaseError.configuration(String( - format: String(localized: "\"%@\" is not a valid key. Keys cannot be empty or contain . # $ [ ] or /."), - key - )) - } - } -} diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseTransport.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Wire/FirebaseTransport.swift similarity index 98% rename from apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseTransport.swift rename to apple/Packages/TableProCore/Sources/TableProFirebaseClient/Wire/FirebaseTransport.swift index c60b7ab6b9..d85a55b7a3 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseTransport.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseClient/Wire/FirebaseTransport.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseCore import TableProGoogleCloud public extension GoogleRESTResponse { diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabasePath.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabasePath.swift new file mode 100644 index 0000000000..9ec0d0dc72 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/RealtimeDatabase/RealtimeDatabasePath.swift @@ -0,0 +1,33 @@ +import Foundation + +public enum RealtimeDatabasePath { + /// Characters the Realtime Database refuses in a key; checked before a write so the error + /// names the key instead of coming back as a bare 400. + static let forbidden = CharacterSet(charactersIn: ".#$[]/").union(.controlCharacters) + + public static func normalized(_ path: String) -> String { + FirebaseScalars.split(path, separator: "/").joined(separator: "/") + } + + /// An empty key stands for the node itself, which is how a node holding a plain value shows. + public static func join(_ parent: String, _ key: String) -> String { + let base = normalized(parent) + guard !key.isEmpty else { return base } + return base.isEmpty ? key : base + "/" + key + } + + /// The `$key` of the row a node holding a plain value shows as. A key cannot hold `/`, so this + /// can never name a child. + public static func nodeKey(_ path: String) -> String { + "/" + normalized(path) + } + + public static func validateKey(_ key: String) throws { + guard !key.isEmpty, key.rangeOfCharacter(from: forbidden) == nil, key.utf8.count <= 768 else { + throw FirebaseError.configuration(String( + format: String(localized: "\"%@\" is not a valid key. Keys cannot be empty or contain . # $ [ ] or /."), + key + )) + } + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseBrowseSpec.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseBrowseSpec.swift new file mode 100644 index 0000000000..48f6178ba0 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseBrowseSpec.swift @@ -0,0 +1,73 @@ +import Foundation + +public struct FirebaseFilterSpec: Codable, Sendable, Equatable { + public let column: String + public let op: String + public let value: String + public let secondValue: String? + + public init(column: String, op: String, value: String, secondValue: String? = nil) { + self.column = column + self.op = op + self.value = value + self.secondValue = secondValue + } + + /// The host sends BETWEEN as `value: "lower,upper"` with the upper bound again in `secondValue`, + /// so the lower bound is `value` without that suffix, whatever commas the bounds hold. + public var betweenBounds: (lower: String, upper: String)? { + guard let upper = secondValue else { + let parts = FirebaseScalars.split(value, separator: ",", omittingEmpty: false) + return parts.count == 2 ? (parts[0], parts[1]) : nil + } + let suffix = Array(("," + upper).unicodeScalars) + let scalars = Array(value.unicodeScalars) + guard scalars.count >= suffix.count, Array(scalars.suffix(suffix.count)) == suffix else { + return (value, upper) + } + var lower = String.UnicodeScalarView() + lower.append(contentsOf: scalars.dropLast(suffix.count)) + return (String(lower), upper) + } +} + +public struct FirebaseSortSpec: Codable, Sendable, Equatable { + public let column: String + public let ascending: Bool + + public init(column: String, ascending: Bool) { + self.column = column + self.ascending = ascending + } +} + +/// Turned into a query only when it runs, because filter values are typed by the fields the +/// collection was last seen holding. +public struct FirebaseBrowseSpec: Codable, Sendable, Equatable { + public let table: String + public let filters: [FirebaseFilterSpec] + public let logicMode: String + public let sorts: [FirebaseSortSpec] + public let limit: Int + public let offset: Int + + public init( + table: String, + filters: [FirebaseFilterSpec] = [], + logicMode: String = "AND", + sorts: [FirebaseSortSpec] = [], + limit: Int, + offset: Int + ) { + self.table = table + self.filters = filters + self.logicMode = logicMode + self.sorts = sorts + self.limit = limit + self.offset = offset + } + + public var usesOr: Bool { + logicMode.uppercased() == "OR" + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseJSON.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseJSON.swift index 3e551da1a8..4644c210b6 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseJSON.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseJSON.swift @@ -144,7 +144,7 @@ public indirect enum FirebaseJSON: Sendable, Hashable { /// JSON has no NaN or infinity, so those are written as strings; the caller that needs them /// back as numbers wraps them in a tag of its own. - static func doubleText(_ value: Double) -> String { + package static func doubleText(_ value: Double) -> String { guard value.isFinite else { return value.isNaN ? "\"NaN\"" : (value > 0 ? "\"Infinity\"" : "\"-Infinity\"") } diff --git a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseStatement.swift b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseStatement.swift index a1f3b9df80..361cb0b725 100644 --- a/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseStatement.swift +++ b/apple/Packages/TableProCore/Sources/TableProFirebaseCore/Wire/FirebaseStatement.swift @@ -196,14 +196,14 @@ public struct FirebaseRequest: Sendable, Equatable { // Paths and request lines are written per Unicode scalar, so they are read back per scalar too. A Character // joins a combining mark to the separator before it: `/` + U+0301 no longer splits, and " " + U+FE0F drops the mark. -enum FirebaseScalars { - static func split(_ text: String, separator: Unicode.Scalar, maxSplits: Int = .max, omittingEmpty: Bool = true) -> [String] { +package enum FirebaseScalars { + package static func split(_ text: String, separator: Unicode.Scalar, maxSplits: Int = .max, omittingEmpty: Bool = true) -> [String] { text.unicodeScalars .split(separator: separator, maxSplits: maxSplits, omittingEmptySubsequences: omittingEmpty) .map(String.init) } - static func removingPrefix(_ prefix: String, from text: String) -> String? { + package static func removingPrefix(_ prefix: String, from text: String) -> String? { guard text.unicodeScalars.starts(with: prefix.unicodeScalars) else { return nil } return String(text.unicodeScalars.dropFirst(prefix.unicodeScalars.count)) } diff --git a/apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorRead.swift b/apple/Packages/TableProCore/Sources/TableProProcess/DescriptorRead.swift similarity index 98% rename from apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorRead.swift rename to apple/Packages/TableProCore/Sources/TableProProcess/DescriptorRead.swift index 65b00e75bf..0cd04b55da 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorRead.swift +++ b/apple/Packages/TableProCore/Sources/TableProProcess/DescriptorRead.swift @@ -1,3 +1,4 @@ +#if canImport(Darwin) import Darwin import Foundation @@ -62,3 +63,4 @@ public enum DescriptorRead { } } } +#endif diff --git a/apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorWrite.swift b/apple/Packages/TableProCore/Sources/TableProProcess/DescriptorWrite.swift similarity index 97% rename from apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorWrite.swift rename to apple/Packages/TableProCore/Sources/TableProProcess/DescriptorWrite.swift index 3925cfe0d4..7bf7b7e07e 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProUtilities/Process/DescriptorWrite.swift +++ b/apple/Packages/TableProCore/Sources/TableProProcess/DescriptorWrite.swift @@ -1,3 +1,4 @@ +#if canImport(Darwin) import Darwin import Foundation @@ -35,3 +36,4 @@ public enum DescriptorWrite { } } } +#endif diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantConnectionSettings.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantConnectionSettings.swift similarity index 98% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantConnectionSettings.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantConnectionSettings.swift index 63e3d523e6..0f9b26885c 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantConnectionSettings.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantConnectionSettings.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore public enum QdrantFieldID { public static let apiKey = "qdApiKey" diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterBuilder.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantFilterBuilder.swift similarity index 96% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterBuilder.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantFilterBuilder.swift index 8b20a24cde..79c149baee 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterBuilder.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantFilterBuilder.swift @@ -1,18 +1,5 @@ import Foundation - -public struct QdrantFilterSpec: Sendable, Equatable { - public let column: String - public let op: String - public let value: String - public let secondValue: String? - - public init(column: String, op: String, value: String, secondValue: String? = nil) { - self.column = column - self.op = op - self.value = value - self.secondValue = secondValue - } -} +import TableProQdrantCore public enum QdrantFilterError: Error, LocalizedError, Equatable, Sendable { case unsupportedOperator(String) diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantPoint.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantPoint.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantPoint.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantPoint.swift index b725bd810c..a449315f06 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantPoint.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantPoint.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore public enum QdrantPointID { // Qdrant refuses an integer id spelled as a string and the other way round. diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantRowWrites.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantRowWrites.swift similarity index 89% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantRowWrites.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantRowWrites.swift index 05039b7f94..52d03e4de0 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantRowWrites.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantRowWrites.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore public struct QdrantCell: Sendable, Equatable { public let column: String @@ -42,29 +43,11 @@ public struct QdrantRowWrite: Sendable, Equatable { public let landedCheck: String? } -public enum QdrantInsertCheck { - public static let tag = "QDRANT_INSERT_CHECK:" - - public static func encode(collection: String, id: Any, payload: [String: Any], vectors: [String: Any]) -> String? { - let spec: [String: Any] = ["collection": collection, "id": id, "payload": payload, "vectors": vectors] - guard let data = try? QdrantJSON.data(spec) else { return nil } - return tag + data.base64EncodedString() - } - - public static func decode(_ text: String) -> (collection: String, id: Any, payload: [String: Any], vectors: [String: Any])? { - guard text.hasPrefix(tag), - let data = Data(base64Encoded: String(text.dropFirst(tag.count))), - let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any], - let collection = object["collection"] as? String, let id = object["id"], - let payload = object["payload"] as? [String: Any] - else { return nil } - return (collection, id, payload, object["vectors"] as? [String: Any] ?? [:]) - } - +public extension QdrantInsertCheck { // The payload and which vectors the point holds. Vector values are not compared: Qdrant sorts a // sparse vector's indices, stores float16 and uint8 vectors rounded and cosine vectors normalized, so // a vector written exactly reads back different. - public static func landed(_ point: QdrantPoint?, payload: [String: Any], vectors: [String: Any]) -> Bool { + static func landed(_ point: QdrantPoint?, payload: [String: Any], vectors: [String: Any]) -> Bool { guard let point, (try? QdrantJSON.text(point.payload)) == (try? QdrantJSON.text(payload)) else { return false } let names: Set switch point.vector { diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantSchema.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSchema.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantSchema.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSchema.swift index 962faf11df..fa49b43695 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantSchema.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSchema.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore // The first seven are Qdrant's payload index schemas; the rest are read off sampled values. public enum QdrantFieldType: String, Sendable, Equatable, CaseIterable { diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSortPlan.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSortPlan.swift new file mode 100644 index 0000000000..04ec330955 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantSortPlan.swift @@ -0,0 +1,27 @@ +import Foundation +import TableProQdrantCore + +public enum QdrantSortPlan: Sendable, Equatable { + case byID + case byPayload(column: String, key: String, ascending: Bool) + + public static func resolve(_ sorts: [QdrantSortSpec]) throws -> QdrantSortPlan { + guard let sort = sorts.first else { return .byID } + guard sorts.count == 1 else { + throw QdrantError.unsupported(String(localized: "Qdrant sorts by one field at a time. Remove the sort from the other columns.")) + } + if sort.column == QdrantSchema.idColumn { + guard sort.ascending else { + throw QdrantError.unsupported(String(localized: "Qdrant lists points by id in ascending order only.")) + } + return .byID + } + guard !QdrantSchema.isVectorColumn(sort.column), sort.column != QdrantSchema.scoreColumn else { + throw QdrantError.unsupported(String(format: String(localized: "Qdrant cannot sort by %@."), sort.column)) + } + guard let key = QdrantKeyPath.quoted(QdrantSchema.payloadKey(forColumn: sort.column)) else { + throw QdrantFilterError.keyNotAddressable(column: sort.column) + } + return .byPayload(column: sort.column, key: key, ascending: sort.ascending) + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantValue.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantValue.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantValue.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantValue.swift index 3945423068..64da205308 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantValue.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/QdrantValue.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore public enum QdrantValueError: Error, LocalizedError, Equatable, Sendable { case notAnInteger(column: String, value: String) diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantClient.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantClient.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantClient.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantClient.swift index 98a69f3420..e586a5095e 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantClient.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantClient.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore public struct QdrantScrollPage: @unchecked Sendable { public let points: [QdrantPoint] diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantScrollPager.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantScrollPager.swift similarity index 100% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantScrollPager.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantScrollPager.swift diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantSortedPager.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantSortedPager.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantSortedPager.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantSortedPager.swift index 302080324e..7181a37299 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantSortedPager.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantSortedPager.swift @@ -1,4 +1,5 @@ import Foundation +import TableProQdrantCore // `order_by` walks Qdrant's range index, which holds only points with a value in it and holds a point // once per value. So the grid's rows are the ordered points first, then the points without a value in diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantTransport.swift b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantTransport.swift similarity index 85% rename from apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantTransport.swift rename to apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantTransport.swift index b92ec486fa..fdad9ba712 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/Wire/QdrantTransport.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantClient/Wire/QdrantTransport.swift @@ -34,8 +34,6 @@ public struct QdrantHTTPResponse: Sendable, Equatable { } } -// The URLSession transport lives in the plugin: the app links this module for the query classifier, -// and an Objective-C class compiled into both would be registered twice in one process. public protocol QdrantTransport: Sendable { func send(_ request: QdrantHTTPRequest) async throws -> QdrantHTTPResponse func cancelAll() diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantBrowse.swift b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantBrowse.swift index c2c5ddefab..aeaed2038e 100644 --- a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantBrowse.swift +++ b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantBrowse.swift @@ -88,28 +88,3 @@ public enum QdrantBrowseQuery { ) } } - -public enum QdrantSortPlan: Sendable, Equatable { - case byID - case byPayload(column: String, key: String, ascending: Bool) - - public static func resolve(_ sorts: [QdrantSortSpec]) throws -> QdrantSortPlan { - guard let sort = sorts.first else { return .byID } - guard sorts.count == 1 else { - throw QdrantError.unsupported(String(localized: "Qdrant sorts by one field at a time. Remove the sort from the other columns.")) - } - if sort.column == QdrantSchema.idColumn { - guard sort.ascending else { - throw QdrantError.unsupported(String(localized: "Qdrant lists points by id in ascending order only.")) - } - return .byID - } - guard !QdrantSchema.isVectorColumn(sort.column), sort.column != QdrantSchema.scoreColumn else { - throw QdrantError.unsupported(String(format: String(localized: "Qdrant cannot sort by %@."), sort.column)) - } - guard let key = QdrantKeyPath.quoted(QdrantSchema.payloadKey(forColumn: sort.column)) else { - throw QdrantFilterError.keyNotAddressable(column: sort.column) - } - return .byPayload(column: sort.column, key: key, ascending: sort.ascending) - } -} diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterSpec.swift b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterSpec.swift new file mode 100644 index 0000000000..5d5cf77165 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantFilterSpec.swift @@ -0,0 +1,15 @@ +import Foundation + +public struct QdrantFilterSpec: Sendable, Equatable { + public let column: String + public let op: String + public let value: String + public let secondValue: String? + + public init(column: String, op: String, value: String, secondValue: String? = nil) { + self.column = column + self.op = op + self.value = value + self.secondValue = secondValue + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantInsertCheck.swift b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantInsertCheck.swift new file mode 100644 index 0000000000..8afb20be51 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProQdrantCore/QdrantInsertCheck.swift @@ -0,0 +1,21 @@ +import Foundation + +public enum QdrantInsertCheck { + public static let tag = "QDRANT_INSERT_CHECK:" + + public static func encode(collection: String, id: Any, payload: [String: Any], vectors: [String: Any]) -> String? { + let spec: [String: Any] = ["collection": collection, "id": id, "payload": payload, "vectors": vectors] + guard let data = try? QdrantJSON.data(spec) else { return nil } + return tag + data.base64EncodedString() + } + + public static func decode(_ text: String) -> (collection: String, id: Any, payload: [String: Any], vectors: [String: Any])? { + guard text.hasPrefix(tag), + let data = Data(base64Encoded: String(text.dropFirst(tag.count))), + let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any], + let collection = object["collection"] as? String, let id = object["id"], + let payload = object["payload"] as? [String: Any] + else { return nil } + return (collection, id, payload, object["vectors"] as? [String: Any] ?? [:]) + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateAuth.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateAuth.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateAuth.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateAuth.swift index bf2a74a611..f49ff8e3fc 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateAuth.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateAuth.swift @@ -1,4 +1,5 @@ import Foundation +import TableProWeaviateCore public enum WeaviateFieldID { public static let authMethod = "wvAuthMethod" diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateFilterBuilder.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateFilterBuilder.swift similarity index 90% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateFilterBuilder.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateFilterBuilder.swift index 43d7f01a2e..0682d56b10 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateFilterBuilder.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateFilterBuilder.swift @@ -1,4 +1,5 @@ import Foundation +import TableProWeaviateCore public enum WeaviateFilterError: Error, LocalizedError, Equatable { case unsupportedOperator(String) @@ -55,51 +56,6 @@ public enum WeaviateFilterError: Error, LocalizedError, Equatable { } } -/// Weaviate has no array value field: an `int[]` property filters with `valueInt`, so the kind is -/// always the element's. -public enum WeaviateValueKind: String, Sendable, Equatable { - case text - case uuid - case int - case number - case boolean - case date - - public var graphQLField: String { - switch self { - case .text, .uuid: return "valueText" - case .int: return "valueInt" - case .number: return "valueNumber" - case .boolean: return "valueBoolean" - case .date: return "valueDate" - } - } - - public var isOrdered: Bool { - self == .int || self == .number || self == .date - } - - /// `Like` compiles to a regex over the inverted index, which Weaviate only builds for text. - public var acceptsPatternMatch: Bool { - self == .text - } - - public static func forDataType(_ dataType: String) -> WeaviateValueKind { - var name = dataType.trimmingCharacters(in: .whitespaces).lowercased() - while name.hasSuffix("[]") { - name = String(name.dropLast(2)) - } - switch name { - case "int": return .int - case "number": return .number - case "boolean", "bool": return .boolean - case "date": return .date - case "uuid": return .uuid - default: return .text - } - } -} - public enum WeaviateFilterBuilder { private static let rawFilterColumn = "__RAW__" diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateGraphQL+Query.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateGraphQL+Query.swift new file mode 100644 index 0000000000..1afa23befa --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateGraphQL+Query.swift @@ -0,0 +1,73 @@ +import Foundation +import TableProWeaviateCore + +extension WeaviateGraphQL { + public static func getQuery( + collection: String, + properties: [String], + limit: Int, + offset: Int, + sorts: [WeaviateSortSpec], + filters: [WeaviateFilterSpec], + logicMode: String, + schema: [String: WeaviateProperty], + includeVector: Bool = true + ) throws -> String { + let types = schema.mapValues(\.dataType) + let fields = properties + .filter { $0 != WeaviateSchema.uuidColumn && $0 != WeaviateSchema.vectorColumn } + .compactMap { selection(for: $0, schema: schema) } + .joined(separator: " ") + var args: [String] = ["limit: \(max(limit, 0))", "offset: \(max(offset, 0))"] + if let whereClause = try WeaviateFilterBuilder.graphQLWhere( + filters: filters, logicMode: logicMode, types: types + ) { + args.append("where: \(whereClause)") + } + let sortArgs = sorts.compactMap { sort -> String? in + guard let path = sortPath(for: sort) else { return nil } + let order = sort.ascending ? "asc" : "desc" + return "{ path: [\"\(WeaviateFilterBuilder.escape(path))\"] order: \(order) }" + } + if !sortArgs.isEmpty { + args.append("sort: [\(sortArgs.joined(separator: " "))]") + } + let argumentList = args.joined(separator: ", ") + let additional = includeVector ? "id vector" : "id" + return """ + { Get { \(collection)(\(argumentList)) { \(fields) _additional { \(additional) } } } } + """ + } + + /// A structured property needs its own sub-selection, and an `object` with no declared nested + /// properties has nothing to select, so it is left out rather than failing the query. + private static func selection(for name: String, schema: [String: WeaviateProperty]) -> String? { + guard let property = schema[name] else { return name } + switch WeaviatePropertyShape.of(property) { + case .scalar: + return name + case .geoCoordinates: + return "\(name) { latitude longitude }" + case .phoneNumber: + return "\(name) { input internationalFormatted nationalFormatted countryCode national valid defaultCountry }" + case .object: + let nested = property.nestedProperties + .compactMap { selection(for: $0.name, schema: [$0.name: $0]) } + .joined(separator: " ") + return nested.isEmpty ? nil : "\(name) { \(nested) }" + case .crossReference(let targets): + let fragments = targets.map { "... on \($0) { _additional { id } }" }.joined(separator: " ") + return "\(name) { \(fragments) }" + } + } + + /// `vector` is a grid column rather than a property, so Weaviate has nothing to sort on. Every + /// real property is passed through: a type it cannot sort, such as uuid, is reported by the + /// server, which beats painting a sort chevron over rows in insertion order. + private static func sortPath(for sort: WeaviateSortSpec) -> String? { + if sort.column == WeaviateSchema.uuidColumn { + return WeaviateSchema.uuidGraphQLPath + } + return sort.column == WeaviateSchema.vectorColumn ? nil : sort.column + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateObjectCodec.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateObjectCodec.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateObjectCodec.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateObjectCodec.swift index c64d73eaaa..b468f49cdd 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateObjectCodec.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateObjectCodec.swift @@ -1,4 +1,5 @@ import Foundation +import TableProWeaviateCore public struct WeaviateObject: Sendable, Equatable { public let uuid: String diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateOperations.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateOperations.swift similarity index 98% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateOperations.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateOperations.swift index 2c83f47e0b..4b81447a1a 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateOperations.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateOperations.swift @@ -1,6 +1,6 @@ // // WeaviateOperations.swift -// TableProWeaviateCore +// TableProWeaviateClient // import Foundation diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviatePathEncoding.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviatePathEncoding.swift similarity index 100% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviatePathEncoding.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviatePathEncoding.swift diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateStatementGenerator.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateStatementGenerator.swift new file mode 100644 index 0000000000..da95cafd5c --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/WeaviateStatementGenerator.swift @@ -0,0 +1,174 @@ +import Foundation +import TableProWeaviateCore + +public struct WeaviateCellChange: Sendable, Equatable { + public let column: String + public let newText: String? + + public init(column: String, newText: String?) { + self.column = column + self.newText = newText + } +} + +public struct WeaviateTrackedChange: Sendable, Equatable { + public enum Kind: String, Sendable, Equatable { + case insert + case update + case delete + } + + public let kind: Kind + public let uuid: String? + public let values: [String: String?] + public let cellChanges: [WeaviateCellChange] + + public init( + kind: Kind, + uuid: String?, + values: [String: String?], + cellChanges: [WeaviateCellChange] + ) { + self.kind = kind + self.uuid = uuid + self.values = values + self.cellChanges = cellChanges + } +} + +public enum WeaviateSkipReason: String, Sendable, Equatable { + case missingUUID + case noEditableColumns + case payloadNotEncodable +} + +public struct WeaviateSkippedChange: Sendable, Equatable { + public let kind: WeaviateTrackedChange.Kind + public let reason: WeaviateSkipReason + + public init(kind: WeaviateTrackedChange.Kind, reason: WeaviateSkipReason) { + self.kind = kind + self.reason = reason + } +} + +/// A skipped change writes nothing while the grid reports the save succeeded, so the driver has to +/// be able to say what it dropped. Same reason the MongoDB generator logs its own skips. +public struct WeaviateWriteBatch: Sendable, Equatable { + public let requests: [WeaviateWriteRequest] + public let skipped: [WeaviateSkippedChange] + + public init(requests: [WeaviateWriteRequest], skipped: [WeaviateSkippedChange]) { + self.requests = requests + self.skipped = skipped + } +} + +public enum WeaviateStatementGenerator { + public static func generate( + collection: String, + columns: [String], + typeNames: [String], + changes: [WeaviateTrackedChange] + ) -> WeaviateWriteBatch { + let types = Dictionary(zip(columns, typeNames), uniquingKeysWith: { first, _ in first }) + var requests: [WeaviateWriteRequest] = [] + var skipped: [WeaviateSkippedChange] = [] + for change in changes { + let request: WeaviateWriteRequest? + switch change.kind { + case .insert: + request = insert(collection: collection, types: types, change: change) + case .update: + request = update(collection: collection, types: types, change: change) + case .delete: + request = delete(collection: collection, change: change) + } + if let request { + requests.append(request) + } else { + skipped.append(WeaviateSkippedChange(kind: change.kind, reason: reason(for: change))) + } + } + return WeaviateWriteBatch(requests: requests, skipped: skipped) + } + + private static func reason(for change: WeaviateTrackedChange) -> WeaviateSkipReason { + if change.kind != .insert, change.uuid?.isEmpty ?? true { + return .missingUUID + } + if change.kind == .update, editablePatch(from: change).isEmpty { + return .noEditableColumns + } + return .payloadNotEncodable + } + + private static func editablePatch(from change: WeaviateTrackedChange) -> [String: String?] { + var patch: [String: String?] = [:] + for cell in change.cellChanges where !WeaviateSchema.immutableColumns.contains(cell.column) { + patch[cell.column] = cell.newText + } + return patch + } + + private static func insert( + collection: String, + types: [String: String], + change: WeaviateTrackedChange + ) -> WeaviateWriteRequest? { + var payload: [String: Any] = [ + "class": collection, + "properties": properties(from: change.values, types: types) + ] + if let uuid = change.uuid, !uuid.isEmpty { + payload["id"] = uuid + } + guard let body = try? WeaviateJSON.text(payload) else { return nil } + return WeaviateWriteRequest(method: "POST", path: "/v1/objects", body: body) + } + + private static func update( + collection: String, + types: [String: String], + change: WeaviateTrackedChange + ) -> WeaviateWriteRequest? { + guard let uuid = change.uuid, !uuid.isEmpty else { return nil } + let patch = editablePatch(from: change) + guard !patch.isEmpty else { return nil } + let payload: [String: Any] = [ + "class": collection, + "properties": properties(from: patch, types: types) + ] + guard let body = try? WeaviateJSON.text(payload) else { return nil } + return WeaviateWriteRequest( + method: "PATCH", + path: "/v1/objects/\(WeaviatePathEncoding.segment(uuid))", + query: ["class": collection], + body: body + ) + } + + private static func delete(collection: String, change: WeaviateTrackedChange) -> WeaviateWriteRequest? { + guard let uuid = change.uuid, !uuid.isEmpty else { return nil } + return WeaviateWriteRequest( + method: "DELETE", + path: "/v1/objects/\(WeaviatePathEncoding.segment(uuid))", + query: ["class": collection], + body: nil + ) + } + + private static func properties(from values: [String: String?], types: [String: String]) -> [String: Any] { + var result: [String: Any] = [:] + for (column, text) in values { + if WeaviateSchema.immutableColumns.contains(column) { continue } + if column.hasPrefix("\(WeaviateObjectCodec.additionalKey).") { continue } + if let text { + result[column] = WeaviateJSON.parsedValue(text, typeName: types[column] ?? "text") + } else { + result[column] = NSNull() + } + } + return result + } +} diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateClient.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateClient.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateClient.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateClient.swift index c4b998249a..745fae5bbb 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateClient.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateClient.swift @@ -1,4 +1,5 @@ import Foundation +import TableProWeaviateCore public final class WeaviateClient: @unchecked Sendable { public let settings: WeaviateConnectionSettings diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateObjectPages.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateObjectPages.swift similarity index 98% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateObjectPages.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateObjectPages.swift index 833bc9c40b..43ed28915a 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateObjectPages.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateObjectPages.swift @@ -1,4 +1,5 @@ import Foundation +import TableProWeaviateCore public struct WeaviateObjectPages: AsyncSequence, Sendable { public typealias Element = [WeaviateObject] diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateTransport.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateTransport.swift similarity index 99% rename from apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateTransport.swift rename to apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateTransport.swift index c6078c2ebc..a91d99c8b5 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/Wire/WeaviateTransport.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateClient/Wire/WeaviateTransport.swift @@ -1,5 +1,6 @@ import Foundation import Security +import TableProWeaviateCore public struct WeaviateHTTPRequest: Sendable, Equatable { public let method: String diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateGraphQL.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateGraphQL.swift index 7fa048ddc5..4dcb2c66f6 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateGraphQL.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateGraphQL.swift @@ -1,75 +1,6 @@ import Foundation public enum WeaviateGraphQL { - public static func getQuery( - collection: String, - properties: [String], - limit: Int, - offset: Int, - sorts: [WeaviateSortSpec], - filters: [WeaviateFilterSpec], - logicMode: String, - schema: [String: WeaviateProperty], - includeVector: Bool = true - ) throws -> String { - let types = schema.mapValues(\.dataType) - let fields = properties - .filter { $0 != WeaviateSchema.uuidColumn && $0 != WeaviateSchema.vectorColumn } - .compactMap { selection(for: $0, schema: schema) } - .joined(separator: " ") - var args: [String] = ["limit: \(max(limit, 0))", "offset: \(max(offset, 0))"] - if let whereClause = try WeaviateFilterBuilder.graphQLWhere( - filters: filters, logicMode: logicMode, types: types - ) { - args.append("where: \(whereClause)") - } - let sortArgs = sorts.compactMap { sort -> String? in - guard let path = sortPath(for: sort) else { return nil } - let order = sort.ascending ? "asc" : "desc" - return "{ path: [\"\(WeaviateFilterBuilder.escape(path))\"] order: \(order) }" - } - if !sortArgs.isEmpty { - args.append("sort: [\(sortArgs.joined(separator: " "))]") - } - let argumentList = args.joined(separator: ", ") - let additional = includeVector ? "id vector" : "id" - return """ - { Get { \(collection)(\(argumentList)) { \(fields) _additional { \(additional) } } } } - """ - } - - /// A structured property needs its own sub-selection, and an `object` with no declared nested - /// properties has nothing to select, so it is left out rather than failing the query. - private static func selection(for name: String, schema: [String: WeaviateProperty]) -> String? { - guard let property = schema[name] else { return name } - switch WeaviatePropertyShape.of(property) { - case .scalar: - return name - case .geoCoordinates: - return "\(name) { latitude longitude }" - case .phoneNumber: - return "\(name) { input internationalFormatted nationalFormatted countryCode national valid defaultCountry }" - case .object: - let nested = property.nestedProperties - .compactMap { selection(for: $0.name, schema: [$0.name: $0]) } - .joined(separator: " ") - return nested.isEmpty ? nil : "\(name) { \(nested) }" - case .crossReference(let targets): - let fragments = targets.map { "... on \($0) { _additional { id } }" }.joined(separator: " ") - return "\(name) { \(fragments) }" - } - } - - /// `vector` is a grid column rather than a property, so Weaviate has nothing to sort on. Every - /// real property is passed through: a type it cannot sort, such as uuid, is reported by the - /// server, which beats painting a sort chevron over rows in insertion order. - private static func sortPath(for sort: WeaviateSortSpec) -> String? { - if sort.column == WeaviateSchema.uuidColumn { - return WeaviateSchema.uuidGraphQLPath - } - return sort.column == WeaviateSchema.vectorColumn ? nil : sort.column - } - public static func looksLikeGraphQL(_ text: String) -> Bool { let trimmed = text.trimmingCharacters(in: .whitespacesAndNewlines) if trimmed.hasPrefix("{") { return true } diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateQuery.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateQuery.swift index 773b8cf34d..f66e1849fb 100644 --- a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateQuery.swift +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateQuery.swift @@ -186,175 +186,3 @@ public enum WeaviateWriteCodec { statement.hasPrefix(writeTag) } } - -public struct WeaviateCellChange: Sendable, Equatable { - public let column: String - public let newText: String? - - public init(column: String, newText: String?) { - self.column = column - self.newText = newText - } -} - -public struct WeaviateTrackedChange: Sendable, Equatable { - public enum Kind: String, Sendable, Equatable { - case insert - case update - case delete - } - - public let kind: Kind - public let uuid: String? - public let values: [String: String?] - public let cellChanges: [WeaviateCellChange] - - public init( - kind: Kind, - uuid: String?, - values: [String: String?], - cellChanges: [WeaviateCellChange] - ) { - self.kind = kind - self.uuid = uuid - self.values = values - self.cellChanges = cellChanges - } -} - -public enum WeaviateSkipReason: String, Sendable, Equatable { - case missingUUID - case noEditableColumns - case payloadNotEncodable -} - -public struct WeaviateSkippedChange: Sendable, Equatable { - public let kind: WeaviateTrackedChange.Kind - public let reason: WeaviateSkipReason - - public init(kind: WeaviateTrackedChange.Kind, reason: WeaviateSkipReason) { - self.kind = kind - self.reason = reason - } -} - -/// A skipped change writes nothing while the grid reports the save succeeded, so the driver has to -/// be able to say what it dropped. Same reason the MongoDB generator logs its own skips. -public struct WeaviateWriteBatch: Sendable, Equatable { - public let requests: [WeaviateWriteRequest] - public let skipped: [WeaviateSkippedChange] - - public init(requests: [WeaviateWriteRequest], skipped: [WeaviateSkippedChange]) { - self.requests = requests - self.skipped = skipped - } -} - -public enum WeaviateStatementGenerator { - public static func generate( - collection: String, - columns: [String], - typeNames: [String], - changes: [WeaviateTrackedChange] - ) -> WeaviateWriteBatch { - let types = Dictionary(zip(columns, typeNames), uniquingKeysWith: { first, _ in first }) - var requests: [WeaviateWriteRequest] = [] - var skipped: [WeaviateSkippedChange] = [] - for change in changes { - let request: WeaviateWriteRequest? - switch change.kind { - case .insert: - request = insert(collection: collection, types: types, change: change) - case .update: - request = update(collection: collection, types: types, change: change) - case .delete: - request = delete(collection: collection, change: change) - } - if let request { - requests.append(request) - } else { - skipped.append(WeaviateSkippedChange(kind: change.kind, reason: reason(for: change))) - } - } - return WeaviateWriteBatch(requests: requests, skipped: skipped) - } - - private static func reason(for change: WeaviateTrackedChange) -> WeaviateSkipReason { - if change.kind != .insert, change.uuid?.isEmpty ?? true { - return .missingUUID - } - if change.kind == .update, editablePatch(from: change).isEmpty { - return .noEditableColumns - } - return .payloadNotEncodable - } - - private static func editablePatch(from change: WeaviateTrackedChange) -> [String: String?] { - var patch: [String: String?] = [:] - for cell in change.cellChanges where !WeaviateSchema.immutableColumns.contains(cell.column) { - patch[cell.column] = cell.newText - } - return patch - } - - private static func insert( - collection: String, - types: [String: String], - change: WeaviateTrackedChange - ) -> WeaviateWriteRequest? { - var payload: [String: Any] = [ - "class": collection, - "properties": properties(from: change.values, types: types) - ] - if let uuid = change.uuid, !uuid.isEmpty { - payload["id"] = uuid - } - guard let body = try? WeaviateJSON.text(payload) else { return nil } - return WeaviateWriteRequest(method: "POST", path: "/v1/objects", body: body) - } - - private static func update( - collection: String, - types: [String: String], - change: WeaviateTrackedChange - ) -> WeaviateWriteRequest? { - guard let uuid = change.uuid, !uuid.isEmpty else { return nil } - let patch = editablePatch(from: change) - guard !patch.isEmpty else { return nil } - let payload: [String: Any] = [ - "class": collection, - "properties": properties(from: patch, types: types) - ] - guard let body = try? WeaviateJSON.text(payload) else { return nil } - return WeaviateWriteRequest( - method: "PATCH", - path: "/v1/objects/\(WeaviatePathEncoding.segment(uuid))", - query: ["class": collection], - body: body - ) - } - - private static func delete(collection: String, change: WeaviateTrackedChange) -> WeaviateWriteRequest? { - guard let uuid = change.uuid, !uuid.isEmpty else { return nil } - return WeaviateWriteRequest( - method: "DELETE", - path: "/v1/objects/\(WeaviatePathEncoding.segment(uuid))", - query: ["class": collection], - body: nil - ) - } - - private static func properties(from values: [String: String?], types: [String: String]) -> [String: Any] { - var result: [String: Any] = [:] - for (column, text) in values { - if WeaviateSchema.immutableColumns.contains(column) { continue } - if column.hasPrefix("\(WeaviateObjectCodec.additionalKey).") { continue } - if let text { - result[column] = WeaviateJSON.parsedValue(text, typeName: types[column] ?? "text") - } else { - result[column] = NSNull() - } - } - return result - } -} diff --git a/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateValueKind.swift b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateValueKind.swift new file mode 100644 index 0000000000..e3d913b6e7 --- /dev/null +++ b/apple/Packages/TableProCore/Sources/TableProWeaviateCore/WeaviateValueKind.swift @@ -0,0 +1,46 @@ +import Foundation + +/// Weaviate has no array value field: an `int[]` property filters with `valueInt`, so the kind is +/// always the element's. +public enum WeaviateValueKind: String, Sendable, Equatable { + case text + case uuid + case int + case number + case boolean + case date + + public var graphQLField: String { + switch self { + case .text, .uuid: return "valueText" + case .int: return "valueInt" + case .number: return "valueNumber" + case .boolean: return "valueBoolean" + case .date: return "valueDate" + } + } + + public var isOrdered: Bool { + self == .int || self == .number || self == .date + } + + /// `Like` compiles to a regex over the inverted index, which Weaviate only builds for text. + public var acceptsPatternMatch: Bool { + self == .text + } + + public static func forDataType(_ dataType: String) -> WeaviateValueKind { + var name = dataType.trimmingCharacters(in: .whitespaces).lowercased() + while name.hasSuffix("[]") { + name = String(name.dropLast(2)) + } + switch name { + case "int": return .int + case "number": return .number + case "boolean", "bool": return .boolean + case "date": return .date + case "uuid": return .uuid + default: return .text + } + } +} diff --git a/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseConnectionSettingsTests.swift b/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseConnectionSettingsTests.swift index 01025bddd3..37e1321d1b 100644 --- a/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseConnectionSettingsTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseConnectionSettingsTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProFirebaseClient @testable import TableProFirebaseCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseStatementTests.swift b/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseStatementTests.swift index e10df0084a..450410a913 100644 --- a/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseStatementTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProFirebaseCoreTests/FirebaseStatementTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProFirebaseClient @testable import TableProFirebaseCore import TableProGoogleCloud import Testing diff --git a/apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorReadTests.swift b/apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorReadTests.swift similarity index 98% rename from apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorReadTests.swift rename to apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorReadTests.swift index 0f81756178..0da9b84c6c 100644 --- a/apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorReadTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorReadTests.swift @@ -1,9 +1,10 @@ +#if canImport(Darwin) import Darwin import Foundation import TableProTestSupport import Testing -@testable import TableProUtilities +@testable import TableProProcess struct DescriptorReadTests { @Test("A read returns what has arrived without waiting for the rest", .timeLimit(.minutes(1))) @@ -134,3 +135,4 @@ struct DescriptorReadTests { #expect(fcntl(descriptor, F_GETFL) & O_NONBLOCK == 0) } } +#endif diff --git a/apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorWriteTests.swift b/apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorWriteTests.swift similarity index 97% rename from apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorWriteTests.swift rename to apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorWriteTests.swift index 076ac2d9d1..5b22ac5fef 100644 --- a/apple/Packages/TableProMacCore/Tests/TableProUtilitiesTests/Process/DescriptorWriteTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProProcessTests/DescriptorWriteTests.swift @@ -1,9 +1,10 @@ +#if canImport(Darwin) import Darwin import Foundation import TableProTestSupport import Testing -@testable import TableProUtilities +@testable import TableProProcess struct DescriptorWriteTests { private struct Measured: Sendable { @@ -61,3 +62,4 @@ struct DescriptorWriteTests { #expect(error?.code == .EPIPE) } } +#endif diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantClientTests.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantClientTests.swift index dc0b58944f..2cd5c16aa1 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantClientTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantClientTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantConsoleTests.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantConsoleTests.swift index 33f6cb4555..1dfe686572 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantConsoleTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantConsoleTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantFilterBuilderTests.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantFilterBuilderTests.swift index d2a4a83fcb..00b6f127cd 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantFilterBuilderTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantFilterBuilderTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantRowWriteTests.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantRowWriteTests.swift index 279cc22ae3..a76c201c2c 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantRowWriteTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantRowWriteTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantSchemaTests.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantSchemaTests.swift index f52f77f40b..9b02aa1480 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantSchemaTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantSchemaTests.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore import Testing diff --git a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantTestSupport.swift b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantTestSupport.swift index 7eed1272c5..be37055ade 100644 --- a/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantTestSupport.swift +++ b/apple/Packages/TableProCore/Tests/TableProQdrantCoreTests/QdrantTestSupport.swift @@ -1,4 +1,5 @@ import Foundation +@testable import TableProQdrantClient @testable import TableProQdrantCore final class RecordingTransport: QdrantTransport, @unchecked Sendable { diff --git a/apple/Packages/TableProCore/Tests/TableProWeaviateCoreTests/WeaviateTunneledTrustTests.swift b/apple/Packages/TableProCore/Tests/TableProWeaviateClientTests/WeaviateTunneledTrustTests.swift similarity index 98% rename from apple/Packages/TableProCore/Tests/TableProWeaviateCoreTests/WeaviateTunneledTrustTests.swift rename to apple/Packages/TableProCore/Tests/TableProWeaviateClientTests/WeaviateTunneledTrustTests.swift index 36f2f36215..95468d435c 100644 --- a/apple/Packages/TableProCore/Tests/TableProWeaviateCoreTests/WeaviateTunneledTrustTests.swift +++ b/apple/Packages/TableProCore/Tests/TableProWeaviateClientTests/WeaviateTunneledTrustTests.swift @@ -1,7 +1,7 @@ import Foundation import Security import TableProTLSTestFixtures -@testable import TableProWeaviateCore +@testable import TableProWeaviateClient import Testing struct WeaviateTunneledTrustTests { diff --git a/apple/Packages/TableProEditor/Package.swift b/apple/Packages/TableProEditor/Package.swift index 8045b0db4b..18ace92c3d 100644 --- a/apple/Packages/TableProEditor/Package.swift +++ b/apple/Packages/TableProEditor/Package.swift @@ -14,7 +14,7 @@ let package = Package( .package(path: "../TableProCore"), .package(url: "https://github.com/ChimeHQ/TextStory", from: "0.9.0"), .package(url: "https://github.com/ChimeHQ/TextFormation", from: "0.8.2"), - .package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.0")) + .package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.6.0")) ], targets: [ .target( @@ -27,7 +27,7 @@ let package = Package( dependencies: [ "TableProTextEngineObjC", "TextStory", - .product(name: "Collections", package: "swift-collections") + .product(name: "DequeModule", package: "swift-collections") ], swiftSettings: [.swiftLanguageMode(.v5)] ), @@ -36,7 +36,8 @@ let package = Package( dependencies: [ "TableProTextEngine", "TableProGrammars", - "TextFormation" + "TextFormation", + .product(name: "_RopeModule", package: "swift-collections") ], swiftSettings: [.swiftLanguageMode(.v5)] ), diff --git a/apple/Packages/TableProMacCore/Package.swift b/apple/Packages/TableProMacCore/Package.swift index 33a1e2a300..143b1afc61 100644 --- a/apple/Packages/TableProMacCore/Package.swift +++ b/apple/Packages/TableProMacCore/Package.swift @@ -58,7 +58,6 @@ let package = Package( .target( name: "TableProMCP", dependencies: [ - "TableProUtilities", .product(name: "TableProCoreTypes", package: "TableProCore"), .product(name: "TableProLogRedaction", package: "TableProCore"), .product(name: "TableProProcess", package: "TableProCore"), @@ -71,7 +70,6 @@ let package = Package( name: "TableProCommandLine", dependencies: [ "TableProMCP", - "TableProUtilities", .product(name: "TableProCoreTypes", package: "TableProCore"), .product(name: "TableProProcess", package: "TableProCore"), .product(name: "ArgumentParser", package: "swift-argument-parser") @@ -122,7 +120,7 @@ let package = Package( dependencies: [ "TableProMCP", "TableProMCPTestSupport", - "TableProUtilities", + .product(name: "TableProProcess", package: "TableProCore"), .product(name: "TableProTestSupport", package: "TableProCore") ], path: "Tests/TableProMCPTests", diff --git a/apple/Packages/TableProMacCore/Sources/TableProCloudAPI/openapi-generator-config.yaml b/apple/Packages/TableProMacCore/Sources/TableProCloudAPI/openapi-generator-config.yaml index 8e60f914f6..fb565cf1e3 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProCloudAPI/openapi-generator-config.yaml +++ b/apple/Packages/TableProMacCore/Sources/TableProCloudAPI/openapi-generator-config.yaml @@ -3,3 +3,13 @@ generate: - client accessModifier: public namingStrategy: idiomatic +# The operations the app calls, and the schemas they reference. A new call adds its operation id here. +filter: + operations: + - get-me + - list-devices + - register-device + - delete-device + - issue-entitlement + - list-library-changes + - push-library-changes diff --git a/apple/Packages/TableProMacCore/Sources/TableProCommandLine/CLILiveEnvironment.swift b/apple/Packages/TableProMacCore/Sources/TableProCommandLine/CLILiveEnvironment.swift index 86b19ab287..b02cba18ff 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProCommandLine/CLILiveEnvironment.swift +++ b/apple/Packages/TableProMacCore/Sources/TableProCommandLine/CLILiveEnvironment.swift @@ -3,7 +3,6 @@ import Darwin import Foundation import TableProMCP import TableProProcess -import TableProUtilities public extension CLIEnvironment { static func live(console: any CLIConsole) -> CLIEnvironment { diff --git a/apple/Packages/TableProMacCore/Sources/TableProMCP/Bridge/BridgeProxy.swift b/apple/Packages/TableProMacCore/Sources/TableProMCP/Bridge/BridgeProxy.swift index b78370b988..6f92183f1f 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProMCP/Bridge/BridgeProxy.swift +++ b/apple/Packages/TableProMacCore/Sources/TableProMCP/Bridge/BridgeProxy.swift @@ -1,6 +1,6 @@ import Foundation import os -import TableProUtilities +import TableProProcess public struct BridgeDiscovery: Sendable { let supportedVersions: [String] diff --git a/apple/Packages/TableProMacCore/Sources/TableProMCP/Identity/MCPClientIdentity.swift b/apple/Packages/TableProMacCore/Sources/TableProMCP/Identity/MCPClientIdentity.swift index 9471fe998f..6859497ac2 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProMCP/Identity/MCPClientIdentity.swift +++ b/apple/Packages/TableProMacCore/Sources/TableProMCP/Identity/MCPClientIdentity.swift @@ -1,6 +1,5 @@ import CryptoKit import Foundation -import TableProUtilities public struct MCPClientIdentity: Sendable, Equatable, Hashable, Identifiable { public static let unknownClientName = String(localized: "Unknown client") @@ -56,7 +55,7 @@ public struct MCPClientIdentity: Sendable, Equatable, Hashable, Identifiable { ] let joined = fields.joined(separator: "\u{1F}") let digest = SHA256.hash(data: Data(joined.utf8)) - return String(digest.hexEncoded.prefix(16)) + return String(digest.map { String(format: "%02x", $0) }.joined().prefix(16)) } } diff --git a/apple/Packages/TableProMacCore/Sources/TableProMCP/Transport/MCPBridgeLogger.swift b/apple/Packages/TableProMacCore/Sources/TableProMCP/Transport/MCPBridgeLogger.swift index d0f63d9665..60d695d898 100644 --- a/apple/Packages/TableProMacCore/Sources/TableProMCP/Transport/MCPBridgeLogger.swift +++ b/apple/Packages/TableProMacCore/Sources/TableProMCP/Transport/MCPBridgeLogger.swift @@ -1,6 +1,6 @@ import Foundation import os -import TableProUtilities +import TableProProcess public enum MCPBridgeLogLevel: String, Sendable { case debug diff --git a/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/BridgeStdoutTests.swift b/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/BridgeStdoutTests.swift index 1bea723d88..77342cdf2e 100644 --- a/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/BridgeStdoutTests.swift +++ b/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/BridgeStdoutTests.swift @@ -2,8 +2,8 @@ import Darwin import Foundation @testable import TableProMCP import TableProMCPTestSupport +import TableProProcess import TableProTestSupport -import TableProUtilities import Testing struct BridgeStdoutTests { diff --git a/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/MCPStderrBridgeLoggerTests.swift b/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/MCPStderrBridgeLoggerTests.swift index f760887de4..9d5f2bd676 100644 --- a/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/MCPStderrBridgeLoggerTests.swift +++ b/apple/Packages/TableProMacCore/Tests/TableProMCPTests/Transport/MCPStderrBridgeLoggerTests.swift @@ -1,8 +1,8 @@ import Darwin import Foundation @testable import TableProMCP +import TableProProcess import TableProTestSupport -import TableProUtilities import Testing struct MCPStderrBridgeLoggerTests { diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebaseCredentialFactory.swift b/apple/Plugins/FirebaseDriverPlugin/FirebaseCredentialFactory.swift index a9de882c51..937f902eca 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebaseCredentialFactory.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebaseCredentialFactory.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseClient import TableProFirebaseCore import TableProGoogleCloud import TableProPluginKit diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebasePlugin.swift b/apple/Plugins/FirebaseDriverPlugin/FirebasePlugin.swift index 42264bf53b..3693ee2e3e 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebasePlugin.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebasePlugin.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseClient import TableProFirebaseCore import TableProPluginKit diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Editing.swift b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Editing.swift index 0dfd9c9ccc..5c1681ca9c 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Editing.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Editing.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseClient import TableProFirebaseCore import TableProPluginKit diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Execution.swift b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Execution.swift index f60e627413..682b0e8057 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Execution.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Execution.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseClient import TableProFirebaseCore import TableProPluginKit diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Metadata.swift b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Metadata.swift index 2cd43b56d8..66d1058169 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Metadata.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver+Metadata.swift @@ -1,4 +1,5 @@ import Foundation +import TableProFirebaseClient import TableProFirebaseCore import TableProPluginKit diff --git a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver.swift b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver.swift index daa0134f66..af0a2a17a4 100644 --- a/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver.swift +++ b/apple/Plugins/FirebaseDriverPlugin/FirebasePluginDriver.swift @@ -1,5 +1,6 @@ import Foundation import os +import TableProFirebaseClient import TableProFirebaseCore import TableProGoogleCloud import TableProLogRedaction diff --git a/apple/Plugins/QdrantDriverPlugin/QdrantPlugin.swift b/apple/Plugins/QdrantDriverPlugin/QdrantPlugin.swift index 7b6a90473d..a273e1d873 100644 --- a/apple/Plugins/QdrantDriverPlugin/QdrantPlugin.swift +++ b/apple/Plugins/QdrantDriverPlugin/QdrantPlugin.swift @@ -1,5 +1,6 @@ import Foundation import TableProPluginKit +import TableProQdrantClient import TableProQdrantCore final class QdrantPlugin: NSObject, TableProPlugin, DriverPlugin, PluginDefaultSortProvider { diff --git a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Execution.swift b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Execution.swift index 4bf1ae92c0..c1dcb1036b 100644 --- a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Execution.swift +++ b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Execution.swift @@ -1,5 +1,6 @@ import Foundation import TableProPluginKit +import TableProQdrantClient import TableProQdrantCore extension QdrantPluginDriver { diff --git a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Metadata.swift b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Metadata.swift index b8f4ad2a45..f5a5767f0d 100644 --- a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Metadata.swift +++ b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver+Metadata.swift @@ -1,5 +1,6 @@ import Foundation import TableProPluginKit +import TableProQdrantClient import TableProQdrantCore extension QdrantPluginDriver { diff --git a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver.swift b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver.swift index 90ea656972..5fa6ecd3ce 100644 --- a/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver.swift +++ b/apple/Plugins/QdrantDriverPlugin/QdrantPluginDriver.swift @@ -1,6 +1,7 @@ import Foundation import os import TableProPluginKit +import TableProQdrantClient import TableProQdrantCore internal final class QdrantPluginDriver: PluginDatabaseDriver, @unchecked Sendable { diff --git a/apple/Plugins/QdrantDriverPlugin/QdrantURLSessionTransport.swift b/apple/Plugins/QdrantDriverPlugin/QdrantURLSessionTransport.swift index 1494bb383a..0f54ba2843 100644 --- a/apple/Plugins/QdrantDriverPlugin/QdrantURLSessionTransport.swift +++ b/apple/Plugins/QdrantDriverPlugin/QdrantURLSessionTransport.swift @@ -1,6 +1,7 @@ import Foundation import Security import TableProPluginKit +import TableProQdrantClient import TableProQdrantCore import TableProTLSClientIdentity diff --git a/apple/Plugins/WeaviateDriverPlugin/WeaviatePlugin.swift b/apple/Plugins/WeaviateDriverPlugin/WeaviatePlugin.swift index 1b1a3d2d41..b0779b42ec 100644 --- a/apple/Plugins/WeaviateDriverPlugin/WeaviatePlugin.swift +++ b/apple/Plugins/WeaviateDriverPlugin/WeaviatePlugin.swift @@ -1,5 +1,6 @@ import Foundation import TableProPluginKit +import TableProWeaviateClient import TableProWeaviateCore final class WeaviatePlugin: NSObject, TableProPlugin, DriverPlugin { diff --git a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Execution.swift b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Execution.swift index 0142ec23db..cb9d6ef252 100644 --- a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Execution.swift +++ b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Execution.swift @@ -1,5 +1,6 @@ import Foundation import TableProPluginKit +import TableProWeaviateClient import TableProWeaviateCore extension WeaviatePluginDriver { diff --git a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Metadata.swift b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Metadata.swift index ba8a40fbde..5af4278f1b 100644 --- a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Metadata.swift +++ b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver+Metadata.swift @@ -1,6 +1,7 @@ import Foundation import os import TableProPluginKit +import TableProWeaviateClient import TableProWeaviateCore extension WeaviatePluginDriver { diff --git a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver.swift b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver.swift index f777b70f49..50a08da72e 100644 --- a/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver.swift +++ b/apple/Plugins/WeaviateDriverPlugin/WeaviatePluginDriver.swift @@ -1,6 +1,7 @@ import Foundation import os import TableProPluginKit +import TableProWeaviateClient import TableProWeaviateCore internal final class WeaviatePluginDriver: PluginDatabaseDriver, @unchecked Sendable { diff --git a/apple/TablePro/Assets.xcassets/cockroachdb-icon.imageset/cockroachdb.svg b/apple/TablePro/Assets.xcassets/cockroachdb-icon.imageset/cockroachdb.svg index 9d5feb8704..d0f8e29fc1 100644 --- a/apple/TablePro/Assets.xcassets/cockroachdb-icon.imageset/cockroachdb.svg +++ b/apple/TablePro/Assets.xcassets/cockroachdb-icon.imageset/cockroachdb.svg @@ -1 +1 @@ -CL +CL diff --git a/apple/TablePro/Assets.xcassets/snowflake-icon.imageset/snowflake.svg b/apple/TablePro/Assets.xcassets/snowflake-icon.imageset/snowflake.svg index 551e9d821a..dbaa3e7fab 100644 --- a/apple/TablePro/Assets.xcassets/snowflake-icon.imageset/snowflake.svg +++ b/apple/TablePro/Assets.xcassets/snowflake-icon.imageset/snowflake.svg @@ -1,4 +1,4 @@ - + diff --git a/apple/TablePro/Assets.xcassets/starrocks-icon.imageset/starrocks.svg b/apple/TablePro/Assets.xcassets/starrocks-icon.imageset/starrocks.svg index 1de2232110..2301c95fc1 100644 --- a/apple/TablePro/Assets.xcassets/starrocks-icon.imageset/starrocks.svg +++ b/apple/TablePro/Assets.xcassets/starrocks-icon.imageset/starrocks.svg @@ -1 +1 @@ - + diff --git a/apple/TablePro/CLI/BridgeMain.swift b/apple/TablePro/CLI/BridgeMain.swift index 3c1ac69d89..103abd4794 100644 --- a/apple/TablePro/CLI/BridgeMain.swift +++ b/apple/TablePro/CLI/BridgeMain.swift @@ -1,7 +1,7 @@ import Foundation import os import TableProMCP -import TableProUtilities +import TableProProcess @main struct TableProMcpBridge { diff --git a/apple/TablePro/Core/Database/CLIToolVersionProbe.swift b/apple/TablePro/Core/Database/CLIToolVersionProbe.swift index 56551ce1f8..38ce4a21f3 100644 --- a/apple/TablePro/Core/Database/CLIToolVersionProbe.swift +++ b/apple/TablePro/Core/Database/CLIToolVersionProbe.swift @@ -6,7 +6,6 @@ import Foundation import os import TableProProcess -import TableProUtilities enum CLIToolVersionProbe { private static let logger = Logger(subsystem: "com.TablePro", category: "CLIToolVersionProbe") diff --git a/apple/TablePro/Core/Database/DatabaseManager+ScopedDriver.swift b/apple/TablePro/Core/Database/DatabaseManager+ScopedDriver.swift index 2189070fbf..c6929eda91 100644 --- a/apple/TablePro/Core/Database/DatabaseManager+ScopedDriver.swift +++ b/apple/TablePro/Core/Database/DatabaseManager+ScopedDriver.swift @@ -24,8 +24,8 @@ enum ScopedDriverRoute: Equatable { } /// What a table read's turn on the session driver came to. -private enum TableReadTurn: Sendable { - case ran(T) +private enum TableReadTurn: Sendable { + case ran(any Sendable) /// The route decided once the turn came, which is never the session driver. case moved(ScopedDriverRoute) } @@ -117,6 +117,28 @@ extension DatabaseManager { ownsSessionState: Bool = true, _ body: @Sendable @escaping (DatabaseDriver) async throws -> T ) async throws -> T { + try await Self.unboxed( + withBoxedScopedDriver( + scope: scope, + route: route, + workload: workload, + cancellation: cancellation, + ownsSessionState: ownsSessionState + ) { driver in + try await body(driver) + } + ) + } + + // The lease chain under the generic entry points runs boxed, so it is compiled once, not once per result type. + private func withBoxedScopedDriver( + scope: DatabaseScope, + route: ScopedDriverRoute, + workload: MetadataConnectionPool.Workload, + cancellation: DriverCancellationPolicy, + ownsSessionState: Bool, + _ body: @Sendable @escaping (DatabaseDriver) async throws -> any Sendable + ) async throws -> any Sendable { let leased = trackedLease(for: scope.connectionId, cancellation: cancellation, body) switch route { case .unavailable(let message): @@ -130,6 +152,13 @@ extension DatabaseManager { } } + nonisolated private static func unboxed(_ value: any Sendable) -> T { + guard let result = value as? T else { + preconditionFailure("A lease returned \(type(of: value)) where \(T.self) was expected") + } + return result + } + // A read that stops on the server once the task awaiting it is cancelled. It runs under a lease owner of its own, // so the cancel reaches this read and nothing else on the connection. func withCancellableRead( @@ -139,10 +168,29 @@ extension DatabaseManager { ownsSessionState: Bool = true, _ body: @Sendable @escaping (DatabaseDriver) async throws -> T ) async throws -> T { + try await Self.unboxed( + withBoxedCancellableRead( + scope: scope, + route: route, + workload: workload, + ownsSessionState: ownsSessionState + ) { driver in + try await body(driver) + } + ) + } + + private func withBoxedCancellableRead( + scope: DatabaseScope, + route: ScopedDriverRoute, + workload: MetadataConnectionPool.Workload, + ownsSessionState: Bool, + _ body: @Sendable @escaping (DatabaseDriver) async throws -> any Sendable + ) async throws -> any Sendable { let owner = DriverLeaseOwner() let connectionId = scope.connectionId return try await withTaskCancellationHandler { - try await withScopedDriver( + try await withBoxedScopedDriver( scope: scope, route: route, workload: workload, @@ -191,6 +239,18 @@ extension DatabaseManager { cancellation: DriverCancellationPolicy, _ body: @Sendable @escaping (DatabaseDriver) async throws -> T ) async throws -> T { + try await Self.unboxed( + withBoxedTableReadDriver(scope: scope, cancellation: cancellation) { driver in + try await body(driver) + } + ) + } + + private func withBoxedTableReadDriver( + scope: DatabaseScope, + cancellation: DriverCancellationPolicy, + _ body: @Sendable @escaping (DatabaseDriver) async throws -> any Sendable + ) async throws -> any Sendable { let leased = trackedLease(for: scope.connectionId, cancellation: cancellation, body) var route = tableReadRoute(for: scope) while true { @@ -382,10 +442,10 @@ extension DatabaseManager { /// The route is asked again through `tableReadRoute` itself, so it reads the same inputs the /// caller's first answer did, the browsed database among them. The driver's own connection is no /// substitute: it carries the database name the connection resolved to, not the one browsed. - private func withTableReadSessionDriver( + private func withTableReadSessionDriver( scope: DatabaseScope, - _ body: @Sendable @escaping (DatabaseDriver) async throws -> T - ) async throws -> TableReadTurn { + _ body: @Sendable @escaping (DatabaseDriver) async throws -> any Sendable + ) async throws -> TableReadTurn { try await withSessionDriverTurn(scope: scope, ownsSessionState: false) { driver in let route = tableReadRoute(for: scope) guard route == .sessionDriver else { return .moved(route) } diff --git a/apple/TablePro/Core/Process/PipeReader.swift b/apple/TablePro/Core/Process/PipeReader.swift index 916db0a0e0..e528b495df 100644 --- a/apple/TablePro/Core/Process/PipeReader.swift +++ b/apple/TablePro/Core/Process/PipeReader.swift @@ -5,7 +5,7 @@ import Foundation import os -import TableProUtilities +import TableProProcess internal final class PipeReader: @unchecked Sendable { private static let logger = Logger(subsystem: "com.TablePro", category: "PipeReader") diff --git a/apple/TablePro/Core/Services/Infrastructure/ConnectionScriptRunner.swift b/apple/TablePro/Core/Services/Infrastructure/ConnectionScriptRunner.swift index 8f1f1379b4..064f3f2944 100644 --- a/apple/TablePro/Core/Services/Infrastructure/ConnectionScriptRunner.swift +++ b/apple/TablePro/Core/Services/Infrastructure/ConnectionScriptRunner.swift @@ -6,7 +6,6 @@ import Darwin import Foundation import TableProProcess -import TableProUtilities enum ConnectionScriptOutcome: Equatable, Sendable { case succeeded diff --git a/apple/TableProTests/Core/Process/PipeReaderTests.swift b/apple/TableProTests/Core/Process/PipeReaderTests.swift index ca96e68471..b6adc42f37 100644 --- a/apple/TableProTests/Core/Process/PipeReaderTests.swift +++ b/apple/TableProTests/Core/Process/PipeReaderTests.swift @@ -3,8 +3,8 @@ import Foundation import Testing @testable import TablePro +import TableProProcess import TableProTestSupport -@testable import TableProUtilities struct PipeReaderTests { private final class Received: @unchecked Sendable { diff --git a/apple/TableProTests/Database/ProcessNativeDumpRunnerTests.swift b/apple/TableProTests/Database/ProcessNativeDumpRunnerTests.swift index b65d93bf32..a8047aff9a 100644 --- a/apple/TableProTests/Database/ProcessNativeDumpRunnerTests.swift +++ b/apple/TableProTests/Database/ProcessNativeDumpRunnerTests.swift @@ -8,8 +8,8 @@ import Foundation import Testing @testable import TablePro +import TableProProcess import TableProTestSupport -@testable import TableProUtilities struct ProcessNativeDumpRunnerTests { // A stand-in dump tool: the runner refuses a shell as the executable, as it does for every app-run tool. diff --git a/apple/project.yml b/apple/project.yml index 7c0b67e1d3..0fcb5d2dfd 100644 --- a/apple/project.yml +++ b/apple/project.yml @@ -103,6 +103,7 @@ targetTemplates: COMBINE_HIDPI_IMAGES: YES DEVELOPMENT_TEAM: $(TABLEPRO_DEVELOPMENT_TEAM) ENABLE_HARDENED_RUNTIME: YES + EXPORTED_SYMBOLS_FILE: $(SRCROOT)/Configs/NoExportedSymbols.exp GENERATE_INFOPLIST_FILE: YES INFOPLIST_FILE: Plugins/${folder}/Info.plist INFOPLIST_KEY_NSPrincipalClass: $(PRODUCT_MODULE_NAME).${principalClass} @@ -474,6 +475,8 @@ targets: Release: CODE_SIGN_ENTITLEMENTS: TablePro/TablePro.entitlements COPY_PHASE_STRIP: YES + # Debug keeps its exports: the test bundle links against the app. + EXPORTED_SYMBOLS_FILE: $(SRCROOT)/Configs/NoExportedSymbols.exp # ─── Plugin ABI ─────────────────────────────────────────────────────────────── @@ -518,11 +521,14 @@ targets: - TablePro/CLI/BridgeMain.swift dependencies: - package: TableProMacCore - products: [TableProMCP, TableProUtilities] + product: TableProMCP + - package: TableProCore + product: TableProProcess scheme: {} settings: base: ENABLE_HARDENED_RUNTIME: YES + EXPORTED_SYMBOLS_FILE: $(SRCROOT)/Configs/NoExportedSymbols.exp PRODUCT_BUNDLE_IDENTIFIER: com.TablePro.tablepro-mcp # The app embeds it; installed on its own it turns the app archive into a generic one. SKIP_INSTALL: YES @@ -544,6 +550,7 @@ targets: settings: base: ENABLE_HARDENED_RUNTIME: YES + EXPORTED_SYMBOLS_FILE: $(SRCROOT)/Configs/NoExportedSymbols.exp PRODUCT_BUNDLE_IDENTIFIER: com.TablePro.tablepro-cli # The app embeds it; installed on its own it turns the app archive into a generic one. SKIP_INSTALL: YES @@ -1319,6 +1326,8 @@ targets: product: TableProGoogleCloud - package: TableProCore product: TableProFirebaseCore + - package: TableProCore + product: TableProFirebaseClient - package: TableProCore product: TableProLogRedaction @@ -1330,6 +1339,8 @@ targets: dependencies: - package: TableProCore product: TableProQdrantCore + - package: TableProCore + product: TableProQdrantClient - package: TableProCore product: TableProTLSClientIdentity @@ -1341,6 +1352,8 @@ targets: dependencies: - package: TableProCore product: TableProWeaviateCore + - package: TableProCore + product: TableProWeaviateClient InfluxDBDriverPlugin: templates: [DriverPlugin] diff --git a/apple/scripts/probes/check-qdrant.sh b/apple/scripts/probes/check-qdrant.sh index 1a4b551f33..a4056a0dba 100755 --- a/apple/scripts/probes/check-qdrant.sh +++ b/apple/scripts/probes/check-qdrant.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # -# Run TableProQdrantCore against a live Qdrant node: cursor paging, every filter kind, sorting with -# keyless points, typed payload and vector writes, the insert id check, facet, export, truncate and -# drop. The probe creates and drops a collection named tablepro_probe. +# Run TableProQdrantCore and TableProQdrantClient against a live Qdrant node: cursor paging, every +# filter kind, sorting with keyless points, typed payload and vector writes, the insert id check, +# facet, export, truncate and drop. The probe creates and drops a collection named tablepro_probe. # # Usage: # scripts/probes/check-qdrant.sh [host] [port] @@ -35,7 +35,10 @@ let package = Package( name: "probe", platforms: [.macOS(.v14)], dependencies: [.package(path: "$CORE")], - targets: [.executableTarget(name: "probe", dependencies: [.product(name: "TableProQdrantCore", package: "TableProCore")])] + targets: [.executableTarget(name: "probe", dependencies: [ + .product(name: "TableProQdrantCore", package: "TableProCore"), + .product(name: "TableProQdrantClient", package: "TableProCore") + ])] ) MANIFEST diff --git a/apple/scripts/probes/qdrant-probe.swift b/apple/scripts/probes/qdrant-probe.swift index 1e0c7b0a23..fb61a608c8 100644 --- a/apple/scripts/probes/qdrant-probe.swift +++ b/apple/scripts/probes/qdrant-probe.swift @@ -1,7 +1,8 @@ import Foundation +import TableProQdrantClient import TableProQdrantCore -// Measures, against a live node, the Qdrant behavior TableProQdrantCore hard-codes. +// Measures, against a live node, the Qdrant behavior TableProQdrantCore and TableProQdrantClient hard-code. // Run through check-qdrant.sh, which builds it against this checkout's TableProCore. var failures = 0 From 2c747f4c5f63395379bb29bec71812a22094cf4c Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 12 Nov 2026 15:04:48 +0700 Subject: [PATCH 2/3] refactor(macos): drop the TableProUtilities import AgentCLIProcess no longer needs --- apple/TablePro/Core/AI/CLI/AgentCLIProcess.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/apple/TablePro/Core/AI/CLI/AgentCLIProcess.swift b/apple/TablePro/Core/AI/CLI/AgentCLIProcess.swift index 15468e4759..1a3cc41198 100644 --- a/apple/TablePro/Core/AI/CLI/AgentCLIProcess.swift +++ b/apple/TablePro/Core/AI/CLI/AgentCLIProcess.swift @@ -6,7 +6,6 @@ import Foundation import os import TableProProcess -import TableProUtilities enum AgentCLIError: Error, LocalizedError { case notInstalled(String) From 508055ad997bbbaceca1e96f22e2e4b2b464079d Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 12 Nov 2026 15:05:09 +0700 Subject: [PATCH 3/3] docs(macos): changelog fragment for the smaller binaries --- apple/changelog.d/4233.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 apple/changelog.d/4233.changed.md diff --git a/apple/changelog.d/4233.changed.md b/apple/changelog.d/4233.changed.md new file mode 100644 index 0000000000..63fb3e9c5d --- /dev/null +++ b/apple/changelog.d/4233.changed.md @@ -0,0 +1 @@ +TablePro and its plugins are smaller to download and install.