11import Foundation
22
3+ /// Configuration for the sync client used to connect to the PowerSync service.
4+ ///
5+ /// Provides options to customize network behavior and logging for PowerSync
6+ /// HTTP requests and responses.
7+ public struct SyncClientConfiguration {
8+ /// Optional configuration for logging PowerSync HTTP requests.
9+ ///
10+ /// When provided, network requests will be logged according to the
11+ /// specified `SyncRequestLoggerConfiguration`. Set to `nil` to disable request logging entirely.
12+ ///
13+ /// - SeeAlso: `SyncRequestLoggerConfiguration` for configuration options
14+ public let requestLogger : SyncRequestLoggerConfiguration ?
15+
16+ /// Creates a new sync client configuration.
17+ /// - Parameter requestLogger: Optional network logger configuration
18+ public init ( requestLogger: SyncRequestLoggerConfiguration ? = nil ) {
19+ self . requestLogger = requestLogger
20+ }
21+ }
22+
323/// Options for configuring a PowerSync connection.
424///
525/// Provides optional parameters to customize sync behavior such as throttling and retry policies.
@@ -42,21 +62,36 @@ public struct ConnectOptions {
4262 @_spi ( PowerSyncExperimental)
4363 public var newClientImplementation : Bool
4464
65+ /// Configuration for the sync client used for PowerSync requests.
66+ ///
67+ /// Provides options to customize network behavior including logging of HTTP
68+ /// requests and responses. When `nil`, default HTTP client settings are used
69+ /// with no network logging.
70+ ///
71+ /// Set this to configure network logging or other HTTP client behaviors
72+ /// specific to PowerSync operations.
73+ ///
74+ /// - SeeAlso: `SyncClientConfiguration` for available configuration options
75+ public var clientConfiguration : SyncClientConfiguration ?
76+
4577 /// Initializes a `ConnectOptions` instance with optional values.
4678 ///
4779 /// - Parameters:
4880 /// - crudThrottle: TimeInterval between CRUD operations in milliseconds. Defaults to `1` second.
4981 /// - retryDelay: Delay TimeInterval between retry attempts in milliseconds. Defaults to `5` seconds.
5082 /// - params: Custom sync parameters to send to the server. Defaults to an empty dictionary.
83+ /// - clientConfiguration: Configuration for the HTTP client used to connect to PowerSync.
5184 public init (
5285 crudThrottle: TimeInterval = 1 ,
5386 retryDelay: TimeInterval = 5 ,
54- params: JsonParam = [ : ]
87+ params: JsonParam = [ : ] ,
88+ clientConfiguration: SyncClientConfiguration ? = nil
5589 ) {
5690 self . crudThrottle = crudThrottle
5791 self . retryDelay = retryDelay
5892 self . params = params
5993 self . newClientImplementation = false
94+ self . clientConfiguration = clientConfiguration
6095 }
6196
6297 /// Initializes a ``ConnectOptions`` instance with optional values, including experimental options.
@@ -65,12 +100,14 @@ public struct ConnectOptions {
65100 crudThrottle: TimeInterval = 1 ,
66101 retryDelay: TimeInterval = 5 ,
67102 params: JsonParam = [ : ] ,
68- newClientImplementation: Bool = false
103+ newClientImplementation: Bool = false ,
104+ clientConfiguration: SyncClientConfiguration ? = nil
69105 ) {
70106 self . crudThrottle = crudThrottle
71107 self . retryDelay = retryDelay
72108 self . params = params
73109 self . newClientImplementation = newClientImplementation
110+ self . clientConfiguration = clientConfiguration
74111 }
75112}
76113
@@ -91,7 +128,6 @@ public protocol PowerSyncDatabaseProtocol: Queries {
91128 /// Wait for the first sync to occur
92129 func waitForFirstSync( ) async throws
93130
94-
95131 /// Replace the schema with a new version. This is for advanced use cases - typically the schema
96132 /// should just be specified once in the constructor.
97133 ///
@@ -179,7 +215,7 @@ public protocol PowerSyncDatabaseProtocol: Queries {
179215 /// The database can still be queried after this is called, but the tables
180216 /// would be empty.
181217 ///
182- /// - Parameter clearLocal: Set to false to preserve data in local-only tables.
218+ /// - Parameter clearLocal: Set to false to preserve data in local-only tables. Defaults to `true`.
183219 func disconnectAndClear( clearLocal: Bool ) async throws
184220
185221 /// Close the database, releasing resources.
@@ -229,8 +265,8 @@ public extension PowerSyncDatabaseProtocol {
229265 )
230266 }
231267
232- func disconnectAndClear( clearLocal : Bool = true ) async throws {
233- try await self . disconnectAndClear ( clearLocal: clearLocal )
268+ func disconnectAndClear( ) async throws {
269+ try await disconnectAndClear ( clearLocal: true )
234270 }
235271
236272 func getCrudBatch( limit: Int32 = 100 ) async throws -> CrudBatch ? {
0 commit comments