@push.rocks/smartmongo 2.2.0 → 3.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 (109) 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/tsmdb/engine/IndexEngine.js +376 -0
  6. package/dist_ts/tsmdb/engine/QueryEngine.js +271 -0
  7. package/dist_ts/{congodb → tsmdb}/engine/TransactionEngine.d.ts +1 -1
  8. package/dist_ts/tsmdb/engine/TransactionEngine.js +287 -0
  9. package/dist_ts/tsmdb/engine/UpdateEngine.js +461 -0
  10. package/dist_ts/{congodb/errors/CongoErrors.d.ts → tsmdb/errors/TsmdbErrors.d.ts} +16 -16
  11. package/dist_ts/tsmdb/errors/TsmdbErrors.js +155 -0
  12. package/dist_ts/{congodb → tsmdb}/index.d.ts +4 -4
  13. package/dist_ts/tsmdb/index.js +26 -0
  14. package/dist_ts/{congodb → tsmdb}/server/CommandRouter.d.ts +4 -4
  15. package/dist_ts/tsmdb/server/CommandRouter.js +132 -0
  16. package/dist_ts/{congodb/server/CongoServer.d.ts → tsmdb/server/TsmdbServer.d.ts} +6 -6
  17. package/dist_ts/tsmdb/server/TsmdbServer.js +227 -0
  18. package/dist_ts/{congodb → tsmdb}/server/WireProtocol.d.ts +1 -1
  19. package/dist_ts/tsmdb/server/WireProtocol.js +298 -0
  20. package/dist_ts/{congodb → tsmdb}/server/handlers/AdminHandler.d.ts +1 -1
  21. package/dist_ts/tsmdb/server/handlers/AdminHandler.js +568 -0
  22. package/dist_ts/{congodb → tsmdb}/server/handlers/AggregateHandler.d.ts +1 -1
  23. package/dist_ts/tsmdb/server/handlers/AggregateHandler.js +277 -0
  24. package/dist_ts/{congodb → tsmdb}/server/handlers/DeleteHandler.d.ts +1 -1
  25. package/dist_ts/tsmdb/server/handlers/DeleteHandler.js +83 -0
  26. package/dist_ts/{congodb → tsmdb}/server/handlers/FindHandler.d.ts +1 -1
  27. package/dist_ts/tsmdb/server/handlers/FindHandler.js +261 -0
  28. package/dist_ts/{congodb → tsmdb}/server/handlers/HelloHandler.d.ts +1 -1
  29. package/dist_ts/{congodb → tsmdb}/server/handlers/HelloHandler.js +2 -2
  30. package/dist_ts/{congodb → tsmdb}/server/handlers/IndexHandler.d.ts +1 -1
  31. package/dist_ts/tsmdb/server/handlers/IndexHandler.js +183 -0
  32. package/dist_ts/{congodb → tsmdb}/server/handlers/InsertHandler.d.ts +1 -1
  33. package/dist_ts/tsmdb/server/handlers/InsertHandler.js +76 -0
  34. package/dist_ts/{congodb → tsmdb}/server/handlers/UpdateHandler.d.ts +1 -1
  35. package/dist_ts/tsmdb/server/handlers/UpdateHandler.js +270 -0
  36. package/dist_ts/tsmdb/server/handlers/index.js +10 -0
  37. package/dist_ts/{congodb → tsmdb}/server/index.d.ts +2 -2
  38. package/dist_ts/tsmdb/server/index.js +7 -0
  39. package/dist_ts/{congodb → tsmdb}/storage/FileStorageAdapter.d.ts +2 -2
  40. package/dist_ts/tsmdb/storage/FileStorageAdapter.js +396 -0
  41. package/dist_ts/{congodb → tsmdb}/storage/IStorageAdapter.d.ts +2 -2
  42. package/dist_ts/{congodb → tsmdb}/storage/IStorageAdapter.js +1 -1
  43. package/dist_ts/{congodb → tsmdb}/storage/MemoryStorageAdapter.d.ts +2 -2
  44. package/dist_ts/tsmdb/storage/MemoryStorageAdapter.js +367 -0
  45. package/dist_ts/{congodb → tsmdb}/storage/OpLog.d.ts +1 -1
  46. package/dist_ts/tsmdb/storage/OpLog.js +221 -0
  47. package/dist_ts/tsmdb/tsmdb.plugins.js +14 -0
  48. package/dist_ts/{congodb → tsmdb}/types/interfaces.d.ts +3 -3
  49. package/dist_ts/{congodb → tsmdb}/types/interfaces.js +1 -1
  50. package/package.json +1 -1
  51. package/readme.hints.md +7 -12
  52. package/readme.md +25 -25
  53. package/ts/00_commitinfo_data.ts +1 -1
  54. package/ts/index.ts +2 -2
  55. package/ts/{congodb → tsmdb}/engine/AggregationEngine.ts +1 -1
  56. package/ts/{congodb → tsmdb}/engine/IndexEngine.ts +7 -7
  57. package/ts/{congodb → tsmdb}/engine/QueryEngine.ts +1 -1
  58. package/ts/{congodb → tsmdb}/engine/TransactionEngine.ts +12 -12
  59. package/ts/{congodb → tsmdb}/engine/UpdateEngine.ts +1 -1
  60. package/ts/{congodb/errors/CongoErrors.ts → tsmdb/errors/TsmdbErrors.ts} +34 -34
  61. package/ts/{congodb → tsmdb}/index.ts +7 -7
  62. package/ts/{congodb → tsmdb}/server/CommandRouter.ts +5 -5
  63. package/ts/{congodb/server/CongoServer.ts → tsmdb/server/TsmdbServer.ts} +8 -8
  64. package/ts/{congodb → tsmdb}/server/WireProtocol.ts +1 -1
  65. package/ts/{congodb → tsmdb}/server/handlers/AdminHandler.ts +6 -6
  66. package/ts/{congodb → tsmdb}/server/handlers/AggregateHandler.ts +1 -1
  67. package/ts/{congodb → tsmdb}/server/handlers/DeleteHandler.ts +1 -1
  68. package/ts/{congodb → tsmdb}/server/handlers/FindHandler.ts +1 -1
  69. package/ts/{congodb → tsmdb}/server/handlers/HelloHandler.ts +1 -1
  70. package/ts/{congodb → tsmdb}/server/handlers/IndexHandler.ts +1 -1
  71. package/ts/{congodb → tsmdb}/server/handlers/InsertHandler.ts +1 -1
  72. package/ts/{congodb → tsmdb}/server/handlers/UpdateHandler.ts +1 -1
  73. package/ts/{congodb → tsmdb}/server/index.ts +2 -2
  74. package/ts/{congodb → tsmdb}/storage/FileStorageAdapter.ts +2 -2
  75. package/ts/{congodb → tsmdb}/storage/IStorageAdapter.ts +2 -2
  76. package/ts/{congodb → tsmdb}/storage/MemoryStorageAdapter.ts +2 -2
  77. package/ts/{congodb → tsmdb}/storage/OpLog.ts +1 -1
  78. package/ts/{congodb → tsmdb}/types/interfaces.ts +3 -3
  79. package/dist_ts/congodb/congodb.plugins.js +0 -14
  80. package/dist_ts/congodb/engine/AggregationEngine.js +0 -189
  81. package/dist_ts/congodb/engine/IndexEngine.js +0 -376
  82. package/dist_ts/congodb/engine/QueryEngine.js +0 -271
  83. package/dist_ts/congodb/engine/TransactionEngine.js +0 -287
  84. package/dist_ts/congodb/engine/UpdateEngine.js +0 -461
  85. package/dist_ts/congodb/errors/CongoErrors.js +0 -155
  86. package/dist_ts/congodb/index.js +0 -26
  87. package/dist_ts/congodb/server/CommandRouter.js +0 -132
  88. package/dist_ts/congodb/server/CongoServer.js +0 -227
  89. package/dist_ts/congodb/server/WireProtocol.js +0 -298
  90. package/dist_ts/congodb/server/handlers/AdminHandler.js +0 -568
  91. package/dist_ts/congodb/server/handlers/AggregateHandler.js +0 -277
  92. package/dist_ts/congodb/server/handlers/DeleteHandler.js +0 -83
  93. package/dist_ts/congodb/server/handlers/FindHandler.js +0 -261
  94. package/dist_ts/congodb/server/handlers/IndexHandler.js +0 -183
  95. package/dist_ts/congodb/server/handlers/InsertHandler.js +0 -76
  96. package/dist_ts/congodb/server/handlers/UpdateHandler.js +0 -270
  97. package/dist_ts/congodb/server/handlers/index.js +0 -10
  98. package/dist_ts/congodb/server/index.js +0 -7
  99. package/dist_ts/congodb/storage/FileStorageAdapter.js +0 -396
  100. package/dist_ts/congodb/storage/MemoryStorageAdapter.js +0 -367
  101. package/dist_ts/congodb/storage/OpLog.js +0 -221
  102. /package/dist_ts/{congodb → tsmdb}/engine/AggregationEngine.d.ts +0 -0
  103. /package/dist_ts/{congodb → tsmdb}/engine/IndexEngine.d.ts +0 -0
  104. /package/dist_ts/{congodb → tsmdb}/engine/QueryEngine.d.ts +0 -0
  105. /package/dist_ts/{congodb → tsmdb}/engine/UpdateEngine.d.ts +0 -0
  106. /package/dist_ts/{congodb → tsmdb}/server/handlers/index.d.ts +0 -0
  107. /package/dist_ts/{congodb/congodb.plugins.d.ts → tsmdb/tsmdb.plugins.d.ts} +0 -0
  108. /package/ts/{congodb → tsmdb}/server/handlers/index.ts +0 -0
  109. /package/ts/{congodb/congodb.plugins.ts → tsmdb/tsmdb.plugins.ts} +0 -0
