@powersync/service-module-mongodb-storage 0.0.0-dev-20250721152112 → 0.0.0-dev-20250722085017
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
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# @powersync/service-module-mongodb-storage
|
|
2
2
|
|
|
3
|
-
## 0.0.0-dev-
|
|
3
|
+
## 0.0.0-dev-20250722085017
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- f1d187b: sdk reporting
|
|
8
8
|
- a700ec9: Reporting mongo storage added to storage engine.
|
|
9
9
|
- Updated dependencies [f1d187b]
|
|
10
|
+
- Updated dependencies [4ebc3bf]
|
|
11
|
+
- Updated dependencies [1aafdaf]
|
|
10
12
|
- Updated dependencies [a700ec9]
|
|
11
|
-
- @powersync/service-core@0.0.0-dev-
|
|
12
|
-
- @powersync/service-types@0.0.0-dev-
|
|
13
|
-
- @powersync/lib-services-framework@0.0.0-dev-
|
|
14
|
-
- @powersync/lib-service-mongodb@0.0.0-dev-
|
|
13
|
+
- @powersync/service-core@0.0.0-dev-20250722085017
|
|
14
|
+
- @powersync/service-types@0.0.0-dev-20250722085017
|
|
15
|
+
- @powersync/lib-services-framework@0.0.0-dev-20250722085017
|
|
16
|
+
- @powersync/lib-service-mongodb@0.0.0-dev-20250722085017
|
|
15
17
|
|
|
16
18
|
## 0.10.4
|
|
17
19
|
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
function dateFilter(userId, clientId) {
|
|
2
|
+
const date = new Date();
|
|
3
|
+
const year = date.getFullYear();
|
|
4
|
+
const month = date.getMonth() + 1;
|
|
5
|
+
const day = date.getDate();
|
|
6
|
+
return {
|
|
7
|
+
user_id: userId,
|
|
8
|
+
client_id: clientId,
|
|
9
|
+
connect_at: {
|
|
10
|
+
$gte: new Date(year, month, day, 0, 0, 0),
|
|
11
|
+
$lt: new Date(year, month, day + 1, 0, 0, 0)
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
1
15
|
export class MongoReportStorage {
|
|
2
16
|
client;
|
|
3
17
|
db;
|
|
@@ -36,16 +50,19 @@ export class MongoReportStorage {
|
|
|
36
50
|
};
|
|
37
51
|
}
|
|
38
52
|
async reportSdkConnect(data) {
|
|
39
|
-
await this.db.sdk_report_events.findOneAndUpdate(
|
|
40
|
-
$set: data
|
|
53
|
+
await this.db.sdk_report_events.findOneAndUpdate(dateFilter(data.user_id, data.client_id), {
|
|
54
|
+
$set: data,
|
|
55
|
+
$unset: {
|
|
56
|
+
disconnect_at: ''
|
|
57
|
+
}
|
|
41
58
|
}, {
|
|
42
59
|
upsert: true
|
|
43
60
|
});
|
|
44
61
|
}
|
|
45
62
|
async reportSdkDisconnect(data) {
|
|
46
|
-
await this.db.sdk_report_events.findOneAndUpdate(
|
|
63
|
+
await this.db.sdk_report_events.findOneAndUpdate(dateFilter(data.user_id, data.client_id), {
|
|
47
64
|
$set: {
|
|
48
|
-
disconnect_at: data.
|
|
65
|
+
disconnect_at: data.disconnect_at
|
|
49
66
|
},
|
|
50
67
|
$unset: {
|
|
51
68
|
jwt_exp: ''
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,kBAAkB;IACZ,MAAM,CAAoB;IAC3B,EAAE,CAAiB;IAEnC,YAAY,EAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,IAAkC;QACvD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAiC;QACnD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAA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
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
|
-
"version": "0.0.0-dev-
|
|
5
|
+
"version": "0.0.0-dev-20250722085017",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"license": "FSL-1.1-Apache-2.0",
|
|
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.0.0-dev-
|
|
31
|
-
"@powersync/lib-services-framework": "0.0.0-dev-
|
|
32
|
-
"@powersync/service-core": "0.0.0-dev-
|
|
33
|
-
"@powersync/service-types": "0.0.0-dev-
|
|
30
|
+
"@powersync/lib-service-mongodb": "0.0.0-dev-20250722085017",
|
|
31
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20250722085017",
|
|
32
|
+
"@powersync/service-core": "0.0.0-dev-20250722085017",
|
|
33
|
+
"@powersync/service-types": "0.0.0-dev-20250722085017",
|
|
34
34
|
"@powersync/service-jsonbig": "0.17.10",
|
|
35
35
|
"@powersync/service-sync-rules": "0.27.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@powersync/service-core-tests": "0.0.0-dev-
|
|
38
|
+
"@powersync/service-core-tests": "0.0.0-dev-20250722085017"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b",
|
|
@@ -9,6 +9,21 @@ import {
|
|
|
9
9
|
SdkDisconnectEventData
|
|
10
10
|
} from '@powersync/service-types/dist/events.js';
|
|
11
11
|
|
|
12
|
+
function dateFilter(userId: string, clientId: string): mongo.Filter<mongo.Document> {
|
|
13
|
+
const date = new Date();
|
|
14
|
+
const year = date.getFullYear();
|
|
15
|
+
const month = date.getMonth() + 1;
|
|
16
|
+
const day = date.getDate();
|
|
17
|
+
return {
|
|
18
|
+
user_id: userId,
|
|
19
|
+
client_id: clientId,
|
|
20
|
+
connect_at: {
|
|
21
|
+
$gte: new Date(year, month, day, 0, 0, 0),
|
|
22
|
+
$lt: new Date(year, month, day + 1, 0, 0, 0)
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
12
27
|
export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
13
28
|
private readonly client: mongo.MongoClient;
|
|
14
29
|
public readonly db: PowerSyncMongo;
|
|
@@ -52,9 +67,12 @@ export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
|
52
67
|
|
|
53
68
|
async reportSdkConnect(data: SdkConnectBucketData): Promise<void> {
|
|
54
69
|
await this.db.sdk_report_events.findOneAndUpdate(
|
|
55
|
-
|
|
70
|
+
dateFilter(data.user_id, data.client_id!),
|
|
56
71
|
{
|
|
57
|
-
$set: data
|
|
72
|
+
$set: data,
|
|
73
|
+
$unset: {
|
|
74
|
+
disconnect_at: ''
|
|
75
|
+
}
|
|
58
76
|
},
|
|
59
77
|
{
|
|
60
78
|
upsert: true
|
|
@@ -62,17 +80,14 @@ export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
|
62
80
|
);
|
|
63
81
|
}
|
|
64
82
|
async reportSdkDisconnect(data: SdkDisconnectEventData): Promise<void> {
|
|
65
|
-
await this.db.sdk_report_events.findOneAndUpdate(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
$unset: {
|
|
72
|
-
jwt_exp: ''
|
|
73
|
-
}
|
|
83
|
+
await this.db.sdk_report_events.findOneAndUpdate(dateFilter(data.user_id, data.client_id!), {
|
|
84
|
+
$set: {
|
|
85
|
+
disconnect_at: data.disconnect_at
|
|
86
|
+
},
|
|
87
|
+
$unset: {
|
|
88
|
+
jwt_exp: ''
|
|
74
89
|
}
|
|
75
|
-
);
|
|
90
|
+
});
|
|
76
91
|
}
|
|
77
92
|
async listCurrentConnections(data: event_types.InstanceRequest): Promise<ListCurrentConnectionsResponse> {
|
|
78
93
|
const result = await this.db.sdk_report_events
|