@powersync/service-module-mongodb-storage 0.0.0-dev-20250722122401 → 0.0.0-dev-20250722130644
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-20250722130644
|
|
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-20250722130644
|
|
14
|
+
- @powersync/service-types@0.0.0-dev-20250722130644
|
|
15
|
+
- @powersync/lib-services-framework@0.0.0-dev-20250722130644
|
|
16
|
+
- @powersync/lib-service-mongodb@0.0.0-dev-20250722130644
|
|
17
17
|
|
|
18
18
|
## 0.10.4
|
|
19
19
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { event_types } from '@powersync/service-types';
|
|
2
1
|
function parseDate(date) {
|
|
3
2
|
const year = date.getFullYear();
|
|
4
3
|
const month = date.getMonth();
|
|
@@ -27,7 +26,7 @@ function timeSpan(timeframe) {
|
|
|
27
26
|
const date = new Date();
|
|
28
27
|
const { year, month, day, today } = parseDate(date);
|
|
29
28
|
switch (timeframe) {
|
|
30
|
-
case
|
|
29
|
+
case 'month': {
|
|
31
30
|
// Cron should run the first day of the new month, this then retrieves from the 1st to the last day of the month
|
|
32
31
|
const thisMonth = month;
|
|
33
32
|
const nextMonth = month == 11 ? 0 : month + 1;
|
|
@@ -35,7 +34,7 @@ function timeSpan(timeframe) {
|
|
|
35
34
|
connect_at: { $gte: new Date(year, thisMonth, 1, 0, 0, 0), $lte: new Date(year, nextMonth, 1, 0, 0, 0) }
|
|
36
35
|
};
|
|
37
36
|
}
|
|
38
|
-
case
|
|
37
|
+
case 'week': {
|
|
39
38
|
// Back tracks the date to the previous week Monday to Sunday
|
|
40
39
|
const daysToSunday = 0 - day;
|
|
41
40
|
const weekEndDate = new Date(date);
|
|
@@ -74,11 +73,13 @@ export class MongoReportStorage {
|
|
|
74
73
|
console.log(data);
|
|
75
74
|
}
|
|
76
75
|
async scrapeSdkData(data) {
|
|
76
|
+
const timespanFilter = timeSpan(data.scrape_time);
|
|
77
|
+
console.log(timespanFilter);
|
|
77
78
|
const result = await this.db.sdk_report_events
|
|
78
79
|
.aggregate([
|
|
79
80
|
{
|
|
80
81
|
$match: {
|
|
81
|
-
connect_at:
|
|
82
|
+
connect_at: timespanFilter
|
|
82
83
|
}
|
|
83
84
|
},
|
|
84
85
|
{
|
|
@@ -123,7 +124,6 @@ export class MongoReportStorage {
|
|
|
123
124
|
}
|
|
124
125
|
])
|
|
125
126
|
.toArray();
|
|
126
|
-
console.log(result[0]);
|
|
127
127
|
return result[0];
|
|
128
128
|
}
|
|
129
129
|
async reportSdkConnect(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoReportStorage.js","sourceRoot":"","sources":["../../src/storage/MongoReportStorage.ts"],"names":[],"mappings":"
|
|
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,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O,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-20250722130644",
|
|
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-20250722130644",
|
|
31
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20250722130644",
|
|
32
|
+
"@powersync/service-core": "0.0.0-dev-20250722130644",
|
|
33
|
+
"@powersync/service-types": "0.0.0-dev-20250722130644",
|
|
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-20250722130644"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b",
|
|
@@ -32,7 +32,7 @@ function timeSpan(timeframe: event_types.TimeFrames): mongo.Filter<mongo.Documen
|
|
|
32
32
|
const date = new Date();
|
|
33
33
|
const { year, month, day, today } = parseDate(date);
|
|
34
34
|
switch (timeframe) {
|
|
35
|
-
case
|
|
35
|
+
case 'month': {
|
|
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;
|
|
@@ -40,7 +40,7 @@ function timeSpan(timeframe: event_types.TimeFrames): mongo.Filter<mongo.Documen
|
|
|
40
40
|
connect_at: { $gte: new Date(year, thisMonth, 1, 0, 0, 0), $lte: new Date(year, nextMonth, 1, 0, 0, 0) }
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
case
|
|
43
|
+
case 'week': {
|
|
44
44
|
// Back tracks the date to the previous week Monday to Sunday
|
|
45
45
|
const daysToSunday = 0 - day;
|
|
46
46
|
const weekEndDate = new Date(date);
|
|
@@ -83,11 +83,13 @@ export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
async scrapeSdkData(data: event_types.ScrapeSdkDataRequest): Promise<event_types.ListCurrentConnectionsResponse> {
|
|
86
|
+
const timespanFilter = timeSpan(data.scrape_time);
|
|
87
|
+
console.log(timespanFilter);
|
|
86
88
|
const result = await this.db.sdk_report_events
|
|
87
89
|
.aggregate([
|
|
88
90
|
{
|
|
89
91
|
$match: {
|
|
90
|
-
connect_at:
|
|
92
|
+
connect_at: timespanFilter
|
|
91
93
|
}
|
|
92
94
|
},
|
|
93
95
|
{
|
|
@@ -132,7 +134,6 @@ export class MongoReportStorage implements storage.ReportStorageFactory {
|
|
|
132
134
|
}
|
|
133
135
|
])
|
|
134
136
|
.toArray();
|
|
135
|
-
console.log(result[0]);
|
|
136
137
|
return result[0] as event_types.ListCurrentConnectionsResponse;
|
|
137
138
|
}
|
|
138
139
|
|