@powersync/service-module-mongodb-storage 0.0.0-dev-20260203155513 → 0.0.0-dev-20260223080959
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 +56 -10
- package/dist/migrations/db/migrations/1770213298299-storage-version.js +29 -0
- package/dist/migrations/db/migrations/1770213298299-storage-version.js.map +1 -0
- package/dist/storage/MongoBucketStorage.d.ts +7 -15
- package/dist/storage/MongoBucketStorage.js +12 -51
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/MongoReportStorage.d.ts +1 -11
- package/dist/storage/MongoReportStorage.js +1 -321
- package/dist/storage/MongoReportStorage.js.map +1 -1
- package/dist/storage/implementation/MongoChecksums.d.ts +5 -2
- package/dist/storage/implementation/MongoChecksums.js +7 -4
- package/dist/storage/implementation/MongoChecksums.js.map +1 -1
- package/dist/storage/implementation/MongoCompactor.d.ts +16 -1
- package/dist/storage/implementation/MongoCompactor.js +80 -23
- package/dist/storage/implementation/MongoCompactor.js.map +1 -1
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.d.ts +2 -12
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js +23 -24
- package/dist/storage/implementation/MongoPersistedSyncRulesContent.js.map +1 -1
- package/dist/storage/implementation/MongoSyncBucketStorage.d.ts +5 -2
- package/dist/storage/implementation/MongoSyncBucketStorage.js +42 -40
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/db.d.ts +0 -10
- package/dist/storage/implementation/db.js +0 -30
- package/dist/storage/implementation/db.js.map +1 -1
- package/dist/storage/implementation/models.d.ts +11 -0
- package/dist/storage/implementation/models.js +9 -1
- package/dist/storage/implementation/models.js.map +1 -1
- package/dist/storage/storage-index.d.ts +0 -1
- package/dist/storage/storage-index.js +0 -1
- package/dist/storage/storage-index.js.map +1 -1
- package/dist/utils/test-utils.d.ts +3 -4
- package/dist/utils/test-utils.js +2 -2
- package/dist/utils/test-utils.js.map +1 -1
- package/dist/utils/util.d.ts +0 -7
- package/dist/utils/util.js +3 -27
- package/dist/utils/util.js.map +1 -1
- package/package.json +7 -7
- package/src/migrations/db/migrations/1770213298299-storage-version.ts +44 -0
- package/src/storage/MongoBucketStorage.ts +20 -59
- package/src/storage/MongoReportStorage.ts +4 -369
- package/src/storage/implementation/MongoChecksums.ts +14 -6
- package/src/storage/implementation/MongoCompactor.ts +94 -25
- package/src/storage/implementation/MongoPersistedSyncRulesContent.ts +25 -32
- package/src/storage/implementation/MongoSyncBucketStorage.ts +60 -44
- package/src/storage/implementation/db.ts +0 -32
- package/src/storage/implementation/models.ts +23 -0
- package/src/storage/storage-index.ts +0 -1
- package/src/utils/test-utils.ts +3 -4
- package/src/utils/util.ts +3 -36
- package/test/src/__snapshots__/storage_sync.test.ts.snap +1116 -21
- package/test/src/compression.test.ts +17 -0
- package/test/src/connection-report-storage.test.ts +6 -2
- package/test/src/storage_compacting.test.ts +29 -22
- package/test/src/storage_sync.test.ts +27 -14
- package/test/src/util.ts +3 -0
- package/test/tsconfig.json +3 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/migrations/db/migrations/1770037239303-sync-reporting.js +0 -44
- package/dist/migrations/db/migrations/1770037239303-sync-reporting.js.map +0 -1
- package/dist/storage/implementation/MongoPersistedSyncRules.d.ts +0 -10
- package/dist/storage/implementation/MongoPersistedSyncRules.js +0 -17
- package/dist/storage/implementation/MongoPersistedSyncRules.js.map +0 -1
- package/src/migrations/db/migrations/1770037239303-sync-reporting.ts +0 -74
- package/src/storage/implementation/MongoPersistedSyncRules.ts +0 -20
- package/test/src/__snapshots__/storage.test.ts.snap +0 -25
- /package/dist/migrations/db/migrations/{1770037239303-sync-reporting.d.ts → 1770213298299-storage-version.d.ts} +0 -0
|
@@ -1,44 +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.createSyncReportingCollection();
|
|
7
|
-
await db.createBucketReportingCollection();
|
|
8
|
-
// Sync data
|
|
9
|
-
await db.sync_report_events.createIndex({
|
|
10
|
-
type: 1
|
|
11
|
-
}, { name: 'sync_type_index' });
|
|
12
|
-
await db.sync_report_events.createIndex({
|
|
13
|
-
date: 1
|
|
14
|
-
}, { name: 'sync_date_index' });
|
|
15
|
-
// Bucket data
|
|
16
|
-
await db.bucket_report_events.createIndex({
|
|
17
|
-
checkpoint_id: 1
|
|
18
|
-
}, { name: 'checkpoint_id_index' });
|
|
19
|
-
await db.bucket_report_events.createIndex({
|
|
20
|
-
date: 1
|
|
21
|
-
}, { name: 'bucket_date_index' });
|
|
22
|
-
await db.bucket_report_events.createIndex({
|
|
23
|
-
status: 1
|
|
24
|
-
}, { name: 'bucket_status_index' });
|
|
25
|
-
await db.bucket_report_events.createIndex({
|
|
26
|
-
name: 1
|
|
27
|
-
}, { name: 'bucket_name_index' });
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
await db.client.close();
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export const down = async (context) => {
|
|
34
|
-
const { service_context: { configuration } } = context;
|
|
35
|
-
const db = storage.createPowerSyncMongo(configuration.storage);
|
|
36
|
-
try {
|
|
37
|
-
await db.db.dropCollection('sync_report_events');
|
|
38
|
-
await db.db.dropCollection('bucket_report_events');
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
await db.client.close();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=1770037239303-sync-reporting.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1770037239303-sync-reporting.js","sourceRoot":"","sources":["../../../../src/migrations/db/migrations/1770037239303-sync-reporting.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,mCAAmC,CAAC;AA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AAM,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,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;QACjD,MAAM,EAAE,CAAC,EAAE,CAAC,cAAc,CAAC,sBAAsB,CAAC,CAAC;IACrD,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { SqlSyncRules, HydratedSyncRules } from '@powersync/service-sync-rules';
|
|
2
|
-
import { storage } from '@powersync/service-core';
|
|
3
|
-
export declare class MongoPersistedSyncRules implements storage.PersistedSyncRules {
|
|
4
|
-
readonly id: number;
|
|
5
|
-
readonly sync_rules: SqlSyncRules;
|
|
6
|
-
readonly checkpoint_lsn: string | null;
|
|
7
|
-
readonly slot_name: string;
|
|
8
|
-
constructor(id: number, sync_rules: SqlSyncRules, checkpoint_lsn: string | null, slot_name: string | null);
|
|
9
|
-
hydratedSyncRules(): HydratedSyncRules;
|
|
10
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { versionedHydrationState } from '@powersync/service-sync-rules';
|
|
2
|
-
export class MongoPersistedSyncRules {
|
|
3
|
-
id;
|
|
4
|
-
sync_rules;
|
|
5
|
-
checkpoint_lsn;
|
|
6
|
-
slot_name;
|
|
7
|
-
constructor(id, sync_rules, checkpoint_lsn, slot_name) {
|
|
8
|
-
this.id = id;
|
|
9
|
-
this.sync_rules = sync_rules;
|
|
10
|
-
this.checkpoint_lsn = checkpoint_lsn;
|
|
11
|
-
this.slot_name = slot_name ?? `powersync_${id}`;
|
|
12
|
-
}
|
|
13
|
-
hydratedSyncRules() {
|
|
14
|
-
return this.sync_rules.hydrate({ hydrationState: versionedHydrationState(this.id) });
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=MongoPersistedSyncRules.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MongoPersistedSyncRules.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoPersistedSyncRules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAIzG,MAAM,OAAO,uBAAuB;IAIhB;IACA;IACA;IALF,SAAS,CAAS;IAElC,YACkB,EAAU,EACV,UAAwB,EACxB,cAA6B,EAC7C,SAAwB;QAHR,OAAE,GAAF,EAAE,CAAQ;QACV,eAAU,GAAV,UAAU,CAAc;QACxB,mBAAc,GAAd,cAAc,CAAe;QAG7C,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,aAAa,EAAE,EAAE,CAAC;IAClD,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACvF,CAAC;CACF"}
|
|
@@ -1,74 +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.createSyncReportingCollection();
|
|
13
|
-
await db.createBucketReportingCollection();
|
|
14
|
-
|
|
15
|
-
// Sync data
|
|
16
|
-
await db.sync_report_events.createIndex(
|
|
17
|
-
{
|
|
18
|
-
type: 1
|
|
19
|
-
},
|
|
20
|
-
{ name: 'sync_type_index' }
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
await db.sync_report_events.createIndex(
|
|
24
|
-
{
|
|
25
|
-
date: 1
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
{ name: 'sync_date_index' }
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
// Bucket data
|
|
32
|
-
await db.bucket_report_events.createIndex(
|
|
33
|
-
{
|
|
34
|
-
checkpoint_id: 1
|
|
35
|
-
},
|
|
36
|
-
{ name: 'checkpoint_id_index' }
|
|
37
|
-
);
|
|
38
|
-
await db.bucket_report_events.createIndex(
|
|
39
|
-
{
|
|
40
|
-
date: 1
|
|
41
|
-
},
|
|
42
|
-
{ name: 'bucket_date_index' }
|
|
43
|
-
);
|
|
44
|
-
await db.bucket_report_events.createIndex(
|
|
45
|
-
{
|
|
46
|
-
status: 1
|
|
47
|
-
},
|
|
48
|
-
{ name: 'bucket_status_index' }
|
|
49
|
-
);
|
|
50
|
-
await db.bucket_report_events.createIndex(
|
|
51
|
-
{
|
|
52
|
-
name: 1
|
|
53
|
-
},
|
|
54
|
-
{ name: 'bucket_name_index' }
|
|
55
|
-
);
|
|
56
|
-
} finally {
|
|
57
|
-
await db.client.close();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export const down: migrations.PowerSyncMigrationFunction = async (context) => {
|
|
62
|
-
const {
|
|
63
|
-
service_context: { configuration }
|
|
64
|
-
} = context;
|
|
65
|
-
|
|
66
|
-
const db = storage.createPowerSyncMongo(configuration.storage as MongoStorageConfig);
|
|
67
|
-
|
|
68
|
-
try {
|
|
69
|
-
await db.db.dropCollection('sync_report_events');
|
|
70
|
-
await db.db.dropCollection('bucket_report_events');
|
|
71
|
-
} finally {
|
|
72
|
-
await db.client.close();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SqlSyncRules, HydratedSyncRules, versionedHydrationState } from '@powersync/service-sync-rules';
|
|
2
|
-
|
|
3
|
-
import { storage } from '@powersync/service-core';
|
|
4
|
-
|
|
5
|
-
export class MongoPersistedSyncRules implements storage.PersistedSyncRules {
|
|
6
|
-
public readonly slot_name: string;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
public readonly id: number,
|
|
10
|
-
public readonly sync_rules: SqlSyncRules,
|
|
11
|
-
public readonly checkpoint_lsn: string | null,
|
|
12
|
-
slot_name: string | null
|
|
13
|
-
) {
|
|
14
|
-
this.slot_name = slot_name ?? `powersync_${id}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
hydratedSyncRules(): HydratedSyncRules {
|
|
18
|
-
return this.sync_rules.hydrate({ hydrationState: versionedHydrationState(this.id) });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`Mongo Sync Bucket Storage - Data > empty storage metrics 1`] = `
|
|
4
|
-
{
|
|
5
|
-
"operations_size_bytes": 0,
|
|
6
|
-
"parameters_size_bytes": 0,
|
|
7
|
-
"replication_size_bytes": 0,
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
exports[`Mongo Sync Bucket Storage - split buckets > empty storage metrics 1`] = `
|
|
12
|
-
{
|
|
13
|
-
"operations_size_bytes": 0,
|
|
14
|
-
"parameters_size_bytes": 0,
|
|
15
|
-
"replication_size_bytes": 0,
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
exports[`Mongo Sync Bucket Storage - split operations > empty storage metrics 1`] = `
|
|
20
|
-
{
|
|
21
|
-
"operations_size_bytes": 0,
|
|
22
|
-
"parameters_size_bytes": 0,
|
|
23
|
-
"replication_size_bytes": 0,
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
File without changes
|