Skip to content

Commit

Permalink
Merge branch 'main' into deprecate/raw-tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriztiaan committed Sep 20, 2024
2 parents fdedc89 + 944ee93 commit e14fa41
Show file tree
Hide file tree
Showing 25 changed files with 22,485 additions and 16,555 deletions.
7 changes: 7 additions & 0 deletions .changeset/afraid-apples-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@powersync/common': patch
'@powersync/web': patch
'@powersync/react-native': patch
---

Fixed issue where sequentially mutating the same row multiple times could cause the CRUD upload queue monitoring to think CRUD operations have not been processed correctly by the `BackendConnector` `uploadData` method.
9 changes: 0 additions & 9 deletions .changeset/light-dots-unite.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/ninety-hats-behave.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/tough-impalas-confess.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/two-bats-return.md

This file was deleted.

10 changes: 10 additions & 0 deletions packages/attachments/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @powersync/attachments

## 2.1.1

### Patch Changes

- 02f0ce7: Updated dependencies.
- Updated dependencies [02f0ce7]
- Updated dependencies [7428f39]
- Updated dependencies [367d65d]
- @powersync/common@1.18.0

## 2.1.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/attachments/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/attachments",
"version": "2.1.0",
"version": "2.1.1",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
Expand All @@ -27,6 +27,6 @@
"watch": "tsc -b -w"
},
"peerDependencies": {
"@powersync/common": "workspace:^1.15.0"
"@powersync/common": "workspace:^1.18.0"
}
}
11 changes: 11 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @powersync/common

## 1.18.0

### Minor Changes

- 7428f39: Remove lodash dependency.
- 367d65d: Correctly identify @powersync/common as an ES module

### Patch Changes

- 02f0ce7: Updated dependencies.

## 1.17.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/common",
"version": "1.17.0",
"version": "1.18.0",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Logger, { ILogger } from 'js-logger';
import { SyncStatus, SyncStatusOptions } from '../../../db/crud/SyncStatus.js';
import { AbortOperation } from '../../../utils/AbortOperation.js';
import { BaseListener, BaseObserver, Disposable } from '../../../utils/BaseObserver.js';
import { throttleLeadingTrailing } from '../../../utils/throttle.js';
import { BucketChecksum, BucketStorageAdapter, Checkpoint } from '../bucket/BucketStorageAdapter.js';
import { CrudEntry } from '../bucket/CrudEntry.js';
import { SyncDataBucket } from '../bucket/SyncDataBucket.js';
Expand All @@ -16,7 +17,6 @@ import {
isStreamingSyncCheckpointDiff,
isStreamingSyncData
} from './streaming-sync-types.js';
import { throttleLeadingTrailing } from '../../../utils/throttle.js';

export enum LockType {
CRUD = 'crud',
Expand Down Expand Up @@ -230,7 +230,7 @@ export abstract class AbstractStreamingSyncImplementation
*/
const nextCrudItem = await this.options.adapter.nextCrudItem();
if (nextCrudItem) {
if (nextCrudItem.id == checkedCrudItem?.id) {
if (nextCrudItem.clientId == checkedCrudItem?.clientId) {
// This will force a higher log level than exceptions which are caught here.
this.logger.warn(`Potentially previously uploaded CRUD entries are still present in the upload queue.
Make sure to handle uploads and complete CRUD transactions or batches by calling and awaiting their [.complete()] method.
Expand Down
10 changes: 10 additions & 0 deletions packages/kysely-driver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @powersync/kysely-driver

## 0.4.1

### Patch Changes

- 02f0ce7: Updated dependencies.
- Updated dependencies [02f0ce7]
- Updated dependencies [7428f39]
- Updated dependencies [367d65d]
- @powersync/common@1.18.0

## 0.4.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/kysely-driver/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/kysely-driver",
"version": "0.4.0",
"version": "0.4.1",
"description": "Kysely driver for PowerSync",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
Expand All @@ -25,7 +25,7 @@
"test": "pnpm build && vitest"
},
"peerDependencies": {
"@powersync/common": "workspace:^1.17.0"
"@powersync/common": "workspace:^1.18.0"
},
"dependencies": {
"kysely": "^0.27.2"
Expand Down
11 changes: 11 additions & 0 deletions packages/react-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @powersync/react-native

## 1.12.1

### Patch Changes

- 02f0ce7: Updated dependencies.
- Updated dependencies [02f0ce7]
- Updated dependencies [7428f39]
- Updated dependencies [367d65d]
- @powersync/common@1.18.0
- @powersync/react@1.4.2

## 1.12.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/react-native",
"version": "1.12.0",
"version": "1.12.1",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
Expand Down Expand Up @@ -29,7 +29,7 @@
"homepage": "https://docs.powersync.com/",
"peerDependencies": {
"@journeyapps/react-native-quick-sqlite": "^1.3.0",
"@powersync/common": "workspace:^1.17.0",
"@powersync/common": "workspace:^1.18.0",
"react": "*",
"react-native": "*"
},
Expand Down
10 changes: 10 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @powersync/react

## 1.4.2

### Patch Changes

- 02f0ce7: Updated dependencies.
- Updated dependencies [02f0ce7]
- Updated dependencies [7428f39]
- Updated dependencies [367d65d]
- @powersync/common@1.18.0

## 1.4.1

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/react",
"version": "1.4.1",
"version": "1.4.2",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
Expand Down Expand Up @@ -29,7 +29,7 @@
"homepage": "https://docs.powersync.com",
"peerDependencies": {
"react": "*",
"@powersync/common": "workspace:^1.17.0"
"@powersync/common": "workspace:^1.18.0"
},
"devDependencies": {
"@testing-library/react": "^15.0.2",
Expand Down
14 changes: 14 additions & 0 deletions packages/web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @powersync/web

## 1.8.0

### Minor Changes

- 7428f39: Remove lodash dependency.
- 02f0ce7: DB and sync workers instantiation can now be overriden with a path or a factory method. Added UMD distribution to introduce `react-native-web` support (available under `@powersync/web/umd`).

### Patch Changes

- Updated dependencies [02f0ce7]
- Updated dependencies [7428f39]
- Updated dependencies [367d65d]
- @powersync/common@1.18.0

## 1.7.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@powersync/web",
"version": "1.7.0",
"version": "1.8.0",
"description": "A Web SDK for JourneyApps PowerSync",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
Expand Down Expand Up @@ -56,7 +56,7 @@
"license": "Apache-2.0",
"peerDependencies": {
"@journeyapps/wa-sqlite": "^0.3.0",
"@powersync/common": "workspace:^1.17.0"
"@powersync/common": "workspace:^1.18.0"
},
"dependencies": {
"@powersync/common": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/db/PowerSyncDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
import { Mutex } from 'async-mutex';
import { WASQLiteOpenFactory } from './adapters/wa-sqlite/WASQLiteOpenFactory';
import {
ResolvedWebSQLOpenOptions,
DEFAULT_WEB_SQL_FLAGS,
ResolvedWebSQLOpenOptions,
resolveWebSQLFlags,
WebSQLFlags
} from './adapters/web-sql-flags';
Expand Down
60 changes: 42 additions & 18 deletions packages/web/tests/stream.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
import { Schema, TableV2, column } from '@powersync/common';
import { Schema, Table, column } from '@powersync/common';
import { WebPowerSyncOpenFactoryOptions } from '@powersync/web';
import Logger from 'js-logger';
import { v4 as uuid } from 'uuid';
import { beforeAll, describe, expect, it, vi } from 'vitest';
import { MockRemote, MockStreamOpenFactory, TestConnector } from './utils/MockStreamOpenFactory';

type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;

export type ConnectedDatabaseUtils = UnwrapPromise<ReturnType<typeof generateConnectedDatabase>>;
export type GenerateConnectedDatabaseOptions = {
powerSyncOptions: Partial<WebPowerSyncOpenFactoryOptions>;
};

const UPLOAD_TIMEOUT_MS = 3000;

export async function generateConnectedDatabase({ useWebWorker } = { useWebWorker: true }) {
export const DEFAULT_CONNECTED_POWERSYNC_OPTIONS = {
powerSyncOptions: {
dbFilename: 'test-stream-connection.db',
flags: {
enableMultiTabs: false,
useWebWorker: true
},
// Makes tests faster
crudUploadThrottleMs: 0,
schema: new Schema({
users: new Table({ name: column.text })
})
}
};

export async function generateConnectedDatabase(
options: GenerateConnectedDatabaseOptions = DEFAULT_CONNECTED_POWERSYNC_OPTIONS
) {
const { powerSyncOptions } = options;
const { powerSyncOptions: defaultPowerSyncOptions } = DEFAULT_CONNECTED_POWERSYNC_OPTIONS;
/**
* Very basic implementation of a listener pattern.
* Required since we cannot extend multiple classes.
Expand All @@ -16,24 +43,14 @@ export async function generateConnectedDatabase({ useWebWorker } = { useWebWorke
const uploadSpy = vi.spyOn(connector, 'uploadData');
const remote = new MockRemote(connector, () => callbacks.forEach((c) => c()));

const users = new TableV2({
name: column.text
});

const schema = new Schema({
users
});

const factory = new MockStreamOpenFactory(
{
dbFilename: 'test-stream-connection.db',
...defaultPowerSyncOptions,
...powerSyncOptions,
flags: {
enableMultiTabs: false,
useWebWorker
},
// Makes tests faster
crudUploadThrottleMs: 0,
schema
...(defaultPowerSyncOptions.flags ?? {}),
...(powerSyncOptions.flags ?? {})
}
},
remote
);
Expand Down Expand Up @@ -83,7 +100,14 @@ describe('Streaming', () => {
test: (createConnectedDatabase: () => ReturnType<typeof generateConnectedDatabase>) => Promise<void>
) => {
const funcWithWebWorker = generateConnectedDatabase;
const funcWithoutWebWorker = () => generateConnectedDatabase({ useWebWorker: false });
const funcWithoutWebWorker = () =>
generateConnectedDatabase({
powerSyncOptions: {
flags: {
useWebWorker: false
}
}
});

it(`${name} - with web worker`, () => test(funcWithWebWorker));
it(`${name} - without web worker`, () => test(funcWithoutWebWorker));
Expand Down
Loading

0 comments on commit e14fa41

Please sign in to comment.