Skip to content

Commit 7366712

Browse files
authored
Merge pull request #274 from datlechin/feat/plugin-ui-capability-metadata
feat: extend DriverPlugin with UI/capability metadata
2 parents 5372d66 + c713761 commit 7366712

File tree

15 files changed

+600
-0
lines changed

15 files changed

+600
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Plugin UI/capability metadata: each driver plugin now self-declares brand color, connection mode, supported features, column types, URL schemes, and grouping strategy via the `DriverPlugin` protocol
1213
- Copy as INSERT/UPDATE SQL statements from data grid context menu
1314
- Plugin download count display in Browse Plugins — fetched from GitHub Releases API and cached for 1 hour
1415
- MSSQL query cancellation (`cancelQuery`) and lock timeout (`applyQueryTimeout`) support

Plugins/ClickHouseDriverPlugin/ClickHousePlugin.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,30 @@ final class ClickHousePlugin: NSObject, TableProPlugin, DriverPlugin {
1818
static let iconName = "bolt.fill"
1919
static let defaultPort = 8123
2020

21+
// MARK: - UI/Capability Metadata
22+
23+
static let brandColorHex = "#FFD100"
24+
static let supportsForeignKeys = false
25+
static let systemDatabaseNames: [String] = ["information_schema", "INFORMATION_SCHEMA", "system"]
26+
static let columnTypesByCategory: [String: [String]] = [
27+
"Integer": [
28+
"UInt8", "UInt16", "UInt32", "UInt64", "UInt128", "UInt256",
29+
"Int8", "Int16", "Int32", "Int64", "Int128", "Int256"
30+
],
31+
"Float": ["Float32", "Float64", "Decimal", "Decimal32", "Decimal64", "Decimal128", "Decimal256"],
32+
"String": ["String", "FixedString", "Enum8", "Enum16"],
33+
"Date": ["Date", "Date32", "DateTime", "DateTime64"],
34+
"Binary": [],
35+
"Boolean": ["Bool"],
36+
"JSON": ["JSON"],
37+
"UUID": ["UUID"],
38+
"Array": ["Array"],
39+
"Map": ["Map"],
40+
"Tuple": ["Tuple"],
41+
"IP": ["IPv4", "IPv6"],
42+
"Geo": ["Point", "Ring", "Polygon", "MultiPolygon"]
43+
]
44+
2145
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2246
ClickHousePluginDriver(config: config)
2347
}

Plugins/DuckDBDriverPlugin/DuckDBPlugin.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ final class DuckDBPlugin: NSObject, TableProPlugin, DriverPlugin {
1919
static let iconName = "duckdb-icon"
2020
static let defaultPort = 0
2121

22+
// MARK: - UI/Capability Metadata
23+
24+
static let requiresAuthentication = false
25+
static let connectionMode: ConnectionMode = .fileBased
26+
static let urlSchemes: [String] = ["duckdb"]
27+
static let fileExtensions: [String] = ["duckdb", "db"]
28+
static let brandColorHex = "#FFD900"
29+
static let supportsDatabaseSwitching = false
30+
static let systemDatabaseNames: [String] = ["information_schema", "pg_catalog"]
31+
static let databaseGroupingStrategy: GroupingStrategy = .flat
32+
static let columnTypesByCategory: [String: [String]] = [
33+
"Integer": ["TINYINT", "SMALLINT", "INTEGER", "BIGINT", "HUGEINT", "UTINYINT", "USMALLINT", "UINTEGER", "UBIGINT"],
34+
"Float": ["FLOAT", "DOUBLE", "DECIMAL", "NUMERIC"],
35+
"String": ["VARCHAR", "TEXT", "CHAR", "BPCHAR"],
36+
"Date": ["DATE", "TIME", "TIMESTAMP", "TIMESTAMPTZ", "TIMESTAMP_S", "TIMESTAMP_MS", "TIMESTAMP_NS", "INTERVAL"],
37+
"Binary": ["BLOB", "BYTEA", "BIT", "BITSTRING"],
38+
"Boolean": ["BOOLEAN"],
39+
"JSON": ["JSON"],
40+
"UUID": ["UUID"],
41+
"List": ["LIST"],
42+
"Struct": ["STRUCT"],
43+
"Map": ["MAP"],
44+
"Union": ["UNION"],
45+
"Enum": ["ENUM"]
46+
]
47+
2248
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2349
DuckDBPluginDriver(config: config)
2450
}

