mongolite-ts 0.5.0 → 0.6.2
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/README.md +181 -0
- package/dist/changeStream.d.ts +114 -0
- package/dist/changeStream.js +338 -0
- package/dist/changeStream.js.map +1 -0
- package/dist/collection.d.ts +26 -0
- package/dist/collection.js +28 -0
- package/dist/collection.js.map +1 -1
- package/dist/cursors/findCursor.js +19 -4
- package/dist/cursors/findCursor.js.map +1 -1
- package/dist/database-manager.d.ts +1 -0
- package/dist/database-manager.js +2 -0
- package/dist/database-manager.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/mongodbSync.d.ts +128 -0
- package/dist/plugins/mongodbSync.js +339 -0
- package/dist/plugins/mongodbSync.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
/**
|
|
3
|
+
* MongoDB Cloud Sync Plugin
|
|
4
|
+
*
|
|
5
|
+
* This plugin provides optional synchronization between MongoLite and MongoDB Cloud.
|
|
6
|
+
* It hooks into MongoLite operations and replicates them to a MongoDB instance.
|
|
7
|
+
*/
|
|
8
|
+
export class MongoDBSyncPlugin extends EventEmitter {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this.operationQueue = [];
|
|
12
|
+
this.isProcessing = false;
|
|
13
|
+
this.queueTimer = null;
|
|
14
|
+
this.mongoClient = null;
|
|
15
|
+
this.mongoDb = null;
|
|
16
|
+
this.isConnected = false;
|
|
17
|
+
this.options = {
|
|
18
|
+
connectionString: options.connectionString,
|
|
19
|
+
databaseName: options.databaseName || 'mongolite_sync',
|
|
20
|
+
enableDirtyReads: options.enableDirtyReads || false,
|
|
21
|
+
retryConfig: {
|
|
22
|
+
maxRetries: 3,
|
|
23
|
+
initialDelayMs: 1000,
|
|
24
|
+
maxDelayMs: 10000,
|
|
25
|
+
...options.retryConfig,
|
|
26
|
+
},
|
|
27
|
+
verbose: options.verbose || false,
|
|
28
|
+
batchSize: options.batchSize || 100,
|
|
29
|
+
queueTimeoutMs: options.queueTimeoutMs || 1000,
|
|
30
|
+
};
|
|
31
|
+
this.log('MongoDB Sync Plugin initialized');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize connection to MongoDB Cloud
|
|
35
|
+
*/
|
|
36
|
+
async initialize() {
|
|
37
|
+
try {
|
|
38
|
+
// Dynamically import MongoDB driver to avoid making it a required dependency
|
|
39
|
+
let mongodb;
|
|
40
|
+
try {
|
|
41
|
+
// Use eval to avoid TypeScript module resolution at compile time
|
|
42
|
+
mongodb = await eval('import("mongodb")');
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new Error('MongoDB driver not found. Install it with: npm install mongodb');
|
|
46
|
+
}
|
|
47
|
+
const mongoModule = mongodb;
|
|
48
|
+
const MongoClient = mongoModule.MongoClient;
|
|
49
|
+
this.mongoClient = new MongoClient(this.options.connectionString);
|
|
50
|
+
await this.mongoClient.connect();
|
|
51
|
+
this.mongoDb = this.mongoClient.db(this.options.databaseName);
|
|
52
|
+
this.isConnected = true;
|
|
53
|
+
this.log('Connected to MongoDB Cloud');
|
|
54
|
+
this.emit('connected');
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.log('Failed to connect to MongoDB:', error);
|
|
58
|
+
this.emit('error', {
|
|
59
|
+
type: 'connection_error',
|
|
60
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
61
|
+
});
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Disconnect from MongoDB
|
|
67
|
+
*/
|
|
68
|
+
async disconnect() {
|
|
69
|
+
if (this.queueTimer) {
|
|
70
|
+
clearTimeout(this.queueTimer);
|
|
71
|
+
this.queueTimer = null;
|
|
72
|
+
}
|
|
73
|
+
// Process any remaining operations
|
|
74
|
+
if (this.operationQueue.length > 0) {
|
|
75
|
+
await this.processQueue();
|
|
76
|
+
}
|
|
77
|
+
if (this.mongoClient) {
|
|
78
|
+
await this.mongoClient.close();
|
|
79
|
+
this.mongoClient = null;
|
|
80
|
+
this.mongoDb = null;
|
|
81
|
+
this.isConnected = false;
|
|
82
|
+
this.log('Disconnected from MongoDB Cloud');
|
|
83
|
+
this.emit('disconnected');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if the plugin is connected to MongoDB
|
|
88
|
+
*/
|
|
89
|
+
get connected() {
|
|
90
|
+
return this.isConnected;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Hook for insert operations
|
|
94
|
+
*/
|
|
95
|
+
async onInsert(collection, document, result) {
|
|
96
|
+
const operation = {
|
|
97
|
+
type: 'insert',
|
|
98
|
+
collection,
|
|
99
|
+
data: { ...document, _id: result.insertedId },
|
|
100
|
+
timestamp: new Date(),
|
|
101
|
+
localId: result.insertedId,
|
|
102
|
+
};
|
|
103
|
+
await this.queueOperation(operation);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Hook for update operations
|
|
107
|
+
*/
|
|
108
|
+
async onUpdate(collection, filter, update, _result) {
|
|
109
|
+
const operation = {
|
|
110
|
+
type: 'update',
|
|
111
|
+
collection,
|
|
112
|
+
filter,
|
|
113
|
+
update,
|
|
114
|
+
timestamp: new Date(),
|
|
115
|
+
};
|
|
116
|
+
await this.queueOperation(operation);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Hook for delete operations
|
|
120
|
+
*/
|
|
121
|
+
async onDelete(collection, filter, _result) {
|
|
122
|
+
const operation = {
|
|
123
|
+
type: 'delete',
|
|
124
|
+
collection,
|
|
125
|
+
filter,
|
|
126
|
+
timestamp: new Date(),
|
|
127
|
+
};
|
|
128
|
+
await this.queueOperation(operation);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Perform a dirty read from MongoDB (optional functionality)
|
|
132
|
+
*/
|
|
133
|
+
async getDirtyRead(collection, filter) {
|
|
134
|
+
if (!this.isConnected || !this.mongoDb) {
|
|
135
|
+
throw new Error('MongoDB sync is not initialized or not connected');
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const mongoCollection = this.mongoDb.collection(collection);
|
|
139
|
+
const results = await mongoCollection.find(filter || {}).toArray();
|
|
140
|
+
// Transform results and type cast with validation
|
|
141
|
+
return results;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
this.emit('error', {
|
|
145
|
+
type: 'dirty_read_error',
|
|
146
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
147
|
+
details: { collection, filter },
|
|
148
|
+
});
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Queue an operation for batch processing
|
|
154
|
+
*/
|
|
155
|
+
async queueOperation(operation) {
|
|
156
|
+
if (!this.isConnected) {
|
|
157
|
+
this.log('Not connected to MongoDB, skipping operation:', operation.type);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
this.operationQueue.push(operation);
|
|
161
|
+
this.log(`Queued ${operation.type} operation for collection ${operation.collection}`);
|
|
162
|
+
// Start queue timer if not already running
|
|
163
|
+
if (!this.queueTimer) {
|
|
164
|
+
this.queueTimer = setTimeout(() => {
|
|
165
|
+
this.processQueue().catch((error) => {
|
|
166
|
+
this.log('Error processing queue:', error);
|
|
167
|
+
this.emit('error', error);
|
|
168
|
+
});
|
|
169
|
+
}, this.options.queueTimeoutMs);
|
|
170
|
+
}
|
|
171
|
+
// Process immediately if queue is full
|
|
172
|
+
if (this.operationQueue.length >= this.options.batchSize) {
|
|
173
|
+
if (this.queueTimer) {
|
|
174
|
+
clearTimeout(this.queueTimer);
|
|
175
|
+
this.queueTimer = null;
|
|
176
|
+
}
|
|
177
|
+
await this.processQueue();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Process the operation queue
|
|
182
|
+
*/
|
|
183
|
+
async processQueue() {
|
|
184
|
+
if (this.isProcessing || this.operationQueue.length === 0) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.isProcessing = true;
|
|
188
|
+
this.queueTimer = null;
|
|
189
|
+
const operations = [...this.operationQueue];
|
|
190
|
+
this.operationQueue = [];
|
|
191
|
+
this.log(`Processing ${operations.length} queued operations`);
|
|
192
|
+
try {
|
|
193
|
+
const results = await this.processBatch(operations);
|
|
194
|
+
// Emit results
|
|
195
|
+
for (const result of results) {
|
|
196
|
+
if (result.success) {
|
|
197
|
+
this.emit('synced', result);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
this.emit('syncError', result);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
this.log(`Successfully processed ${results.filter((r) => r.success).length}/${results.length} operations`);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
this.log('Error processing operation batch:', error);
|
|
207
|
+
this.emit('error', error);
|
|
208
|
+
// Re-queue failed operations for retry
|
|
209
|
+
this.operationQueue.unshift(...operations);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
this.isProcessing = false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Process a batch of operations
|
|
217
|
+
*/
|
|
218
|
+
async processBatch(operations) {
|
|
219
|
+
if (!this.isConnected || !this.mongoDb) {
|
|
220
|
+
throw new Error('MongoDB is not connected');
|
|
221
|
+
}
|
|
222
|
+
const results = [];
|
|
223
|
+
// Group operations by collection for efficiency
|
|
224
|
+
const operationsByCollection = new Map();
|
|
225
|
+
for (const operation of operations) {
|
|
226
|
+
if (!operationsByCollection.has(operation.collection)) {
|
|
227
|
+
operationsByCollection.set(operation.collection, []);
|
|
228
|
+
}
|
|
229
|
+
operationsByCollection.get(operation.collection).push(operation);
|
|
230
|
+
}
|
|
231
|
+
// Process each collection's operations
|
|
232
|
+
for (const [collectionName, collectionOps] of operationsByCollection) {
|
|
233
|
+
const mongoCollection = this.mongoDb.collection(collectionName);
|
|
234
|
+
for (const operation of collectionOps) {
|
|
235
|
+
const result = await this.executeOperation(mongoCollection, operation);
|
|
236
|
+
results.push(result);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return results;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Execute a single operation on MongoDB
|
|
243
|
+
*/
|
|
244
|
+
async executeOperation(mongoCollection, operation) {
|
|
245
|
+
const { retryConfig } = this.options;
|
|
246
|
+
const maxRetries = retryConfig?.maxRetries ?? 3;
|
|
247
|
+
const initialDelayMs = retryConfig?.initialDelayMs ?? 1000;
|
|
248
|
+
const maxDelayMs = retryConfig?.maxDelayMs ?? 10000;
|
|
249
|
+
let lastError = null;
|
|
250
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
251
|
+
try {
|
|
252
|
+
let mongodbResult;
|
|
253
|
+
switch (operation.type) {
|
|
254
|
+
case 'insert':
|
|
255
|
+
if (!operation.data) {
|
|
256
|
+
throw new Error('Insert operation requires data');
|
|
257
|
+
}
|
|
258
|
+
if (Array.isArray(operation.data)) {
|
|
259
|
+
mongodbResult = await mongoCollection.insertMany(operation.data);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
mongodbResult = await mongoCollection.insertOne(operation.data);
|
|
263
|
+
}
|
|
264
|
+
break;
|
|
265
|
+
case 'update':
|
|
266
|
+
if (!operation.filter || !operation.update) {
|
|
267
|
+
throw new Error('Update operation requires filter and update data');
|
|
268
|
+
}
|
|
269
|
+
mongodbResult = await mongoCollection.updateMany(operation.filter, operation.update);
|
|
270
|
+
break;
|
|
271
|
+
case 'delete':
|
|
272
|
+
if (!operation.filter) {
|
|
273
|
+
throw new Error('Delete operation requires filter');
|
|
274
|
+
}
|
|
275
|
+
mongodbResult = await mongoCollection.deleteMany(operation.filter);
|
|
276
|
+
break;
|
|
277
|
+
default:
|
|
278
|
+
throw new Error(`Unsupported operation type: ${operation.type}`);
|
|
279
|
+
}
|
|
280
|
+
this.log(`Successfully executed ${operation.type} on MongoDB collection ${operation.collection}`);
|
|
281
|
+
return {
|
|
282
|
+
success: true,
|
|
283
|
+
operation,
|
|
284
|
+
mongodbResult,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
lastError = error;
|
|
289
|
+
this.log(`Attempt ${attempt + 1} failed for ${operation.type} operation:`, error);
|
|
290
|
+
if (attempt < maxRetries) {
|
|
291
|
+
const delay = Math.min(initialDelayMs * Math.pow(2, attempt), maxDelayMs);
|
|
292
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
success: false,
|
|
298
|
+
operation,
|
|
299
|
+
error: lastError || new Error('Unknown error'),
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get queue status
|
|
304
|
+
*/
|
|
305
|
+
getQueueStatus() {
|
|
306
|
+
return {
|
|
307
|
+
queueLength: this.operationQueue.length,
|
|
308
|
+
isProcessing: this.isProcessing,
|
|
309
|
+
isConnected: this.isConnected,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Flush the queue (process immediately)
|
|
314
|
+
*/
|
|
315
|
+
async flush() {
|
|
316
|
+
if (this.queueTimer) {
|
|
317
|
+
clearTimeout(this.queueTimer);
|
|
318
|
+
this.queueTimer = null;
|
|
319
|
+
}
|
|
320
|
+
await this.processQueue();
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Log messages if verbose mode is enabled
|
|
324
|
+
*/
|
|
325
|
+
log(...args) {
|
|
326
|
+
if (this.options.verbose) {
|
|
327
|
+
console.log('[MongoDBSync]', ...args);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Factory function to create and initialize a MongoDB sync plugin
|
|
333
|
+
*/
|
|
334
|
+
export async function createMongoDBSyncPlugin(options) {
|
|
335
|
+
const plugin = new MongoDBSyncPlugin(options);
|
|
336
|
+
await plugin.initialize();
|
|
337
|
+
return plugin;
|
|
338
|
+
}
|
|
339
|
+
//# sourceMappingURL=mongodbSync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodbSync.js","sourceRoot":"","sources":["../../src/plugins/mongodbSync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAiFtC;;;;;GAKG;AACH,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IASjD,YAAY,OAA2B;QACrC,KAAK,EAAE,CAAC;QARF,mBAAc,GAAuB,EAAE,CAAC;QACxC,iBAAY,GAAG,KAAK,CAAC;QACrB,eAAU,GAA0B,IAAI,CAAC;QACzC,gBAAW,GAA+B,IAAI,CAAC;QAC/C,YAAO,GAAyB,IAAI,CAAC;QACrC,gBAAW,GAAG,KAAK,CAAC;QAK1B,IAAI,CAAC,OAAO,GAAG;YACb,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;YAC1C,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,gBAAgB;YACtD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,IAAI,KAAK;YACnD,WAAW,EAAE;gBACX,UAAU,EAAE,CAAC;gBACb,cAAc,EAAE,IAAI;gBACpB,UAAU,EAAE,KAAK;gBACjB,GAAG,OAAO,CAAC,WAAW;aACvB;YACD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;YACjC,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,GAAG;YACnC,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI;SAC/C,CAAC;QAEF,IAAI,CAAC,GAAG,CAAC,iCAAiC,CAAC,CA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AAC;QACxC,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAA2B;IAE3B,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongolite-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "A MongoDB-like client using SQLite as a persistent store, written in TypeScript.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"test": "node --import tsx --test tests/*.test.ts",
|
|
14
14
|
"test:coverage": "c8 --reporter=lcov --reporter=text node --import tsx --test tests/*.test.ts",
|
|
15
15
|
"prepare": "npm run build",
|
|
16
|
+
"prepublish": "npm run build",
|
|
16
17
|
"lint": "eslint src/**/*.ts tests/**/*.ts",
|
|
17
18
|
"lint:fix": "eslint src/**/*.ts tests/**/*.ts --fix",
|
|
18
19
|
"verify-build": "node --import tsx scripts/verify-build.js",
|