@push.rocks/smartmongo 2.2.0 → 4.0.0

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.
Files changed (126) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/index.d.ts +1 -1
  3. package/dist_ts/index.js +3 -3
  4. package/dist_ts/tsmdb/engine/AggregationEngine.js +189 -0
  5. package/dist_ts/{congodb → tsmdb}/engine/IndexEngine.d.ts +23 -3
  6. package/dist_ts/tsmdb/engine/IndexEngine.js +678 -0
  7. package/dist_ts/tsmdb/engine/QueryEngine.js +271 -0
  8. package/dist_ts/tsmdb/engine/QueryPlanner.d.ts +64 -0
  9. package/dist_ts/tsmdb/engine/QueryPlanner.js +308 -0
  10. package/dist_ts/tsmdb/engine/SessionEngine.d.ts +117 -0
  11. package/dist_ts/tsmdb/engine/SessionEngine.js +232 -0
  12. package/dist_ts/{congodb → tsmdb}/engine/TransactionEngine.d.ts +1 -1
  13. package/dist_ts/tsmdb/engine/TransactionEngine.js +287 -0
  14. package/dist_ts/tsmdb/engine/UpdateEngine.js +461 -0
  15. package/dist_ts/{congodb/errors/CongoErrors.d.ts → tsmdb/errors/TsmdbErrors.d.ts} +16 -16
  16. package/dist_ts/tsmdb/errors/TsmdbErrors.js +155 -0
  17. package/dist_ts/{congodb → tsmdb}/index.d.ts +11 -4
  18. package/dist_ts/tsmdb/index.js +31 -0
  19. package/dist_ts/tsmdb/server/CommandRouter.d.ts +87 -0
  20. package/dist_ts/tsmdb/server/CommandRouter.js +222 -0
  21. package/dist_ts/{congodb/server/CongoServer.d.ts → tsmdb/server/TsmdbServer.d.ts} +6 -6
  22. package/dist_ts/tsmdb/server/TsmdbServer.js +229 -0
  23. package/dist_ts/{congodb → tsmdb}/server/WireProtocol.d.ts +1 -1
  24. package/dist_ts/tsmdb/server/WireProtocol.js +298 -0
  25. package/dist_ts/{congodb → tsmdb}/server/handlers/AdminHandler.d.ts +1 -1
  26. package/dist_ts/tsmdb/server/handlers/AdminHandler.js +668 -0
  27. package/dist_ts/{congodb → tsmdb}/server/handlers/AggregateHandler.d.ts +1 -1
  28. package/dist_ts/tsmdb/server/handlers/AggregateHandler.js +277 -0
  29. package/dist_ts/{congodb → tsmdb}/server/handlers/DeleteHandler.d.ts +1 -1
  30. package/dist_ts/tsmdb/server/handlers/DeleteHandler.js +95 -0
  31. package/dist_ts/{congodb → tsmdb}/server/handlers/FindHandler.d.ts +1 -1
  32. package/dist_ts/tsmdb/server/handlers/FindHandler.js +291 -0
  33. package/dist_ts/{congodb → tsmdb}/server/handlers/HelloHandler.d.ts +1 -1
  34. package/dist_ts/{congodb → tsmdb}/server/handlers/HelloHandler.js +2 -2
  35. package/dist_ts/{congodb → tsmdb}/server/handlers/IndexHandler.d.ts +1 -1
  36. package/dist_ts/tsmdb/server/handlers/IndexHandler.js +183 -0
  37. package/dist_ts/{congodb → tsmdb}/server/handlers/InsertHandler.d.ts +1 -1
  38. package/dist_ts/tsmdb/server/handlers/InsertHandler.js +79 -0
  39. package/dist_ts/{congodb → tsmdb}/server/handlers/UpdateHandler.d.ts +1 -1
  40. package/dist_ts/tsmdb/server/handlers/UpdateHandler.js +296 -0
  41. package/dist_ts/tsmdb/server/handlers/index.js +10 -0
  42. package/dist_ts/{congodb → tsmdb}/server/index.d.ts +2 -2
  43. package/dist_ts/tsmdb/server/index.js +7 -0
  44. package/dist_ts/{congodb → tsmdb}/storage/FileStorageAdapter.d.ts +27 -3
  45. package/dist_ts/tsmdb/storage/FileStorageAdapter.js +465 -0
  46. package/dist_ts/{congodb → tsmdb}/storage/IStorageAdapter.d.ts +7 -2
  47. package/dist_ts/{congodb → tsmdb}/storage/IStorageAdapter.js +1 -1
  48. package/dist_ts/{congodb → tsmdb}/storage/MemoryStorageAdapter.d.ts +3 -2
  49. package/dist_ts/tsmdb/storage/MemoryStorageAdapter.js +378 -0
  50. package/dist_ts/{congodb → tsmdb}/storage/OpLog.d.ts +1 -1
  51. package/dist_ts/tsmdb/storage/OpLog.js +221 -0
  52. package/dist_ts/tsmdb/storage/WAL.d.ts +117 -0
  53. package/dist_ts/tsmdb/storage/WAL.js +286 -0
  54. package/dist_ts/tsmdb/tsmdb.plugins.js +14 -0
  55. package/dist_ts/{congodb → tsmdb}/types/interfaces.d.ts +3 -3
  56. package/dist_ts/{congodb → tsmdb}/types/interfaces.js +1 -1
  57. package/dist_ts/tsmdb/utils/checksum.d.ts +30 -0
  58. package/dist_ts/tsmdb/utils/checksum.js +77 -0
  59. package/dist_ts/tsmdb/utils/index.d.ts +1 -0
  60. package/dist_ts/tsmdb/utils/index.js +2 -0
  61. package/package.json +1 -1
  62. package/readme.hints.md +7 -12
  63. package/readme.md +25 -25
  64. package/ts/00_commitinfo_data.ts +1 -1
  65. package/ts/index.ts +2 -2
  66. package/ts/{congodb → tsmdb}/engine/AggregationEngine.ts +1 -1
  67. package/ts/tsmdb/engine/IndexEngine.ts +798 -0
  68. package/ts/{congodb → tsmdb}/engine/QueryEngine.ts +1 -1
  69. package/ts/tsmdb/engine/QueryPlanner.ts +393 -0
  70. package/ts/tsmdb/engine/SessionEngine.ts +292 -0
  71. package/ts/{congodb → tsmdb}/engine/TransactionEngine.ts +12 -12
  72. package/ts/{congodb → tsmdb}/engine/UpdateEngine.ts +1 -1
  73. package/ts/{congodb/errors/CongoErrors.ts → tsmdb/errors/TsmdbErrors.ts} +34 -34
  74. package/ts/{congodb → tsmdb}/index.ts +16 -7
  75. package/ts/{congodb → tsmdb}/server/CommandRouter.ts +114 -5
  76. package/ts/{congodb/server/CongoServer.ts → tsmdb/server/TsmdbServer.ts} +11 -8
  77. package/ts/{congodb → tsmdb}/server/WireProtocol.ts +1 -1
  78. package/ts/{congodb → tsmdb}/server/handlers/AdminHandler.ts +116 -11
  79. package/ts/{congodb → tsmdb}/server/handlers/AggregateHandler.ts +1 -1
  80. package/ts/{congodb → tsmdb}/server/handlers/DeleteHandler.ts +18 -3
  81. package/ts/{congodb → tsmdb}/server/handlers/FindHandler.ts +43 -14
  82. package/ts/{congodb → tsmdb}/server/handlers/HelloHandler.ts +1 -1
  83. package/ts/{congodb → tsmdb}/server/handlers/IndexHandler.ts +1 -1
  84. package/ts/{congodb → tsmdb}/server/handlers/InsertHandler.ts +7 -1
  85. package/ts/{congodb → tsmdb}/server/handlers/UpdateHandler.ts +34 -5
  86. package/ts/{congodb → tsmdb}/server/index.ts +2 -2
  87. package/ts/{congodb → tsmdb}/storage/FileStorageAdapter.ts +90 -7
  88. package/ts/{congodb → tsmdb}/storage/IStorageAdapter.ts +8 -2
  89. package/ts/{congodb → tsmdb}/storage/MemoryStorageAdapter.ts +14 -2
  90. package/ts/{congodb → tsmdb}/storage/OpLog.ts +1 -1
  91. package/ts/tsmdb/storage/WAL.ts +375 -0
  92. package/ts/{congodb → tsmdb}/types/interfaces.ts +3 -3
  93. package/ts/tsmdb/utils/checksum.ts +88 -0
  94. package/ts/tsmdb/utils/index.ts +1 -0
  95. package/dist_ts/congodb/congodb.plugins.js +0 -14
  96. package/dist_ts/congodb/engine/AggregationEngine.js +0 -189
  97. package/dist_ts/congodb/engine/IndexEngine.js +0 -376
  98. package/dist_ts/congodb/engine/QueryEngine.js +0 -271
  99. package/dist_ts/congodb/engine/TransactionEngine.js +0 -287
  100. package/dist_ts/congodb/engine/UpdateEngine.js +0 -461
  101. package/dist_ts/congodb/errors/CongoErrors.js +0 -155
  102. package/dist_ts/congodb/index.js +0 -26
  103. package/dist_ts/congodb/server/CommandRouter.d.ts +0 -51
  104. package/dist_ts/congodb/server/CommandRouter.js +0 -132
  105. package/dist_ts/congodb/server/CongoServer.js +0 -227
  106. package/dist_ts/congodb/server/WireProtocol.js +0 -298
  107. package/dist_ts/congodb/server/handlers/AdminHandler.js +0 -568
  108. package/dist_ts/congodb/server/handlers/AggregateHandler.js +0 -277
  109. package/dist_ts/congodb/server/handlers/DeleteHandler.js +0 -83
  110. package/dist_ts/congodb/server/handlers/FindHandler.js +0 -261
  111. package/dist_ts/congodb/server/handlers/IndexHandler.js +0 -183
  112. package/dist_ts/congodb/server/handlers/InsertHandler.js +0 -76
  113. package/dist_ts/congodb/server/handlers/UpdateHandler.js +0 -270
  114. package/dist_ts/congodb/server/handlers/index.js +0 -10
  115. package/dist_ts/congodb/server/index.js +0 -7
  116. package/dist_ts/congodb/storage/FileStorageAdapter.js +0 -396
  117. package/dist_ts/congodb/storage/MemoryStorageAdapter.js +0 -367
  118. package/dist_ts/congodb/storage/OpLog.js +0 -221
  119. package/ts/congodb/engine/IndexEngine.ts +0 -479
  120. /package/dist_ts/{congodb → tsmdb}/engine/AggregationEngine.d.ts +0 -0
  121. /package/dist_ts/{congodb → tsmdb}/engine/QueryEngine.d.ts +0 -0
  122. /package/dist_ts/{congodb → tsmdb}/engine/UpdateEngine.d.ts +0 -0
  123. /package/dist_ts/{congodb → tsmdb}/server/handlers/index.d.ts +0 -0
  124. /package/dist_ts/{congodb/congodb.plugins.d.ts → tsmdb/tsmdb.plugins.d.ts} +0 -0
  125. /package/ts/{congodb → tsmdb}/server/handlers/index.ts +0 -0
  126. /package/ts/{congodb/congodb.plugins.ts → tsmdb/tsmdb.plugins.ts} +0 -0
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @push.rocks/smartmongo
2
2
 
