@powersync/service-module-mongodb 0.0.0-dev-20260313100403 → 0.0.0-dev-20260515144844
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 +95 -7
- package/dist/api/MongoRouteAPIAdapter.js +2 -2
- package/dist/api/MongoRouteAPIAdapter.js.map +1 -1
- package/dist/replication/ChangeStream.d.ts +8 -16
- package/dist/replication/ChangeStream.js +284 -371
- package/dist/replication/ChangeStream.js.map +1 -1
- package/dist/replication/ChangeStreamReplicationJob.d.ts +1 -1
- package/dist/replication/ChangeStreamReplicationJob.js +3 -3
- package/dist/replication/ChangeStreamReplicationJob.js.map +1 -1
- package/dist/replication/ChangeStreamReplicator.d.ts +1 -2
- package/dist/replication/ChangeStreamReplicator.js +1 -22
- package/dist/replication/ChangeStreamReplicator.js.map +1 -1
- package/dist/replication/JsonBufferWriter.d.ts +80 -0
- package/dist/replication/JsonBufferWriter.js +342 -0
- package/dist/replication/JsonBufferWriter.js.map +1 -0
- package/dist/replication/MongoManager.d.ts +1 -1
- package/dist/replication/MongoManager.js +1 -1
- package/dist/replication/MongoManager.js.map +1 -1
- package/dist/replication/MongoRelation.js +4 -0
- package/dist/replication/MongoRelation.js.map +1 -1
- package/dist/replication/MongoSnapshotQuery.d.ts +3 -1
- package/dist/replication/MongoSnapshotQuery.js +9 -4
- package/dist/replication/MongoSnapshotQuery.js.map +1 -1
- package/dist/replication/RawChangeStream.d.ts +55 -0
- package/dist/replication/RawChangeStream.js +322 -0
- package/dist/replication/RawChangeStream.js.map +1 -0
- package/dist/replication/SourceRowConverter.d.ts +46 -0
- package/dist/replication/SourceRowConverter.js +42 -0
- package/dist/replication/SourceRowConverter.js.map +1 -0
- package/dist/replication/bufferToSqlite.d.ts +43 -0
- package/dist/replication/bufferToSqlite.js +740 -0
- package/dist/replication/bufferToSqlite.js.map +1 -0
- package/dist/replication/internal-mongodb-utils.d.ts +9 -0
- package/dist/replication/internal-mongodb-utils.js +16 -0
- package/dist/replication/internal-mongodb-utils.js.map +1 -0
- package/dist/replication/replication-index.d.ts +5 -2
- package/dist/replication/replication-index.js +5 -2
- package/dist/replication/replication-index.js.map +1 -1
- package/dist/replication/replication-utils.d.ts +1 -1
- package/dist/types/types.js.map +1 -1
- package/package.json +11 -11
- package/scripts/benchmark-change-document-json.mts +358 -0
- package/scripts/benchmark-change-document.mts +370 -0
- package/src/api/MongoRouteAPIAdapter.ts +2 -2
- package/src/replication/ChangeStream.ts +380 -350
- package/src/replication/ChangeStreamReplicationJob.ts +3 -3
- package/src/replication/ChangeStreamReplicator.ts +2 -26
- package/src/replication/JsonBufferWriter.ts +390 -0
- package/src/replication/MongoManager.ts +2 -2
- package/src/replication/MongoRelation.ts +5 -2
- package/src/replication/MongoSnapshotQuery.ts +13 -6
- package/src/replication/RawChangeStream.ts +460 -0
- package/src/replication/SourceRowConverter.ts +65 -0
- package/src/replication/bufferToSqlite.ts +944 -0
- package/src/replication/internal-mongodb-utils.ts +25 -0
- package/src/replication/replication-index.ts +5 -2
- package/src/replication/replication-utils.ts +2 -2
- package/src/types/types.ts +1 -1
- package/test/src/buffer_to_sqlite.test.ts +1146 -0
- package/test/src/change_stream.test.ts +105 -3
- package/test/src/change_stream_utils.ts +4 -10
- package/test/src/mongo_test.test.ts +66 -64
- package/test/src/parse_document_id.test.ts +54 -0
- package/test/src/raw_change_stream.test.ts +547 -0
- package/test/src/resume.test.ts +12 -2
- package/test/src/util.ts +56 -3
- package/test/tsconfig.json +0 -1
- package/tsconfig.scripts.json +13 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { mongo } from '@powersync/lib-service-mongodb';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Get the byte size of the current batch on a cursor.
|
|
5
|
+
*
|
|
6
|
+
* Call after hasNext(), before or after readBufferedDocuments().
|
|
7
|
+
*
|
|
8
|
+
* This is built on internal APIs, and may stop working in future driver versions.
|
|
9
|
+
*/
|
|
10
|
+
export function getCursorBatchBytes(cursor: mongo.AbstractCursor): number {
|
|
11
|
+
const documents = (cursor as any).documents as CursorResponse | undefined;
|
|
12
|
+
return getResponseBytes(documents);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Define the internal types from the driver.
|
|
16
|
+
// Here we're using them defensively, assuming it may be undefined at any point.
|
|
17
|
+
|
|
18
|
+
interface CursorResponse {
|
|
19
|
+
toBytes?(): Uint8Array;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getResponseBytes(response: CursorResponse | undefined): number {
|
|
23
|
+
const buffer = response?.toBytes?.();
|
|
24
|
+
return buffer?.byteLength ?? 0;
|
|
25
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
export * from './MongoRelation.js';
|
|
2
1
|
export * from './ChangeStream.js';
|
|
3
|
-
export * from './ChangeStreamReplicator.js';
|
|
4
2
|
export * from './ChangeStreamReplicationJob.js';
|
|
3
|
+
export * from './ChangeStreamReplicator.js';
|
|
4
|
+
export * from './internal-mongodb-utils.js';
|
|
5
|
+
export * from './MongoRelation.js';
|
|
6
|
+
export * from './RawChangeStream.js';
|
|
7
|
+
export * from './SourceRowConverter.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ErrorCode, ServiceError } from '@powersync/lib-services-framework';
|
|
2
|
-
import { MongoManager } from './MongoManager.js';
|
|
3
|
-
import { PostImagesOption } from '../types/types.js';
|
|
4
2
|
import * as bson from 'bson';
|
|
3
|
+
import { PostImagesOption } from '../types/types.js';
|
|
4
|
+
import { MongoManager } from './MongoManager.js';
|
|
5
5
|
|
|
6
6
|
export const CHECKPOINTS_COLLECTION = '_powersync_checkpoints';
|
|
7
7
|
|
package/src/types/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as lib_mongo from '@powersync/lib-service-mongodb/types';
|
|
2
1
|
import type { MongoConnectionParams } from '@powersync/lib-service-mongodb/types';
|
|
2
|
+
import * as lib_mongo from '@powersync/lib-service-mongodb/types';
|
|
3
3
|
import * as service_types from '@powersync/service-types';
|
|
4
4
|
import { LookupFunction } from 'node:net';
|
|
5
5
|
import * as t from 'ts-codec';
|