@powersync/service-module-mongodb-storage 0.0.0-dev-20250722135642 → 0.0.0-dev-20250722140738
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,6 +1,6 @@
|
|
|
1
1
|
# @powersync/service-module-mongodb-storage
|
|
2
2
|
|
|
3
|
-
## 0.0.0-dev-
|
|
3
|
+
## 0.0.0-dev-20250722140738
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
- Updated dependencies [4ebc3bf]
|
|
11
11
|
- Updated dependencies [1aafdaf]
|
|
12
12
|
- Updated dependencies [a700ec9]
|
|
13
|
-
- @powersync/service-core@0.0.0-dev-
|
|
14
|
-
- @powersync/service-types@0.0.0-dev-
|
|
15
|
-
- @powersync/lib-services-framework@0.0.0-dev-
|
|
16
|
-
- @powersync/lib-service-mongodb@0.0.0-dev-
|
|
13
|
+
- @powersync/service-core@0.0.0-dev-20250722140738
|
|
14
|
+
- @powersync/service-types@0.0.0-dev-20250722140738
|
|
15
|
+
- @powersync/lib-services-framework@0.0.0-dev-20250722140738
|
|
16
|
+
- @powersync/lib-service-mongodb@0.0.0-dev-20250722140738
|
|
17
17
|
|
|
18
18
|
## 0.10.4
|
|
19
19
|
|
|
@@ -17,8 +17,8 @@ function updateDocFilter(userId, clientId) {
|
|
|
17
17
|
user_id: userId,
|
|
18
18
|
client_id: clientId,
|
|
19
19
|
connect_at: {
|
|
20
|
-
$gte: new Date(
|
|
21
|
-
$lt: new Date(
|
|
20
|
+
$gte: new Date(year, month, today),
|
|
21
|
+
$lt: new Date(year, month, nextDay)
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -30,9 +30,7 @@ function timeSpan(timeframe) {
|
|
|
30
30
|
// Cron should run the first day of the new month, this then retrieves from the 1st to the last day of the month
|
|
31
31
|
const thisMonth = month;
|
|
32
32
|
const nextMonth = month == 11 ? 0 : month + 1;
|
|
33
|
-
return {
|
|
34
|
-
connect_at: { $gte: new Date(`${year}-${thisMonth}-${1}`), $lte: new Date(`${year}-${nextMonth}-${1}`) }
|
|
35
|
-
};
|
|
33
|
+
return { $gte: new Date(year, thisMonth), $lte: new Date(year, nextMonth) };
|
|
36
34
|
}
|
|
37
35
|
case 'week': {
|
|
38
36
|
// Back tracks the date to the previous week Monday to Sunday
|
|
@@ -44,20 +42,16 @@ function timeSpan(timeframe) {
|
|
|
44
42
|
const weekStart = parseDate(weekStartDate);
|
|
45
43
|
const weekEnd = parseDate(weekEndDate);
|
|
46
44
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
$lte: new Date(`${weekEnd.year}-${weekEnd.month}-${weekEnd.today + 1}`) // +1 to include the end date
|
|
50
|
-
}
|
|
45
|
+
$gte: new Date(weekStart.year, weekStart.month, weekStart.today),
|
|
46
|
+
$lte: new Date(weekEnd.year, weekEnd.month, weekEnd.today)
|
|
51
47
|
};
|
|
52
48
|
}
|
|
53
49
|
default: {
|
|
54
50
|
// Start from today to just before tomorrow
|
|
55
51
|
const nextDay = today + 1;
|
|
56
52
|
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$lt: new Date(`${year}-${month}-${nextDay}`)
|
|
60
|
-
}
|
|
53
|
+
$gte: new Date(year, month, today),
|
|
54
|
+
$lt: new Date(year, month, nextDay)
|
|
61
55
|
};
|
|
62
56
|
}
|
|
63
57
|
}
|
|
@@ -81,47 +75,47 @@ export class MongoReportStorage {
|
|
|
81
75
|
$match: {
|
|
82
76
|
connect_at: timespanFilter
|
|
83
77
|
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
$facet: {
|
|
81
|
+
unique_user_ids: [
|
|
82
|
+
{
|
|
83
|
+
$group: {
|
|
84
|
+
_id: '$user_id'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
$count: 'count'
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
unique_user_sdk: [
|
|
92
|
+
{
|
|
93
|
+
$group: {
|
|
94
|
+
_id: {
|
|
95
|
+
user_id: '$user_id',
|
|
96
|
+
sdk: '$sdk'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
$count: 'count'
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
unique_user_client: [
|
|
105
|
+
{
|
|
106
|
+
$group: {
|
|
107
|
+
_id: {
|
|
108
|
+
user_id: '$user_id',
|
|
109
|
+
client_id: '$client_id'
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
$count: 'count'
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
84
118
|
}
|
|
85
|
-
// {
|
|
86
|
-
// $facet: {
|
|
87
|
-
// unique_user_ids: [
|
|
88
|
-
// {
|
|
89
|
-
// $group: {
|
|
90
|
-
// _id: '$user_id'
|
|
91
|
-
// }
|
|
92
|
-
// },
|
|
93
|
-
// {
|
|
94
|
-
// $count: 'count'
|
|
95
|
-
// }
|
|
96
|
-
// ],
|
|
97
|
-
// unique_user_sdk: [
|
|
98
|
-
// {
|
|
99
|
-
// $group: {
|
|
100
|
-
// _id: {
|
|
101
|
-
// user_id: '$user_id',
|
|
102
|
-
// sdk: '$sdk'
|
|
103
|
-
// }
|
|
104
|
-
// }
|
|
105
|
-
// },
|
|
106
|
-
// {
|
|
107
|
-
// $count: 'count'
|
|
108
|
-
// }
|
|
109
|
-
// ],
|
|
110
|
-
// unique_user_client: [
|
|
111
|
-
// {
|
|
112
|
-
// $group: {
|
|
113
|
-
// _id: {
|
|
114
|
-
// user_id: '$user_id',
|
|
115
|
-
// client_id: '$client_id'
|
|
116
|
-
// }
|
|
117
|
-
// }
|
|
118
|
-
// },
|
|
119
|
-
// {
|
|
120
|
-
// $count: 'count'
|
|
121
|
-
// }
|
|
122
|
-
// ]
|
|
123
|
-
// }
|
|
124
|
-
// }
|
|
125
119
|
])
|
|
126
120
|
.toArray();
|
|
127
121
|
return result[0];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"AAKA,SAAS,SAAS,CAAC,IAAU;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC1B,OAAO;QACL,IAAI;QACJ,KAAK;QACL,KAAK;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AACD,SAAS,eAAe,CAAC,MAAc,EAAE,QAAgB;IACvD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC;IAC1B,OAAO;QACL,OAAO,EAAE,MAAM;QACf,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE;YACV,IAAI,EAAE,IAAI,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"AAKA,SAAS,SAAS,CAAC,IAAU;IAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;IAC1B,OAAO;QACL,IAAI;QACJ,KAAK;QACL,KAA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AAO,EAAE,IAAI,CAAC,SAAU,CAAC,EAAE;YAC/F,IAAI,EAAE;gBACJ,aAAa,EAAE,IAAI,CAAC,aAAa;aAClC;YACD,MAAM,EAAE;gBACN,OAAO,EAAE,EAAE;aACZ;SACF,CAAC,CAAC;IACL,CAAC;IACD,KAAK,CAAC,sBAAsB,CAAC,IAAiC;QAC5D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,iBAAiB;aAC3C,SAAS,CAAqC;YAC7C;gBACE,MAAM,EAAE;oBACN,GAAG,EAAE,IAAI;oBACT,QAAQ,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE;oBACnC,UAAU,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE;oBACvC,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;iBAC5B;aACF;YACD;gBACE,QAAQ,EAAE;oBACR,GAAG,EAAE,CAAC;oBACN,KAAK,EAAE,WAAW;oBAClB,OAAO,EAAE,aAAa;oBACtB,IAAI,EAAE,OAAO;iBACd;aACF;SACF,CAAC;aACD,OAAO,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,MAAM,CAAC,CAAC,CAAC;SACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,QAAQ;IACV,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@powersync/service-module-mongodb-storage",
|
|
3
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-20250722140738",
|
|
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-20250722140738",
|
|
31
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20250722140738",
|
|
32
|
+
"@powersync/service-core": "0.0.0-dev-20250722140738",
|
|
33
|
+
"@powersync/service-types": "0.0.0-dev-20250722140738",
|
|
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-20250722140738"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b",
|
|
@@ -15,20 +15,20 @@ function parseDate(date: Date) {
|
|
|
15
15
|
day
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function updateDocFilter(userId: string, clientId: string)
|
|
18
|
+
function updateDocFilter(userId: string, clientId: string) {
|
|
19
19
|
const { year, month, today } = parseDate(new Date());
|
|
20
20
|
const nextDay = today + 1;
|
|
21
21
|
return {
|
|
22
22
|
user_id: userId,
|
|
23
23
|
client_id: clientId,
|
|
24
24
|
connect_at: {
|
|
25
|
-
$gte: new Date(
|
|
26
|
-
$lt: new Date(
|
|
25
|
+
$gte: new Date(year, month, today),
|
|
26
|
+
$lt: new Date(year, month, nextDay)
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function timeSpan(timeframe: event_types.TimeFrames)
|
|
31
|
+
function timeSpan(timeframe: event_types.TimeFrames) {
|
|
32
32
|
const date = new Date();
|
|
33
33
|
const { year, month, day, today } = parseDate(date);
|
|
34
34
|
switch (timeframe) {
|
|
@@ -36,9 +36,7 @@ function timeSpan(timeframe: event_types.TimeFrames): mongo.Filter<mongo.Documen
|
|
|
36
36
|
// Cron should run the first day of the new month, this then retrieves from the 1st to the last day of the month
|
|
37
37
|
const thisMonth = month;
|
|
38
38
|
const nextMonth = month == 11 ? 0 : month + 1;
|
|
39
|
-
return {
|
|
40
|
-
connect_at: { $gte: new Date(`${year}-${thisMonth}-${1}`), $lte: new Date(`${year}-${nextMonth}-${1}`) }
|
|
41
|
-
};
|
|
39
|
+
return { $gte: new Date(year, thisMonth), $lte: new Date(year, nextMonth) };
|
|
42
40
|
}
|
|
43
41
|
case 'week': {
|
|
44
42
|
// Back tracks the date to the previous week Monday to Sunday
|
|
@@ -50,20 +48,16 @@ function timeSpan(timeframe: event_types.TimeFrames): mongo.Filter<mongo.Documen
|
|
|
50
48
|
const weekStart = parseDate(weekStartDate);
|
|
51
49
|
const weekEnd = parseDate(weekEndDate);
|
|
52
50
|
return {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
$lte: new Date(`${weekEnd.year}-${weekEnd.month}-${weekEnd.today + 1}`) // +1 to include the end date
|
|
56
|
-
}
|
|
51
|
+
$gte: new Date(weekStart.year, weekStart.month, weekStart.today),
|
|
52
|
+
$lte: new Date(weekEnd.year, weekEnd.month, weekEnd.today)
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
55
|
default: {
|
|
60
56
|
// Start from today to just before tomorrow
|
|
61
57
|
const nextDay = today + 1;
|
|
62
58
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
$lt: new Date(`${year}-${month}-${nextDay}`)
|
|
66
|
-
}
|
|
59
|
+
$gte: new Date(year, month, today),
|
|
60
|
+
$lt: new Date(year, month, nextDay)
|
|
67
61
|
};
|
|
68
62
|
}
|
|
69
63
|
}
|
|
@@ -91,47 +85,47 @@ export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
|
91
85
|
$match: {
|
|
92
86
|
connect_at: timespanFilter
|
|
93
87
|
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
$facet: {
|
|
91
|
+
unique_user_ids: [
|
|
92
|
+
{
|
|
93
|
+
$group: {
|
|
94
|
+
_id: '$user_id'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
$count: 'count'
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
unique_user_sdk: [
|
|
102
|
+
{
|
|
103
|
+
$group: {
|
|
104
|
+
_id: {
|
|
105
|
+
user_id: '$user_id',
|
|
106
|
+
sdk: '$sdk'
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
$count: 'count'
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
unique_user_client: [
|
|
115
|
+
{
|
|
116
|
+
$group: {
|
|
117
|
+
_id: {
|
|
118
|
+
user_id: '$user_id',
|
|
119
|
+
client_id: '$client_id'
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
$count: 'count'
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
94
128
|
}
|
|
95
|
-
// {
|
|
96
|
-
// $facet: {
|
|
97
|
-
// unique_user_ids: [
|
|
98
|
-
// {
|
|
99
|
-
// $group: {
|
|
100
|
-
// _id: '$user_id'
|
|
101
|
-
// }
|
|
102
|
-
// },
|
|
103
|
-
// {
|
|
104
|
-
// $count: 'count'
|
|
105
|
-
// }
|
|
106
|
-
// ],
|
|
107
|
-
// unique_user_sdk: [
|
|
108
|
-
// {
|
|
109
|
-
// $group: {
|
|
110
|
-
// _id: {
|
|
111
|
-
// user_id: '$user_id',
|
|
112
|
-
// sdk: '$sdk'
|
|
113
|
-
// }
|
|
114
|
-
// }
|
|
115
|
-
// },
|
|
116
|
-
// {
|
|
117
|
-
// $count: 'count'
|
|
118
|
-
// }
|
|
119
|
-
// ],
|
|
120
|
-
// unique_user_client: [
|
|
121
|
-
// {
|
|
122
|
-
// $group: {
|
|
123
|
-
// _id: {
|
|
124
|
-
// user_id: '$user_id',
|
|
125
|
-
// client_id: '$client_id'
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
// },
|
|
129
|
-
// {
|
|
130
|
-
// $count: 'count'
|
|
131
|
-
// }
|
|
132
|
-
// ]
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
129
|
])
|
|
136
130
|
.toArray();
|
|
137
131
|
return result[0] as event_types.ListCurrentConnectionsResponse;
|