@powersync/service-module-mongodb-storage 0.0.0-dev-20260225093637 → 0.0.0-dev-20260313100403
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 +51 -7
- package/dist/storage/MongoBucketStorage.js +17 -3
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/MongoReportStorage.d.ts +3 -3
- package/dist/storage/MongoReportStorage.js +5 -5
- package/dist/storage/MongoReportStorage.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatch.d.ts +13 -11
- package/dist/storage/implementation/MongoBucketBatch.js +208 -127
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoChecksums.d.ts +4 -4
- package/dist/storage/implementation/MongoChecksums.js +1 -0
- package/dist/storage/implementation/MongoChecksums.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.d.ts +2 -2
- package/dist/storage/implementation/MongoCompactor.js +52 -26
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoParameterCompactor.d.ts +2 -2
- package/dist/storage/implementation/MongoParameterCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js +3 -7
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +9 -4
- package/dist/storage/implementation/MongoSyncBucketStorage.js +35 -33
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +3 -3
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/implementation/MongoWriteCheckpointAPI.d.ts +4 -4
- package/dist/storage/implementation/MongoWriteCheckpointAPI.js.map +1 -1
- package/dist/storage/implementation/OperationBatch.js +3 -2
- package/dist/storage/implementation/OperationBatch.js.map +1 -1
- package/dist/storage/implementation/PersistedBatch.d.ts +11 -4
- package/dist/storage/implementation/PersistedBatch.js +42 -11
- package/dist/storage/implementation/PersistedBatch.js.map +1 -1
- package/dist/storage/implementation/db.d.ts +35 -1
- package/dist/storage/implementation/db.js +99 -0
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +15 -2
- package/dist/storage/implementation/models.js +2 -1
- package/dist/storage/implementation/models.js.map +1 -1
- package/dist/utils/test-utils.d.ts +4 -1
- package/dist/utils/test-utils.js +15 -12
- package/dist/utils/test-utils.js.map +1 -1
- package/dist/utils/util.d.ts +2 -1
- package/dist/utils/util.js +15 -1
- package/dist/utils/util.js.map +1 -1
- package/package.json +7 -7
- package/src/storage/MongoBucketStorage.ts +30 -8
- package/src/storage/MongoReportStorage.ts +5 -5
- package/src/storage/implementation/MongoBucketBatch.ts +263 -177
- package/src/storage/implementation/MongoChecksums.ts +5 -3
- package/src/storage/implementation/MongoCompactor.ts +62 -31
- package/src/storage/implementation/MongoParameterCompactor.ts +3 -3
- package/src/storage/implementation/MongoPersistedSyncRulesContent.ts +4 -11
- package/src/storage/implementation/MongoSyncBucketStorage.ts +33 -26
- package/src/storage/implementation/MongoSyncRulesLock.ts +3 -3
- package/src/storage/implementation/MongoWriteCheckpointAPI.ts +4 -4
- package/src/storage/implementation/OperationBatch.ts +3 -2
- package/src/storage/implementation/PersistedBatch.ts +42 -11
- package/src/storage/implementation/db.ts +129 -1
- package/src/storage/implementation/models.ts +18 -3
- package/src/utils/test-utils.ts +15 -12
- package/src/utils/util.ts +17 -2
- package/test/src/__snapshots__/{connection-report-storage.test.ts.snap → client-connections-storage.test.ts.snap} +68 -68
- package/test/src/__snapshots__/storage.test.ts.snap +201 -0
- package/test/src/__snapshots__/storage_compacting.test.ts.snap +17 -0
- package/test/src/__snapshots__/storage_sync.test.ts.snap +1111 -16
- package/test/src/{connection-report-storage.test.ts → client-connections-storage.test.ts} +1 -1
- package/test/src/storage.test.ts +9 -7
- package/test/src/storage_compacting.test.ts +54 -45
- package/test/src/storage_sync.test.ts +53 -51
- package/test/src/util.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -10,13 +10,16 @@ import {
|
|
|
10
10
|
CheckpointEventDocument,
|
|
11
11
|
ClientConnectionDocument,
|
|
12
12
|
CurrentDataDocument,
|
|
13
|
+
CurrentDataDocumentV3,
|
|
13
14
|
CustomWriteCheckpointDocument,
|
|
14
15
|
IdSequenceDocument,
|
|
15
16
|
InstanceDocument,
|
|
16
17
|
SourceTableDocument,
|
|
18
|
+
StorageConfig,
|
|
17
19
|
SyncRuleDocument,
|
|
18
20
|
WriteCheckpointDocument
|
|
19
21
|
} from './models.js';
|
|
22
|
+
import { ServiceAssertionError } from '@powersync/lib-services-framework';
|
|
20
23
|
|
|
21
24
|
export interface PowerSyncMongoOptions {
|
|
22
25
|
/**
|
|
@@ -27,6 +30,7 @@ export interface PowerSyncMongoOptions {
|
|
|
27
30
|
|
|
28
31
|
export class PowerSyncMongo {
|
|
29
32
|
readonly current_data: mongo.Collection<CurrentDataDocument>;
|
|
33
|
+
readonly v3_current_data: mongo.Collection<CurrentDataDocumentV3>;
|
|
30
34
|
readonly bucket_data: mongo.Collection<BucketDataDocument>;
|
|
31
35
|
readonly bucket_parameters: mongo.Collection<BucketParameterDocument>;
|
|
32
36
|
readonly op_id_sequence: mongo.Collection<IdSequenceDocument>;
|
|
@@ -51,7 +55,8 @@ export class PowerSyncMongo {
|
|
|
51
55
|
});
|
|
52
56
|
this.db = db;
|
|
53
57
|
|
|
54
|
-
this.current_data = db.collection
|
|
58
|
+
this.current_data = db.collection('current_data');
|
|
59
|
+
this.v3_current_data = db.collection('v3_current_data');
|
|
55
60
|
this.bucket_data = db.collection('bucket_data');
|
|
56
61
|
this.bucket_parameters = db.collection('bucket_parameters');
|
|
57
62
|
this.op_id_sequence = db.collection('op_id_sequence');
|
|
@@ -66,11 +71,16 @@ export class PowerSyncMongo {
|
|
|
66
71
|
this.connection_report_events = this.db.collection('connection_report_events');
|
|
67
72
|
}
|
|
68
73
|
|
|
74
|
+
versioned(storageConfig: StorageConfig) {
|
|
75
|
+
return new VersionedPowerSyncMongo(this, storageConfig);
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
/**
|
|
70
79
|
* Clear all collections.
|
|
71
80
|
*/
|
|
72
81
|
async clear() {
|
|
73
82
|
await this.current_data.deleteMany({});
|
|
83
|
+
await this.v3_current_data.deleteMany({});
|
|
74
84
|
await this.bucket_data.deleteMany({});
|
|
75
85
|
await this.bucket_parameters.deleteMany({});
|
|
76
86
|
await this.op_id_sequence.deleteMany({});
|
|
@@ -171,6 +181,124 @@ export class PowerSyncMongo {
|
|
|
171
181
|
{ name: 'dirty_count' }
|
|
172
182
|
);
|
|
173
183
|
}
|
|
184
|
+
|
|
185
|
+
async initializeStorageVersion(storageConfig: StorageConfig) {
|
|
186
|
+
if (storageConfig.softDeleteCurrentData) {
|
|
187
|
+
// Initialize the v3_current_data collection, which is used for the new storage version.
|
|
188
|
+
// No-op if this already exists
|
|
189
|
+
await this.v3_current_data.createIndex(
|
|
190
|
+
{
|
|
191
|
+
'_id.g': 1,
|
|
192
|
+
pending_delete: 1
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
partialFilterExpression: { pending_delete: { $exists: true } },
|
|
196
|
+
name: 'pending_delete'
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* This is similar to PowerSyncMongo, but blocks access to certain collections based on the storage version.
|
|
205
|
+
*/
|
|
206
|
+
export class VersionedPowerSyncMongo {
|
|
207
|
+
readonly client: mongo.MongoClient;
|
|
208
|
+
readonly db: mongo.Db;
|
|
209
|
+
|
|
210
|
+
readonly storageConfig: StorageConfig;
|
|
211
|
+
#upstream: PowerSyncMongo;
|
|
212
|
+
|
|
213
|
+
constructor(upstream: PowerSyncMongo, storageConfig: StorageConfig) {
|
|
214
|
+
this.#upstream = upstream;
|
|
215
|
+
this.client = upstream.client;
|
|
216
|
+
this.db = upstream.db;
|
|
217
|
+
this.storageConfig = storageConfig;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Uses either `current_data` or `v3_current_data` collection based on the storage version.
|
|
222
|
+
*
|
|
223
|
+
* Use in places where it does not matter which version is used.
|
|
224
|
+
*/
|
|
225
|
+
get common_current_data(): mongo.Collection<CurrentDataDocument> {
|
|
226
|
+
if (this.storageConfig.softDeleteCurrentData) {
|
|
227
|
+
return this.#upstream.v3_current_data;
|
|
228
|
+
} else {
|
|
229
|
+
return this.#upstream.current_data;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
get v1_current_data() {
|
|
234
|
+
if (this.storageConfig.softDeleteCurrentData) {
|
|
235
|
+
throw new ServiceAssertionError(
|
|
236
|
+
'current_data collection should not be used when softDeleteCurrentData is enabled'
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return this.#upstream.current_data;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
get v3_current_data() {
|
|
243
|
+
if (!this.storageConfig.softDeleteCurrentData) {
|
|
244
|
+
throw new ServiceAssertionError(
|
|
245
|
+
'v3_current_data collection should not be used when softDeleteCurrentData is disabled'
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return this.#upstream.v3_current_data;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
get bucket_data() {
|
|
252
|
+
return this.#upstream.bucket_data;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
get bucket_parameters() {
|
|
256
|
+
return this.#upstream.bucket_parameters;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
get op_id_sequence() {
|
|
260
|
+
return this.#upstream.op_id_sequence;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
get sync_rules() {
|
|
264
|
+
return this.#upstream.sync_rules;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
get source_tables() {
|
|
268
|
+
return this.#upstream.source_tables;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
get custom_write_checkpoints() {
|
|
272
|
+
return this.#upstream.custom_write_checkpoints;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
get write_checkpoints() {
|
|
276
|
+
return this.#upstream.write_checkpoints;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
get instance() {
|
|
280
|
+
return this.#upstream.instance;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
get locks() {
|
|
284
|
+
return this.#upstream.locks;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
get bucket_state() {
|
|
288
|
+
return this.#upstream.bucket_state;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
get checkpoint_events() {
|
|
292
|
+
return this.#upstream.checkpoint_events;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
get connection_report_events() {
|
|
296
|
+
return this.#upstream.connection_report_events;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
notifyCheckpoint() {
|
|
300
|
+
return this.#upstream.notifyCheckpoint();
|
|
301
|
+
}
|
|
174
302
|
}
|
|
175
303
|
|
|
176
304
|
export function createPowerSyncMongo(config: MongoStorageConfig, options?: lib_mongo.MongoConnectionOptions) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { InternalOpId, storage } from '@powersync/service-core';
|
|
1
|
+
import { InternalOpId, SerializedSyncPlan, storage } from '@powersync/service-core';
|
|
2
2
|
import { SqliteJsonValue } from '@powersync/service-sync-rules';
|
|
3
3
|
import * as bson from 'bson';
|
|
4
4
|
import { event_types } from '@powersync/service-types';
|
|
5
|
+
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Replica id uniquely identifying a row on the source database.
|
|
@@ -37,6 +38,19 @@ export interface CurrentDataDocument {
|
|
|
37
38
|
lookups: bson.Binary[];
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
export interface CurrentDataDocumentV3 {
|
|
42
|
+
_id: SourceKey;
|
|
43
|
+
data: bson.Binary;
|
|
44
|
+
buckets: CurrentBucket[];
|
|
45
|
+
lookups: bson.Binary[];
|
|
46
|
+
/**
|
|
47
|
+
* If set, this can be deleted, once there is a consistent checkpoint >= pending_delete.
|
|
48
|
+
*
|
|
49
|
+
* This must only be set if buckets = [], lookups = [].
|
|
50
|
+
*/
|
|
51
|
+
pending_delete?: bigint;
|
|
52
|
+
}
|
|
53
|
+
|
|
40
54
|
export interface CurrentBucket {
|
|
41
55
|
bucket: string;
|
|
42
56
|
table: string;
|
|
@@ -199,6 +213,7 @@ export interface SyncRuleDocument {
|
|
|
199
213
|
last_fatal_error_ts: Date | null;
|
|
200
214
|
|
|
201
215
|
content: string;
|
|
216
|
+
serialized_plan?: SerializedSyncPlan | null;
|
|
202
217
|
|
|
203
218
|
lock?: {
|
|
204
219
|
id: string;
|
|
@@ -220,10 +235,10 @@ export interface StorageConfig extends storage.StorageVersionConfig {
|
|
|
220
235
|
|
|
221
236
|
const LONG_CHECKSUMS_STORAGE_VERSION = 2;
|
|
222
237
|
|
|
223
|
-
export function getMongoStorageConfig(storageVersion: number): StorageConfig
|
|
238
|
+
export function getMongoStorageConfig(storageVersion: number): StorageConfig {
|
|
224
239
|
const baseConfig = storage.STORAGE_VERSION_CONFIG[storageVersion];
|
|
225
240
|
if (baseConfig == null) {
|
|
226
|
-
|
|
241
|
+
throw new ServiceError(ErrorCode.PSYNC_S1005, `Unsupported storage version ${storageVersion}`);
|
|
227
242
|
}
|
|
228
243
|
|
|
229
244
|
return { ...baseConfig, longChecksums: storageVersion >= LONG_CHECKSUMS_STORAGE_VERSION };
|
package/src/utils/test-utils.ts
CHANGED
|
@@ -11,22 +11,25 @@ export type MongoTestStorageOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export function mongoTestStorageFactoryGenerator(factoryOptions: MongoTestStorageOptions) {
|
|
14
|
-
return
|
|
15
|
-
|
|
14
|
+
return {
|
|
15
|
+
factory: async (options?: TestStorageOptions) => {
|
|
16
|
+
const db = connectMongoForTests(factoryOptions.url, factoryOptions.isCI);
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
// None of the tests insert data into this collection, so it was never created
|
|
19
|
+
if (!(await db.db.listCollections({ name: db.bucket_parameters.collectionName }).hasNext())) {
|
|
20
|
+
await db.db.createCollection('bucket_parameters');
|
|
21
|
+
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
// Full migrations are not currently run for tests, so we manually create this
|
|
24
|
+
await db.createCheckpointEventsCollection();
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
if (!options?.doNotClear) {
|
|
27
|
+
await db.clear();
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
return new MongoBucketStorage(db, { slot_name_prefix: 'test_' }, factoryOptions.internalOptions);
|
|
31
|
+
},
|
|
32
|
+
tableIdStrings: false
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
|
package/src/utils/util.ts
CHANGED
|
@@ -91,10 +91,10 @@ export function mapOpEntry(row: BucketDataDocument): utils.OplogEntry {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
export function replicaIdToSubkey(table:
|
|
94
|
+
export function replicaIdToSubkey(table: storage.SourceTableId, id: storage.ReplicaId): string {
|
|
95
95
|
if (storage.isUUID(id)) {
|
|
96
96
|
// Special case for UUID for backwards-compatiblity
|
|
97
|
-
return `${table
|
|
97
|
+
return `${tableIdString(table)}/${id.toHexString()}`;
|
|
98
98
|
} else {
|
|
99
99
|
// Hashed UUID from the table and id
|
|
100
100
|
const repr = bson.serialize({ table, id });
|
|
@@ -102,6 +102,21 @@ export function replicaIdToSubkey(table: bson.ObjectId, id: storage.ReplicaId):
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
export function mongoTableId(table: storage.SourceTableId): bson.ObjectId {
|
|
106
|
+
if (typeof table == 'string') {
|
|
107
|
+
throw new ServiceAssertionError(`Got string table id, expected ObjectId`);
|
|
108
|
+
}
|
|
109
|
+
return table;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function tableIdString(table: storage.SourceTableId) {
|
|
113
|
+
if (typeof table == 'string') {
|
|
114
|
+
return table;
|
|
115
|
+
} else {
|
|
116
|
+
return table.toHexString();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
105
120
|
export function setSessionSnapshotTime(session: mongo.ClientSession, time: bson.Timestamp) {
|
|
106
121
|
// This is a workaround for the lack of direct support for snapshot reads in the MongoDB driver.
|
|
107
122
|
if (!session.snapshotEnabled) {
|
|
@@ -19,7 +19,7 @@ exports[`Connection reporting storage > Should create a connection report if its
|
|
|
19
19
|
|
|
20
20
|
exports[`Connection reporting storage > Should delete rows older than specified range 1`] = `
|
|
21
21
|
{
|
|
22
|
-
"
|
|
22
|
+
"sdk_breakdown": [
|
|
23
23
|
{
|
|
24
24
|
"clients": 1,
|
|
25
25
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -51,7 +51,7 @@ exports[`Connection reporting storage > Should delete rows older than specified
|
|
|
51
51
|
"users": 1,
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
|
-
"
|
|
54
|
+
"total_users": 5,
|
|
55
55
|
}
|
|
56
56
|
`;
|
|
57
57
|
|
|
@@ -77,9 +77,9 @@ exports[`Connection reporting storage > Should update a connection report if its
|
|
|
77
77
|
]
|
|
78
78
|
`;
|
|
79
79
|
|
|
80
|
-
exports[`Report storage tests >
|
|
80
|
+
exports[`Report storage tests > getClientConnectionsSummary returns the past day summary 1`] = `
|
|
81
81
|
{
|
|
82
|
-
"
|
|
82
|
+
"sdk_breakdown": [
|
|
83
83
|
{
|
|
84
84
|
"clients": 1,
|
|
85
85
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -101,13 +101,13 @@ exports[`Report storage tests > Should show connection report data for user over
|
|
|
101
101
|
"users": 1,
|
|
102
102
|
},
|
|
103
103
|
],
|
|
104
|
-
"
|
|
104
|
+
"total_users": 3,
|
|
105
105
|
}
|
|
106
106
|
`;
|
|
107
107
|
|
|
108
|
-
exports[`Report storage tests >
|
|
108
|
+
exports[`Report storage tests > getClientConnectionsSummary returns the past month summary 1`] = `
|
|
109
109
|
{
|
|
110
|
-
"
|
|
110
|
+
"sdk_breakdown": [
|
|
111
111
|
{
|
|
112
112
|
"clients": 1,
|
|
113
113
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -149,13 +149,13 @@ exports[`Report storage tests > Should show connection report data for user over
|
|
|
149
149
|
"users": 1,
|
|
150
150
|
},
|
|
151
151
|
],
|
|
152
|
-
"
|
|
152
|
+
"total_users": 7,
|
|
153
153
|
}
|
|
154
154
|
`;
|
|
155
155
|
|
|
156
|
-
exports[`Report storage tests >
|
|
156
|
+
exports[`Report storage tests > getClientConnectionsSummary returns the past week summary 1`] = `
|
|
157
157
|
{
|
|
158
|
-
"
|
|
158
|
+
"sdk_breakdown": [
|
|
159
159
|
{
|
|
160
160
|
"clients": 1,
|
|
161
161
|
"sdk": "powersync-dart/1.6.4",
|
|
@@ -187,50 +187,11 @@ exports[`Report storage tests > Should show connection report data for user over
|
|
|
187
187
|
"users": 1,
|
|
188
188
|
},
|
|
189
189
|
],
|
|
190
|
-
"
|
|
190
|
+
"total_users": 5,
|
|
191
191
|
}
|
|
192
192
|
`;
|
|
193
193
|
|
|
194
|
-
exports[`Report storage tests >
|
|
195
|
-
{
|
|
196
|
-
"sdks": [
|
|
197
|
-
{
|
|
198
|
-
"clients": 1,
|
|
199
|
-
"sdk": "powersync-dart/1.6.4",
|
|
200
|
-
"users": 1,
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
"clients": 1,
|
|
204
|
-
"sdk": "powersync-js/1.21.1",
|
|
205
|
-
"users": 1,
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
"clients": 1,
|
|
209
|
-
"sdk": "unknown",
|
|
210
|
-
"users": 1,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
"users": 2,
|
|
214
|
-
}
|
|
215
|
-
`;
|
|
216
|
-
|
|
217
|
-
exports[`Report storage tests > Should show paginated response of all connections of specified client_id 1`] = `
|
|
218
|
-
{
|
|
219
|
-
"count": 1,
|
|
220
|
-
"cursor": undefined,
|
|
221
|
-
"items": [
|
|
222
|
-
{
|
|
223
|
-
"client_id": "client_two",
|
|
224
|
-
"sdk": "powersync-js/1.21.1",
|
|
225
|
-
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
226
|
-
"user_id": "user_two",
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
"more": false,
|
|
230
|
-
}
|
|
231
|
-
`;
|
|
232
|
-
|
|
233
|
-
exports[`Report storage tests > Should show paginated response of all connections with a limit 1`] = `
|
|
194
|
+
exports[`Report storage tests > getClientSessions returns paginated sessions with a limit 1`] = `
|
|
234
195
|
{
|
|
235
196
|
"count": 4,
|
|
236
197
|
"cursor": "<removed-for-snapshot>",
|
|
@@ -264,7 +225,7 @@ exports[`Report storage tests > Should show paginated response of all connection
|
|
|
264
225
|
}
|
|
265
226
|
`;
|
|
266
227
|
|
|
267
|
-
exports[`Report storage tests >
|
|
228
|
+
exports[`Report storage tests > getClientSessions returns paginated sessions with a limit 2`] = `
|
|
268
229
|
{
|
|
269
230
|
"count": 4,
|
|
270
231
|
"cursor": undefined,
|
|
@@ -298,7 +259,7 @@ exports[`Report storage tests > Should show paginated response of all connection
|
|
|
298
259
|
}
|
|
299
260
|
`;
|
|
300
261
|
|
|
301
|
-
exports[`Report storage tests >
|
|
262
|
+
exports[`Report storage tests > getClientSessions returns paginated sessions with a limit and date range 1`] = `
|
|
302
263
|
{
|
|
303
264
|
"count": 4,
|
|
304
265
|
"cursor": "<removed-for-snapshot>",
|
|
@@ -332,7 +293,7 @@ exports[`Report storage tests > Should show paginated response of all connection
|
|
|
332
293
|
}
|
|
333
294
|
`;
|
|
334
295
|
|
|
335
|
-
exports[`Report storage tests >
|
|
296
|
+
exports[`Report storage tests > getClientSessions returns paginated sessions with a limit and date range 2`] = `
|
|
336
297
|
{
|
|
337
298
|
"count": 2,
|
|
338
299
|
"cursor": undefined,
|
|
@@ -366,29 +327,23 @@ exports[`Report storage tests > Should show paginated response of all connection
|
|
|
366
327
|
}
|
|
367
328
|
`;
|
|
368
329
|
|
|
369
|
-
exports[`Report storage tests >
|
|
330
|
+
exports[`Report storage tests > getClientSessions returns sessions for a client_id 1`] = `
|
|
370
331
|
{
|
|
371
|
-
"count":
|
|
332
|
+
"count": 1,
|
|
372
333
|
"cursor": undefined,
|
|
373
334
|
"items": [
|
|
374
335
|
{
|
|
375
|
-
"client_id": "
|
|
376
|
-
"sdk": "powersync-
|
|
377
|
-
"user_agent": "powersync-
|
|
378
|
-
"user_id": "
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
"client_id": "",
|
|
382
|
-
"sdk": "unknown",
|
|
383
|
-
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
384
|
-
"user_id": "user_one",
|
|
336
|
+
"client_id": "client_two",
|
|
337
|
+
"sdk": "powersync-js/1.21.1",
|
|
338
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
339
|
+
"user_id": "user_two",
|
|
385
340
|
},
|
|
386
341
|
],
|
|
387
342
|
"more": false,
|
|
388
343
|
}
|
|
389
344
|
`;
|
|
390
345
|
|
|
391
|
-
exports[`Report storage tests >
|
|
346
|
+
exports[`Report storage tests > getClientSessions returns sessions for a date range 1`] = `
|
|
392
347
|
{
|
|
393
348
|
"count": 6,
|
|
394
349
|
"cursor": undefined,
|
|
@@ -434,7 +389,29 @@ exports[`Report storage tests > Should show paginated response of connections ov
|
|
|
434
389
|
}
|
|
435
390
|
`;
|
|
436
391
|
|
|
437
|
-
exports[`Report storage tests >
|
|
392
|
+
exports[`Report storage tests > getClientSessions returns sessions for a user_id 1`] = `
|
|
393
|
+
{
|
|
394
|
+
"count": 2,
|
|
395
|
+
"cursor": undefined,
|
|
396
|
+
"items": [
|
|
397
|
+
{
|
|
398
|
+
"client_id": "client_one",
|
|
399
|
+
"sdk": "powersync-dart/1.6.4",
|
|
400
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
401
|
+
"user_id": "user_one",
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"client_id": "",
|
|
405
|
+
"sdk": "unknown",
|
|
406
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
407
|
+
"user_id": "user_one",
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
"more": false,
|
|
411
|
+
}
|
|
412
|
+
`;
|
|
413
|
+
|
|
414
|
+
exports[`Report storage tests > getClientSessions returns sessions for client_id and user_id within a date range 1`] = `
|
|
438
415
|
{
|
|
439
416
|
"count": 1,
|
|
440
417
|
"cursor": undefined,
|
|
@@ -449,3 +426,26 @@ exports[`Report storage tests > Should show paginated response of connections ov
|
|
|
449
426
|
"more": false,
|
|
450
427
|
}
|
|
451
428
|
`;
|
|
429
|
+
|
|
430
|
+
exports[`Report storage tests > getCurrentConnections returns current connections 1`] = `
|
|
431
|
+
{
|
|
432
|
+
"sdk_breakdown": [
|
|
433
|
+
{
|
|
434
|
+
"clients": 1,
|
|
435
|
+
"sdk": "powersync-dart/1.6.4",
|
|
436
|
+
"users": 1,
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"clients": 1,
|
|
440
|
+
"sdk": "powersync-js/1.21.1",
|
|
441
|
+
"users": 1,
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"clients": 1,
|
|
445
|
+
"sdk": "unknown",
|
|
446
|
+
"users": 1,
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
"total_users": 2,
|
|
450
|
+
}
|
|
451
|
+
`;
|