usagepilot
Version:
Open-core usage tracking for AI applications. Record, aggregate, and bill for token consumption across tenants with 95% storage reduction
62 lines (57 loc) • 1.38 kB
TypeScript
/* SPDX-License-Identifier: MIT */
/**
* PostgreSQL storage configuration
*/
export interface PostgresStorageConfig {
/** PostgreSQL connection string */
connectionString?: string;
/** Database host */
host?: string;
/** Database port */
port?: number;
/** Database name */
database?: string;
/** Database user */
user?: string;
/** Database password */
password?: string;
/** SSL configuration */
ssl?: boolean | object;
/** Connection pool configuration */
pool?: {
/** Minimum pool size */
min?: number;
/** Maximum pool size */
max?: number;
/** Connection idle timeout in milliseconds */
idleTimeoutMillis?: number;
};
/** Table name prefix */
tablePrefix?: string;
/** Schema name */
schema?: string;
}
/**
* PostgreSQL storage adapter for UsagePilot
*/
export class PostgresStorage {
/**
* Create a new PostgresStorage instance
* @param config PostgreSQL configuration
*/
constructor(config: PostgresStorageConfig);
/**
* Initialize the storage adapter and create necessary tables
* @returns Promise that resolves when initialization is complete
*/
initialize(): Promise<void>;
/**
* Close all database connections
* @returns Promise that resolves when cleanup is complete
*/
close(): Promise<void>;
}
/**
* Default export
*/
export default PostgresStorage;