Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/rules/plugin-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name>` for a Release one:

```bash
nm -m "$BIN" | grep -v undefined | grep -E '_\$s17TableProPluginKit[0-9A-Za-z_]*Mn$' \
Expand Down
2 changes: 2 additions & 0 deletions apple/Configs/NoExportedSymbols.exp
Original file line number Diff line number Diff line change
@@ -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.
39 changes: 31 additions & 8 deletions apple/Packages/TableProCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down Expand Up @@ -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: [],
Expand All @@ -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"],
Expand All @@ -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: [],
Expand Down Expand Up @@ -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(
Expand All @@ -409,7 +432,7 @@ let package = Package(
),
.testTarget(
name: "TableProQdrantCoreTests",
dependencies: ["TableProQdrantCore"],
dependencies: ["TableProQdrantCore", "TableProQdrantClient"],
path: "Tests/TableProQdrantCoreTests",
swiftSettings: pluginCoreSettings
),
Expand Down Expand Up @@ -514,7 +537,7 @@ let package = Package(
),
.testTarget(
name: "TableProProcessTests",
dependencies: ["TableProProcess"],
dependencies: ["TableProProcess", "TableProTestSupport"],
path: "Tests/TableProProcessTests"
),
.testTarget(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore

public enum FirebaseFieldID {
public static let authMethod = "fbAuthMethod"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore
import TableProGoogleCloud

public final class FirestoreClient: @unchecked Sendable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore

public struct FirestoreDocument: Sendable, Equatable {
/// Relative to `.../documents`, such as `users/alice`.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore

public indirect enum FirestoreValue: Sendable, Hashable {
case null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore
import TableProGoogleCloud

public final class RealtimeDatabaseClient: @unchecked Sendable {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore

public struct RealtimeDatabaseRowSet: Sendable, Equatable {
public let columns: [String]
Expand Down Expand Up @@ -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
))
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import TableProFirebaseCore
import TableProGoogleCloud

public extension GoogleRESTResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
))
}
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
Loading
Loading