@@ -1,9 +1,9 @@
1
- import type * as plugins from '../congodb.plugins.js';
1
+ import type * as plugins from '../tsmdb.plugins.js';
2
2
  export type Document = Record<string, any>;
3
3
  export interface WithId<TSchema> {
4
4
  _id: plugins.bson.ObjectId;
5
5
  }
6
- export interface ICongoClientOptions {
6
+ export interface ITsmdbClientOptions {
7
7
  /** Storage adapter type: 'memory' or 'file' */
8
8
  storageType?: 'memory' | 'file';
9
9
  /** Path for file-based storage */
@@ -14,7 +14,7 @@ export interface ICongoClientOptions {
14
14
  persistPath?: string;
15
15
  }
16
16
  export interface IParsedConnectionString {
17
- protocol: 'congo';
17
+ protocol: 'tsmdb';
18
18
  storageType: 'memory' | 'file';
19
19
  options: {
20
20
  persist?: string;
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL2NvbmdvZGIvdHlwZXMvaW50ZXJmYWNlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3RzL3RzbWRiL3R5cGVzL2ludGVyZmFjZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartmongo",
3
- "version": "2.2.0",
3
+ "version": "3.0.0",
4
4
  "private": false,
5
5
  "description": "A module for creating and managing a local MongoDB instance for testing purposes.",
6
6
  "main": "dist_ts/index.js",
package/readme.hints.md CHANGED
@@ -9,21 +9,21 @@
9
9
  - **Why:** Deno wraps CommonJS exports in a `default` property, so default imports are required
10
10
  - Fixed in version 2.0.13 (changed from `import * as mongoPlugin`)
11
11
 
12
- ## CongoDB - MongoDB Wire Protocol Server
12
+ ## TsmDB - MongoDB Wire Protocol Server
13
13
 
14
14
  ### Architecture
15
- CongoDB implements the MongoDB binary wire protocol (OP_MSG, OP_QUERY) allowing official MongoDB drivers to connect directly.
15
+ TsmDB implements the MongoDB binary wire protocol (OP_MSG, OP_QUERY) allowing official MongoDB drivers to connect directly.
16
16
 
17
17
  ```
18
- Official MongoClient → TCP (wire protocol) → CongoServer → Engines → Storage
18
+ Official MongoClient → TCP (wire protocol) → TsmdbServer → Engines → Storage
19
19
  (mongodb npm) OP_MSG/BSON (port)
20
20
  ```
21
21
 
22
22
  ### Module Structure
23
23
  ```
24
- ts/congodb/
24
+ ts/tsmdb/
25
25
  ├── server/ # Wire protocol server
26
- │ ├── CongoServer.ts # TCP server, connection handling
26
+ │ ├── TsmdbServer.ts # TCP server, connection handling
27
27
  │ ├── WireProtocol.ts # OP_MSG/OP_QUERY parsing & encoding
28
28
  │ ├── CommandRouter.ts # Route commands to handlers
29
29
  │ └── handlers/ # Command implementations
@@ -53,11 +53,11 @@ ts/congodb/
53
53
 
54
54
  ### Usage Example
55
55
  ```typescript
56
- import { CongoServer } from '@push.rocks/smartmongo/congodb';
56
+ import { TsmdbServer } from '@push.rocks/smartmongo/tsmdb';
57
57
  import { MongoClient } from 'mongodb';
58
58
 
59
59
  // Start server
60
- const server = new CongoServer({ port: 27117 });
60
+ const server = new TsmdbServer({ port: 27117 });
61
61
  await server.start();
62
62
 
63
63
  // Connect with official MongoDB driver
@@ -82,8 +82,3 @@ await server.stop();
82
82
  - **Aggregation**: aggregate, count, distinct
83
83
  - **Indexes**: createIndexes, dropIndexes, listIndexes
84
84
  - **Admin**: ping, listDatabases, listCollections, drop, dropDatabase, create, serverStatus, buildInfo
85
-
86
- ### Notes
87
- - The old CongoClient/CongoDb/CongoCollection classes have been removed
88
- - Use the official `mongodb` npm package's MongoClient instead
89
- - Server supports MongoDB wire protocol versions 0-21 (MongoDB 3.6 through 7.0 compatible)
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: '3.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
@@ -1,4 +1,4 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
  import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
3
3
  import type {
4
4
  Document,
@@ -7,7 +7,7 @@ import type {
7
7
  IIndexInfo,
8
8
  ICreateIndexOptions,
9
9
  } from '../types/interfaces.js';
10
- import { CongoDuplicateKeyError, CongoIndexError } from '../errors/CongoErrors.js';
10
+ import { TsmdbDuplicateKeyError, TsmdbIndexError } from '../errors/TsmdbErrors.js';
11
11
  import { QueryEngine } from './QueryEngine.js';
12
12
 
13
13
  /**
@@ -116,7 +116,7 @@ export class IndexEngine {
116
116
  const keyStr = JSON.stringify(keyValue);
117
117
 
118
118
  if (indexData.unique && indexData.entries.has(keyStr)) {
119
- throw new CongoDuplicateKeyError(
119
+ throw new TsmdbDuplicateKeyError(
120
120
  `E11000 duplicate key error index: ${this.dbName}.${this.collName}.$${name}`,
121
121
  key as Record<string, 1>,
122
122
  keyValue
@@ -148,11 +148,11 @@ export class IndexEngine {
148
148
  await this.initialize();
149
149
 
150
150
  if (name === '_id_') {
151
- throw new CongoIndexError('cannot drop _id index');
151
+ throw new TsmdbIndexError('cannot drop _id index');
152
152
  }
153
153
 
154
154
  if (!this.indexes.has(name)) {
155
- throw new CongoIndexError(`index not found: ${name}`);
155
+ throw new TsmdbIndexError(`index not found: ${name}`);
156
156
  }
157
157
 
158
158
  this.indexes.delete(name);
@@ -215,7 +215,7 @@ export class IndexEngine {
215
215
  if (indexData.unique) {
216
216
  const existing = indexData.entries.get(keyStr);
217
217
  if (existing && existing.size > 0) {
218
- throw new CongoDuplicateKeyError(
218
+ throw new TsmdbDuplicateKeyError(
219
219
  `E11000 duplicate key error collection: ${this.dbName}.${this.collName} index: ${name}`,
220
220
  indexData.key as Record<string, 1>,
221
221
  keyValue
@@ -260,7 +260,7 @@ export class IndexEngine {
260
260
  if (indexData.unique) {
261
261
  const existing = indexData.entries.get(newKeyStr);
262
262
  if (existing && existing.size > 0) {
263
- throw new CongoDuplicateKeyError(
263
+ throw new TsmdbDuplicateKeyError(
264
264
  `E11000 duplicate key error collection: ${this.dbName}.${this.collName} index: ${name}`,
265
265
  indexData.key as Record<string, 1>,
266
266
  newKeyValue
@@ -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, ISortSpecification, ISortDirection } from '../types/interfaces.js';
3
3
 
4
4
  // Import mingo Query class
@@ -1,7 +1,7 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
  import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
3
3
  import type { Document, IStoredDocument, ITransactionOptions } from '../types/interfaces.js';
4
- import { CongoTransactionError, CongoWriteConflictError } from '../errors/CongoErrors.js';
4
+ import { TsmdbTransactionError, TsmdbWriteConflictError } from '../errors/TsmdbErrors.js';
5
5
 
6
6
  /**
7
7
  * Transaction state
@@ -70,7 +70,7 @@ export class TransactionEngine {
70
70
  async getSnapshot(txnId: string, dbName: string, collName: string): Promise<IStoredDocument[]> {
71
71
  const txn = this.transactions.get(txnId);
72
72
  if (!txn || txn.status !== 'active') {
73
- throw new CongoTransactionError('Transaction is not active');
73
+ throw new TsmdbTransactionError('Transaction is not active');
74
74
  }
75
75
 
76
76
  const ns = `${dbName}.${collName}`;
@@ -148,7 +148,7 @@ export class TransactionEngine {
148
148
  recordInsert(txnId: string, dbName: string, collName: string, doc: IStoredDocument): void {
149
149
  const txn = this.transactions.get(txnId);
150
150
  if (!txn || txn.status !== 'active') {
151
- throw new CongoTransactionError('Transaction is not active');
151
+ throw new TsmdbTransactionError('Transaction is not active');
152
152
  }
153
153
 
154
154
  const ns = `${dbName}.${collName}`;
@@ -174,7 +174,7 @@ export class TransactionEngine {
174
174
  ): void {
175
175
  const txn = this.transactions.get(txnId);
176
176
  if (!txn || txn.status !== 'active') {
177
- throw new CongoTransactionError('Transaction is not active');
177
+ throw new TsmdbTransactionError('Transaction is not active');
178
178
  }
179
179
 
180
180
  const ns = `${dbName}.${collName}`;
@@ -203,7 +203,7 @@ export class TransactionEngine {
203
203
  recordDelete(txnId: string, dbName: string, collName: string, doc: IStoredDocument): void {
204
204
  const txn = this.transactions.get(txnId);
205
205
  if (!txn || txn.status !== 'active') {
206
- throw new CongoTransactionError('Transaction is not active');
206
+ throw new TsmdbTransactionError('Transaction is not active');
207
207
  }
208
208
 
209
209
  const ns = `${dbName}.${collName}`;
@@ -231,10 +231,10 @@ export class TransactionEngine {
231
231
  async commitTransaction(txnId: string): Promise<void> {
232
232
  const txn = this.transactions.get(txnId);
233
233
  if (!txn) {
234
- throw new CongoTransactionError('Transaction not found');
234
+ throw new TsmdbTransactionError('Transaction not found');
235
235
  }
236
236
  if (txn.status !== 'active') {
237
- throw new CongoTransactionError(`Cannot commit transaction in state: ${txn.status}`);
237
+ throw new TsmdbTransactionError(`Cannot commit transaction in state: ${txn.status}`);
238
238
  }
239
239
 
240
240
  // Check for write conflicts
@@ -245,7 +245,7 @@ export class TransactionEngine {
245
245
  const hasConflicts = await this.storage.hasConflicts(dbName, collName, ids, txn.startTime);
246
246
  if (hasConflicts) {
247
247
  txn.status = 'aborted';
248
- throw new CongoWriteConflictError();
248
+ throw new TsmdbWriteConflictError();
249
249
  }
250
250
  }
251
251
 
@@ -281,7 +281,7 @@ export class TransactionEngine {
281
281
  async abortTransaction(txnId: string): Promise<void> {
282
282
  const txn = this.transactions.get(txnId);
283
283
  if (!txn) {
284
- throw new CongoTransactionError('Transaction not found');
284
+ throw new TsmdbTransactionError('Transaction not found');
285
285
  }
286
286
  if (txn.status !== 'active') {
287
287
  // Already committed or aborted, just return
@@ -336,7 +336,7 @@ export class TransactionEngine {
336
336
  await this.abortTransaction(txnId);
337
337
  this.endTransaction(txnId);
338
338
 
339
- if (error instanceof CongoWriteConflictError && attempt < maxRetries - 1) {
339
+ if (error instanceof TsmdbWriteConflictError && attempt < maxRetries - 1) {
340
340
  // Retry on write conflict
341
341
  lastError = error;
342
342
  continue;
@@ -346,6 +346,6 @@ export class TransactionEngine {
346
346
  }
347
347
  }
348
348
 
349
- throw lastError || new CongoTransactionError('Transaction failed after max retries');
349
+ throw lastError || new TsmdbTransactionError('Transaction failed after max retries');
350
350
  }
351
351
  }
@@ -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 } from '../types/interfaces.js';
3
3
  import { QueryEngine } from './QueryEngine.js';
4
4
 
@@ -1,14 +1,14 @@
1
1
  /**
2
- * Base error class for all CongoDB errors
2
+ * Base error class for all TsmDB errors
3
3
  * Mirrors MongoDB driver error hierarchy
4
4
  */
5
- export class CongoError extends Error {
5
+ export class TsmdbError extends Error {
6
6
  public code?: number;
7
7
  public codeName?: string;
8
8
 
9
9
  constructor(message: string, code?: number, codeName?: string) {
10
10
  super(message);
11
- this.name = 'CongoError';
11
+ this.name = 'TsmdbError';
12
12
  this.code = code;
13
13
  this.codeName = codeName;
14
14
  Object.setPrototypeOf(this, new.target.prototype);
@@ -18,33 +18,33 @@ export class CongoError extends Error {
18
18
  /**
19
19
  * Error thrown during connection issues
20
20
  */
21
- export class CongoConnectionError extends CongoError {
21
+ export class TsmdbConnectionError extends TsmdbError {
22
22
  constructor(message: string) {
23
23
  super(message);
24
- this.name = 'CongoConnectionError';
24
+ this.name = 'TsmdbConnectionError';
25
25
  }
26
26
  }
27
27
 
28
28
  /**
29
29
  * Error thrown when an operation times out
30
30
  */
31
- export class CongoTimeoutError extends CongoError {
31
+ export class TsmdbTimeoutError extends TsmdbError {
32
32
  constructor(message: string) {
33
33
  super(message, 50, 'MaxTimeMSExpired');
34
- this.name = 'CongoTimeoutError';
34
+ this.name = 'TsmdbTimeoutError';
35
35
  }
36
36
  }
37
37
 
38
38
  /**
39
39
  * Error thrown during write operations
40
40
  */
41
- export class CongoWriteError extends CongoError {
41
+ export class TsmdbWriteError extends TsmdbError {
42
42
  public writeErrors?: IWriteError[];
43
43
  public result?: any;
44
44
 
45
45
  constructor(message: string, code?: number, writeErrors?: IWriteError[]) {
46
46
  super(message, code);
47
- this.name = 'CongoWriteError';
47
+ this.name = 'TsmdbWriteError';
48
48
  this.writeErrors = writeErrors;
49
49
  }
50
50
  }
@@ -52,13 +52,13 @@ export class CongoWriteError extends CongoError {
52
52
  /**
53
53
  * Error thrown for duplicate key violations
54
54
  */
55
- export class CongoDuplicateKeyError extends CongoWriteError {
55
+ export class TsmdbDuplicateKeyError extends TsmdbWriteError {
56
56
  public keyPattern?: Record<string, 1>;
57
57
  public keyValue?: Record<string, any>;
58
58
 
59
59
  constructor(message: string, keyPattern?: Record<string, 1>, keyValue?: Record<string, any>) {
60
60
  super(message, 11000);
61
- this.name = 'CongoDuplicateKeyError';
61
+ this.name = 'TsmdbDuplicateKeyError';
62
62
  this.codeName = 'DuplicateKey';
63
63
  this.keyPattern = keyPattern;
64
64
  this.keyValue = keyValue;
@@ -68,13 +68,13 @@ export class CongoDuplicateKeyError extends CongoWriteError {
68
68
  /**
69
69
  * Error thrown for bulk write failures
70
70
  */
71
- export class CongoBulkWriteError extends CongoError {
71
+ export class TsmdbBulkWriteError extends TsmdbError {
72
72
  public writeErrors: IWriteError[];
73
73
  public result: any;
74
74
 
75
75
  constructor(message: string, writeErrors: IWriteError[], result: any) {
76
76
  super(message, 65);
77
- this.name = 'CongoBulkWriteError';
77
+ this.name = 'TsmdbBulkWriteError';
78
78
  this.writeErrors = writeErrors;
79
79
  this.result = result;
80
80
  }
@@ -83,20 +83,20 @@ export class CongoBulkWriteError extends CongoError {
83
83
  /**
84
84
  * Error thrown during transaction operations
85
85
  */
86
- export class CongoTransactionError extends CongoError {
86
+ export class TsmdbTransactionError extends TsmdbError {
87
87
  constructor(message: string, code?: number) {
88
88
  super(message, code);
89
- this.name = 'CongoTransactionError';
89
+ this.name = 'TsmdbTransactionError';
90
90
  }
91
91
  }
92
92
 
93
93
  /**
94
94
  * Error thrown when a transaction is aborted due to conflict
95
95
  */
96
- export class CongoWriteConflictError extends CongoTransactionError {
96
+ export class TsmdbWriteConflictError extends TsmdbTransactionError {
97
97
  constructor(message: string = 'Write conflict during transaction') {
98
98
  super(message, 112);
99
- this.name = 'CongoWriteConflictError';
99
+ this.name = 'TsmdbWriteConflictError';
100
100
  this.codeName = 'WriteConflict';
101
101
  }
102
102
  }
@@ -104,20 +104,20 @@ export class CongoWriteConflictError extends CongoTransactionError {
104
104
  /**
105
105
  * Error thrown for invalid arguments
106
106
  */
107
- export class CongoArgumentError extends CongoError {
107
+ export class TsmdbArgumentError extends TsmdbError {
108
108
  constructor(message: string) {
109
109
  super(message);
110
- this.name = 'CongoArgumentError';
110
+ this.name = 'TsmdbArgumentError';
111
111
  }
112
112
  }
113
113
 
114
114
  /**
115
115
  * Error thrown when an operation is not supported
116
116
  */
117
- export class CongoNotSupportedError extends CongoError {
117
+ export class TsmdbNotSupportedError extends TsmdbError {
118
118
  constructor(message: string) {
119
119
  super(message, 115);
120
- this.name = 'CongoNotSupportedError';
120
+ this.name = 'TsmdbNotSupportedError';
121
121
  this.codeName = 'CommandNotSupported';
122
122
  }
123
123
  }
@@ -125,20 +125,20 @@ export class CongoNotSupportedError extends CongoError {
125
125
  /**
126
126
  * Error thrown when cursor is exhausted or closed
127
127
  */
128
- export class CongoCursorError extends CongoError {
128
+ export class TsmdbCursorError extends TsmdbError {
129
129
  constructor(message: string) {
130
130
  super(message);
131
- this.name = 'CongoCursorError';
131
+ this.name = 'TsmdbCursorError';
132
132
  }
133
133
  }
134
134
 
135
135
  /**
136
136
  * Error thrown when a namespace (database.collection) is invalid
137
137
  */
138
- export class CongoNamespaceError extends CongoError {
138
+ export class TsmdbNamespaceError extends TsmdbError {
139
139
  constructor(message: string) {
140
140
  super(message, 73);
141
- this.name = 'CongoNamespaceError';
141
+ this.name = 'TsmdbNamespaceError';
142
142
  this.codeName = 'InvalidNamespace';
143
143
  }
144
144
  }
@@ -146,10 +146,10 @@ export class CongoNamespaceError extends CongoError {
146
146
  /**
147
147
  * Error thrown when an index operation fails
148
148
  */
149
- export class CongoIndexError extends CongoError {
149
+ export class TsmdbIndexError extends TsmdbError {
150
150
  constructor(message: string, code?: number) {
151
151
  super(message, code || 86);
152
- this.name = 'CongoIndexError';
152
+ this.name = 'TsmdbIndexError';
153
153
  }
154
154
  }
155
155
 
@@ -164,18 +164,18 @@ export interface IWriteError {
164
164
  }
165
165
 
166
166
  /**
167
- * Convert any error to a CongoError
167
+ * Convert any error to a TsmdbError
168
168
  */
169
- export function toCongoError(error: any): CongoError {
170
- if (error instanceof CongoError) {
169
+ export function toTsmdbError(error: any): TsmdbError {
170
+ if (error instanceof TsmdbError) {
171
171
  return error;
172
172
  }
173
- const congoError = new CongoError(error.message || String(error));
173
+ const tsmdbError = new TsmdbError(error.message || String(error));
174
174
  if (error.code) {
175
- congoError.code = error.code;
175
+ tsmdbError.code = error.code;
176
176
  }
177
177
  if (error.codeName) {
178
- congoError.codeName = error.codeName;
178
+ tsmdbError.codeName = error.codeName;
179
179
  }
180
- return congoError;
180
+ return tsmdbError;
181
181
  }
@@ -1,8 +1,8 @@
1
- // CongoDB - MongoDB Wire Protocol compatible in-memory database server
2
- // Use the official MongoDB driver to connect to CongoServer
1
+ // TsmDB - MongoDB Wire Protocol compatible in-memory database server
2
+ // Use the official MongoDB driver to connect to TsmdbServer
3
3
 
4
4
  // Re-export plugins for external use
5
- import * as plugins from './congodb.plugins.js';
5
+ import * as plugins from './tsmdb.plugins.js';
6
6
  export { plugins };
7
7
 
8
8
  // Export BSON types for convenience
@@ -12,7 +12,7 @@ export { ObjectId, Binary, Timestamp, Long, Decimal128, UUID } from 'bson';
12
12
  export * from './types/interfaces.js';
13
13
 
14
14
  // Export errors
15
- export * from './errors/CongoErrors.js';
15
+ export * from './errors/TsmdbErrors.js';
16
16
 
17
17
  // Export storage adapters
18
18
  export type { IStorageAdapter } from './storage/IStorageAdapter.js';
@@ -27,9 +27,9 @@ export { AggregationEngine } from './engine/AggregationEngine.js';
27
27
  export { IndexEngine } from './engine/IndexEngine.js';
28
28
  export { TransactionEngine } from './engine/TransactionEngine.js';
29
29
 
30
- // Export server (the main entry point for using CongoDB)
31
- export { CongoServer } from './server/CongoServer.js';
32
- export type { ICongoServerOptions } from './server/CongoServer.js';
30
+ // Export server (the main entry point for using TsmDB)
31
+ export { TsmdbServer } from './server/TsmdbServer.js';
32
+ export type { ITsmdbServerOptions } from './server/TsmdbServer.js';
33
33
 
34
34
  // Export wire protocol utilities (for advanced usage)
35
35
  export { WireProtocol } from './server/WireProtocol.js';