A database library for GitSense Chat Bridge (GSCB) that provides a clean and type-safe interface for database operations.
npm install gscb-db
import { DatabaseClient, DatabaseConfig } from '@gitsense/gscb-db';
// Configure the database
const config: DatabaseConfig = {
path: './data.db',
poolSize: 5,
timeout: 5000,
verbose: false
};
// Create and initialize the client
const client = new DatabaseClient(config);
await client.initialize();
// Use the services
const groupId = await client.groups.createGroup({
name: 'My Group',
type: 'git-repo',
gitMeta: {
type: 'repo',
path: '/path/to/repo',
bare: false,
importedAt: new Date().toISOString()
}
});
// Close the client when done
await client.close();
- Connection pooling with configurable size and timeout
- Full TypeScript support with strict typing
- Comprehensive error handling
- Transaction support
- Logging with Winston
- Schema migrations
- CRUD operations for all entities:
- Groups
- Chats
- Messages
- Prompts
The main client class that provides access to all services.
const client = new DatabaseClient(config);
await client.initialize();
// Access services
client.groups // GroupService
client.chats // ChatService
client.messages // MessageService
client.prompts // PromptService
Each service provides CRUD operations for its respective entity:
-
createX
: Create a new entity -
getXById
: Get an entity by ID -
updateX
: Update an existing entity -
deleteX
: Delete an entity - Additional methods specific to each entity type
The library provides specific error types for different scenarios:
-
GSCBError
: Base error class -
DatabaseError
: Database-related errors -
ConnectionError
: Connection issues -
QueryError
: SQL query errors -
ValidationError
: Data validation errors -
NotFoundError
: Resource not found
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
MIT