Plugins/MSSQLDriverPlugin/MSSQLPlugin.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ final class MSSQLPlugin: NSObject, TableProPlugin, DriverPlugin {
2222
ConnectionField(id: "mssqlSchema", label: "Schema", placeholder: "dbo")
2323
]
2424

25+
// MARK: - UI/Capability Metadata
26+
27+
static let brandColorHex = "#E34517"
28+
static let systemDatabaseNames: [String] = ["master", "tempdb", "model", "msdb"]
29+
static let databaseGroupingStrategy: GroupingStrategy = .bySchema
30+
static let columnTypesByCategory: [String: [String]] = [
31+
"Integer": ["TINYINT", "SMALLINT", "INT", "BIGINT"],
32+
"Float": ["FLOAT", "REAL", "DECIMAL", "NUMERIC", "MONEY", "SMALLMONEY"],
33+
"String": ["CHAR", "VARCHAR", "TEXT", "NCHAR", "NVARCHAR", "NTEXT"],
34+
"Date": ["DATE", "TIME", "DATETIME", "DATETIME2", "SMALLDATETIME", "DATETIMEOFFSET"],
35+
"Binary": ["BINARY", "VARBINARY", "IMAGE"],
36+
"Boolean": ["BIT"],
37+
"XML": ["XML"],
38+
"UUID": ["UNIQUEIDENTIFIER"],
39+
"Spatial": ["GEOMETRY", "GEOGRAPHY"],
40+
"Other": ["SQL_VARIANT", "TIMESTAMP", "ROWVERSION", "CURSOR", "TABLE", "HIERARCHYID"]
41+
]
42+
2543
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2644
MSSQLPluginDriver(config: config)
2745
}

Plugins/MongoDBDriverPlugin/MongoDBPlugin.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,29 @@ final class MongoDBPlugin: NSObject, TableProPlugin, DriverPlugin {
2222
ConnectionField(id: "mongoWriteConcern", label: "Write Concern", placeholder: "majority")
2323
]
2424

25+
// MARK: - UI/Capability Metadata
26+
27+
static let requiresAuthentication = false
28+
static let urlSchemes: [String] = ["mongodb", "mongodb+srv"]
29+
static let brandColorHex = "#00ED63"
30+
static let queryLanguageName = "MQL"
31+
static let editorLanguage: EditorLanguage = .javascript
32+
static let supportsForeignKeys = false
33+
static let supportsSchemaEditing = false
34+
static let systemDatabaseNames: [String] = ["admin", "local", "config"]
35+
static let databaseGroupingStrategy: GroupingStrategy = .flat
36+
static let columnTypesByCategory: [String: [String]] = [
37+
"String": ["string", "objectId", "regex"],
38+
"Number": ["int", "long", "double", "decimal"],
39+
"Date": ["date", "timestamp"],
40+
"Binary": ["binData"],
41+
"Boolean": ["bool"],
42+
"Array": ["array"],
43+
"Object": ["object"],
44+
"Null": ["null"],
45+
"Other": ["javascript", "minKey", "maxKey"]
46+
]
47+
2548
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2649
MongoDBPluginDriver(config: config)
2750
}

