@powersync/service-module-mongodb-storage 0.0.0-dev-20250818104041 → 0.0.0-dev-20250820110726
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 +8 -7
- package/dist/migrations/db/migrations/1752661449910-connection-reporting.js +48 -0
- package/dist/migrations/db/migrations/1752661449910-connection-reporting.js.map +1 -0
- package/dist/storage/MongoReportStorage.d.ts +7 -7
- package/dist/storage/MongoReportStorage.js +17 -17
- package/dist/storage/MongoReportStorage.js.map +1 -1
- package/dist/storage/implementation/MongoTestReportStorageFactoryGenerator.js +1 -1
- package/dist/storage/implementation/MongoTestReportStorageFactoryGenerator.js.map +1 -1
- package/dist/storage/implementation/db.d.ts +3 -3
- package/dist/storage/implementation/db.js +6 -6
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +1 -1
- package/package.json +8 -8
- package/src/migrations/db/migrations/1752661449910-connection-reporting.ts +70 -0
- package/src/storage/MongoReportStorage.ts +22 -20
- package/src/storage/implementation/MongoTestReportStorageFactoryGenerator.ts +1 -1
- package/src/storage/implementation/db.ts +7 -7
- package/src/storage/implementation/models.ts +1 -1
- package/test/src/__snapshots__/{sdk-report-storage.test.ts.snap → connection-report-storage.test.ts.snap} +32 -32
- package/test/src/__snapshots__/storage_sync.test.ts.snap +197 -0
- package/test/src/{sdk-report-storage.test.ts → connection-report-storage.test.ts} +24 -24
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/migrations/db/migrations/1752661449910-sdk-reporting.js +0 -48
- package/dist/migrations/db/migrations/1752661449910-sdk-reporting.js.map +0 -1
- package/src/migrations/db/migrations/1752661449910-sdk-reporting.ts +0 -70
- /package/dist/migrations/db/migrations/{1752661449910-sdk-reporting.d.ts → 1752661449910-connection-reporting.d.ts} +0 -0
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as storage from '../../../storage/storage-index.js';
|
|
2
|
-
export const up = async (context) => {
|
|
3
|
-
const { service_context: { configuration } } = context;
|
|
4
|
-
const db = storage.createPowerSyncMongo(configuration.storage);
|
|
5
|
-
try {
|
|
6
|
-
await db.createSdkReportingCollection();
|
|
7
|
-
await db.sdk_report_events.createIndex({
|
|
8
|
-
connected_at: 1,
|
|
9
|
-
jwt_exp: 1,
|
|
10
|
-
disconnected_at: 1
|
|
11
|
-
}, { name: 'sdk_list_index' });
|
|
12
|
-
await db.sdk_report_events.createIndex({
|
|
13
|
-
user_id: 1
|
|
14
|
-
}, { name: 'sdk_user_id_index' });
|
|
15
|
-
await db.sdk_report_events.createIndex({
|
|
16
|
-
client_id: 1
|
|
17
|
-
}, { name: 'sdk_client_id_index' });
|
|
18
|
-
await db.sdk_report_events.createIndex({
|
|
19
|
-
sdk: 1
|
|
20
|
-
}, { name: 'sdk_index' });
|
|
21
|
-
}
|
|
22
|
-
finally {
|
|
23
|
-
await db.client.close();
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export const down = async (context) => {
|
|
27
|
-
const { service_context: { configuration } } = context;
|
|
28
|
-
const db = storage.createPowerSyncMongo(configuration.storage);
|
|
29
|
-
try {
|
|
30
|
-
if (await db.sdk_report_events.indexExists('sdk_list_index')) {
|
|
31
|
-
await db.sdk_report_events.dropIndex('sdk_list_index');
|
|
32
|
-
}
|
|
33
|
-
if (await db.sdk_report_events.indexExists('sdk_user_id_index')) {
|
|
34
|
-
await db.sdk_report_events.dropIndex('sdk_user_id_index');
|
|
35
|
-
}
|
|
36
|
-
if (await db.sdk_report_events.indexExists('sdk_client_id_index')) {
|
|
37
|
-
await db.sdk_report_events.dropIndex('sdk_client_id_index');
|
|
38
|
-
}
|
|
39
|
-
if (await db.sdk_report_events.indexExists('sdk_index')) {
|
|
40
|
-
await db.sdk_report_events.dropIndex('sdk_index');
|
|
41
|
-
}
|
|
42
|
-
await db.db.dropCollection('sdk_report_events');
|
|
43
|
-
}
|
|
44
|
-
finally {
|
|
45
|
-
await db.client.close();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=1752661449910-sdk-reporting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1752661449910-sdk-reporting.js","sourceRoot":"","sources":["../../../../src/migrations/db/migrations/1752661449910-sdk-reporting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,mCAAmC,CAAC;AAG7D,MAAM,CAAC,MAAM,EAAE,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IACZ,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,aAAa,CAAC,OAA6B,CAAC,CAAC;IAErF,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,4BAA4B,EAAE,CAAC;QAExC,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CACpC;YACE,YAAY,EAAE,CAAC;YACf,OAAO,EAAE,CAAC;YACV,eAAe,EAAE,CAAC;SACnB,EACD,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAC3B,CAAC;QAEF,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CACpC;YACE,OAAO,EAAE,CAAC;SACX,EACD,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAC9B,CAAC;QACF,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CACpC;YACE,SAAS,EAAE,CAAC;SACb,EACD,EAAE,IAAI,EAAE,qBAAqB,EAAE,CAChC,CAAC;QACF,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CACpC;YACE,GAAG,EAAE,CAAC;SACP,EACD,EAAE,IAAI,EAAE,WAAW,EAAE,CACtB,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAA0C,KAAK,EAAE,OAAO,EAAE,EAAE;IAC3E,MAAM,EACJ,eAAe,EAAE,EAAE,aAAa,EAAE,EACnC,GAAG,OAAO,CAAC;IAEZ,MAAM,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,aAAa,CAAC,OAA6B,CAAC,CAAC;IAErF,IAAI,CAAC;QACH,IAAI,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC7D,MAAM,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;QACzD,CAAC;QACD,IAAI,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAChE,MAAM,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAClE,MAAM,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,MAAM,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC;YACxD,MAAM,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACpD,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAClD,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { migrations } from '@powersync/service-core';
|
|
2
|
-
import * as storage from '../../../storage/storage-index.js';
|
|
3
|
-
import { MongoStorageConfig } from '../../../types/types.js';
|
|
4
|
-
|
|
5
|
-
export const up: migrations.PowerSyncMigrationFunction = async (context) => {
|
|
6
|
-
const {
|
|
7
|
-
service_context: { configuration }
|
|
8
|
-
} = context;
|
|
9
|
-
const db = storage.createPowerSyncMongo(configuration.storage as MongoStorageConfig);
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
await db.createSdkReportingCollection();
|
|
13
|
-
|
|
14
|
-
await db.sdk_report_events.createIndex(
|
|
15
|
-
{
|
|
16
|
-
connected_at: 1,
|
|
17
|
-
jwt_exp: 1,
|
|
18
|
-
disconnected_at: 1
|
|
19
|
-
},
|
|
20
|
-
{ name: 'sdk_list_index' }
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
await db.sdk_report_events.createIndex(
|
|
24
|
-
{
|
|
25
|
-
user_id: 1
|
|
26
|
-
},
|
|
27
|
-
{ name: 'sdk_user_id_index' }
|
|
28
|
-
);
|
|
29
|
-
await db.sdk_report_events.createIndex(
|
|
30
|
-
{
|
|
31
|
-
client_id: 1
|
|
32
|
-
},
|
|
33
|
-
{ name: 'sdk_client_id_index' }
|
|
34
|
-
);
|
|
35
|
-
await db.sdk_report_events.createIndex(
|
|
36
|
-
{
|
|
37
|
-
sdk: 1
|
|
38
|
-
},
|
|
39
|
-
{ name: 'sdk_index' }
|
|
40
|
-
);
|
|
41
|
-
} finally {
|
|
42
|
-
await db.client.close();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const down: migrations.PowerSyncMigrationFunction = async (context) => {
|
|
47
|
-
const {
|
|
48
|
-
service_context: { configuration }
|
|
49
|
-
} = context;
|
|
50
|
-
|
|
51
|
-
const db = storage.createPowerSyncMongo(configuration.storage as MongoStorageConfig);
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
if (await db.sdk_report_events.indexExists('sdk_list_index')) {
|
|
55
|
-
await db.sdk_report_events.dropIndex('sdk_list_index');
|
|
56
|
-
}
|
|
57
|
-
if (await db.sdk_report_events.indexExists('sdk_user_id_index')) {
|
|
58
|
-
await db.sdk_report_events.dropIndex('sdk_user_id_index');
|
|
59
|
-
}
|
|
60
|
-
if (await db.sdk_report_events.indexExists('sdk_client_id_index')) {
|
|
61
|
-
await db.sdk_report_events.dropIndex('sdk_client_id_index');
|
|
62
|
-
}
|
|
63
|
-
if (await db.sdk_report_events.indexExists('sdk_index')) {
|
|
64
|
-
await db.sdk_report_events.dropIndex('sdk_index');
|
|
65
|
-
}
|
|
66
|
-
await db.db.dropCollection('sdk_report_events');
|
|
67
|
-
} finally {
|
|
68
|
-
await db.client.close();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
File without changes
|