3
- A powerful MongoDB toolkit for testing and development — featuring both a real MongoDB memory server (**SmartMongo**) and an ultra-fast, lightweight wire-protocol-compatible in-memory database server (**CongoDB**). 🚀
3
+ A powerful MongoDB toolkit for testing and development — featuring both a real MongoDB memory server (**SmartMongo**) and an ultra-fast, lightweight wire-protocol-compatible in-memory database server (**TsmDB**). 🚀
4
4
 
5
5
  ## Install
6
6
 
@@ -18,7 +18,7 @@ For reporting bugs, issues, or security vulnerabilities, please visit [community
18
18
 
19
19
  `@push.rocks/smartmongo` provides two powerful approaches for MongoDB in testing and development:
20
20
 
21
- | Feature | SmartMongo | CongoDB |
21
+ | Feature | SmartMongo | TsmDB |
22
22
  |---------|------------|---------|
23
23
  | **Type** | Real MongoDB (memory server) | Pure TypeScript wire protocol server |
24
24
  | **Speed** | ~2-5s startup | ⚡ Instant startup (~5ms) |
@@ -51,16 +51,16 @@ console.log(descriptor.mongoDbUrl); // mongodb://127.0.0.1:xxxxx/...
51
51
  await mongo.stop();
52
52
  ```
53
53
 
54
- ### Option 2: CongoDB (Wire Protocol Server)
54
+ ### Option 2: TsmDB (Wire Protocol Server)
55
55
 
56
56
  A lightweight, pure TypeScript MongoDB-compatible server that speaks the wire protocol — use the official `mongodb` driver directly!
57
57
 
58
58
  ```typescript
59
- import { congodb } from '@push.rocks/smartmongo';
59
+ import { tsmdb } from '@push.rocks/smartmongo';
60
60
  import { MongoClient } from 'mongodb';
61
61
 
62
- // Start CongoDB server
63
- const server = new congodb.CongoServer({ port: 27017 });
62
+ // Start TsmDB server
63
+ const server = new tsmdb.TsmdbServer({ port: 27017 });
64
64
  await server.start();
65
65
 
66
66
  // Connect with the official MongoDB driver!
@@ -116,14 +116,14 @@ await mongo.stopAndDumpToDir('./test-data');
116
116
  await mongo.stopAndDumpToDir('./test-data', (doc) => `${doc.collection}-${doc._id}.bson`);
117
117
  ```
118
118
 
119
- ## 🔧 CongoDB API
119
+ ## 🔧 TsmDB API
120
120
 
121
121
  ### Server Configuration
122
122
 
123
123
  ```typescript
124
- import { congodb } from '@push.rocks/smartmongo';
124
+ import { tsmdb } from '@push.rocks/smartmongo';
125
125
 
126
- const server = new congodb.CongoServer({
126
+ const server = new tsmdb.TsmdbServer({
127
127
  port: 27017, // Default MongoDB port
128
128
  host: '127.0.0.1', // Bind address
129
129
  storage: 'memory', // 'memory' or 'file'
@@ -143,7 +143,7 @@ await server.stop();
143
143
 
144
144
  ### Supported MongoDB Operations
145
145
 
146
- CongoDB supports the core MongoDB operations via the wire protocol:
146
+ TsmDB supports the core MongoDB operations via the wire protocol:
147
147
 
148
148
  #### 🔹 CRUD Operations
149
149
  ```typescript
@@ -279,23 +279,23 @@ console.log(result.deletedCount); // 1
279
279
 
280
280
  ### Storage Adapters
281
281
 
282
- CongoDB supports pluggable storage:
282
+ TsmDB supports pluggable storage:
283
283
 
284
284
  ```typescript
285
285
  // In-memory (default) - fast, data lost on stop
286
- const server = new congodb.CongoServer({ storage: 'memory' });
286
+ const server = new tsmdb.TsmdbServer({ storage: 'memory' });
287
287
 
288
288
  // In-memory with persistence - periodic snapshots to disk
289
- const server = new congodb.CongoServer({
289
+ const server = new tsmdb.TsmdbServer({
290
290
  storage: 'memory',
291
291
  persistPath: './data/snapshot.json',
292
292
  persistIntervalMs: 30000 // Save every 30 seconds
293
293
  });
294
294
 
295
295
  // File-based - persistent storage
296
- const server = new congodb.CongoServer({
296
+ const server = new tsmdb.TsmdbServer({
297
297
  storage: 'file',
298
- storagePath: './data/congodb'
298
+ storagePath: './data/tsmdb'
299
299
  });
300
300
  ```
301
301
 
@@ -309,22 +309,22 @@ const server = new congodb.CongoServer({
309
309
  | **Indexes** | `createIndexes`, `dropIndexes`, `listIndexes` |
310
310
  | **Admin** | `ping`, `listDatabases`, `listCollections`, `drop`, `dropDatabase`, `create`, `serverStatus`, `buildInfo` |
311
311
 
312
- CongoDB supports MongoDB wire protocol versions 0-21, compatible with MongoDB 3.6 through 7.0 drivers.
312
+ TsmDB supports MongoDB wire protocol versions 0-21, compatible with MongoDB 3.6 through 7.0 drivers.
313
313
 
314
314
  ## 🧪 Testing Examples
315
315
 
316
- ### Jest/Mocha with CongoDB
316
+ ### Jest/Mocha with TsmDB
317
317
 
318
318
  ```typescript
319
- import { congodb } from '@push.rocks/smartmongo';
319
+ import { tsmdb } from '@push.rocks/smartmongo';
320
320
  import { MongoClient } from 'mongodb';
321
321
 
322
- let server: congodb.CongoServer;
322
+ let server: tsmdb.TsmdbServer;
323
323
  let client: MongoClient;
324
324
  let db: Db;
325
325
 
326
326
  beforeAll(async () => {
327
- server = new congodb.CongoServer({ port: 27117 });
327
+ server = new tsmdb.TsmdbServer({ port: 27117 });
328
328
  await server.start();
329
329
 
330
330
  client = new MongoClient('mongodb://127.0.0.1:27117');
@@ -355,14 +355,14 @@ test('should insert and find user', async () => {
355
355
 
356
356
  ```typescript
357
357
  import { expect, tap } from '@git.zone/tstest/tapbundle';
358
- import { congodb } from '@push.rocks/smartmongo';
358
+ import { tsmdb } from '@push.rocks/smartmongo';
359
359
  import { MongoClient } from 'mongodb';
360
360
 
361
- let server: congodb.CongoServer;
361
+ let server: tsmdb.TsmdbServer;
362
362
  let client: MongoClient;
363
363
 
364
364
  tap.test('setup', async () => {
365
- server = new congodb.CongoServer({ port: 27117 });
365
+ server = new tsmdb.TsmdbServer({ port: 27117 });
366
366
  await server.start();
367
367
  client = new MongoClient('mongodb://127.0.0.1:27117');
368
368
  await client.connect();
@@ -401,7 +401,7 @@ export default tap.start();
401
401
 
402
402
  ## 🏗️ Architecture
403
403
 
404
- ### CongoDB Wire Protocol Stack
404
+ ### TsmDB Wire Protocol Stack
405
405
 
406
406
  ```
407
407
  ┌─────────────────────────────────────────────────────────────┐
@@ -411,7 +411,7 @@ export default tap.start();
411
411
  │ TCP + OP_MSG/BSON
412
412
 
413
413
  ┌─────────────────────────────────────────────────────────────┐
414
- CongoServer
414
+ TsmdbServer
415
415
  │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────┐ │
416
416
  │ │ WireProtocol │→ │CommandRouter │→ │ Handlers │ │
417
417
  │ │ (OP_MSG) │ │ │ │ (Find, Insert..) │ │
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartmongo',
6
- version: '2.2.0',
6
+ version: '4.0.0',
7
7
  description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
8
8
  }
package/ts/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { commitinfo } from './00_commitinfo_data.js';
2
2
  import * as plugins from './smartmongo.plugins.js';
3
3
 
4
- // Export CongoDB module
5
- export * as congodb from './congodb/index.js';
4
+ // Export TsmDB module
5
+ export * as tsmdb from './tsmdb/index.js';
6
6
 
7
7
  export class SmartMongo {
8
8
  // STATIC
@@ -1,4 +1,4 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
  import type { Document, IStoredDocument, IAggregateOptions } from '../types/interfaces.js';
3
3
 
4
4
  // Import mingo Aggregator