import { DataSourceInfo, ProviderInfo } from './types.js';
import sql from 'mssql';
import { DatabaseProviderBase } from '@memberjunction/core';
type StreamCallback = (jsonObject: any) => void;
/**
 * Utility function to handle HTTP/HTTPS requests with optional compression, custom headers, and streaming response callback for JSON objects.
 * This function accumulates data chunks and parses complete JSON objects, assuming newline-delimited JSON in the stream.
 *
 * @param {string} url - The URL to which the request is sent.
 * @param {any} payload - The payload to be sent with the request.
 * @param {boolean} useCompression - Flag to determine if payload compression should be used.
 * @param {Record<string, string> | null} headers - Custom headers for the request. Can be null.
 * @param {StreamCallback} [streamCallback] - Optional callback for handling streaming JSON objects.
 * @returns {Promise<any[]>} - A promise that resolves to an array of all JSON objects received during the streaming process.
 */
export declare function sendPostRequest(url: string, payload: any, useCompression: boolean, headers: Record<string, string> | null, streamCallback?: StreamCallback): Promise<any[]>;
/**
 * Returns the read-only data source if it exists, otherwise returns the read-write data source if options is not provided or if options.allowFallbackToReadWrite is true.
 * @param dataSources
 * @param options
 * @returns
 */
export declare function GetReadOnlyDataSource(dataSources: DataSourceInfo[], options?: {
    allowFallbackToReadWrite: boolean;
}): sql.ConnectionPool & {
    query: (sql: string, params?: any) => Promise<any[]>;
};
/**
 * Returns the read-only provider if it exists, otherwise returns the original provider if options is not provided or if options.allowFallbackToReadWrite is true.
 * @param options
 * @returns
 */
export declare function GetReadOnlyProvider(providers: Array<ProviderInfo>, options?: {
    allowFallbackToReadWrite: boolean;
}): DatabaseProviderBase;
/**
 * Returns the read-write provider if it exists, otherwise returns the original provider if options is not provided or if options.allowFallbackToReadOnly is true.
 * @param options
 * @returns
 */
export declare function GetReadWriteProvider(providers: Array<ProviderInfo>, options?: {
    allowFallbackToReadOnly: boolean;
}): DatabaseProviderBase;
/**
 * Returns the read-write data source if it exists, otherwise throws an error.
 * @param dataSources
 * @returns
 */
export declare function GetReadWriteDataSource(dataSources: DataSourceInfo[]): sql.ConnectionPool & {
    query: (sql: string, params?: any) => Promise<any[]>;
};
/**
 * Extends a ConnectionPool with a query method that returns results in the format expected by generated code
 * This provides backwards compatibility with code that expects TypeORM-style query results
 */
export declare function extendConnectionPoolWithQuery(pool: sql.ConnectionPool): sql.ConnectionPool & {
    query: (sql: string, params?: any) => Promise<any[]>;
};
export {};
//# sourceMappingURL=util.d.ts.map