import { Output, Options } from '@codecov/bundler-plugin-core';
export { Options } from '@codecov/bundler-plugin-core';

/** Configuration options for the bundle-analyzer analyzer. */
interface BundleAnalyzerOptions {
    /**
     * Asynchronous function to customize the report output.
     *
     * This function allows you to modify the report output before it is finalized. By default, it
     * returns the original output without modification.
     *
     * @returns {Promise<Output>} A promise that resolves to the customized output.
     */
    beforeReportUpload?: (original: Output) => Promise<Output>;
    /**
     * Patterns to ignore certain files or directories in the analysis. The patterns follow the
     * standard glob pattern syntax. By default, it returns an empty list.
     */
    ignorePatterns?: string[];
    /**
     * A pattern to normalize asset names (e.g., for hashing). By default, it returns an empty string,
     * which will replace anything "hashlike" with "*".
     */
    normalizeAssetsPattern?: string;
}

/**
 * Generates a Codecov bundle stats report and optionally uploads it to Codecov. This function can
 * be imported into your code or used via the bundle-analyzer CLI.
 *
 * @param {string[]} buildDirectoryPaths - The path(s) to the build directory or directories
 *        containing the production assets for the report. Can be absolute or relative.
 * @param {Options} coreOptions - Configuration options for generating and uploading the report.
 * @param {BundleAnalyzerOptions} [bundleAnalyzerOptions] - Optional configuration for
 *        bundle-analyzer usage.
 *
 * @returns {Promise<string>} A promise that resolves when the report is generated and uploaded
 *          (dry-runned or uploaded).
 *
 * @example
 * const buildDirs = ['/path/to/build/directory', '/path/to/another/build']; // absolute or relative paths
 * const coreOpts = {
 *   dryRun: true,
 *   uploadToken: 'your-upload-token',
 *   retryCount: 3,
 *   apiUrl: 'https://api.codecov.io',
 *   bundleName: 'my-bundle', // bundle identifier in Codecov
 *   enableBundleAnalysis: true,
 *   debug: true,
 * };
 * const bundleAnalyzerOpts = {
 *   beforeReportUpload: async (original) => original,
 *   ignorePatterns: ["*.map"],
 *   normalizeAssetsPattern: "[name]-[hash].js",
 * };
 *
 * createAndUploadReport(buildDirs, coreOpts, bundleAnalyzerOpts)
 *   .then(() => console.log('Report successfully generated and uploaded.'))
 *   .catch((error) => console.error('Failed to generate or upload report:', error));
 */
declare const createAndUploadReport: (buildDirectoryPaths: string[], coreOptions: Options, bundleAnalyzerOptions?: BundleAnalyzerOptions) => Promise<string>;

export { type BundleAnalyzerOptions, createAndUploadReport };
