Skip to content

Commit

Permalink
use raw-data
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensJourney committed Nov 8, 2023
1 parent b0f7446 commit 80441ca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-hotels-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@journeyapps/powersync-sdk-common': patch
---

Added `raw-data:true` to PowerSync instance streaming requests. This aides with server and client side OplogEntry processing.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface OplogEntryJSON {
object_type: string;
object_id: string;
checksum: number;
data: string | object;
data: string;
subkey: string | object;
}

Expand All @@ -20,7 +20,7 @@ export class OplogEntry {
typeof row.subkey == 'string' ? row.subkey : JSON.stringify(row.subkey),
row.object_type,
row.object_id,
typeof row.data == 'string' ? JSON.parse(row.data) : row.data
row.data
);
}

Expand All @@ -31,7 +31,7 @@ export class OplogEntry {
public subkey: string,
public object_type?: string,
public object_id?: string,
public data?: Record<string, any>
public data?: string
) {}

toJSON(): OplogEntryJSON {
Expand All @@ -41,7 +41,7 @@ export class OplogEntry {
object_type: this.object_type,
object_id: this.object_id,
checksum: this.checksum,
data: JSON.stringify(this.data),
data: this.data,
subkey: JSON.stringify(this.subkey)
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ export abstract class AbstractStreamingSyncImplementation extends BaseObserver<S
for await (let line of this.streamingSyncRequest(
{
buckets: req,
include_checksum: true
include_checksum: true,
raw_data: true
},
signal
)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ export interface StreamingSyncRequest {
* Whether or not to compute a checksum for each checkpoint
*/
include_checksum: boolean;

/**
* Changes the response to stringified data in each OplogEntry
*/
raw_data: boolean;
}

export interface StreamingSyncCheckpoint {
Expand Down

0 comments on commit 80441ca

Please sign in to comment.