Skip to content

Commit 86f3c1d

Browse files
authored
Merge pull request #726 from powersync-ja/expose-connection-params
feat: expose connection options
2 parents 3008dbc + d1f8396 commit 86f3c1d

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

.changeset/sharp-pans-sniff.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/common': minor
3+
---
4+
5+
Exposed the connection and connection option used by `connect()`

packages/common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,24 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
193193
return this.connectionManager.syncStreamImplementation;
194194
}
195195

196+
/**
197+
* The connector used to connect to the PowerSync service.
198+
*
199+
* @returns The connector used to connect to the PowerSync service or null if `connect()` has not been called.
200+
*/
201+
get connector() {
202+
return this.connectionManager.connector;
203+
}
204+
205+
/**
206+
* The resolved connection options used to connect to the PowerSync service.
207+
*
208+
* @returns The resolved connection options used to connect to the PowerSync service or null if `connect()` has not been called.
209+
*/
210+
get connectionOptions() {
211+
return this.connectionManager.connectionOptions;
212+
}
213+
196214
protected _schema: Schema;
197215

198216
private _database: DBAdapter;

packages/common/src/client/ConnectionManager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ export class ConnectionManager extends BaseObserver<ConnectionManagerListener> {
118118
this.syncDisposer = null;
119119
}
120120

121+
get connector() {
122+
return this.pendingConnectionOptions?.connector ?? null;
123+
}
124+
125+
get connectionOptions() {
126+
return this.pendingConnectionOptions?.options ?? null;
127+
}
128+
121129
get logger() {
122130
return this.options.logger;
123131
}

0 commit comments

Comments
 (0)