Skip to content

Commit 2bf2f24

Browse files
Merge pull request #29 from powersync-ja/raw-data
[Update] Raw Data
2 parents a0aecb3 + 80441ca commit 2bf2f24

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

.changeset/moody-hotels-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@journeyapps/powersync-sdk-common': patch
3+
---
4+
5+
Added `raw-data:true` to PowerSync instance streaming requests. This aides with server and client side OplogEntry processing.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface OplogEntryJSON {
77
object_type: string;
88
object_id: string;
99
checksum: number;
10-
data: string | object;
10+
data: string;
1111
subkey: string | object;
1212
}
1313

@@ -20,7 +20,7 @@ export class OplogEntry {
2020
typeof row.subkey == 'string' ? row.subkey : JSON.stringify(row.subkey),
2121
row.object_type,
2222
row.object_id,
23-
typeof row.data == 'string' ? JSON.parse(row.data) : row.data
23+
row.data
2424
);
2525
}
2626

@@ -31,7 +31,7 @@ export class OplogEntry {
3131
public subkey: string,
3232
public object_type?: string,
3333
public object_id?: string,
34-
public data?: Record<string, any>
34+
public data?: string
3535
) {}
3636

3737
toJSON(): OplogEntryJSON {
@@ -41,7 +41,7 @@ export class OplogEntry {
4141
object_type: this.object_type,
4242
object_id: this.object_id,
4343
checksum: this.checksum,
44-
data: JSON.stringify(this.data),
44+
data: this.data,
4545
subkey: JSON.stringify(this.subkey)
4646
};
4747
}

packages/powersync-sdk-common/src/client/sync/stream/AbstractStreamingSyncImplementation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export abstract class AbstractStreamingSyncImplementation extends BaseObserver<S
166166
for await (let line of this.streamingSyncRequest(
167167
{
168168
buckets: req,
169-
include_checksum: true
169+
include_checksum: true,
170+
raw_data: true
170171
},
171172
signal
172173
)) {

packages/powersync-sdk-common/src/client/sync/stream/streaming-sync-types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export interface StreamingSyncRequest {
7070
* Whether or not to compute a checksum for each checkpoint
7171
*/
7272
include_checksum: boolean;
73+
74+
/**
75+
* Changes the response to stringified data in each OplogEntry
76+
*/
77+
raw_data: boolean;
7378
}
7479

7580
export interface StreamingSyncCheckpoint {

0 commit comments

Comments
 (0)