Skip to content

Commit 12b6560

Browse files
committed
refactor: interfaces to be more clear
1 parent 78d21c0 commit 12b6560

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

packages/common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { CrudEntry, CrudEntryJSON } from './sync/bucket/CrudEntry.js';
2424
import { CrudTransaction } from './sync/bucket/CrudTransaction.js';
2525
import {
2626
DEFAULT_CRUD_UPLOAD_THROTTLE_MS,
27-
type PowerSyncConnectionOptionalOptions,
27+
type AdditionalConnectionOptions,
2828
type PowerSyncConnectionOptions,
2929
StreamingSyncImplementation,
3030
StreamingSyncImplementationListener
@@ -36,7 +36,7 @@ export interface DisconnectAndClearOptions {
3636
clearLocal?: boolean;
3737
}
3838

39-
export interface BasePowerSyncDatabaseOptions extends PowerSyncConnectionOptionalOptions {
39+
export interface BasePowerSyncDatabaseOptions extends AdditionalConnectionOptions {
4040
/** Schema used for the local database. */
4141
schema: Schema;
4242
logger?: ILogger;
@@ -233,7 +233,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
233233

234234
protected abstract generateSyncStreamImplementation(
235235
connector: PowerSyncBackendConnector,
236-
options?: PowerSyncConnectionOptionalOptions
236+
options?: AdditionalConnectionOptions
237237
): StreamingSyncImplementation;
238238

239239
protected abstract generateBucketStorageAdapter(): BucketStorageAdapter;

packages/common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,16 @@ export interface LockOptions<T> {
3737
signal?: AbortSignal;
3838
}
3939

40-
export interface AbstractStreamingSyncImplementationOptions {
40+
export interface AbstractStreamingSyncImplementationOptions extends AdditionalConnectionOptions {
4141
adapter: BucketStorageAdapter;
4242
uploadCrud: () => Promise<void>;
43-
crudUploadThrottleMs?: number;
4443
/**
4544
* An identifier for which PowerSync DB this sync implementation is
4645
* linked to. Most commonly DB name, but not restricted to DB name.
4746
*/
4847
identifier?: string;
4948
logger?: ILogger;
5049
remote: AbstractRemote;
51-
retryDelayMs?: number;
5250
}
5351

5452
export interface StreamingSyncImplementationListener extends BaseListener {
@@ -67,23 +65,21 @@ export interface StreamingSyncImplementationListener extends BaseListener {
6765
* Configurable options to be used when connecting to the PowerSync
6866
* backend instance.
6967
*/
70-
export interface PowerSyncConnectionOptions extends PowerSyncConnectionOptionalOptions, PowerSyncConnectionRequiredOptions {}
71-
72-
export interface PowerSyncConnectionRequiredOptions {
73-
/**
68+
export interface PowerSyncConnectionOptions extends AdditionalConnectionOptions {
69+
/**
7470
* The connection method to use when streaming updates from
7571
* the PowerSync backend instance.
7672
* Defaults to a HTTP streaming connection.
7773
*/
78-
connectionMethod: SyncStreamConnectionMethod;
74+
connectionMethod: SyncStreamConnectionMethod;
7975

80-
/**
81-
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
82-
*/
83-
params: Record<string, StreamingSyncRequestParameterType>;
76+
/**
77+
* These parameters are passed to the sync rules, and will be available under the`user_parameters` object.
78+
*/
79+
params: Record<string, StreamingSyncRequestParameterType>;
8480
}
8581

86-
export interface PowerSyncConnectionOptionalOptions {
82+
export interface AdditionalConnectionOptions {
8783
/**
8884
* Delay for retrying sync streaming operations
8985
* from the PowerSync backend after an error occurs.
@@ -126,7 +122,7 @@ export const DEFAULT_STREAMING_SYNC_OPTIONS = {
126122
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
127123
};
128124

129-
export const DEFAULT_STREAM_CONNECTION_OPTIONS: PowerSyncConnectionRequiredOptions = {
125+
export const DEFAULT_STREAM_CONNECTION_OPTIONS: PowerSyncConnectionOptions = {
130126
connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET,
131127
params: {}
132128
};
@@ -444,7 +440,7 @@ The next upload iteration will be delayed.`);
444440
type: LockType.SYNC,
445441
signal,
446442
callback: async () => {
447-
const resolvedOptions: PowerSyncConnectionRequiredOptions = {
443+
const resolvedOptions: PowerSyncConnectionOptions = {
448444
...DEFAULT_STREAM_CONNECTION_OPTIONS,
449445
...(options ?? {})
450446
};

packages/web/src/db/PowerSyncDatabase.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
type PowerSyncBackendConnector,
44
type PowerSyncCloseOptions,
55
type PowerSyncConnectionOptions,
6-
type PowerSyncConnectionOptionalOptions,
6+
type AdditionalConnectionOptions,
77
AbstractPowerSyncDatabase,
88
DBAdapter,
99
DEFAULT_POWERSYNC_CLOSE_OPTIONS,
@@ -168,7 +168,7 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
168168
protected generateSyncStreamImplementation(
169169
connector: PowerSyncBackendConnector,
170170
// This is used to pass in options on connection instead of only during db creation
171-
options?: PowerSyncConnectionOptionalOptions
171+
options?: AdditionalConnectionOptions
172172
): StreamingSyncImplementation {
173173
const remote = new WebRemote(connector);
174174
// Use the options passed in during connect, or fallback to the options set during database creation

0 commit comments

Comments
 (0)