Skip to content

Commit e577134

Browse files
committed
Update docs on fraction
1 parent 6fa0b6a commit e577134

File tree

5 files changed

+30
-33
lines changed

5 files changed

+30
-33
lines changed

packages/common/src/client/sync/bucket/SqliteBucketStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
213213
// The two parameters could be replaced with one, but: https://github.com/powersync-ja/better-sqlite3/pull/6
214214
const jsonBucketCount = JSON.stringify(bucketToCount);
215215
await tx.execute(
216-
'UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?->name WHERE ?->name IS NOT NULL',
216+
"UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?->name WHERE name != '$local' AND ?->name IS NOT NULL",
217217
[jsonBucketCount, jsonBucketCount]
218218
);
219219
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,7 @@ The next upload iteration will be delayed.`);
501501
return [req, localDescriptions];
502502
}
503503

504-
protected async streamingSyncIteration(
505-
signal: AbortSignal,
506-
options?: PowerSyncConnectionOptions
507-
): Promise<void> {
504+
protected async streamingSyncIteration(signal: AbortSignal, options?: PowerSyncConnectionOptions): Promise<void> {
508505
await this.obtainLock({
509506
type: LockType.SYNC,
510507
signal,
@@ -693,7 +690,7 @@ The next upload iteration will be delayed.`);
693690
* (uses the same one), this should have some delay.
694691
*/
695692
await this.delayRetry();
696-
return ;
693+
return;
697694
}
698695
this.triggerCrudUpload();
699696
} else {

packages/common/src/db/crud/SyncProgress.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,19 @@ export interface ProgressWithOperations {
3636

3737
/**
3838
* Relative progress, as {@link downloadedOperations} of {@link totalOperations}.
39+
*
40+
* This will be a number between `0.0` and `1.0` (inclusive).
3941
*
40-
* This will be a number between `0.0` and `1.0`.
42+
* When this number reaches `1.0`, all changes have been received from the sync service.
43+
* Actually applying these changes happens before the `downloadProgress` field is cleared from
44+
* {@link SyncStatus}, so progress can stay at `1.0` for a short while before completing.
4145
*/
4246
downloadedFraction: number;
4347
}
4448

4549
/**
4650
* Provides realtime progress on how PowerSync is downloading rows.
47-
*
51+
*
4852
* The progress until the next complete sync is available through the fields on {@link ProgressWithOperations},
4953
* which this class implements.
5054
* Additionally, the {@link SyncProgress.untilPriority} method can be used to otbain progress towards
@@ -63,7 +67,6 @@ export interface ProgressWithOperations {
6367
* to be updated one-by-one.
6468
*/
6569
export class SyncProgress implements ProgressWithOperations {
66-
6770
totalOperations: number;
6871
downloadedOperations: number;
6972
downloadedFraction: number;

packages/common/src/db/crud/SyncStatus.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class SyncStatus {
4242

4343
/**
4444
* Indicates if the client is currently connected to the PowerSync service.
45-
*
45+
*
4646
* @returns {boolean} True if connected, false otherwise. Defaults to false if not specified.
4747
*/
4848
get connected() {
@@ -51,7 +51,7 @@ export class SyncStatus {
5151

5252
/**
5353
* Indicates if the client is in the process of establishing a connection to the PowerSync service.
54-
*
54+
*
5555
* @returns {boolean} True if connecting, false otherwise. Defaults to false if not specified.
5656
*/
5757
get connecting() {
@@ -61,7 +61,7 @@ export class SyncStatus {
6161
/**
6262
* Time that a last sync has fully completed, if any.
6363
* This timestamp is reset to null after a restart of the PowerSync service.
64-
*
64+
*
6565
* @returns {Date | undefined} The timestamp of the last successful sync, or undefined if no sync has completed.
6666
*/
6767
get lastSyncedAt() {
@@ -70,7 +70,7 @@ export class SyncStatus {
7070

7171
/**
7272
* Indicates whether there has been at least one full sync completed since initialization.
73-
*
73+
*
7474
* @returns {boolean | undefined} True if at least one sync has completed, false if no sync has completed,
7575
* or undefined when the state is still being loaded from the database.
7676
*/
@@ -80,7 +80,7 @@ export class SyncStatus {
8080

8181
/**
8282
* Provides the current data flow status regarding uploads and downloads.
83-
*
83+
*
8484
* @returns {SyncDataFlowStatus} An object containing:
8585
* - downloading: True if actively downloading changes (only when connected is also true)
8686
* - uploading: True if actively uploading changes
@@ -104,7 +104,7 @@ export class SyncStatus {
104104

105105
/**
106106
* Provides sync status information for all bucket priorities, sorted by priority (highest first).
107-
*
107+
*
108108
* @returns {SyncPriorityStatus[]} An array of status entries for different sync priority levels,
109109
* sorted with highest priorities (lower numbers) first.
110110
*/
@@ -128,18 +128,18 @@ export class SyncStatus {
128128
}
129129

130130
/**
131-
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
131+
* Reports the sync status (a pair of {@link SyncStatus#hasSynced} and {@link SyncStatus#lastSyncedAt} fields)
132132
* for a specific bucket priority level.
133-
*
133+
*
134134
* When buckets with different priorities are declared, PowerSync may choose to synchronize higher-priority
135135
* buckets first. When a consistent view over all buckets for all priorities up until the given priority is
136136
* reached, PowerSync makes data from those buckets available before lower-priority buckets have finished
137137
* syncing.
138-
*
139-
* This method returns the status for the requested priority or the next higher priority level that has
140-
* status information available. This is because when PowerSync makes data for a given priority available,
138+
*
139+
* This method returns the status for the requested priority or the next higher priority level that has
140+
* status information available. This is because when PowerSync makes data for a given priority available,
141141
* all buckets in higher-priorities are guaranteed to be consistent with that checkpoint.
142-
*
142+
*
143143
* For example, if PowerSync just finished synchronizing buckets in priority level 3, calling this method
144144
* with a priority of 1 may return information for priority level 3.
145145
*
@@ -166,7 +166,7 @@ export class SyncStatus {
166166
/**
167167
* Compares this SyncStatus instance with another to determine if they are equal.
168168
* Equality is determined by comparing the serialized JSON representation of both instances.
169-
*
169+
*
170170
* @param {SyncStatus} status The SyncStatus instance to compare against
171171
* @returns {boolean} True if the instances are considered equal, false otherwise
172172
*/
@@ -177,7 +177,7 @@ export class SyncStatus {
177177
/**
178178
* Creates a human-readable string representation of the current sync status.
179179
* Includes information about connection state, sync completion, and data flow.
180-
*
180+
*
181181
* @returns {string} A string representation of the sync status
182182
*/
183183
getMessage() {
@@ -187,7 +187,7 @@ export class SyncStatus {
187187

188188
/**
189189
* Serializes the SyncStatus instance to a plain object.
190-
*
190+
*
191191
* @returns {SyncStatusOptions} A plain object representation of the sync status
192192
*/
193193
toJSON(): SyncStatusOptions {

packages/node/src/db/PowerSyncDatabase.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import { Dispatcher } from 'undici';
2424

2525
export type NodePowerSyncDatabaseOptions = PowerSyncDatabaseOptions & {
2626
database: DBAdapter | SQLOpenFactory | NodeSQLOpenOptions;
27-
/**
27+
/**
2828
* Options to override how the SDK will connect to the sync service.
2929
*
3030
* This option is intended to be used for internal tests.
3131
*/
32-
remoteOptions?: Partial<AbstractRemoteOptions>;
32+
remoteOptions?: Partial<AbstractRemoteOptions>;
3333
};
3434

3535
export type NodeAdditionalConnectionOptions = AdditionalConnectionOptions & {
@@ -87,13 +87,10 @@ export class PowerSyncDatabase extends AbstractPowerSyncDatabase {
8787
connector: PowerSyncBackendConnector,
8888
options: NodeAdditionalConnectionOptions
8989
): AbstractStreamingSyncImplementation {
90-
const remote = new NodeRemote(
91-
connector, this.options.logger,
92-
{
93-
dispatcher: options.dispatcher,
94-
...(this.options as NodePowerSyncDatabaseOptions).remoteOptions,
95-
}
96-
);
90+
const remote = new NodeRemote(connector, this.options.logger, {
91+
dispatcher: options.dispatcher,
92+
...(this.options as NodePowerSyncDatabaseOptions).remoteOptions
93+
});
9794

9895
return new NodeStreamingSyncImplementation({
9996
adapter: this.bucketStorageAdapter,

0 commit comments

Comments
 (0)