Skip to content

PowerSync collection: Upgrade PowerSync SDK to v2#1688

Open
simolus3 wants to merge 2 commits into
TanStack:mainfrom
powersync-ja:powersync-v2
Open

PowerSync collection: Upgrade PowerSync SDK to v2#1688
simolus3 wants to merge 2 commits into
TanStack:mainfrom
powersync-ja:powersync-v2

Conversation

@simolus3

@simolus3 simolus3 commented Jul 21, 2026

Copy link
Copy Markdown

🎯 Changes

This upgrades @powersync/ dependencies to their latest version, which includes breaking changes affecting @tanstack/powersync-db-collection:

  1. AbstractPowerSyncDatabase is a deprecated type-alias, we should use CommonPowerSyncDatabase instead.
  2. The internal logger on databases is based on a single log() function instead of one per severity now.
  3. Table.columnMap has been removed in favor of a type parameter, this changes a few helper types to infer the column structure instead of extracting it from a field.
  4. The CrudEntry class is an implementation detail and no longer exposed. The integration used that in tests, this replaces usages by directly querying from the underlying internal table instead.

This simplifies some types around serializeForSQLite, but nothing that affects compiled JS.

✅ Checklist

  • I have tested this code locally with pnpm test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • Added compatibility with PowerSync version 2.
    • Improved type inference for table records, optional fields, and SQLite serialization.
    • Updated transaction handling to use the current PowerSync database interface.
  • Bug Fixes

    • Standardized logging for synchronization, serialization, and mutation processing errors.
    • Reduced warning noise when metadata is unavailable.
  • Documentation

    • Updated backend connector examples and batching guidance for the current database API.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The collection package is updated for PowerSync 2, including database type contracts, table-derived serialization types, structured logging, direct CRUD test queries, documentation, dependency versions, and release metadata.

Changes

PowerSync 2 collection migration

Layer / File(s) Summary
PowerSync 2 database contracts
packages/powersync-db-collection/package.json, packages/powersync-db-collection/src/PowerSyncTransactor.ts, docs/collections/powersync-collection.md, .changeset/olive-guests-bathe.md
Dependencies, database types, connector examples, and release metadata are updated for PowerSync 2.
Table-derived typing and serialization
packages/powersync-db-collection/src/helpers.ts, packages/powersync-db-collection/src/serialization.ts, packages/powersync-db-collection/src/powersync.ts
Extracted table shapes and serializeForSQLite now derive their types from table row definitions.
Structured runtime logging
packages/powersync-db-collection/src/powersync.ts, packages/powersync-db-collection/src/PowerSyncTransactor.ts
Synchronization, deserialization, cleanup, and mutation paths use structured logger calls with explicit levels and error fields.
Database and CRUD test updates
packages/powersync-db-collection/tests/powersync.test.ts
Tests use direct PowerSyncDatabase queries for CRUD operations and transaction identifiers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: upgrading the PowerSync SDK to v2.
Description check ✅ Passed The description matches the template, includes changes, testing, and release impact, and is sufficiently complete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
packages/powersync-db-collection/package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​powersync/​common@​2.0.0981007798100
Addednpm/​@​powersync/​node@​0.20.07810010098100

View full report

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/powersync-db-collection/src/helpers.ts`:
- Around line 65-71: The AnyTableColumnType type uses any for column values;
replace it with unknown in the mapped type while preserving the existing keys
and id: string requirement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b88345c5-d8cc-4d9b-90ee-e8b1a52cc9eb

📥 Commits

Reviewing files that changed from the base of the PR and between f42db5c and 485206c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • .changeset/olive-guests-bathe.md
  • docs/collections/powersync-collection.md
  • packages/powersync-db-collection/package.json
  • packages/powersync-db-collection/src/PowerSyncTransactor.ts
  • packages/powersync-db-collection/src/helpers.ts
  • packages/powersync-db-collection/src/powersync.ts
  • packages/powersync-db-collection/src/serialization.ts
  • packages/powersync-db-collection/tests/powersync.test.ts

Comment on lines 65 to 71
/**
* Maps the schema of TTable to a type which
* requires the keys be equal, but the values can have any value type.
*/
export type AnyTableColumnType<TTable extends Table> = {
[K in keyof TTable[`columnMap`]]: any
[K in keyof ExtractedTableColumns<TTable>]: any
} & { id: string }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Avoid using any types; prefer unknown.

As per coding guidelines: "Avoid using any types; use unknown instead when the type is truly unknown". Using unknown for the column values improves type safety by requiring type guards before operations on the values.

💻 Proposed fix
 export type AnyTableColumnType<TTable extends Table> = {
-  [K in keyof ExtractedTableColumns<TTable>]: any
+  [K in keyof ExtractedTableColumns<TTable>]: unknown
 } & { id: string }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Maps the schema of TTable to a type which
* requires the keys be equal, but the values can have any value type.
*/
export type AnyTableColumnType<TTable extends Table> = {
[K in keyof TTable[`columnMap`]]: any
[K in keyof ExtractedTableColumns<TTable>]: any
} & { id: string }
/**
* Maps the schema of TTable to a type which
* requires the keys be equal, but the values can have any value type.
*/
export type AnyTableColumnType<TTable extends Table> = {
[K in keyof ExtractedTableColumns<TTable>]: unknown
} & { id: string }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/powersync-db-collection/src/helpers.ts` around lines 65 - 71, The
AnyTableColumnType type uses any for column values; replace it with unknown in
the mapped type while preserving the existing keys and id: string requirement.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant