@powersync/service-core 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/db/mongo.d.ts +6 -0
- package/dist/db/mongo.js +6 -0
- package/dist/db/mongo.js.map +1 -1
- package/dist/storage/BucketStorage.d.ts +0 -1
- package/dist/storage/BucketStorage.js.map +1 -1
- package/dist/storage/MongoBucketStorage.js +19 -9
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +1 -1
- package/dist/storage/mongo/MongoSyncBucketStorage.js +26 -17
- package/dist/storage/mongo/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/mongo/db.d.ts +9 -0
- package/dist/storage/mongo/db.js +11 -0
- package/dist/storage/mongo/db.js.map +1 -1
- package/package.json +2 -2
- package/src/db/mongo.ts +7 -0
- package/src/storage/BucketStorage.ts +0 -2
- package/src/storage/MongoBucketStorage.ts +18 -9
- package/src/storage/mongo/MongoSyncBucketStorage.ts +26 -21
- package/src/storage/mongo/db.ts +12 -0
- package/test/src/data_storage.test.ts +22 -0
- package/test/src/sync.test.ts +0 -7
- package/test/src/util.ts +14 -3
- package/tsconfig.tsbuildinfo +1 -1
package/test/src/sync.test.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { JSONBig } from '@powersync/service-jsonbig';
|
|
|
5
5
|
import { RequestParameters } from '@powersync/service-sync-rules';
|
|
6
6
|
import * as timers from 'timers/promises';
|
|
7
7
|
import { describe, expect, test } from 'vitest';
|
|
8
|
-
import { ZERO_LSN } from '../../src/replication/WalStream.js';
|
|
9
8
|
import { streamResponse } from '../../src/sync/sync.js';
|
|
10
9
|
import { makeTestTable, MONGO_STORAGE_FACTORY, StorageFactory } from './util.js';
|
|
11
10
|
|
|
@@ -33,7 +32,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
const storage = await f.getInstance(syncRules.parsed());
|
|
36
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
37
35
|
await storage.autoActivate();
|
|
38
36
|
|
|
39
37
|
const result = await storage.startBatch({}, async (batch) => {
|
|
@@ -82,7 +80,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
82
80
|
});
|
|
83
81
|
|
|
84
82
|
const storage = await f.getInstance(syncRules.parsed());
|
|
85
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
86
83
|
await storage.autoActivate();
|
|
87
84
|
|
|
88
85
|
const result = await storage.startBatch({}, async (batch) => {
|
|
@@ -125,7 +122,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
125
122
|
});
|
|
126
123
|
|
|
127
124
|
const storage = await f.getInstance(syncRules.parsed());
|
|
128
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
129
125
|
await storage.autoActivate();
|
|
130
126
|
|
|
131
127
|
const stream = streamResponse({
|
|
@@ -152,7 +148,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
152
148
|
});
|
|
153
149
|
|
|
154
150
|
const storage = await f.getInstance(syncRules.parsed());
|
|
155
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
156
151
|
await storage.autoActivate();
|
|
157
152
|
|
|
158
153
|
const stream = streamResponse({
|
|
@@ -211,7 +206,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
211
206
|
});
|
|
212
207
|
|
|
213
208
|
const storage = await f.getInstance(syncRules.parsed());
|
|
214
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
215
209
|
await storage.autoActivate();
|
|
216
210
|
|
|
217
211
|
const exp = Date.now() / 1000 + 0.1;
|
|
@@ -249,7 +243,6 @@ function defineTests(factory: StorageFactory) {
|
|
|
249
243
|
});
|
|
250
244
|
|
|
251
245
|
const storage = await f.getInstance(syncRules.parsed());
|
|
252
|
-
await storage.setSnapshotDone(ZERO_LSN);
|
|
253
246
|
await storage.autoActivate();
|
|
254
247
|
|
|
255
248
|
await storage.startBatch({}, async (batch) => {
|
package/test/src/util.ts
CHANGED
|
@@ -22,11 +22,22 @@ Metrics.getInstance().resetCounters();
|
|
|
22
22
|
|
|
23
23
|
export const TEST_URI = env.PG_TEST_URL;
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export interface StorageOptions {
|
|
26
|
+
/**
|
|
27
|
+
* By default, collections are only cleared/
|
|
28
|
+
* Setting this to true will drop the collections completely.
|
|
29
|
+
*/
|
|
30
|
+
dropAll?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type StorageFactory = (options?: StorageOptions) => Promise<BucketStorageFactory>;
|
|
26
33
|
|
|
27
|
-
export const MONGO_STORAGE_FACTORY: StorageFactory = async () => {
|
|
34
|
+
export const MONGO_STORAGE_FACTORY: StorageFactory = async (options?: StorageOptions) => {
|
|
28
35
|
const db = await connectMongo();
|
|
29
|
-
|
|
36
|
+
if (options?.dropAll) {
|
|
37
|
+
await db.drop();
|
|
38
|
+
} else {
|
|
39
|
+
await db.clear();
|
|
40
|
+
}
|
|
30
41
|
return new MongoBucketStorage(db, { slot_name_prefix: 'test_' });
|
|
31
42
|
};
|
|
32
43
|
|