fixed all libs to be buildiable and dependency hell from removing some

This commit is contained in:
Bojan Kucera 2025-06-04 16:07:08 -04:00
parent 5c64b1ccf8
commit a282dac6cd
40 changed files with 4050 additions and 8219 deletions

View file

@ -1,4 +1,4 @@
import { Pool, PoolClient, QueryResult as PgQueryResult } from 'pg';
import { Pool, PoolClient, QueryResult as PgQueryResult, QueryResultRow } from 'pg';
import { postgresConfig } from '@stock-bot/config';
import { Logger } from '@stock-bot/logger';
import type {
@ -115,7 +115,7 @@ export class PostgreSQLClient {
/**
* Execute a query
*/
async query<T = any>(text: string, params?: any[]): Promise<QueryResult<T>> {
async query<T extends QueryResultRow = any>(text: string, params?: any[]): Promise<QueryResult<T>> {
if (!this.pool) {
throw new Error('PostgreSQL client not connected');
}
@ -191,7 +191,7 @@ export class PostgreSQLClient {
/**
* Execute a stored procedure or function
*/
async callFunction<T = any>(functionName: string, params?: any[]): Promise<QueryResult<T>> {
async callFunction<T extends QueryResultRow = any>(functionName: string, params?: any[]): Promise<QueryResult<T>> {
const placeholders = params ? params.map((_, i) => `$${i + 1}`).join(', ') : '';
const query = `SELECT * FROM ${functionName}(${placeholders})`;
return await this.query<T>(query, params);

View file

@ -9,7 +9,7 @@ export { PostgreSQLClient } from './client';
export { PostgreSQLHealthMonitor } from './health';
export { PostgreSQLTransactionManager } from './transactions';
export { PostgreSQLQueryBuilder } from './query-builder';
export { PostgreSQLMigrationManager } from './migrations';
// export { PostgreSQLMigrationManager } from './migrations'; // TODO: Implement migrations
// Types
export type {

View file

@ -1,3 +1,4 @@
import type { QueryResultRow } from 'pg';
import type { PostgreSQLClient } from './client';
import type { WhereCondition, JoinCondition, OrderByCondition, QueryResult } from './types';
@ -137,7 +138,7 @@ export class PostgreSQLQueryBuilder {
/**
* Build and execute the query
*/
async execute<T = any>(): Promise<QueryResult<T>> {
async execute<T extends QueryResultRow = any>(): Promise<QueryResult<T>> {
const { sql, params } = this.build();
return await this.client.query<T>(sql, params);
}

View file

@ -1,4 +1,4 @@
import type { Pool, PoolClient, QueryResult as PgQueryResult } from 'pg';
import type { Pool, PoolClient, QueryResult as PgQueryResult, QueryResultRow } from 'pg';
/**
* PostgreSQL Client Configuration
@ -64,7 +64,7 @@ export interface PostgreSQLMetrics {
/**
* Query Result Types
*/
export interface QueryResult<T = any> extends PgQueryResult<T> {
export interface QueryResult<T extends QueryResultRow = any> extends PgQueryResult<T> {
executionTime?: number;
}