Plugins/MySQLDriverPlugin/MySQLPlugin.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ final class MySQLPlugin: NSObject, TableProPlugin, DriverPlugin {
2525
static let additionalConnectionFields: [ConnectionField] = []
2626
static let additionalDatabaseTypeIds: [String] = ["MariaDB"]
2727

28+
// MARK: - UI/Capability Metadata
29+
30+
static let urlSchemes: [String] = ["mysql"]
31+
static let brandColorHex = "#FF9500"
32+
static let systemDatabaseNames: [String] = ["information_schema", "mysql", "performance_schema", "sys"]
33+
static let columnTypesByCategory: [String: [String]] = [
34+
"Integer": ["TINYINT", "SMALLINT", "MEDIUMINT", "INT", "INTEGER", "BIGINT"],
35+
"Float": ["FLOAT", "DOUBLE", "DECIMAL", "NUMERIC", "REAL"],
36+
"String": ["CHAR", "VARCHAR", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "ENUM", "SET"],
37+
"Date": ["DATE", "TIME", "DATETIME", "TIMESTAMP", "YEAR"],
38+
"Binary": ["BINARY", "VARBINARY", "TINYBLOB", "BLOB", "MEDIUMBLOB", "LONGBLOB", "BIT"],
39+
"Boolean": ["BOOLEAN", "BOOL"],
40+
"JSON": ["JSON"],
41+
"Spatial": ["GEOMETRY", "POINT", "LINESTRING", "POLYGON"]
42+
]
43+
2844
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2945
MySQLPluginDriver(config: config)
3046
}

Plugins/OracleDriverPlugin/OraclePlugin.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ final class OraclePlugin: NSObject, TableProPlugin, DriverPlugin {
2121
ConnectionField(id: "oracleServiceName", label: "Service Name", placeholder: "ORCL")
2222
]
2323

24+
// MARK: - UI/Capability Metadata
25+
26+
static let brandColorHex = "#C3160B"
27+
static let systemDatabaseNames: [String] = ["SYS", "SYSTEM", "OUTLN", "DBSNMP", "APPQOSSYS", "WMSYS", "XDB"]
28+
static let databaseGroupingStrategy: GroupingStrategy = .bySchema
29+
static let columnTypesByCategory: [String: [String]] = [
30+
"Integer": ["NUMBER", "INTEGER", "INT", "SMALLINT"],
31+
"Float": ["FLOAT", "BINARY_FLOAT", "BINARY_DOUBLE", "DECIMAL", "NUMERIC", "REAL", "DOUBLE PRECISION"],
32+
"String": ["VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR", "CLOB", "NCLOB", "LONG"],
33+
"Date": ["DATE", "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITH LOCAL TIME ZONE", "INTERVAL YEAR TO MONTH", "INTERVAL DAY TO SECOND"],
34+
"Binary": ["RAW", "LONG RAW", "BLOB", "BFILE"],
35+
"Boolean": [],
36+
"XML": ["XMLTYPE"],
37+
"Spatial": ["SDO_GEOMETRY"],
38+
"Other": ["ROWID", "UROWID"]
39+
]
40+
2441
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2542
OraclePluginDriver(config: config)
2643
}

