@powersync/common 1.53.1 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs +560 -353
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +560 -353
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +560 -353
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +560 -353
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +733 -198
- package/lib/attachments/AttachmentContext.d.ts +7 -6
- package/lib/attachments/AttachmentContext.js +2 -1
- package/lib/attachments/AttachmentContext.js.map +1 -1
- package/lib/attachments/AttachmentErrorHandler.d.ts +6 -6
- package/lib/attachments/AttachmentQueue.d.ts +61 -20
- package/lib/attachments/AttachmentQueue.js +16 -18
- package/lib/attachments/AttachmentQueue.js.map +1 -1
- package/lib/attachments/LocalStorageAdapter.d.ts +14 -8
- package/lib/attachments/LocalStorageAdapter.js +3 -0
- package/lib/attachments/LocalStorageAdapter.js.map +1 -1
- package/lib/attachments/RemoteStorageAdapter.d.ts +4 -4
- package/lib/attachments/Schema.d.ts +12 -4
- package/lib/attachments/Schema.js +8 -3
- package/lib/attachments/Schema.js.map +1 -1
- package/lib/attachments/WatchedAttachmentItem.d.ts +3 -1
- package/lib/client/AbstractPowerSyncDatabase.d.ts +110 -58
- package/lib/client/AbstractPowerSyncDatabase.js +59 -48
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- package/lib/client/AbstractPowerSyncOpenFactory.d.ts +6 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js +3 -0
- package/lib/client/AbstractPowerSyncOpenFactory.js.map +1 -1
- package/lib/client/ConnectionManager.d.ts +4 -1
- package/lib/client/ConnectionManager.js +1 -1
- package/lib/client/ConnectionManager.js.map +1 -1
- package/lib/client/Query.d.ts +9 -0
- package/lib/client/SQLOpenFactory.d.ts +12 -0
- package/lib/client/SQLOpenFactory.js +6 -0
- package/lib/client/SQLOpenFactory.js.map +1 -1
- package/lib/client/compilableQueryWatch.d.ts +6 -0
- package/lib/client/compilableQueryWatch.js +3 -0
- package/lib/client/compilableQueryWatch.js.map +1 -1
- package/lib/client/connection/PowerSyncBackendConnector.d.ts +3 -0
- package/lib/client/connection/PowerSyncCredentials.d.ts +3 -0
- package/lib/client/constants.d.ts +3 -0
- package/lib/client/constants.js +3 -0
- package/lib/client/constants.js.map +1 -1
- package/lib/client/runOnSchemaChange.d.ts +3 -0
- package/lib/client/runOnSchemaChange.js +3 -0
- package/lib/client/runOnSchemaChange.js.map +1 -1
- package/lib/client/sync/bucket/BucketStorageAdapter.d.ts +12 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js +6 -0
- package/lib/client/sync/bucket/BucketStorageAdapter.js.map +1 -1
- package/lib/client/sync/bucket/CrudBatch.d.ts +2 -0
- package/lib/client/sync/bucket/CrudBatch.js +2 -0
- package/lib/client/sync/bucket/CrudBatch.js.map +1 -1
- package/lib/client/sync/bucket/CrudEntry.d.ts +9 -0
- package/lib/client/sync/bucket/CrudEntry.js +4 -0
- package/lib/client/sync/bucket/CrudEntry.js.map +1 -1
- package/lib/client/sync/bucket/CrudTransaction.d.ts +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js +3 -0
- package/lib/client/sync/bucket/CrudTransaction.js.map +1 -1
- package/lib/client/sync/bucket/SqliteBucketStorage.d.ts +3 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js +3 -0
- package/lib/client/sync/bucket/SqliteBucketStorage.js.map +1 -1
- package/lib/client/sync/stream/AbstractRemote.d.ts +30 -1
- package/lib/client/sync/stream/AbstractRemote.js +15 -1
- package/lib/client/sync/stream/AbstractRemote.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +61 -14
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +60 -47
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/JsonValue.d.ts +3 -0
- package/lib/client/sync/stream/WebsocketClientTransport.js +2 -1
- package/lib/client/sync/stream/WebsocketClientTransport.js.map +1 -1
- package/lib/client/sync/sync-streams.d.ts +22 -7
- package/lib/client/triggers/TriggerManager.d.ts +19 -18
- package/lib/client/triggers/TriggerManager.js +2 -1
- package/lib/client/triggers/TriggerManager.js.map +1 -1
- package/lib/client/triggers/TriggerManagerImpl.d.ts +1 -1
- package/lib/client/triggers/TriggerManagerImpl.js +3 -3
- package/lib/client/triggers/TriggerManagerImpl.js.map +1 -1
- package/lib/client/triggers/sanitizeSQL.d.ts +4 -0
- package/lib/client/triggers/sanitizeSQL.js +4 -0
- package/lib/client/triggers/sanitizeSQL.js.map +1 -1
- package/lib/client/watched/GetAllQuery.d.ts +4 -0
- package/lib/client/watched/GetAllQuery.js +2 -0
- package/lib/client/watched/GetAllQuery.js.map +1 -1
- package/lib/client/watched/WatchedQuery.d.ts +24 -2
- package/lib/client/watched/WatchedQuery.js +9 -0
- package/lib/client/watched/WatchedQuery.js.map +1 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.d.ts +1 -1
- package/lib/client/watched/processors/AbstractQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/DifferentialQueryProcessor.d.ts +20 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js +4 -0
- package/lib/client/watched/processors/DifferentialQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/OnChangeQueryProcessor.d.ts +4 -0
- package/lib/client/watched/processors/OnChangeQueryProcessor.js.map +1 -1
- package/lib/client/watched/processors/comparators.d.ts +8 -0
- package/lib/client/watched/processors/comparators.js +4 -0
- package/lib/client/watched/processors/comparators.js.map +1 -1
- package/lib/db/ConnectionClosedError.d.ts +2 -0
- package/lib/db/ConnectionClosedError.js +2 -0
- package/lib/db/ConnectionClosedError.js.map +1 -1
- package/lib/db/DBAdapter.d.ts +56 -6
- package/lib/db/DBAdapter.js +15 -3
- package/lib/db/DBAdapter.js.map +1 -1
- package/lib/db/crud/SyncProgress.d.ts +6 -1
- package/lib/db/crud/SyncProgress.js +2 -0
- package/lib/db/crud/SyncProgress.js.map +1 -1
- package/lib/db/crud/SyncStatus.d.ts +36 -38
- package/lib/db/crud/SyncStatus.js +19 -14
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/db/crud/UploadQueueStatus.d.ts +3 -0
- package/lib/db/crud/UploadQueueStatus.js +3 -0
- package/lib/db/crud/UploadQueueStatus.js.map +1 -1
- package/lib/db/schema/Column.d.ts +28 -0
- package/lib/db/schema/Column.js +16 -3
- package/lib/db/schema/Column.js.map +1 -1
- package/lib/db/schema/Index.d.ts +9 -0
- package/lib/db/schema/Index.js +6 -0
- package/lib/db/schema/Index.js.map +1 -1
- package/lib/db/schema/IndexedColumn.d.ts +9 -0
- package/lib/db/schema/IndexedColumn.js +6 -0
- package/lib/db/schema/IndexedColumn.js.map +1 -1
- package/lib/db/schema/RawTable.d.ts +7 -1
- package/lib/db/schema/Schema.d.ts +6 -1
- package/lib/db/schema/Schema.js +3 -1
- package/lib/db/schema/Schema.js.map +1 -1
- package/lib/db/schema/Table.d.ts +27 -3
- package/lib/db/schema/Table.js +9 -0
- package/lib/db/schema/Table.js.map +1 -1
- package/lib/db/schema/TableV2.d.ts +2 -0
- package/lib/db/schema/TableV2.js +2 -0
- package/lib/db/schema/TableV2.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/types/types.d.ts +6 -0
- package/lib/utils/AbortOperation.d.ts +2 -0
- package/lib/utils/AbortOperation.js +2 -0
- package/lib/utils/AbortOperation.js.map +1 -1
- package/lib/utils/BaseObserver.d.ts +12 -0
- package/lib/utils/BaseObserver.js +3 -0
- package/lib/utils/BaseObserver.js.map +1 -1
- package/lib/utils/ControlledExecutor.d.ts +6 -0
- package/lib/utils/ControlledExecutor.js +3 -0
- package/lib/utils/ControlledExecutor.js.map +1 -1
- package/lib/utils/Logger.d.ts +9 -0
- package/lib/utils/Logger.js +6 -0
- package/lib/utils/Logger.js.map +1 -1
- package/lib/utils/async.d.ts +13 -7
- package/lib/utils/async.js +38 -24
- package/lib/utils/async.js.map +1 -1
- package/lib/utils/mutex.d.ts +8 -0
- package/lib/utils/mutex.js +3 -0
- package/lib/utils/mutex.js.map +1 -1
- package/lib/utils/parseQuery.d.ts +6 -0
- package/lib/utils/parseQuery.js +3 -0
- package/lib/utils/parseQuery.js.map +1 -1
- package/lib/utils/stream_transform.d.ts +3 -1
- package/lib/utils/stream_transform.js.map +1 -1
- package/package.json +3 -2
- package/src/attachments/AttachmentContext.ts +7 -6
- package/src/attachments/AttachmentErrorHandler.ts +6 -6
- package/src/attachments/AttachmentQueue.ts +71 -23
- package/src/attachments/LocalStorageAdapter.ts +14 -8
- package/src/attachments/README.md +2 -0
- package/src/attachments/RemoteStorageAdapter.ts +4 -4
- package/src/attachments/Schema.ts +12 -4
- package/src/attachments/WatchedAttachmentItem.ts +3 -1
- package/src/client/AbstractPowerSyncDatabase.ts +117 -62
- package/src/client/AbstractPowerSyncOpenFactory.ts +6 -0
- package/src/client/ConnectionManager.ts +4 -1
- package/src/client/Query.ts +9 -0
- package/src/client/SQLOpenFactory.ts +12 -0
- package/src/client/compilableQueryWatch.ts +6 -0
- package/src/client/connection/PowerSyncBackendConnector.ts +3 -0
- package/src/client/connection/PowerSyncCredentials.ts +3 -0
- package/src/client/constants.ts +3 -0
- package/src/client/runOnSchemaChange.ts +3 -0
- package/src/client/sync/bucket/BucketStorageAdapter.ts +12 -0
- package/src/client/sync/bucket/CrudBatch.ts +2 -0
- package/src/client/sync/bucket/CrudEntry.ts +9 -0
- package/src/client/sync/bucket/CrudTransaction.ts +3 -0
- package/src/client/sync/bucket/SqliteBucketStorage.ts +3 -0
- package/src/client/sync/stream/AbstractRemote.ts +30 -1
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +86 -59
- package/src/client/sync/stream/JsonValue.ts +3 -0
- package/src/client/sync/stream/WebsocketClientTransport.ts +3 -1
- package/src/client/sync/sync-streams.ts +22 -9
- package/src/client/triggers/TriggerManager.ts +19 -18
- package/src/client/triggers/TriggerManagerImpl.ts +5 -5
- package/src/client/triggers/sanitizeSQL.ts +5 -0
- package/src/client/watched/GetAllQuery.ts +5 -1
- package/src/client/watched/WatchedQuery.ts +24 -2
- package/src/client/watched/processors/AbstractQueryProcessor.ts +6 -6
- package/src/client/watched/processors/DifferentialQueryProcessor.ts +28 -5
- package/src/client/watched/processors/OnChangeQueryProcessor.ts +9 -3
- package/src/client/watched/processors/comparators.ts +8 -0
- package/src/db/ConnectionClosedError.ts +2 -0
- package/src/db/DBAdapter.ts +58 -6
- package/src/db/crud/SyncProgress.ts +6 -1
- package/src/db/crud/SyncStatus.ts +40 -21
- package/src/db/crud/UploadQueueStatus.ts +3 -0
- package/src/db/schema/Column.ts +28 -3
- package/src/db/schema/Index.ts +9 -0
- package/src/db/schema/IndexedColumn.ts +9 -0
- package/src/db/schema/RawTable.ts +7 -1
- package/src/db/schema/Schema.ts +8 -3
- package/src/db/schema/Table.ts +30 -5
- package/src/db/schema/TableV2.ts +2 -0
- package/src/index.ts +1 -1
- package/src/types/types.ts +6 -0
- package/src/utils/AbortOperation.ts +2 -0
- package/src/utils/BaseObserver.ts +12 -0
- package/src/utils/ControlledExecutor.ts +6 -0
- package/src/utils/Logger.ts +9 -0
- package/src/utils/async.ts +51 -24
- package/src/utils/mutex.ts +12 -0
- package/src/utils/parseQuery.ts +6 -0
- package/src/utils/stream_transform.ts +3 -1
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @alpha
|
|
3
|
+
*/
|
|
1
4
|
export type AttachmentData = ArrayBuffer | string;
|
|
2
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
3
9
|
export enum EncodingType {
|
|
4
10
|
UTF8 = 'utf8',
|
|
5
11
|
Base64 = 'base64'
|
|
@@ -15,41 +21,41 @@ export enum EncodingType {
|
|
|
15
21
|
export interface LocalStorageAdapter {
|
|
16
22
|
/**
|
|
17
23
|
* Saves data to a local file.
|
|
18
|
-
* @param filePath Path where the file will be stored
|
|
19
|
-
* @param data Data to store (ArrayBuffer, Blob, or string)
|
|
24
|
+
* @param filePath - Path where the file will be stored
|
|
25
|
+
* @param data - Data to store (ArrayBuffer, Blob, or string)
|
|
20
26
|
* @returns Number of bytes written
|
|
21
27
|
*/
|
|
22
28
|
saveFile(filePath: string, data: AttachmentData): Promise<number>;
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
31
|
* Retrieves file data as an ArrayBuffer.
|
|
26
|
-
* @param filePath Path where the file is stored
|
|
32
|
+
* @param filePath - Path where the file is stored
|
|
27
33
|
* @returns ArrayBuffer containing the file data
|
|
28
34
|
*/
|
|
29
35
|
readFile(filePath: string): Promise<ArrayBuffer>;
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Deletes the file at the given path.
|
|
33
|
-
* @param filePath Path where the file is stored
|
|
39
|
+
* @param filePath - Path where the file is stored
|
|
34
40
|
*/
|
|
35
41
|
deleteFile(filePath: string): Promise<void>;
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
44
|
* Checks if a file exists at the given path.
|
|
39
|
-
* @param filePath Path where the file is stored
|
|
45
|
+
* @param filePath - Path where the file is stored
|
|
40
46
|
* @returns True if the file exists, false otherwise
|
|
41
47
|
*/
|
|
42
48
|
fileExists(filePath: string): Promise<boolean>;
|
|
43
49
|
|
|
44
50
|
/**
|
|
45
51
|
* Creates a directory at the specified path.
|
|
46
|
-
* @param path The full path to the directory
|
|
52
|
+
* @param path - The full path to the directory
|
|
47
53
|
*/
|
|
48
54
|
makeDir(path: string): Promise<void>;
|
|
49
55
|
|
|
50
56
|
/**
|
|
51
57
|
* Removes a directory at the specified path.
|
|
52
|
-
* @param path The full path to the directory
|
|
58
|
+
* @param path - The full path to the directory
|
|
53
59
|
*/
|
|
54
60
|
rmDir(path: string): Promise<void>;
|
|
55
61
|
|
|
@@ -65,7 +71,7 @@ export interface LocalStorageAdapter {
|
|
|
65
71
|
|
|
66
72
|
/**
|
|
67
73
|
* Returns the file path for the provided filename in the storage directory.
|
|
68
|
-
* @param filename The filename to get the path for
|
|
74
|
+
* @param filename - The filename to get the path for
|
|
69
75
|
* @returns The full file path
|
|
70
76
|
*/
|
|
71
77
|
getLocalUri(filename: string): string;
|
|
@@ -427,10 +427,12 @@ type WatchedAttachmentItem = {
|
|
|
427
427
|
id: string;
|
|
428
428
|
fileExtension: string; // e.g., 'jpg', 'pdf'
|
|
429
429
|
metaData?: string;
|
|
430
|
+
mediaType?: string; // e.g., 'image/jpeg'
|
|
430
431
|
} | {
|
|
431
432
|
id: string;
|
|
432
433
|
filename: string; // e.g., 'document.pdf'
|
|
433
434
|
metaData?: string;
|
|
435
|
+
mediaType?: string; // e.g., 'application/pdf'
|
|
434
436
|
};
|
|
435
437
|
```
|
|
436
438
|
|
|
@@ -10,21 +10,21 @@ import { AttachmentRecord } from './Schema.js';
|
|
|
10
10
|
export interface RemoteStorageAdapter {
|
|
11
11
|
/**
|
|
12
12
|
* Uploads a file to remote storage.
|
|
13
|
-
* @param fileData The binary content of the file to upload
|
|
14
|
-
* @param attachment The associated attachment metadata
|
|
13
|
+
* @param fileData - The binary content of the file to upload
|
|
14
|
+
* @param attachment - The associated attachment metadata
|
|
15
15
|
*/
|
|
16
16
|
uploadFile(fileData: ArrayBuffer, attachment: AttachmentRecord): Promise<void>;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Downloads a file from remote storage.
|
|
20
|
-
* @param attachment The attachment describing the file to download
|
|
20
|
+
* @param attachment - The attachment describing the file to download
|
|
21
21
|
* @returns The binary data of the downloaded file
|
|
22
22
|
*/
|
|
23
23
|
downloadFile(attachment: AttachmentRecord): Promise<ArrayBuffer>;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Deletes a file from remote storage.
|
|
27
|
-
* @param attachment The attachment describing the file to delete
|
|
27
|
+
* @param attachment - The attachment describing the file to delete
|
|
28
28
|
*/
|
|
29
29
|
deleteFile(attachment: AttachmentRecord): Promise<void>;
|
|
30
30
|
}
|
|
@@ -2,12 +2,17 @@ import { column } from '../db/schema/Column.js';
|
|
|
2
2
|
import { Table } from '../db/schema/Table.js';
|
|
3
3
|
import { TableV2Options } from '../db/schema/Table.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The default name of the local table storing attachment data.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
5
10
|
export const ATTACHMENT_TABLE = 'attachments';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* AttachmentRecord represents an attachment in the local database.
|
|
9
14
|
*
|
|
10
|
-
* @
|
|
15
|
+
* @alpha
|
|
11
16
|
*/
|
|
12
17
|
export interface AttachmentRecord {
|
|
13
18
|
id: string;
|
|
@@ -27,7 +32,7 @@ export interface AttachmentRecord {
|
|
|
27
32
|
* @param row - The database row object
|
|
28
33
|
* @returns The corresponding AttachmentRecord
|
|
29
34
|
*
|
|
30
|
-
* @
|
|
35
|
+
* @alpha
|
|
31
36
|
*/
|
|
32
37
|
export function attachmentFromSql(row: any): AttachmentRecord {
|
|
33
38
|
return {
|
|
@@ -46,7 +51,7 @@ export function attachmentFromSql(row: any): AttachmentRecord {
|
|
|
46
51
|
/**
|
|
47
52
|
* AttachmentState represents the current synchronization state of an attachment.
|
|
48
53
|
*
|
|
49
|
-
* @
|
|
54
|
+
* @alpha
|
|
50
55
|
*/
|
|
51
56
|
export enum AttachmentState {
|
|
52
57
|
QUEUED_UPLOAD = 0, // Attachment to be uploaded
|
|
@@ -56,12 +61,15 @@ export enum AttachmentState {
|
|
|
56
61
|
ARCHIVED = 4 // Attachment has been orphaned, i.e. the associated record has been deleted
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @alpha
|
|
66
|
+
*/
|
|
59
67
|
export interface AttachmentTableOptions extends Omit<TableV2Options, 'name' | 'columns'> {}
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
70
|
* AttachmentTable defines the schema for the attachment queue table.
|
|
63
71
|
*
|
|
64
|
-
* @
|
|
72
|
+
* @alpha
|
|
65
73
|
*/
|
|
66
74
|
export class AttachmentTable extends Table {
|
|
67
75
|
constructor(options?: AttachmentTableOptions) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WatchedAttachmentItem represents an attachment reference in your application's data model.
|
|
3
3
|
* Use either filename OR fileExtension (not both).
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @alpha
|
|
6
6
|
*/
|
|
7
7
|
export type WatchedAttachmentItem =
|
|
8
8
|
| {
|
|
@@ -10,10 +10,12 @@ export type WatchedAttachmentItem =
|
|
|
10
10
|
filename: string;
|
|
11
11
|
fileExtension?: never;
|
|
12
12
|
metaData?: string;
|
|
13
|
+
mediaType?: string;
|
|
13
14
|
}
|
|
14
15
|
| {
|
|
15
16
|
id: string;
|
|
16
17
|
fileExtension: string;
|
|
17
18
|
filename?: never;
|
|
18
19
|
metaData?: string;
|
|
20
|
+
mediaType?: string;
|
|
19
21
|
};
|