@powersync/web
Enumerations
| Enumeration | Description |
|---|---|
| AttachmentState | AttachmentState represents the current synchronization state of an attachment. |
| ColumnType | - |
| DiffTriggerOperation | SQLite operations to track changes for with TriggerManager |
| EncodingType | - |
| FetchStrategy | - |
| LockType | - |
| OpTypeEnum | - |
| PowerSyncControlCommand | - |
| PSInternalTable | - |
| RowUpdateType | Update table operation numbers from SQLite |
| SyncClientImplementation | - |
| SyncStreamConnectionMethod | - |
| TemporaryStorageOption | - |
| UpdateType | Type of local change. |
| WASQLiteVFS | List of currently tested virtual filesystems |
| WatchedQueryListenerEvent | - |
Classes
| Class | Description |
|---|---|
| AbortOperation | Calls to Abortcontroller.abort(reason: any) will result in the reason being thrown. This is not necessarily an error, but extends error for better logging purposes. |
| AbstractPowerSyncDatabase | - |
| AbstractPowerSyncDatabaseOpenFactory | - |
| AbstractQueryProcessor | Performs underlying watching and yields a stream of results. |
| AbstractRemote | - |
| AbstractStreamingSyncImplementation | - |
| AbstractWebPowerSyncDatabaseOpenFactory | Intermediate PowerSync Database Open factory for Web which uses a mock SSR DB Adapter if running on server side. Most SQLite DB implementations only run on client side, this will safely return empty query results in SSR which will allow for generating server partial views. |
| ArrayComparator | An efficient comparator for WatchedQuery created with Query#watch. This has the ability to determine if a query result has changes without necessarily processing all items in the result. |
| AttachmentContext | AttachmentContext provides database operations for managing attachment records. |
| AttachmentQueue | AttachmentQueue manages the lifecycle and synchronization of attachments between local and remote storage. Provides automatic synchronization, upload/download queuing, attachment monitoring, verification and repair of local files, and cleanup of archived attachments. |
| AttachmentService | Service for querying and watching attachment records in the database. |
| AttachmentTable | AttachmentTable defines the schema for the attachment queue table. |
| BaseObserver | - |
| Column | - |
| ConnectionClosedError | Thrown when an underlying database connection is closed. This is particularly relevant when worker connections are marked as closed while operations are still in progress. |
| ConnectionManager | - |
| ControlledExecutor | - |
| CrudBatch | A batch of client-side changes. |
| CrudEntry | A single client-side change. |
| CrudTransaction | A batch of client-side changes. |
| DataStream | A very basic implementation of a data stream with backpressure support which does not use native JS streams or async iterators. This is handy for environments such as React Native which need polyfills for the above. |
| DifferentialQueryProcessor | Uses the PowerSync onChange event to trigger watched queries. Results are emitted on every change of the relevant tables. |
| FetchImplementationProvider | Class wrapper for providing a fetch implementation. The class wrapper is used to distinguish the fetchImplementation option in [AbstractRemoteOptions] from the general fetch method which is typeof "function" |
| GetAllQuery | Performs a AbstractPowerSyncDatabase.getAll operation for a watched query. |
| Index | - |
| IndexDBFileSystemStorageAdapter | IndexDBFileSystemStorageAdapter implements LocalStorageAdapter using IndexedDB. Suitable for web browsers and web-based environments. |
| IndexedColumn | - |
| Mutex | An asynchronous mutex implementation. |
| OnChangeQueryProcessor | Uses the PowerSync onChange event to trigger watched queries. Results are emitted on every change of the relevant tables. |
| OplogEntry | - |
| OpType | Used internally for sync buckets. |
| PowerSyncDatabase | A PowerSync database which provides SQLite functionality which is automatically synced. |
| Schema | A schema is a collection of tables. It is used to define the structure of a database. |
| Semaphore | An asynchronous semaphore implementation with associated items per lease. |
| SharedWebStreamingSyncImplementation | The local part of the sync implementation on the web, which talks to a sync implementation hosted in a shared worker. |
| SqliteBucketStorage | - |
| SyncDataBatch | - |
| SyncDataBucket | - |
| SyncingService | Orchestrates attachment synchronization between local and remote storage. Handles uploads, downloads, deletions, and state transitions. |
| SyncProgress | Provides realtime progress on how PowerSync is downloading rows. |
| SyncStatus | - |
| Table | - |
| Generate a new table from the columns and indexes | |
| TriggerManagerImpl | - |
| UploadQueueStats | - |
| WASQLiteOpenFactory | Opens a SQLite connection using WA-SQLite. |
| - | |
| WebRemote | - |
| WebStreamingSyncImplementation | - |
Interfaces
AbstractQueryProcessorOptions<Data, Settings>
Internal
Extended by
Type Parameters
| Type Parameter | Default type |
|---|---|
Data | - |
Settings extends WatchedQueryOptions | WatchedQueryOptions |
Properties
| Property | Type |
|---|---|
db | AbstractPowerSyncDatabase |
placeholderData | Data |
watchOptions | Settings |
AbstractStreamingSyncImplementationOptions
Internal
Extends
Extended by
Properties
| Property | Type | Description | Overrides | Inherited from |
|---|---|---|---|---|
adapter | BucketStorageAdapter | - | - | - |
crudUploadThrottleMs | number | Backend Connector CRUD operations are throttled to occur at most every crudUploadThrottleMs milliseconds. | - | RequiredAdditionalConnectionOptions.crudUploadThrottleMs |
identifier? | string | An identifier for which PowerSync DB this sync implementation is linked to. Most commonly DB name, but not restricted to DB name. | - | - |
logger? | ILogger | - | - | - |
remote | AbstractRemote | - | - | - |
retryDelayMs | number | Delay for retrying sync streaming operations from the PowerSync backend after an error occurs. | - | RequiredAdditionalConnectionOptions.retryDelayMs |
subscriptions | SubscribedStream[] | - | RequiredAdditionalConnectionOptions.subscriptions | - |
uploadCrud | () => Promise<void> | - | - | - |
AdditionalConnectionOptions
Internal
Extended by
Properties
ArrayQueryDefinition<RowType>
Options for building a query with AbstractPowerSyncDatabase#query. This query will be executed with AbstractPowerSyncDatabase#getAll.
Type Parameters
| Type Parameter | Default type |
|---|---|
RowType | unknown |
Properties
| Property | Type | Description |
|---|---|---|
mapper? | (row: Record<string, unknown>) => RowType | Maps the raw SQLite row to a custom typed object. Example mapper: (row) => ({ ...row, created_at: new Date(row.created_at as string), }) |
parameters? | readonly Readonly<QueryParam>[] | - |
sql | string | - |
AttachmentErrorHandler
Experimental Alpha
SyncErrorHandler provides custom error handling for attachment sync operations. Implementations determine whether failed operations should be retried or archived.
This is currently experimental and may change without a major version bump.
Methods
onDeleteError()
onDeleteError(attachment, error): Promise<boolean>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | AttachmentRecord | The attachment that failed to delete |
error | unknown | The error encountered during the delete |
Returns
Promise<boolean>
true to retry the operation, false to archive the attachment
onDownloadError()
onDownloadError(attachment, error): Promise<boolean>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | AttachmentRecord | The attachment that failed to download |
error | unknown | The error encountered during the download |
Returns
Promise<boolean>
true to retry the operation, false to archive the attachment
onUploadError()
onUploadError(attachment, error): Promise<boolean>
Alpha
Parameters
| Parameter | Type | Description |
|---|---|---|
attachment | AttachmentRecord | The attachment that failed to upload |
error | unknown | The error encountered during the upload |
Returns
Promise<boolean>
true to retry the operation, false to archive the attachment
AttachmentRecord
Experimental
AttachmentRecord represents an attachment in the local database.
Properties
| Property | Type | Description |
|---|---|---|
filename | string | Experimental |
hasSynced? | boolean | Experimental |
id | string | Experimental |
localUri? | string | Experimental |
mediaType? | string | Experimental |
metaData? | string | Experimental |
size? | number | Experimental |
state | AttachmentState | Experimental |
timestamp? | number | Experimental |
AttachmentTableOptions
Extends
Omit<TableV2Options,"name"|"columns">
Properties
| Property | Type | Inherited from |
|---|---|---|
ignoreEmptyUpdates? | boolean | Omit.ignoreEmptyUpdates |
indexes? | IndexShorthand | Omit.indexes |
insertOnly? | boolean | Omit.insertOnly |
localOnly? | boolean | Omit.localOnly |
trackMetadata? | boolean | Omit.trackMetadata |
trackPrevious? | boolean | TrackPreviousOptions | Omit.trackPrevious |
viewName? | string | Omit.viewName |
BaseConnectionOptions
Internal
Extended by
Properties
| Property | Type | Description |
|---|---|---|
appMetadata? | Record<string, string> | A set of metadata to be included in service logs. |
clientImplementation? | SyncClientImplementation | Whether to use a JavaScript implementation to handle received sync lines from the sync service, or whether this work should be offloaded to the PowerSync core extension. This defaults to the JavaScript implementation (SyncClientImplementation.JAVASCRIPT) since the (SyncClientImplementation.RUST) implementation is experimental at the moment. |
connectionMethod? | SyncStreamConnectionMethod | The connection method to use when streaming updates from the PowerSync backend instance. Defaults to a HTTP streaming connection. |
fetchStrategy? | FetchStrategy | The fetch strategy to use when streaming updates from the PowerSync backend instance. |
includeDefaultStreams? | boolean | Whether to include streams that have auto_subscribe: true in their definition. This defaults to true. |
params? | Record<string, JSONValue> | These parameters are passed to the sync rules, and will be available under theuser_parameters object. |
serializedSchema? | any | The serialized schema - mainly used to forward information about raw tables to the sync client. |