Plugins/PostgreSQLDriverPlugin/PostgreSQLPlugin.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,29 @@ final class PostgreSQLPlugin: NSObject, TableProPlugin, DriverPlugin {
2424
static let additionalConnectionFields: [ConnectionField] = []
2525
static let additionalDatabaseTypeIds: [String] = ["Redshift"]
2626

27+
// MARK: - UI/Capability Metadata
28+
29+
static let urlSchemes: [String] = ["postgresql", "postgres"]
30+
static let brandColorHex = "#336791"
31+
static let systemDatabaseNames: [String] = ["postgres", "template0", "template1"]
32+
static let databaseGroupingStrategy: GroupingStrategy = .bySchema
33+
static let columnTypesByCategory: [String: [String]] = [
34+
"Integer": ["SMALLINT", "INTEGER", "BIGINT", "SERIAL", "BIGSERIAL", "SMALLSERIAL"],
35+
"Float": ["REAL", "DOUBLE PRECISION", "NUMERIC", "DECIMAL", "MONEY"],
36+
"String": ["CHARACTER VARYING", "VARCHAR", "CHARACTER", "CHAR", "TEXT", "NAME"],
37+
"Date": ["DATE", "TIME", "TIMESTAMP", "TIMESTAMPTZ", "INTERVAL", "TIME WITH TIME ZONE", "TIMESTAMP WITH TIME ZONE"],
38+
"Binary": ["BYTEA"],
39+
"Boolean": ["BOOLEAN"],
40+
"JSON": ["JSON", "JSONB"],
41+
"UUID": ["UUID"],
42+
"Array": ["ARRAY"],
43+
"Network": ["INET", "CIDR", "MACADDR", "MACADDR8"],
44+
"Geometric": ["POINT", "LINE", "LSEG", "BOX", "PATH", "POLYGON", "CIRCLE"],
45+
"Range": ["INT4RANGE", "INT8RANGE", "NUMRANGE", "TSRANGE", "TSTZRANGE", "DATERANGE"],
46+
"Text Search": ["TSVECTOR", "TSQUERY"],
47+
"XML": ["XML"]
48+
]
49+
2750
static func driverVariant(for databaseTypeId: String) -> String? {
2851
switch databaseTypeId {
2952
case "PostgreSQL": return "PostgreSQL"

Plugins/RedisDriverPlugin/RedisPlugin.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@ final class RedisPlugin: NSObject, TableProPlugin, DriverPlugin {
2424
static let additionalConnectionFields: [ConnectionField] = []
2525
static let additionalDatabaseTypeIds: [String] = []
2626

27+
// MARK: - UI/Capability Metadata
28+
29+
static let requiresAuthentication = false
30+
static let urlSchemes: [String] = ["redis"]
31+
static let brandColorHex = "#DC382D"
32+
static let queryLanguageName = "Redis CLI"
33+
static let editorLanguage: EditorLanguage = .bash
34+
static let supportsForeignKeys = false
35+
static let supportsSchemaEditing = false
36+
static let supportsDatabaseSwitching = false
37+
static let supportsImport = false
38+
static let databaseGroupingStrategy: GroupingStrategy = .flat
39+
static let defaultGroupName = "db0"
40+
static let columnTypesByCategory: [String: [String]] = [
41+
"String": ["string"],
42+
"List": ["list"],
43+
"Set": ["set"],
44+
"Sorted Set": ["zset"],
45+
"Hash": ["hash"],
46+
"Stream": ["stream"],
47+
"HyperLogLog": ["hyperloglog"],
48+
"Bitmap": ["bitmap"],
49+
"Geospatial": ["geo"]
50+
]
51+
2752
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2853
RedisPluginDriver(config: config)
2954
}

Plugins/SQLiteDriverPlugin/SQLitePlugin.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,24 @@ final class SQLitePlugin: NSObject, TableProPlugin, DriverPlugin {
1919
static let iconName = "doc.fill"
2020
static let defaultPort = 0
2121

22+
// MARK: - UI/Capability Metadata
23+
24+
static let requiresAuthentication = false
25+
static let connectionMode: ConnectionMode = .fileBased
26+
static let urlSchemes: [String] = ["sqlite"]
27+
static let fileExtensions: [String] = ["db", "sqlite", "sqlite3"]
28+
static let brandColorHex = "#003B57"
29+
static let supportsDatabaseSwitching = false
30+
static let databaseGroupingStrategy: GroupingStrategy = .flat
31+
static let columnTypesByCategory: [String: [String]] = [
32+
"Integer": ["INTEGER", "INT", "TINYINT", "SMALLINT", "MEDIUMINT", "BIGINT"],
33+
"Float": ["REAL", "DOUBLE", "FLOAT", "NUMERIC", "DECIMAL"],
34+
"String": ["TEXT", "VARCHAR", "CHARACTER", "CHAR", "CLOB", "NVARCHAR", "NCHAR"],
35+
"Date": ["DATE", "TIME", "DATETIME", "TIMESTAMP"],
36+
"Binary": ["BLOB"],
37+
"Boolean": ["BOOLEAN"]
38+
]
39+
2240
func createDriver(config: DriverConnectionConfig) -> any PluginDatabaseDriver {
2341
SQLitePluginDriver(config: config)
2442
}

0 commit comments

Comments
 (0)