BREAKING CHANGE(tsmdb): rename CongoDB to TsmDB and relocate/rename wire-protocol server implementation and public exports
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartmongo',
|
||||
version: '2.2.0',
|
||||
version: '3.0.0',
|
||||
description: 'A module for creating and managing a local MongoDB instance for testing purposes.'
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { commitinfo } from './00_commitinfo_data.js';
|
||||
import * as plugins from './smartmongo.plugins.js';
|
||||
|
||||
// Export CongoDB module
|
||||
export * as congodb from './congodb/index.js';
|
||||
// Export TsmDB module
|
||||
export * as tsmdb from './tsmdb/index.js';
|
||||
|
||||
export class SmartMongo {
|
||||
// STATIC
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { Document, IStoredDocument, IAggregateOptions } from '../types/interfaces.js';
|
||||
|
||||
// Import mingo Aggregator
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
|
||||
import type {
|
||||
Document,
|
||||
@@ -7,7 +7,7 @@ import type {
|
||||
IIndexInfo,
|
||||
ICreateIndexOptions,
|
||||
} from '../types/interfaces.js';
|
||||
import { CongoDuplicateKeyError, CongoIndexError } from '../errors/CongoErrors.js';
|
||||
import { TsmdbDuplicateKeyError, TsmdbIndexError } from '../errors/TsmdbErrors.js';
|
||||
import { QueryEngine } from './QueryEngine.js';
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ export class IndexEngine {
|
||||
const keyStr = JSON.stringify(keyValue);
|
||||
|
||||
if (indexData.unique && indexData.entries.has(keyStr)) {
|
||||
throw new CongoDuplicateKeyError(
|
||||
throw new TsmdbDuplicateKeyError(
|
||||
`E11000 duplicate key error index: ${this.dbName}.${this.collName}.$${name}`,
|
||||
key as Record<string, 1>,
|
||||
keyValue
|
||||
@@ -148,11 +148,11 @@ export class IndexEngine {
|
||||
await this.initialize();
|
||||
|
||||
if (name === '_id_') {
|
||||
throw new CongoIndexError('cannot drop _id index');
|
||||
throw new TsmdbIndexError('cannot drop _id index');
|
||||
}
|
||||
|
||||
if (!this.indexes.has(name)) {
|
||||
throw new CongoIndexError(`index not found: ${name}`);
|
||||
throw new TsmdbIndexError(`index not found: ${name}`);
|
||||
}
|
||||
|
||||
this.indexes.delete(name);
|
||||
@@ -215,7 +215,7 @@ export class IndexEngine {
|
||||
if (indexData.unique) {
|
||||
const existing = indexData.entries.get(keyStr);
|
||||
if (existing && existing.size > 0) {
|
||||
throw new CongoDuplicateKeyError(
|
||||
throw new TsmdbDuplicateKeyError(
|
||||
`E11000 duplicate key error collection: ${this.dbName}.${this.collName} index: ${name}`,
|
||||
indexData.key as Record<string, 1>,
|
||||
keyValue
|
||||
@@ -260,7 +260,7 @@ export class IndexEngine {
|
||||
if (indexData.unique) {
|
||||
const existing = indexData.entries.get(newKeyStr);
|
||||
if (existing && existing.size > 0) {
|
||||
throw new CongoDuplicateKeyError(
|
||||
throw new TsmdbDuplicateKeyError(
|
||||
`E11000 duplicate key error collection: ${this.dbName}.${this.collName} index: ${name}`,
|
||||
indexData.key as Record<string, 1>,
|
||||
newKeyValue
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { Document, IStoredDocument, ISortSpecification, ISortDirection } from '../types/interfaces.js';
|
||||
|
||||
// Import mingo Query class
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
|
||||
import type { Document, IStoredDocument, ITransactionOptions } from '../types/interfaces.js';
|
||||
import { CongoTransactionError, CongoWriteConflictError } from '../errors/CongoErrors.js';
|
||||
import { TsmdbTransactionError, TsmdbWriteConflictError } from '../errors/TsmdbErrors.js';
|
||||
|
||||
/**
|
||||
* Transaction state
|
||||
@@ -70,7 +70,7 @@ export class TransactionEngine {
|
||||
async getSnapshot(txnId: string, dbName: string, collName: string): Promise<IStoredDocument[]> {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn || txn.status !== 'active') {
|
||||
throw new CongoTransactionError('Transaction is not active');
|
||||
throw new TsmdbTransactionError('Transaction is not active');
|
||||
}
|
||||
|
||||
const ns = `${dbName}.${collName}`;
|
||||
@@ -148,7 +148,7 @@ export class TransactionEngine {
|
||||
recordInsert(txnId: string, dbName: string, collName: string, doc: IStoredDocument): void {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn || txn.status !== 'active') {
|
||||
throw new CongoTransactionError('Transaction is not active');
|
||||
throw new TsmdbTransactionError('Transaction is not active');
|
||||
}
|
||||
|
||||
const ns = `${dbName}.${collName}`;
|
||||
@@ -174,7 +174,7 @@ export class TransactionEngine {
|
||||
): void {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn || txn.status !== 'active') {
|
||||
throw new CongoTransactionError('Transaction is not active');
|
||||
throw new TsmdbTransactionError('Transaction is not active');
|
||||
}
|
||||
|
||||
const ns = `${dbName}.${collName}`;
|
||||
@@ -203,7 +203,7 @@ export class TransactionEngine {
|
||||
recordDelete(txnId: string, dbName: string, collName: string, doc: IStoredDocument): void {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn || txn.status !== 'active') {
|
||||
throw new CongoTransactionError('Transaction is not active');
|
||||
throw new TsmdbTransactionError('Transaction is not active');
|
||||
}
|
||||
|
||||
const ns = `${dbName}.${collName}`;
|
||||
@@ -231,10 +231,10 @@ export class TransactionEngine {
|
||||
async commitTransaction(txnId: string): Promise<void> {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn) {
|
||||
throw new CongoTransactionError('Transaction not found');
|
||||
throw new TsmdbTransactionError('Transaction not found');
|
||||
}
|
||||
if (txn.status !== 'active') {
|
||||
throw new CongoTransactionError(`Cannot commit transaction in state: ${txn.status}`);
|
||||
throw new TsmdbTransactionError(`Cannot commit transaction in state: ${txn.status}`);
|
||||
}
|
||||
|
||||
// Check for write conflicts
|
||||
@@ -245,7 +245,7 @@ export class TransactionEngine {
|
||||
const hasConflicts = await this.storage.hasConflicts(dbName, collName, ids, txn.startTime);
|
||||
if (hasConflicts) {
|
||||
txn.status = 'aborted';
|
||||
throw new CongoWriteConflictError();
|
||||
throw new TsmdbWriteConflictError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ export class TransactionEngine {
|
||||
async abortTransaction(txnId: string): Promise<void> {
|
||||
const txn = this.transactions.get(txnId);
|
||||
if (!txn) {
|
||||
throw new CongoTransactionError('Transaction not found');
|
||||
throw new TsmdbTransactionError('Transaction not found');
|
||||
}
|
||||
if (txn.status !== 'active') {
|
||||
// Already committed or aborted, just return
|
||||
@@ -336,7 +336,7 @@ export class TransactionEngine {
|
||||
await this.abortTransaction(txnId);
|
||||
this.endTransaction(txnId);
|
||||
|
||||
if (error instanceof CongoWriteConflictError && attempt < maxRetries - 1) {
|
||||
if (error instanceof TsmdbWriteConflictError && attempt < maxRetries - 1) {
|
||||
// Retry on write conflict
|
||||
lastError = error;
|
||||
continue;
|
||||
@@ -346,6 +346,6 @@ export class TransactionEngine {
|
||||
}
|
||||
}
|
||||
|
||||
throw lastError || new CongoTransactionError('Transaction failed after max retries');
|
||||
throw lastError || new TsmdbTransactionError('Transaction failed after max retries');
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { Document, IStoredDocument } from '../types/interfaces.js';
|
||||
import { QueryEngine } from './QueryEngine.js';
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Base error class for all CongoDB errors
|
||||
* Base error class for all TsmDB errors
|
||||
* Mirrors MongoDB driver error hierarchy
|
||||
*/
|
||||
export class CongoError extends Error {
|
||||
export class TsmdbError extends Error {
|
||||
public code?: number;
|
||||
public codeName?: string;
|
||||
|
||||
constructor(message: string, code?: number, codeName?: string) {
|
||||
super(message);
|
||||
this.name = 'CongoError';
|
||||
this.name = 'TsmdbError';
|
||||
this.code = code;
|
||||
this.codeName = codeName;
|
||||
Object.setPrototypeOf(this, new.target.prototype);
|
||||
@@ -18,33 +18,33 @@ export class CongoError extends Error {
|
||||
/**
|
||||
* Error thrown during connection issues
|
||||
*/
|
||||
export class CongoConnectionError extends CongoError {
|
||||
export class TsmdbConnectionError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'CongoConnectionError';
|
||||
this.name = 'TsmdbConnectionError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when an operation times out
|
||||
*/
|
||||
export class CongoTimeoutError extends CongoError {
|
||||
export class TsmdbTimeoutError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message, 50, 'MaxTimeMSExpired');
|
||||
this.name = 'CongoTimeoutError';
|
||||
this.name = 'TsmdbTimeoutError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown during write operations
|
||||
*/
|
||||
export class CongoWriteError extends CongoError {
|
||||
export class TsmdbWriteError extends TsmdbError {
|
||||
public writeErrors?: IWriteError[];
|
||||
public result?: any;
|
||||
|
||||
constructor(message: string, code?: number, writeErrors?: IWriteError[]) {
|
||||
super(message, code);
|
||||
this.name = 'CongoWriteError';
|
||||
this.name = 'TsmdbWriteError';
|
||||
this.writeErrors = writeErrors;
|
||||
}
|
||||
}
|
||||
@@ -52,13 +52,13 @@ export class CongoWriteError extends CongoError {
|
||||
/**
|
||||
* Error thrown for duplicate key violations
|
||||
*/
|
||||
export class CongoDuplicateKeyError extends CongoWriteError {
|
||||
export class TsmdbDuplicateKeyError extends TsmdbWriteError {
|
||||
public keyPattern?: Record<string, 1>;
|
||||
public keyValue?: Record<string, any>;
|
||||
|
||||
constructor(message: string, keyPattern?: Record<string, 1>, keyValue?: Record<string, any>) {
|
||||
super(message, 11000);
|
||||
this.name = 'CongoDuplicateKeyError';
|
||||
this.name = 'TsmdbDuplicateKeyError';
|
||||
this.codeName = 'DuplicateKey';
|
||||
this.keyPattern = keyPattern;
|
||||
this.keyValue = keyValue;
|
||||
@@ -68,13 +68,13 @@ export class CongoDuplicateKeyError extends CongoWriteError {
|
||||
/**
|
||||
* Error thrown for bulk write failures
|
||||
*/
|
||||
export class CongoBulkWriteError extends CongoError {
|
||||
export class TsmdbBulkWriteError extends TsmdbError {
|
||||
public writeErrors: IWriteError[];
|
||||
public result: any;
|
||||
|
||||
constructor(message: string, writeErrors: IWriteError[], result: any) {
|
||||
super(message, 65);
|
||||
this.name = 'CongoBulkWriteError';
|
||||
this.name = 'TsmdbBulkWriteError';
|
||||
this.writeErrors = writeErrors;
|
||||
this.result = result;
|
||||
}
|
||||
@@ -83,20 +83,20 @@ export class CongoBulkWriteError extends CongoError {
|
||||
/**
|
||||
* Error thrown during transaction operations
|
||||
*/
|
||||
export class CongoTransactionError extends CongoError {
|
||||
export class TsmdbTransactionError extends TsmdbError {
|
||||
constructor(message: string, code?: number) {
|
||||
super(message, code);
|
||||
this.name = 'CongoTransactionError';
|
||||
this.name = 'TsmdbTransactionError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a transaction is aborted due to conflict
|
||||
*/
|
||||
export class CongoWriteConflictError extends CongoTransactionError {
|
||||
export class TsmdbWriteConflictError extends TsmdbTransactionError {
|
||||
constructor(message: string = 'Write conflict during transaction') {
|
||||
super(message, 112);
|
||||
this.name = 'CongoWriteConflictError';
|
||||
this.name = 'TsmdbWriteConflictError';
|
||||
this.codeName = 'WriteConflict';
|
||||
}
|
||||
}
|
||||
@@ -104,20 +104,20 @@ export class CongoWriteConflictError extends CongoTransactionError {
|
||||
/**
|
||||
* Error thrown for invalid arguments
|
||||
*/
|
||||
export class CongoArgumentError extends CongoError {
|
||||
export class TsmdbArgumentError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'CongoArgumentError';
|
||||
this.name = 'TsmdbArgumentError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when an operation is not supported
|
||||
*/
|
||||
export class CongoNotSupportedError extends CongoError {
|
||||
export class TsmdbNotSupportedError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message, 115);
|
||||
this.name = 'CongoNotSupportedError';
|
||||
this.name = 'TsmdbNotSupportedError';
|
||||
this.codeName = 'CommandNotSupported';
|
||||
}
|
||||
}
|
||||
@@ -125,20 +125,20 @@ export class CongoNotSupportedError extends CongoError {
|
||||
/**
|
||||
* Error thrown when cursor is exhausted or closed
|
||||
*/
|
||||
export class CongoCursorError extends CongoError {
|
||||
export class TsmdbCursorError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = 'CongoCursorError';
|
||||
this.name = 'TsmdbCursorError';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a namespace (database.collection) is invalid
|
||||
*/
|
||||
export class CongoNamespaceError extends CongoError {
|
||||
export class TsmdbNamespaceError extends TsmdbError {
|
||||
constructor(message: string) {
|
||||
super(message, 73);
|
||||
this.name = 'CongoNamespaceError';
|
||||
this.name = 'TsmdbNamespaceError';
|
||||
this.codeName = 'InvalidNamespace';
|
||||
}
|
||||
}
|
||||
@@ -146,10 +146,10 @@ export class CongoNamespaceError extends CongoError {
|
||||
/**
|
||||
* Error thrown when an index operation fails
|
||||
*/
|
||||
export class CongoIndexError extends CongoError {
|
||||
export class TsmdbIndexError extends TsmdbError {
|
||||
constructor(message: string, code?: number) {
|
||||
super(message, code || 86);
|
||||
this.name = 'CongoIndexError';
|
||||
this.name = 'TsmdbIndexError';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,18 +164,18 @@ export interface IWriteError {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert any error to a CongoError
|
||||
* Convert any error to a TsmdbError
|
||||
*/
|
||||
export function toCongoError(error: any): CongoError {
|
||||
if (error instanceof CongoError) {
|
||||
export function toTsmdbError(error: any): TsmdbError {
|
||||
if (error instanceof TsmdbError) {
|
||||
return error;
|
||||
}
|
||||
const congoError = new CongoError(error.message || String(error));
|
||||
const tsmdbError = new TsmdbError(error.message || String(error));
|
||||
if (error.code) {
|
||||
congoError.code = error.code;
|
||||
tsmdbError.code = error.code;
|
||||
}
|
||||
if (error.codeName) {
|
||||
congoError.codeName = error.codeName;
|
||||
tsmdbError.codeName = error.codeName;
|
||||
}
|
||||
return congoError;
|
||||
return tsmdbError;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// CongoDB - MongoDB Wire Protocol compatible in-memory database server
|
||||
// Use the official MongoDB driver to connect to CongoServer
|
||||
// TsmDB - MongoDB Wire Protocol compatible in-memory database server
|
||||
// Use the official MongoDB driver to connect to TsmdbServer
|
||||
|
||||
// Re-export plugins for external use
|
||||
import * as plugins from './congodb.plugins.js';
|
||||
import * as plugins from './tsmdb.plugins.js';
|
||||
export { plugins };
|
||||
|
||||
// Export BSON types for convenience
|
||||
@@ -12,7 +12,7 @@ export { ObjectId, Binary, Timestamp, Long, Decimal128, UUID } from 'bson';
|
||||
export * from './types/interfaces.js';
|
||||
|
||||
// Export errors
|
||||
export * from './errors/CongoErrors.js';
|
||||
export * from './errors/TsmdbErrors.js';
|
||||
|
||||
// Export storage adapters
|
||||
export type { IStorageAdapter } from './storage/IStorageAdapter.js';
|
||||
@@ -27,9 +27,9 @@ export { AggregationEngine } from './engine/AggregationEngine.js';
|
||||
export { IndexEngine } from './engine/IndexEngine.js';
|
||||
export { TransactionEngine } from './engine/TransactionEngine.js';
|
||||
|
||||
// Export server (the main entry point for using CongoDB)
|
||||
export { CongoServer } from './server/CongoServer.js';
|
||||
export type { ICongoServerOptions } from './server/CongoServer.js';
|
||||
// Export server (the main entry point for using TsmDB)
|
||||
export { TsmdbServer } from './server/TsmdbServer.js';
|
||||
export type { ITsmdbServerOptions } from './server/TsmdbServer.js';
|
||||
|
||||
// Export wire protocol utilities (for advanced usage)
|
||||
export { WireProtocol } from './server/WireProtocol.js';
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
|
||||
import type { IParsedCommand } from './WireProtocol.js';
|
||||
import type { CongoServer } from './CongoServer.js';
|
||||
import type { TsmdbServer } from './TsmdbServer.js';
|
||||
|
||||
// Import handlers
|
||||
import { HelloHandler } from './handlers/HelloHandler.js';
|
||||
@@ -18,7 +18,7 @@ import { AdminHandler } from './handlers/AdminHandler.js';
|
||||
*/
|
||||
export interface IHandlerContext {
|
||||
storage: IStorageAdapter;
|
||||
server: CongoServer;
|
||||
server: TsmdbServer;
|
||||
database: string;
|
||||
command: plugins.bson.Document;
|
||||
documentSequences?: Map<string, plugins.bson.Document[]>;
|
||||
@@ -36,14 +36,14 @@ export interface ICommandHandler {
|
||||
*/
|
||||
export class CommandRouter {
|
||||
private storage: IStorageAdapter;
|
||||
private server: CongoServer;
|
||||
private server: TsmdbServer;
|
||||
private handlers: Map<string, ICommandHandler> = new Map();
|
||||
|
||||
// Cursor state for getMore operations
|
||||
private cursors: Map<bigint, ICursorState> = new Map();
|
||||
private cursorIdCounter: bigint = BigInt(1);
|
||||
|
||||
constructor(storage: IStorageAdapter, server: CongoServer) {
|
||||
constructor(storage: IStorageAdapter, server: TsmdbServer) {
|
||||
this.storage = storage;
|
||||
this.server = server;
|
||||
this.registerHandlers();
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as net from 'net';
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import { WireProtocol, OP_QUERY } from './WireProtocol.js';
|
||||
import { CommandRouter } from './CommandRouter.js';
|
||||
import { MemoryStorageAdapter } from '../storage/MemoryStorageAdapter.js';
|
||||
@@ -9,7 +9,7 @@ import type { IStorageAdapter } from '../storage/IStorageAdapter.js';
|
||||
/**
|
||||
* Server configuration options
|
||||
*/
|
||||
export interface ICongoServerOptions {
|
||||
export interface ITsmdbServerOptions {
|
||||
/** Port to listen on (default: 27017) */
|
||||
port?: number;
|
||||
/** Host to bind to (default: 127.0.0.1) */
|
||||
@@ -36,25 +36,25 @@ interface IConnectionState {
|
||||
}
|
||||
|
||||
/**
|
||||
* CongoServer - MongoDB Wire Protocol compatible server
|
||||
* TsmdbServer - MongoDB Wire Protocol compatible server
|
||||
*
|
||||
* This server implements the MongoDB wire protocol (OP_MSG) to allow
|
||||
* official MongoDB drivers to connect and perform operations.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* import { CongoServer } from '@push.rocks/smartmongo/congodb';
|
||||
* import { TsmdbServer } from '@push.rocks/smartmongo/tsmdb';
|
||||
* import { MongoClient } from 'mongodb';
|
||||
*
|
||||
* const server = new CongoServer({ port: 27017 });
|
||||
* const server = new TsmdbServer({ port: 27017 });
|
||||
* await server.start();
|
||||
*
|
||||
* const client = new MongoClient('mongodb://127.0.0.1:27017');
|
||||
* await client.connect();
|
||||
* ```
|
||||
*/
|
||||
export class CongoServer {
|
||||
private options: Required<ICongoServerOptions>;
|
||||
export class TsmdbServer {
|
||||
private options: Required<ITsmdbServerOptions>;
|
||||
private server: net.Server | null = null;
|
||||
private storage: IStorageAdapter;
|
||||
private commandRouter: CommandRouter;
|
||||
@@ -63,7 +63,7 @@ export class CongoServer {
|
||||
private isRunning = false;
|
||||
private startTime: Date = new Date();
|
||||
|
||||
constructor(options: ICongoServerOptions = {}) {
|
||||
constructor(options: ITsmdbServerOptions = {}) {
|
||||
this.options = {
|
||||
port: options.port ?? 27017,
|
||||
host: options.host ?? '127.0.0.1',
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
|
||||
/**
|
||||
* MongoDB Wire Protocol Implementation
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
|
||||
/**
|
||||
@@ -246,7 +246,7 @@ export class AdminHandler implements ICommandHandler {
|
||||
ok: 1,
|
||||
host: `${server.host}:${server.port}`,
|
||||
version: '7.0.0',
|
||||
process: 'congodb',
|
||||
process: 'tsmdb',
|
||||
pid: process.pid,
|
||||
uptime,
|
||||
uptimeMillis: uptime * 1000,
|
||||
@@ -269,7 +269,7 @@ export class AdminHandler implements ICommandHandler {
|
||||
numRequests: 0,
|
||||
},
|
||||
storageEngine: {
|
||||
name: 'congodb',
|
||||
name: 'tsmdb',
|
||||
supportsCommittedReads: true,
|
||||
persistent: false,
|
||||
},
|
||||
@@ -283,7 +283,7 @@ export class AdminHandler implements ICommandHandler {
|
||||
return {
|
||||
ok: 1,
|
||||
version: '7.0.0',
|
||||
gitVersion: 'congodb',
|
||||
gitVersion: 'tsmdb',
|
||||
modules: [],
|
||||
allocator: 'system',
|
||||
javascriptEngine: 'none',
|
||||
@@ -294,7 +294,7 @@ export class AdminHandler implements ICommandHandler {
|
||||
compiled: 'disabled',
|
||||
},
|
||||
buildEnvironment: {
|
||||
distmod: 'congodb',
|
||||
distmod: 'tsmdb',
|
||||
distarch: process.arch,
|
||||
cc: '',
|
||||
ccflags: '',
|
||||
@@ -307,7 +307,7 @@ export class AdminHandler implements ICommandHandler {
|
||||
bits: 64,
|
||||
debug: false,
|
||||
maxBsonObjectSize: 16777216,
|
||||
storageEngines: ['congodb'],
|
||||
storageEngines: ['tsmdb'],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext, ICursorState } from '../CommandRouter.js';
|
||||
import { AggregationEngine } from '../../engine/AggregationEngine.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
import { QueryEngine } from '../../engine/QueryEngine.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext, ICursorState } from '../CommandRouter.js';
|
||||
import { QueryEngine } from '../../engine/QueryEngine.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
import { IndexEngine } from '../../engine/IndexEngine.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../../congodb.plugins.js';
|
||||
import * as plugins from '../../tsmdb.plugins.js';
|
||||
import type { ICommandHandler, IHandlerContext } from '../CommandRouter.js';
|
||||
import { QueryEngine } from '../../engine/QueryEngine.js';
|
||||
import { UpdateEngine } from '../../engine/UpdateEngine.js';
|
||||
@@ -1,7 +1,7 @@
|
||||
// Server module exports
|
||||
|
||||
export { CongoServer } from './CongoServer.js';
|
||||
export type { ICongoServerOptions } from './CongoServer.js';
|
||||
export { TsmdbServer } from './TsmdbServer.js';
|
||||
export type { ITsmdbServerOptions } from './TsmdbServer.js';
|
||||
export { WireProtocol } from './WireProtocol.js';
|
||||
export { CommandRouter } from './CommandRouter.js';
|
||||
export type { ICommandHandler, IHandlerContext, ICursorState } from './CommandRouter.js';
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from './IStorageAdapter.js';
|
||||
import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
|
||||
|
||||
/**
|
||||
* File-based storage adapter for CongoDB
|
||||
* File-based storage adapter for TsmDB
|
||||
* Stores data in JSON files on disk for persistence
|
||||
*/
|
||||
export class FileStorageAdapter implements IStorageAdapter {
|
||||
@@ -1,8 +1,8 @@
|
||||
import type * as plugins from '../congodb.plugins.js';
|
||||
import type * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
|
||||
|
||||
/**
|
||||
* Storage adapter interface for CongoDB
|
||||
* Storage adapter interface for TsmDB
|
||||
* Implementations can provide different storage backends (memory, file, etc.)
|
||||
*/
|
||||
export interface IStorageAdapter {
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from './IStorageAdapter.js';
|
||||
import type { IStoredDocument, IOpLogEntry, Document } from '../types/interfaces.js';
|
||||
|
||||
/**
|
||||
* In-memory storage adapter for CongoDB
|
||||
* In-memory storage adapter for TsmDB
|
||||
* Optionally supports persistence to a file
|
||||
*/
|
||||
export class MemoryStorageAdapter implements IStorageAdapter {
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from '../congodb.plugins.js';
|
||||
import * as plugins from '../tsmdb.plugins.js';
|
||||
import type { IStorageAdapter } from './IStorageAdapter.js';
|
||||
import type { IOpLogEntry, Document, IResumeToken, ChangeStreamOperationType } from '../types/interfaces.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type * as plugins from '../congodb.plugins.js';
|
||||
import type * as plugins from '../tsmdb.plugins.js';
|
||||
|
||||
// ============================================================================
|
||||
// Document Types
|
||||
@@ -14,7 +14,7 @@ export interface WithId<TSchema> {
|
||||
// Client Options
|
||||
// ============================================================================
|
||||
|
||||
export interface ICongoClientOptions {
|
||||
export interface ITsmdbClientOptions {
|
||||
/** Storage adapter type: 'memory' or 'file' */
|
||||
storageType?: 'memory' | 'file';
|
||||
/** Path for file-based storage */
|
||||
@@ -30,7 +30,7 @@ export interface ICongoClientOptions {
|
||||
// ============================================================================
|
||||
|
||||
export interface IParsedConnectionString {
|
||||
protocol: 'congo';
|
||||
protocol: 'tsmdb';
|
||||
storageType: 'memory' | 'file';
|
||||
options: {
|
||||
persist?: string;
|
||||
Reference in New Issue
Block a user