@powersync/service-module-mongodb-storage 0.12.11 → 0.12.13
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 +25 -0
- package/dist/storage/MongoReportStorage.d.ts +1 -0
- package/dist/storage/MongoReportStorage.js +13 -0
- package/dist/storage/MongoReportStorage.js.map +1 -1
- package/dist/utils/util.d.ts +7 -0
- package/dist/utils/util.js +32 -0
- package/dist/utils/util.js.map +1 -1
- package/package.json +7 -7
- package/src/storage/MongoReportStorage.ts +22 -0
- package/src/utils/util.ts +40 -0
- package/test/src/__snapshots__/connection-report-storage.test.ts.snap +238 -2
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @powersync/service-module-mongodb-storage
|
|
2
2
|
|
|
3
|
+
## 0.12.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 57f7660: General client connections analytics added
|
|
8
|
+
- Updated dependencies [57f7660]
|
|
9
|
+
- Updated dependencies [c050acd]
|
|
10
|
+
- Updated dependencies [0156d10]
|
|
11
|
+
- Updated dependencies [6eee0b3]
|
|
12
|
+
- @powersync/service-core@1.17.0
|
|
13
|
+
- @powersync/service-types@0.13.2
|
|
14
|
+
- @powersync/service-sync-rules@0.29.8
|
|
15
|
+
- @powersync/lib-services-framework@0.7.11
|
|
16
|
+
- @powersync/lib-service-mongodb@0.6.13
|
|
17
|
+
|
|
18
|
+
## 0.12.12
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [fff0024]
|
|
23
|
+
- @powersync/service-sync-rules@0.29.7
|
|
24
|
+
- @powersync/service-core@1.16.3
|
|
25
|
+
- @powersync/lib-services-framework@0.7.10
|
|
26
|
+
- @powersync/lib-service-mongodb@0.6.12
|
|
27
|
+
|
|
3
28
|
## 0.12.11
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -6,6 +6,7 @@ export declare class MongoReportStorage implements storage.ReportStorage {
|
|
|
6
6
|
constructor(db: PowerSyncMongo);
|
|
7
7
|
deleteOldConnectionData(data: event_types.DeleteOldConnectionData): Promise<void>;
|
|
8
8
|
getClientConnectionReports(data: event_types.ClientConnectionReportRequest): Promise<event_types.ClientConnectionReportResponse>;
|
|
9
|
+
getGeneralClientConnectionAnalytics(data: event_types.ClientConnectionAnalyticsRequest): Promise<event_types.PaginatedResponse<event_types.ClientConnection>>;
|
|
9
10
|
reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void>;
|
|
10
11
|
reportClientDisconnection(data: event_types.ClientDisconnectionEventData): Promise<void>;
|
|
11
12
|
getConnectedClients(): Promise<event_types.ClientConnectionReportResponse>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from '@powersync/lib-services-framework';
|
|
2
|
+
import { createPaginatedConnectionQuery } from '../utils/util.js';
|
|
2
3
|
export class MongoReportStorage {
|
|
3
4
|
db;
|
|
4
5
|
constructor(db) {
|
|
@@ -32,6 +33,18 @@ export class MongoReportStorage {
|
|
|
32
33
|
.toArray();
|
|
33
34
|
return result[0];
|
|
34
35
|
}
|
|
36
|
+
async getGeneralClientConnectionAnalytics(data) {
|
|
37
|
+
const { cursor, date_range } = data;
|
|
38
|
+
const limit = data?.limit || 100;
|
|
39
|
+
const connected_at = date_range ? { connected_at: { $lte: date_range.end, $gte: date_range.start } } : undefined;
|
|
40
|
+
const user_id = data.user_id != null ? { user_id: data.user_id } : undefined;
|
|
41
|
+
const client_id = data.client_id != null ? { client_id: data.client_id } : undefined;
|
|
42
|
+
return (await createPaginatedConnectionQuery({
|
|
43
|
+
...client_id,
|
|
44
|
+
...user_id,
|
|
45
|
+
...connected_at
|
|
46
|
+
}, this.db.connection_report_events, limit, cursor));
|
|
47
|
+
}
|
|
35
48
|
async reportClientConnection(data) {
|
|
36
49
|
const updateFilter = this.updateDocFilter(data.user_id, data.client_id);
|
|
37
50
|
await this.db.connection_report_events.findOneAndUpdate(updateFilter, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,OAAO,kBAAkB;IACb,EAAE,CAAiB;IAEnC,YAAY,EAAkB;QAC5B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IACD,KAAK,CAAC,uBAAuB,CAAC,IAAyC;QACrE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC;YAC/D,YAAY,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;YAC3B,GAAG,EAAE;gBACH,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBACtC,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;aACtE;SACF,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CACT,YAAY,IAAI,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,YAAY,qEAAqE,CAC5H,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,IAA+C;QAE/C,MAAM,EAAE,KAAK,EAAE,GAA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,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC;QAC1B,OAAO;YACL,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE;gBACZ,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBAC5C,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;aAC9C;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/dist/utils/util.d.ts
CHANGED
|
@@ -22,3 +22,10 @@ export declare function readSingleBatch<T>(cursor: mongo.AbstractCursor<T>): Pro
|
|
|
22
22
|
export declare function mapOpEntry(row: BucketDataDocument): utils.OplogEntry;
|
|
23
23
|
export declare function replicaIdToSubkey(table: bson.ObjectId, id: storage.ReplicaId): string;
|
|
24
24
|
export declare function setSessionSnapshotTime(session: mongo.ClientSession, time: bson.Timestamp): void;
|
|
25
|
+
export declare const createPaginatedConnectionQuery: <T extends mongo.Document>(query: mongo.Filter<T>, collection: mongo.Collection<T>, limit: number, cursor?: string) => Promise<{
|
|
26
|
+
items: mongo.WithId<T>[];
|
|
27
|
+
count: number;
|
|
28
|
+
/** Setting the cursor to the connected at date of the last item in the list */
|
|
29
|
+
cursor: any;
|
|
30
|
+
more: boolean;
|
|
31
|
+
}>;
|
package/dist/utils/util.js
CHANGED
|
@@ -106,4 +106,36 @@ export function setSessionSnapshotTime(session, time) {
|
|
|
106
106
|
throw new ServiceAssertionError(`Session snapshotTime is already set`);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
export const createPaginatedConnectionQuery = async (query, collection, limit, cursor) => {
|
|
110
|
+
const createQuery = (cursor) => {
|
|
111
|
+
if (!cursor) {
|
|
112
|
+
return query;
|
|
113
|
+
}
|
|
114
|
+
const connected_at = query.connected_at
|
|
115
|
+
? { $lt: new Date(cursor), $gte: query.connected_at.$gte }
|
|
116
|
+
: { $lt: new Date(cursor) };
|
|
117
|
+
return {
|
|
118
|
+
...query,
|
|
119
|
+
connected_at
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
const findCursor = collection.find(createQuery(cursor), {
|
|
123
|
+
sort: {
|
|
124
|
+
/** We are sorting by connected at date descending to match cursor Postgres implementation */
|
|
125
|
+
connected_at: -1
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const items = await findCursor.limit(limit).toArray();
|
|
129
|
+
const count = items.length;
|
|
130
|
+
/** The returned total has been defaulted to 0 due to the overhead using documentCount from the mogo driver.
|
|
131
|
+
* cursor.count has been deprecated.
|
|
132
|
+
* */
|
|
133
|
+
return {
|
|
134
|
+
items,
|
|
135
|
+
count,
|
|
136
|
+
/** Setting the cursor to the connected at date of the last item in the list */
|
|
137
|
+
cursor: count === limit ? items[items.length - 1].connected_at.toISOString() : undefined,
|
|
138
|
+
more: !(count !== limit)
|
|
139
|
+
};
|
|
140
|
+
};
|
|
109
141
|
//# sourceMappingURL=util.js.map
|
package/dist/utils/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/utils/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,MAAM,UAAU,cAAc,CAAI,MAAkB,EAAE,IAAiB;IACrE,IAAI,MAAM,GAAG;QACX,IAAI,EAAE;YACJ,GAAG,MAAM;SACH;QACR,G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3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
|
-
"version": "0.12.
|
|
5
|
+
"version": "0.12.13",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"license": "FSL-1.1-ALv2",
|
|
8
8
|
"type": "module",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"lru-cache": "^10.2.2",
|
|
28
28
|
"ts-codec": "^1.3.0",
|
|
29
29
|
"uuid": "^11.1.0",
|
|
30
|
-
"@powersync/lib-service-mongodb": "0.6.
|
|
31
|
-
"@powersync/lib-services-framework": "0.7.
|
|
32
|
-
"@powersync/service-core": "1.
|
|
30
|
+
"@powersync/lib-service-mongodb": "0.6.13",
|
|
31
|
+
"@powersync/lib-services-framework": "0.7.11",
|
|
32
|
+
"@powersync/service-core": "1.17.0",
|
|
33
33
|
"@powersync/service-jsonbig": "0.17.12",
|
|
34
|
-
"@powersync/service-sync-rules": "0.29.
|
|
35
|
-
"@powersync/service-types": "0.13.
|
|
34
|
+
"@powersync/service-sync-rules": "0.29.8",
|
|
35
|
+
"@powersync/service-types": "0.13.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@powersync/service-core-tests": "0.12.
|
|
38
|
+
"@powersync/service-core-tests": "0.12.13"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b",
|
|
@@ -2,6 +2,7 @@ import { storage } from '@powersync/service-core';
|
|
|
2
2
|
import { event_types } from '@powersync/service-types';
|
|
3
3
|
import { PowerSyncMongo } from './implementation/db.js';
|
|
4
4
|
import { logger } from '@powersync/lib-services-framework';
|
|
5
|
+
import { createPaginatedConnectionQuery } from '../utils/util.js';
|
|
5
6
|
|
|
6
7
|
export class MongoReportStorage implements storage.ReportStorage {
|
|
7
8
|
public readonly db: PowerSyncMongo;
|
|
@@ -43,6 +44,27 @@ export class MongoReportStorage implements storage.ReportStorage {
|
|
|
43
44
|
return result[0];
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
async getGeneralClientConnectionAnalytics(
|
|
48
|
+
data: event_types.ClientConnectionAnalyticsRequest
|
|
49
|
+
): Promise<event_types.PaginatedResponse<event_types.ClientConnection>> {
|
|
50
|
+
const { cursor, date_range } = data;
|
|
51
|
+
const limit = data?.limit || 100;
|
|
52
|
+
|
|
53
|
+
const connected_at = date_range ? { connected_at: { $lte: date_range.end, $gte: date_range.start } } : undefined;
|
|
54
|
+
const user_id = data.user_id != null ? { user_id: data.user_id } : undefined;
|
|
55
|
+
const client_id = data.client_id != null ? { client_id: data.client_id } : undefined;
|
|
56
|
+
return (await createPaginatedConnectionQuery(
|
|
57
|
+
{
|
|
58
|
+
...client_id,
|
|
59
|
+
...user_id,
|
|
60
|
+
...connected_at
|
|
61
|
+
},
|
|
62
|
+
this.db.connection_report_events,
|
|
63
|
+
limit,
|
|
64
|
+
cursor
|
|
65
|
+
)) as event_types.PaginatedResponse<event_types.ClientConnection>;
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
async reportClientConnection(data: event_types.ClientConnectionBucketData): Promise<void> {
|
|
47
69
|
const updateFilter = this.updateDocFilter(data.user_id, data.client_id!);
|
|
48
70
|
await this.db.connection_report_events.findOneAndUpdate(
|
package/src/utils/util.ts
CHANGED
|
@@ -114,3 +114,43 @@ export function setSessionSnapshotTime(session: mongo.ClientSession, time: bson.
|
|
|
114
114
|
throw new ServiceAssertionError(`Session snapshotTime is already set`);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
export const createPaginatedConnectionQuery = async <T extends mongo.Document>(
|
|
119
|
+
query: mongo.Filter<T>,
|
|
120
|
+
collection: mongo.Collection<T>,
|
|
121
|
+
limit: number,
|
|
122
|
+
cursor?: string
|
|
123
|
+
) => {
|
|
124
|
+
const createQuery = (cursor?: string) => {
|
|
125
|
+
if (!cursor) {
|
|
126
|
+
return query;
|
|
127
|
+
}
|
|
128
|
+
const connected_at = query.connected_at
|
|
129
|
+
? { $lt: new Date(cursor), $gte: query.connected_at.$gte }
|
|
130
|
+
: { $lt: new Date(cursor) };
|
|
131
|
+
return {
|
|
132
|
+
...query,
|
|
133
|
+
connected_at
|
|
134
|
+
} as mongo.Filter<T>;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const findCursor = collection.find(createQuery(cursor), {
|
|
138
|
+
sort: {
|
|
139
|
+
/** We are sorting by connected at date descending to match cursor Postgres implementation */
|
|
140
|
+
connected_at: -1
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const items = await findCursor.limit(limit).toArray();
|
|
145
|
+
const count = items.length;
|
|
146
|
+
/** The returned total has been defaulted to 0 due to the overhead using documentCount from the mogo driver.
|
|
147
|
+
* cursor.count has been deprecated.
|
|
148
|
+
* */
|
|
149
|
+
return {
|
|
150
|
+
items,
|
|
151
|
+
count,
|
|
152
|
+
/** Setting the cursor to the connected at date of the last item in the list */
|
|
153
|
+
cursor: count === limit ? items[items.length - 1].connected_at.toISOString() : undefined,
|
|
154
|
+
more: !(count !== limit)
|
|
155
|
+
};
|
|
156
|
+
};
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
exports[`Connection reporting storage > Should create a connection report if its after a day 1`] = `
|
|
4
4
|
[
|
|
5
5
|
{
|
|
6
|
-
"client_id": "
|
|
6
|
+
"client_id": "client_one",
|
|
7
7
|
"sdk": "powersync-js/1.24.5",
|
|
8
8
|
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
9
9
|
"user_id": "user_week",
|
|
10
10
|
},
|
|
11
11
|
{
|
|
12
|
-
"client_id": "
|
|
12
|
+
"client_id": "client_one",
|
|
13
13
|
"sdk": "powersync-js/1.24.5",
|
|
14
14
|
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
15
15
|
"user_id": "user_week",
|
|
@@ -213,3 +213,239 @@ exports[`Report storage tests > Should show currently connected users 1`] = `
|
|
|
213
213
|
"users": 2,
|
|
214
214
|
}
|
|
215
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`] = `
|
|
234
|
+
{
|
|
235
|
+
"count": 4,
|
|
236
|
+
"cursor": "<removed-for-snapshot>",
|
|
237
|
+
"items": [
|
|
238
|
+
{
|
|
239
|
+
"client_id": "client_one",
|
|
240
|
+
"sdk": "powersync-dart/1.6.4",
|
|
241
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
242
|
+
"user_id": "user_one",
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"client_id": "client_four",
|
|
246
|
+
"sdk": "powersync-js/1.21.4",
|
|
247
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
248
|
+
"user_id": "user_four",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"client_id": "",
|
|
252
|
+
"sdk": "unknown",
|
|
253
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
254
|
+
"user_id": "user_one",
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"client_id": "client_two",
|
|
258
|
+
"sdk": "powersync-js/1.21.1",
|
|
259
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
260
|
+
"user_id": "user_two",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
"more": true,
|
|
264
|
+
}
|
|
265
|
+
`;
|
|
266
|
+
|
|
267
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit 2`] = `
|
|
268
|
+
{
|
|
269
|
+
"count": 4,
|
|
270
|
+
"cursor": undefined,
|
|
271
|
+
"items": [
|
|
272
|
+
{
|
|
273
|
+
"client_id": "client_three",
|
|
274
|
+
"sdk": "powersync-js/1.21.2",
|
|
275
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
276
|
+
"user_id": "user_three",
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"client_id": "client_one",
|
|
280
|
+
"sdk": "powersync-js/1.24.5",
|
|
281
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
282
|
+
"user_id": "user_week",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"client_id": "client_month",
|
|
286
|
+
"sdk": "powersync-js/1.23.6",
|
|
287
|
+
"user_agent": "powersync-js/1.23.0 powersync-web Firefox/141 linux",
|
|
288
|
+
"user_id": "user_month",
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"client_id": "client_expired",
|
|
292
|
+
"sdk": "powersync-js/1.23.7",
|
|
293
|
+
"user_agent": "powersync-js/1.23.0 powersync-web Firefox/141 linux",
|
|
294
|
+
"user_id": "user_expired",
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
"more": false,
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
|
|
301
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit with date range 1`] = `
|
|
302
|
+
{
|
|
303
|
+
"count": 4,
|
|
304
|
+
"cursor": "<removed-for-snapshot>",
|
|
305
|
+
"items": [
|
|
306
|
+
{
|
|
307
|
+
"client_id": "",
|
|
308
|
+
"sdk": "unknown",
|
|
309
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
310
|
+
"user_id": "user_one",
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"client_id": "client_two",
|
|
314
|
+
"sdk": "powersync-js/1.21.1",
|
|
315
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
316
|
+
"user_id": "user_two",
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"client_id": "client_three",
|
|
320
|
+
"sdk": "powersync-js/1.21.2",
|
|
321
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
322
|
+
"user_id": "user_three",
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"client_id": "client_one",
|
|
326
|
+
"sdk": "powersync-js/1.24.5",
|
|
327
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
328
|
+
"user_id": "user_week",
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
"more": true,
|
|
332
|
+
}
|
|
333
|
+
`;
|
|
334
|
+
|
|
335
|
+
exports[`Report storage tests > Should show paginated response of all connections with a limit with date range 2`] = `
|
|
336
|
+
{
|
|
337
|
+
"count": 2,
|
|
338
|
+
"cursor": undefined,
|
|
339
|
+
"items": [
|
|
340
|
+
{
|
|
341
|
+
"client_id": "",
|
|
342
|
+
"sdk": "unknown",
|
|
343
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
344
|
+
"user_id": "user_one",
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"client_id": "client_two",
|
|
348
|
+
"sdk": "powersync-js/1.21.1",
|
|
349
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
350
|
+
"user_id": "user_two",
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"client_id": "client_three",
|
|
354
|
+
"sdk": "powersync-js/1.21.2",
|
|
355
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
356
|
+
"user_id": "user_three",
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"client_id": "client_one",
|
|
360
|
+
"sdk": "powersync-js/1.24.5",
|
|
361
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
362
|
+
"user_id": "user_week",
|
|
363
|
+
},
|
|
364
|
+
],
|
|
365
|
+
"more": false,
|
|
366
|
+
}
|
|
367
|
+
`;
|
|
368
|
+
|
|
369
|
+
exports[`Report storage tests > Should show paginated response of connections of specified user_id 1`] = `
|
|
370
|
+
{
|
|
371
|
+
"count": 2,
|
|
372
|
+
"cursor": undefined,
|
|
373
|
+
"items": [
|
|
374
|
+
{
|
|
375
|
+
"client_id": "client_one",
|
|
376
|
+
"sdk": "powersync-dart/1.6.4",
|
|
377
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
378
|
+
"user_id": "user_one",
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"client_id": "",
|
|
382
|
+
"sdk": "unknown",
|
|
383
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
384
|
+
"user_id": "user_one",
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
"more": false,
|
|
388
|
+
}
|
|
389
|
+
`;
|
|
390
|
+
|
|
391
|
+
exports[`Report storage tests > Should show paginated response of connections over a date range 1`] = `
|
|
392
|
+
{
|
|
393
|
+
"count": 6,
|
|
394
|
+
"cursor": undefined,
|
|
395
|
+
"items": [
|
|
396
|
+
{
|
|
397
|
+
"client_id": "client_one",
|
|
398
|
+
"sdk": "powersync-dart/1.6.4",
|
|
399
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
400
|
+
"user_id": "user_one",
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
"client_id": "client_four",
|
|
404
|
+
"sdk": "powersync-js/1.21.4",
|
|
405
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
406
|
+
"user_id": "user_four",
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"client_id": "client_two",
|
|
410
|
+
"sdk": "powersync-js/1.21.1",
|
|
411
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Chromium/138 linux",
|
|
412
|
+
"user_id": "user_two",
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
"client_id": "",
|
|
416
|
+
"sdk": "unknown",
|
|
417
|
+
"user_agent": "Dart (flutter-web) Chrome/128 android",
|
|
418
|
+
"user_id": "user_one",
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
"client_id": "client_three",
|
|
422
|
+
"sdk": "powersync-js/1.21.2",
|
|
423
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
424
|
+
"user_id": "user_three",
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
"client_id": "client_one",
|
|
428
|
+
"sdk": "powersync-js/1.24.5",
|
|
429
|
+
"user_agent": "powersync-js/1.21.0 powersync-web Firefox/141 linux",
|
|
430
|
+
"user_id": "user_week",
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
"more": false,
|
|
434
|
+
}
|
|
435
|
+
`;
|
|
436
|
+
|
|
437
|
+
exports[`Report storage tests > Should show paginated response of connections over a date range of specified client_id and user_id 1`] = `
|
|
438
|
+
{
|
|
439
|
+
"count": 1,
|
|
440
|
+
"cursor": undefined,
|
|
441
|
+
"items": [
|
|
442
|
+
{
|
|
443
|
+
"client_id": "client_one",
|
|
444
|
+
"sdk": "powersync-dart/1.6.4",
|
|
445
|
+
"user_agent": "powersync-dart/1.6.4 Dart (flutter-web) Chrome/128 android",
|
|
446
|
+
"user_id": "user_one",
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
"more": false,
|
|
450
|
+
}
|
|
451
|
+
`;
|