Skip to content

Commit 69e9ec1

Browse files
committed
More code commenting
1 parent 457d890 commit 69e9ec1

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,15 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
9191
*/
9292
protected static transactionMutex: Mutex = new Mutex();
9393

94+
/**
95+
* Returns true if the connection is closed.
96+
*/
9497
closed: boolean;
9598
ready: boolean;
9699

100+
/**
101+
* Current connection status.
102+
*/
97103
currentStatus?: SyncStatus;
98104
syncStreamImplementation?: AbstractStreamingSyncImplementation;
99105
sdkVersion: string;
@@ -202,7 +208,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
202208
}
203209

204210
/**
205-
* Queues a CRUD upload when internal CRUD tables have been updated
211+
* Queues a CRUD upload when internal CRUD tables have been updated.
206212
*/
207213
protected async watchCrudUploads() {
208214
for await (const event of this.onChange({
@@ -223,7 +229,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
223229
}
224230

225231
/**
226-
* Connects to stream of events from PowerSync instance
232+
* Connects to stream of events from the PowerSync instance.
227233
*/
228234
async connect(connector: PowerSyncBackendConnector) {
229235
// close connection if one is open
@@ -293,7 +299,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
293299
});
294300
}
295301

296-
/*
302+
/**
297303
* Close the database, releasing resources.
298304
*
299305
* Also disconnects any active connection.
@@ -441,7 +447,8 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
441447
}
442448

443449
/**
444-
* Execute a statement and optionally return results.
450+
* Execute a write (INSERT/UPDATE/DELETE) query
451+
* and optionally return results.
445452
*/
446453
async execute(sql: string, parameters?: any[]) {
447454
await this.waitForReady();
@@ -624,6 +631,9 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
624631
});
625632
}
626633

634+
/**
635+
* @ignore
636+
*/
627637
private async executeReadOnly(sql: string, params: any[]) {
628638
await this.waitForReady();
629639
return this.database.readLock((tx) => tx.execute(sql, params));

packages/powersync-sdk-common/src/client/connection/PowerSyncBackendConnector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { PowerSyncCredentials } from './PowerSyncCredentials';
22
import type { AbstractPowerSyncDatabase } from '../AbstractPowerSyncDatabase';
33

44
export interface PowerSyncBackendConnector {
5-
/** Get credentials for PowerSync.
5+
/** Allows the PowerSync client to retrieve an authentication token from your backend
6+
* which is used to authenticate against the PowerSync service.
67
*
78
* This should always fetch a fresh set of credentials - don't use cached
89
* values.

packages/powersync-sdk-common/src/client/sync/bucket/CrudEntry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ import hash from 'object-hash';
77
*/
88
export type OpId = string;
99

10+
/**
11+
* Type of local change.
12+
*/
1013
export enum UpdateType {
14+
/** Insert or replace existing row. All non-null columns are included in the data. Generated by INSERT statements. */
1115
PUT = 'PUT',
16+
/** Update existing row. Contains the id, and value of each changed column. Generated by UPDATE statements. */
1217
PATCH = 'PATCH',
18+
/** Delete existing row. Contains the id. Generated by DELETE statements. */
1319
DELETE = 'DELETE'
1420
}
1521

packages/powersync-sdk-common/src/client/sync/bucket/OpType.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export enum OpTypeEnum {
77

88
export type OpTypeJSON = string;
99

10+
/**
11+
* Used internally for sync buckets.
12+
*/
1013
export class OpType {
1114
static fromJSON(jsonValue: OpTypeJSON) {
1215
return new OpType(OpTypeEnum[jsonValue]);

packages/powersync-sdk-common/src/utils/BaseObserver.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export class BaseObserver<T extends BaseListener = BaseListener> implements Base
1515
this.listeners = {};
1616
}
1717

18+
/**
19+
* Register a listener for updates on the PowerSync client.
20+
*/
1821
registerListener(listener: Partial<T>): () => void {
1922
const id = v4();
2023
this.listeners[id] = listener;

0 commit comments

Comments
 (0)