@push.rocks/smartmongo 2.1.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 +398 -44
  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,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';
@@ -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 { IParsedCommand } from './WireProtocol.js';
4
- import type { CongoServer } from './CongoServer.js';
4
+ import type { TsmdbServer } from './TsmdbServer.js';
5
5
 
6
6
  // Import handlers
7
7
  import { HelloHandler } from './handlers/HelloHandler.js';
@@ -18,7 +18,7 @@ import { AdminHandler } from './handlers/AdminHandler.js';
18
18
  */
19
19
  export interface IHandlerContext {
20
20
  storage: IStorageAdapter;
21
- server: CongoServer;
21
+ server: TsmdbServer;
22
22
  database: string;
23
23
  command: plugins.bson.Document;
24
24
  documentSequences?: Map<string, plugins.bson.Document[]>;
@@ -36,14 +36,14 @@ export interface ICommandHandler {
36
36
  */
37
37
  export class CommandRouter {
38
38
  private storage: IStorageAdapter;
39
- private server: CongoServer;
39
+ private server: TsmdbServer;
40
40
  private handlers: Map<string, ICommandHandler> = new Map();
41
41
 
42
42
  // Cursor state for getMore operations
43
43
  private cursors: Map<bigint, ICursorState> = new Map();
44
44
  private cursorIdCounter: bigint = BigInt(1);
45
45
 
46
- constructor(storage: IStorageAdapter, server: CongoServer) {
46
+ constructor(storage: IStorageAdapter, server: TsmdbServer) {
47
47
  this.storage = storage;
48
48
  this.server = server;
49
49
  this.registerHandlers();
@@ -1,5 +1,5 @@
1
1
  import * as net from 'net';
2
- import * as plugins from '../congodb.plugins.js';
2
+ import * as plugins from '../tsmdb.plugins.js';
3
3
  import { WireProtocol, OP_QUERY } from './WireProtocol.js';
4
4
  import { CommandRouter } from './CommandRouter.js';
5
5
  import { MemoryStorageAdapter } from '../storage/MemoryStorageAdapter.js';
@@ -9,7 +9,7 @@ import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
9
9
  /**
10
10
  * Server configuration options
11
11
  */
12
- export interface ICongoServerOptions {
12
+ export interface ITsmdbServerOptions {
13
13
  /** Port to listen on (default: 27017) */
14
14
  port?: number;
15
15
  /** Host to bind to (default: 127.0.0.1) */
@@ -36,25 +36,25 @@ interface IConnectionState {
36
36
  }
37
37
 
38
38
  /**
39
- * CongoServer - MongoDB Wire Protocol compatible server
39
+ * TsmdbServer - MongoDB Wire Protocol compatible server
40
40
  *
41
41
  * This server implements the MongoDB wire protocol (OP_MSG) to allow
42
42
  * official MongoDB drivers to connect and perform operations.
43
43
  *
44
44
  * @example
45
45
  * ```typescript
46
- * import { CongoServer } from '@push.rocks/smartmongo/congodb';
46
+ * import { TsmdbServer } from '@push.rocks/smartmongo/tsmdb';
47
47
  * import { MongoClient } from 'mongodb';
48
48
  *
49
- * const server = new CongoServer({ port: 27017 });
49
+ * const server = new TsmdbServer({ port: 27017 });
50
50
  * await server.start();
51
51
  *
52
52
  * const client = new MongoClient('mongodb://127.0.0.1:27017');
53
53
  * await client.connect();
54
54
  * ```
55
55
  */
56
- export class CongoServer {
57
- private options: Required<ICongoServerOptions>;
56
+ export class TsmdbServer {
57
+ private options: Required<ITsmdbServerOptions>;
58
58
  private server: net.Server | null = null;
59
59
  private storage: IStorageAdapter;
60
60
  private commandRouter: CommandRouter;
@@ -63,7 +63,7 @@ export class CongoServer {
63
63
  private isRunning = false;
64
64
  private startTime: Date = new Date();
65
65
 
66
- constructor(options: ICongoServerOptions = {}) {
66
+ constructor(options: ITsmdbServerOptions = {}) {
67
67
  this.options = {
68
68
  port: options.port ?? 27017,
69
69
  host: options.host ?? '127.0.0.1',
@@ -1,4 +1,4 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
 
3
3
  /**
4
4
  * MongoDB Wire Protocol Implementation
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
 
4
4
  /**
@@ -246,7 +246,7 @@ export class AdminHandler implements ICommandHandler {
246
246
  ok: 1,
247
247
  host: `${server.host}:${server.port}`,
248
248
  version: '7.0.0',
249
- process: 'congodb',
249
+ process: 'tsmdb',
250
250
  pid: process.pid,
251
251
  uptime,
252
252
  uptimeMillis: uptime * 1000,
@@ -269,7 +269,7 @@ export class AdminHandler implements ICommandHandler {
269
269
  numRequests: 0,
270
270
  },
271
271
  storageEngine: {
272
- name: 'congodb',
272
+ name: 'tsmdb',
273
273
  supportsCommittedReads: true,
274
274
  persistent: false,
275
275
  },
@@ -283,7 +283,7 @@ export class AdminHandler implements ICommandHandler {
283
283
  return {
284
284
  ok: 1,
285
285
  version: '7.0.0',
286
- gitVersion: 'congodb',
286
+ gitVersion: 'tsmdb',
287
287
  modules: [],
288
288
  allocator: 'system',
289
289
  javascriptEngine: 'none',
@@ -294,7 +294,7 @@ export class AdminHandler implements ICommandHandler {
294
294
  compiled: 'disabled',
295
295
  },
296
296
  buildEnvironment: {
297
- distmod: 'congodb',
297
+ distmod: 'tsmdb',
298
298
  distarch: process.arch,
299
299
  cc: '',
300
300
  ccflags: '',
@@ -307,7 +307,7 @@ export class AdminHandler implements ICommandHandler {
307
307
  bits: 64,
308
308
  debug: false,
309
309
  maxBsonObjectSize: 16777216,
310
- storageEngines: ['congodb'],
310
+ storageEngines: ['tsmdb'],
311
311
  };
312
312
  }
313
313
 
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext, ICursorState } from '../CommandRouter.js';
3
3
  import { AggregationEngine } from '../../engine/AggregationEngine.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
  import { QueryEngine } from '../../engine/QueryEngine.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext, ICursorState } from '../CommandRouter.js';
3
3
  import { QueryEngine } from '../../engine/QueryEngine.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
  import { IndexEngine } from '../../engine/IndexEngine.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import * as plugins from '../../congodb.plugins.js';
1
+ import * as plugins from '../../tsmdb.plugins.js';
2
2
  import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
3
3
  import { QueryEngine } from '../../engine/QueryEngine.js';
4
4
  import { UpdateEngine } from '../../engine/UpdateEngine.js';
@@ -1,7 +1,7 @@
1
1
  // Server module exports
2
2
 
3
- export { CongoServer } from './CongoServer.js';
4
- export type { ICongoServerOptions } from './CongoServer.js';
3
+ export { TsmdbServer } from './TsmdbServer.js';
4
+ export type { ITsmdbServerOptions } from './TsmdbServer.js';
5
5
  export { WireProtocol } from './WireProtocol.js';
6
6
  export { CommandRouter } from './CommandRouter.js';
7
7
  export type { ICommandHandler, IHandlerContext, ICursorState } from './CommandRouter.js';
@@ -1,9 +1,9 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
  import type { IStorageAdapter } from './IStorageAdapter.js';
3
3
  import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
4
4
 
5
5
  /**
6
- * File-based storage adapter for CongoDB
6
+ * File-based storage adapter for TsmDB
7
7
  * Stores data in JSON files on disk for persistence
8
8
  */
9
9
  export class FileStorageAdapter implements IStorageAdapter {
@@ -1,8 +1,8 @@
1
- import type * as plugins from '../congodb.plugins.js';
1
+ import type * as plugins from '../tsmdb.plugins.js';
2
2
  import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
3
3
 
4
4
  /**
5
- * Storage adapter interface for CongoDB
5
+ * Storage adapter interface for TsmDB
6
6
  * Implementations can provide different storage backends (memory, file, etc.)
7
7
  */
8
8
  export interface IStorageAdapter {
@@ -1,9 +1,9 @@
1
- import * as plugins from '../congodb.plugins.js';
1
+ import * as plugins from '../tsmdb.plugins.js';
2
2
  import type { IStorageAdapter } from './IStorageAdapter.js';
3
3
  import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
4
4
 
5
5
  /**
6
- * In-memory storage adapter for CongoDB
6
+ * In-memory storage adapter for TsmDB
7
7
  * Optionally supports persistence to a file
8
8
  */
9
9
  export class MemoryStorageAdapter implements IStorageAdapter {
@@ -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 './IStorageAdapter.js';
3
3
  import type { IOpLogEntry, Document, IResumeToken, ChangeStreamOperationType } from '../types/interfaces.js';
4
4