From 69592d068fde84cf871d2ed1474e6d4373038e91 Mon Sep 17 00:00:00 2001 From: stevensJourney <51082125+stevensJourney@users.noreply.github.com> Date: Tue, 20 Feb 2024 11:46:52 +0200 Subject: [PATCH] [Fix] Shared sync (#71) --- .changeset/pink-rings-retire.md | 5 +++++ .changeset/sharp-meals-join.md | 5 +++++ .changeset/small-pianos-clap.md | 6 ++++++ packages/powersync-sdk-common/package.json | 2 -- .../src/client/AbstractPowerSyncDatabase.ts | 8 ++++---- .../src/client/sync/bucket/CrudEntry.ts | 18 ++++++++++++++++-- pnpm-lock.yaml | 10 ---------- 7 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 .changeset/pink-rings-retire.md create mode 100644 .changeset/sharp-meals-join.md create mode 100644 .changeset/small-pianos-clap.md diff --git a/.changeset/pink-rings-retire.md b/.changeset/pink-rings-retire.md new file mode 100644 index 00000000..30ac4286 --- /dev/null +++ b/.changeset/pink-rings-retire.md @@ -0,0 +1,5 @@ +--- +'@journeyapps/powersync-sdk-web': patch +--- + +Fixed issue on NextJS 14.1.0 where shared sync web worker would fail to initialize. diff --git a/.changeset/sharp-meals-join.md b/.changeset/sharp-meals-join.md new file mode 100644 index 00000000..24782658 --- /dev/null +++ b/.changeset/sharp-meals-join.md @@ -0,0 +1,5 @@ +--- +'@journeyapps/powersync-sdk-common': patch +--- + +Improve `AbstractPowerSyncDatabase.getCrudBatch` should use a `getAll` instead of using `database.execute`. diff --git a/.changeset/small-pianos-clap.md b/.changeset/small-pianos-clap.md new file mode 100644 index 00000000..a277bbf6 --- /dev/null +++ b/.changeset/small-pianos-clap.md @@ -0,0 +1,6 @@ +--- +'@journeyapps/powersync-sdk-common': patch +--- + +Removed `object-hash` package as a dependency as this caused issues with NextJs 14.1.0. +Added `equals` method on `CrudEntry` class to better align comparison operations with Javascript. diff --git a/packages/powersync-sdk-common/package.json b/packages/powersync-sdk-common/package.json index bedbad32..2b981fc6 100644 --- a/packages/powersync-sdk-common/package.json +++ b/packages/powersync-sdk-common/package.json @@ -31,13 +31,11 @@ "event-iterator": "^2.0.0", "js-logger": "^1.6.1", "lodash": "^4.17.21", - "object-hash": "^3.0.0", "uuid": "^3.0.0" }, "devDependencies": { "@types/lodash": "^4.14.197", "@types/node": "^20.5.9", - "@types/object-hash": "^3.0.4", "@types/uuid": "^3.0.0", "typescript": "^5.1.3" } diff --git a/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts b/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts index 54cb440b..24376326 100644 --- a/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts +++ b/packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts @@ -299,7 +299,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver { - const result = await this.database.execute( + const result = await this.getAll( `SELECT id, tx_id, data FROM ${PSInternalTable.CRUD} ORDER BY id ASC LIMIT ?`, [limit + 1] ); - const all: CrudEntry[] = result.rows?._array?.map((row) => CrudEntry.fromRow(row)) ?? []; + const all: CrudEntry[] = result.map((row) => CrudEntry.fromRow(row)) ?? []; let haveMore = false; if (all.length > limit) { @@ -623,7 +623,7 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver