Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/four-lamps-fall.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
'@tanstack/powersync-direct-collection': major
'@tanstack/powersync-direct-db-collection': major
---

Release the first PowerSync Direct collection candidate alongside the DB 1.0
Expand Down
7 changes: 7 additions & 0 deletions .changeset/powersync-direct-package-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/powersync-direct-db-collection': patch
---

Rename the package to `@tanstack/powersync-direct-db-collection` to follow the
collection adapter naming convention. Update dependencies and imports to use
the new package name.
2 changes: 1 addition & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@tanstack/trailbase-db-collection": "1.0.0-rc.0",
"@tanstack/vue-db": "1.0.0-rc.0",
"@tanstack/db-adapter-conformance": "0.0.0",
"@tanstack/powersync-direct-collection": "1.0.0-rc.0"
"@tanstack/powersync-direct-db-collection": "1.0.0-rc.0"
},
"changesets": [
"bright-cups-infer",
Expand Down
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ If you have been assigned to fix an issue or develop a new feature, please follo
- Git stage your required changes and commit them.
- Submit a PR for review.

### Package names

Public packages live in `packages/<name>` and use `@tanstack/<name>` in their
manifest. Use lowercase words separated by single hyphens. Include `db` as a
whole word: framework bindings use `<framework>-db`, collection adapters use
`<provider>-db-collection`, and SQLite persistence adapters use
`<host>-db-sqlite-persistence`. A provider or host may contain several words.
Core and support packages may start with `db-`. Any name that ends in
`-collection` must end in `-db-collection`.

`@tanstack/offline-transactions` keeps its existing name as the sole exception
to the `db` word. Private packages, nested test apps, and examples are outside
this public package convention.

`pnpm lint:package-names` checks these rules. Both `pnpm lint` and the CI
`pnpm lint:check` command run it. Its generated oracle runs with
`pnpm test:lint-rules`. The check reports every broken rule for every public
package in one pass.

### Editing the docs locally and previewing changes

The documentation for all TanStack projects is hosted on [tanstack.com](https://tanstack.com), which is a TanStack Start application (https://github.com/TanStack/tanstack.com). You need to run this app locally to preview your changes in the `TanStack/db` docs.
Expand Down
14 changes: 7 additions & 7 deletions docs/collections/powersync-direct-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ title: PowerSync In-Memory Collection
PowerSync in-memory collections integrate TanStack DB with [PowerSync](https://powersync.com) without a local SQLite database. Collections are backed directly by PowerSync [Sync Streams](https://docs.powersync.com/sync/streams/overview), giving you a lightweight, real-time sync integration for web apps.

> [!TIP]
> This documents `@tanstack/powersync-direct-collection`, which is based on a JavaScript implementation of the PowerSync protocol.
> This documents `@tanstack/powersync-direct-db-collection`, which is based on a JavaScript implementation of the PowerSync protocol.
> If you need offline-ready persistence, use the [PowerSync SQLite collection](./powersync-collection.md) instead.

## Overview

The `@tanstack/powersync-direct-collection` package allows you to create collections that:
The `@tanstack/powersync-direct-db-collection` package allows you to create collections that:

- Reactively update when PowerSync records change
- Integrate deeply with [Sync Streams](https://docs.powersync.com/sync/streams/overview), subscribing eagerly or only for the data that live queries need
Expand All @@ -30,7 +30,7 @@ As all data is kept in memory, it is a good fit when all of the following apply:
Install the PowerSync collection package. As it uses a JavaScript implementation instead of SQLite, no other PowerSync SDK is required.

```bash
npm install @tanstack/powersync-direct-collection @tanstack/react-db
npm install @tanstack/powersync-direct-db-collection @tanstack/react-db
```

The package uses recent JavaScript features and targets modern browsers, Node.js and other modern runtimes. Runtimes like React Native are not supported without transformations and polyfills.
Expand All @@ -40,7 +40,7 @@ The package uses recent JavaScript features and targets modern browsers, Node.js
Create one `PowerSyncClient` for your app. All collections created with the same client share one connection to the PowerSync Service.

```ts
import { PowerSyncClient } from '@tanstack/powersync-direct-collection'
import { PowerSyncClient } from '@tanstack/powersync-direct-db-collection'

export const powerSync = new PowerSyncClient({
endpoint: 'https://<your-instance>.powersync.journeyapps.com',
Expand All @@ -61,7 +61,7 @@ Each collection holds the rows of one PowerSync table. Use `streams` to choose w

```ts
import { createCollection } from '@tanstack/react-db'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-collection'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-db-collection'
import { z } from 'zod'

const Todo = z.object({
Expand Down Expand Up @@ -141,7 +141,7 @@ A client can subscribe with relevant parameters:

```ts
import { createCollection, parseLoadSubsetOptions } from '@tanstack/react-db'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-collection'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-db-collection'

export const todos = createCollection(
powerSyncCollectionOptions<Todo>({
Expand Down Expand Up @@ -171,7 +171,7 @@ PowerSync syncs data from your backend database to clients. Writes are your resp

```ts
import { createCollection } from '@tanstack/react-db'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-collection'
import { powerSyncCollectionOptions } from '@tanstack/powersync-direct-db-collection'

export const todos = createCollection(
powerSyncCollectionOptions<Todo>({
Expand Down
25 changes: 21 additions & 4 deletions docs/contributing/oracle-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ The successful release does not close the counterexamples in
[#2296](https://github.com/TanStack/db/issues/2296), or the reach gap in
[#2287](https://github.com/TanStack/db/issues/2287).

Package naming is owned by
[`scripts/package-names-oracle.property.test.js`](../../scripts/package-names-oracle.property.test.js).
It checks `scripts/check-package-names.mjs` through its real CLI, over generated
workspaces with one to four targets, combined faults, and private/nested
discovery boundaries. Native probes inside validation branches supply reach;
independent predictions and forced controls check their entries in both
directions. Weighted `collection`/`collections` stem words and constructed tails
exercise suffix-shaped names across authored families, including namespace
prefixes and spelling changes. Its edit-based model does not parse rendered
names with the linter's rules.
The existing PowerSync name is a
fixed regression of the same comparison. See the
[naming evidence](oracle-reviews/2026-11-27-package-naming.md) for RED/GREEN,
reach, replay, mutants, and limits. PowerSync Direct's package moved to
`powersync-direct-db-collection`; historical review records retain their
original paths and package names.

Use [Oracle Testing Rubric](oracle-rubric.md) when adding or reviewing a
law. This map identifies existing owners, their judgment, and their limits. It
is not a claim that every state or every test has been audited.
Expand Down Expand Up @@ -9259,7 +9276,7 @@ these commands do not imply that the current portfolio is entirely GREEN.
| Contract and oracle owner | Added receiving paths and observations |
| --- | --- |
| Complete eager replacement and initial gate: `db-adapter-conformance/tests/eager-reload-oracle.ts` | Query, Convex, Electric, RxDB, native and Direct PowerSync, TrailBase and actual Neon SDK; complete empty/change/omission results, applied receipts, optimistic settlement, terminal first loads where applicable. Provider-consumption barriers precede the comparison; missing readiness is an observed mismatch. LocalStorage receives complete replacement; local-only retains its user-owned rows under its existing owner. |
| Initial receipt cleanup: `powersync-direct-collection/tests/initial-receipt-oracle.ts` | Actual provider and persistence boundaries for Electric, RxDB, native PowerSync and Neon, including Node SQLite and Chromium worker/OPFS where recorded. Rejected deferred receipts and application of already-admitted receipts are explicit alternative premises. Detached host failures and teardown diagnostics remain observable. |
| Initial receipt cleanup: `powersync-direct-db-collection/tests/initial-receipt-oracle.ts` | Actual provider and persistence boundaries for Electric, RxDB, native PowerSync and Neon, including Node SQLite and Chromium worker/OPFS where recorded. Rejected deferred receipts and application of already-admitted receipts are explicit alternative premises. Detached host failures and teardown diagnostics remain observable. |
| Native PowerSync hooks: `powersync-db-collection/tests/hook-lifecycle-oracle.ts` | Real Node/browser SQLite; returned cleanup ownership, pending-hook retirement, subset release, and successful load settlement behind an actual held applied receipt. |
| Native PowerSync decoding: `powersync-db-collection/tests/batch-decode-oracle.ts` | Real Node/browser SQLite pages; valid transformed keys and values, refused initial/live pages, terminal health and watcher release, corrected source data and new demand, cleanup/restart. Native CRUD also crosses refusal and cleanup: each confirmation belongs to its captured sync run, including a healthy same-table peer and a healthy-first two-Collection transaction. Two active observers release in either order; a peer cannot retire the writing Collection's optimism before its own source commit. Complete own/peer rows and publication cuts distinguish premature confirmation from waiting for every observer. Held SDK returns expose detached rejections without erasing already committed SQL effects. Earlier accepted initial pages remain legal; SQL cancellation is not promised. |
| RxDB mutation settlement: `rxdb-db-collection/tests/mutation-source-batch-oracle.ts`, receiving `db/tests/optimistic-history-oracle.ts` | Built-in CRUD handlers and real SDK change events before/after handler settlement; whole application rows, settlement publications and detached failure observations. No invented explicit confirmation API. |
Expand Down Expand Up @@ -9353,10 +9370,10 @@ shares its owner's model and comparison.
| --- | --- | --- |
| Eager lifecycle/health: `db-adapter-conformance/src/eager-live-source-oracle.ts` | Real standalone SDK in Node and Chromium; transport interruptions, changed/unchanged successor checkpoints, table/status/lease release at failure and cleanup | [Eager review](oracle-reviews/2026-11-17-powersync-direct-eager.md) and [request-fixture correction](oracle-reviews/2026-11-23-powersync-request-fixtures.md) |
| Complete replacement and initial gate: `db-adapter-conformance/tests/eager-reload-oracle.ts` | Node and Chromium; fresh/reload/shared-failed provider, explicit/default streams, empty/nonempty rows, retry in a new run, optimistic settlement and applied receipts | [Reload review](oracle-reviews/2026-11-17-powersync-direct-reload.md) |
| Initial receipt cleanup: `powersync-direct-collection/tests/initial-receipt-oracle.ts` | Controlled receipt, actual controlled persistence, Node SQLite and worker/OPFS; receipt created/pending/rejected, public cleanup and detached failure, with late teardown diagnostics preserved | [Reload review](oracle-reviews/2026-11-17-powersync-direct-reload.md) and [persistence review](oracle-reviews/2026-11-17-powersync-direct-persistence.md) |
| Initial receipt cleanup: `powersync-direct-db-collection/tests/initial-receipt-oracle.ts` | Controlled receipt, actual controlled persistence, Node SQLite and worker/OPFS; receipt created/pending/rejected, public cleanup and detached failure, with late teardown diagnostics preserved | [Reload review](oracle-reviews/2026-11-17-powersync-direct-reload.md) and [persistence review](oracle-reviews/2026-11-17-powersync-direct-persistence.md) |
| On-demand stream ownership: `db-adapter-conformance/tests/on-demand-streams-oracle.ts` | Real source/live-query Collections across five Node/browser/persisted paths; shared/partial/disjoint incidence, parameter and priority forwarding, failure timing, independent retirement and recovery, empty/throwing mappers, mapper-triggered cleanup and public snapshot-request cancellation before/during/after mapping beside a ready peer. Cold histories remain beside a confirmed-empty distinct-donor prelude; actual SDK callbacks and held receipts establish before-application reach. | [On-demand review](oracle-reviews/2026-11-17-powersync-direct-on-demand.md), [mapper cancellation review](oracle-reviews/2026-11-18-powersync-direct-mapper-abort.md) |
| Decode admission/refusal: `db-adapter-conformance/tests/decode-refusal-oracle.ts` | Eager and on-demand, actual SDK Node and Chromium; cold initial/live and idle cached startup; valid boolean/Date conversion, ordinary Error and three unprintable thrown-value shapes, changed id at first/middle/last row; ordered coherent source/query readiness, terminal health, every publication, valid startup handler admission, pending-query retirement and owned resource cleanup. Final 334 Node/327 Chromium GREEN; isolated cause/handler mutants rejected and actual early-readiness variant permitted; 72 declared states reached in each campaign. No persistence/reload/mutation or arbitrary remote schedule claim | [Decode review](oracle-reviews/2026-11-17-powersync-direct-decode.md) |
| Mutation confirmation: `db/tests/mutation-confirmation-oracle.ts`; cancellation: `powersync-direct-collection/tests/mutation-confirmation-cancellation-oracle.ts` | Node and Chromium, eager and retained on-demand queries; CRUD through handlers/manual transactions, response-first/checkpoint-first pending cuts, accepted rows and settlement publications, signal/Collection cleanup cancellation | [Mutation review](oracle-reviews/2026-11-17-powersync-direct-mutation.md) |
| Mutation confirmation: `db/tests/mutation-confirmation-oracle.ts`; cancellation: `powersync-direct-db-collection/tests/mutation-confirmation-cancellation-oracle.ts` | Node and Chromium, eager and retained on-demand queries; CRUD through handlers/manual transactions, response-first/checkpoint-first pending cuts, accepted rows and settlement publications, signal/Collection cleanup cancellation | [Mutation review](oracle-reviews/2026-11-17-powersync-direct-mutation.md) |
| Persisted startup: `db-adapter-conformance/tests/persisted-startup-oracle.ts` | Controlled persistence, Node SQLite and Chromium worker/OPFS; source/restore order, fallback, immediate public/durable rows, refresh fulfillment, local reopen and source read count | [Persistence review](oracle-reviews/2026-11-17-powersync-direct-persistence.md) |
| Shared client: `db-adapter-conformance/tests/shared-client-oracle.ts` | Node and Chromium; two source Collections on one table/client, passive cached startup, equal/partial/disjoint row support, scoped rejection and changed errors across requests, healthy-peer update/deletion, pre-checkpoint and changed/unchanged recovery, either peer cleanup and final resource release | [Shared-client review](oracle-reviews/2026-11-17-powersync-direct-shared-client.md) and [request-fixture correction](oracle-reviews/2026-11-23-powersync-request-fixtures.md) |

Expand Down Expand Up @@ -9457,7 +9474,7 @@ histories, no claim about arbitrary SDK or hosted-runner resource behavior.

The [review evaluation](oracle-reviews/2026-11-24-pr2446-c366-review.md)
records each finding, its oracle gap, actual receiving evidence and limits.
`powersync-direct-collection/tests/startup-ownership-oracle.property.test.ts`
`powersync-direct-db-collection/tests/startup-ownership-oracle.property.test.ts`
receives the shared construction judgment from `shared-client-oracle.ts` on
Node and Chromium. Generated startup steps fail before or after table/status
registration, acquisition and sync waiting. Actual SDK normalization refusals
Expand Down
Loading
Loading