import { APIResource } from "../core/resource.js"; import { APIPromise } from "../core/api-promise.js"; import { RequestOptions } from "../internal/request-options.js"; export declare class Fixer extends APIResource { /** * Handle fixer requests - supports two formats: 1) JSON with inline file contents * in files array, 2) multipart/form-data with tar.zst bundle and manifest (same as * Sandbox API). Use multipart for better performance with large projects. * * @example * ```ts * const response = await client.fixer.run({ * files: [ * { * path: 'src/index.ts', * contents: "export const hello = 'world';", * }, * { * path: 'src/utils.ts', * contents: 'export function helper() {}', * }, * ], * fixes: [], * mode: 'project', * response_encoding: 'json', * response_format: 'ALL_FILES', * }); * ``` */ run(body?: FixerRunParams | null | undefined, options?: RequestOptions): APIPromise; } export interface FixerRunResponse { /** * The actual response data */ data: FixerRunResponse.Data; /** * The error from the API query */ error?: FixerRunResponse.Error | null; /** * Meta information */ meta?: FixerRunResponse.Meta; /** * Multipart response: base64-encoded tar.zst archive of files (new format) */ files_data?: string; /** * Multipart response: JSON array of file metadata (new format) */ files_manifest?: Array<{ path: string; size: number; digest?: string; type?: string; mode?: string; }>; /** * Multipart response: base64-encoded tar.zst archive of bundled files (new format, optional) */ bundle_data?: string; /** * Multipart response: JSON array of bundle file metadata (new format, optional) */ bundle_manifest?: Array<{ path: string; size: number; digest?: string; type?: string; mode?: string; }>; } export declare namespace FixerRunResponse { /** * The actual response data */ interface Data { /** * Version of the fixer */ fixer_version: string; /** * Final per-file status after fixing */ status: Data.Status; /** * Suggested changes to fix the issues */ suggested_changes: Data.SuggestedChanges; /** * Bundle information if bundling was requested */ bundle?: Data.Bundle | null; /** * Per-file strategy statistics */ file_to_strategy_statistics?: { [key: string]: Array; }; /** * Diagnostics after fixing, split into relevant vs other based on requested fix types */ final_diagnostics?: Data.PartitionedDiagnosticResponse | null; /** * Fix types that were used */ fix_types_used?: Array<'dependency' | 'parsing' | 'css' | 'ai_fallback' | 'types' | 'ui' | 'sql'>; /** * Diagnostics before fixing, split into relevant vs other based on requested fix types */ initial_diagnostics?: Data.PartitionedDiagnosticResponse | null; } namespace Data { /** * Final per-file status after fixing */ interface Status { /** * Overall composite status */ composite_status: 'FIXED_EVERYTHING' | 'FIXED_REQUESTED' | 'PARTIALLY_FIXED' | 'NO_REQUESTED_ISSUES' | 'NO_ISSUES' | 'FAILED'; /** * Status of each file */ file_to_composite_status?: { [key: string]: 'FIXED_EVERYTHING' | 'FIXED_REQUESTED' | 'PARTIALLY_FIXED' | 'NO_REQUESTED_ISSUES' | 'NO_ISSUES' | 'FAILED'; }; } /** * Response format when requesting DIFF format */ interface DiffFormat { diff?: string | null; diff_data?: string | null; diff_manifest?: Array<{ [key: string]: unknown; }> | null; } /** * Response format when requesting CHANGED_FILES format */ interface ChangedFilesFormat { changed_files?: Array | null; changed_files_data?: string | null; changed_files_manifest?: Array<{ [key: string]: unknown; }> | null; } /** * Response format when requesting ALL_FILES format */ interface AllFilesFormat { all_files?: Array | null; all_files_data?: string | null; all_files_manifest?: Array<{ [key: string]: unknown; }> | null; } /** * Suggested changes to fix the issues */ interface SuggestedChanges { /** * List of all files with their current contents. Only present when * response_encoding is "json". */ all_files?: Array | null; /** * List of changed files with their new contents. Only present when * response_encoding is "json". */ changed_files?: Array | null; /** * Unified diff of changes. Only present when response_encoding is "json". */ diff?: string | null; } namespace SuggestedChanges { interface AllFile { /** * Contents of the file */ contents: string; /** * Path of the file */ path: string; } interface ChangedFile { /** * Contents of the file */ contents: string; /** * Path of the file */ path: string; } } /** * Bundle information if bundling was requested */ interface Bundle { build_system: string; status: 'SUCCESS' | 'FAILED' | 'NOT_ATTEMPTED' | 'PARTIAL_SUCCESS'; template_path: string; bundle_url?: string | null; debug?: { [key: string]: string; }; files?: Array; /** * Base64-encoded tar.zst archive containing bundled files (multipart format) */ files_data?: string | null; } namespace Bundle { interface File { /** * Contents of the file */ contents: string; /** * Path of the file */ path: string; } } interface FileToStrategyStatistic { strategy_name: string; version_hash: string; fixes_applied?: boolean; fixes_fired?: boolean; } /** * Location information for a diagnostic */ interface DiagnosticLocation { /** * Line number (1-based) */ line: number | null; /** * Column number (1-based) */ column: number | null; /** * Position of the first character of the error location in the source code */ starting_character_position: number | null; /** * Span of the error */ span: number; } /** * A single diagnostic entry */ interface Diagnostic { /** * Diagnostic message */ message: string; /** * Type of the diagnostic */ type: string; /** * Code given by the diagnostic generator */ code?: number | null; /** * File where diagnostic occurs */ file_path: string; /** * Location of the diagnostic */ location: DiagnosticLocation; /** * Surrounding code context */ context?: string | null; } /** * Diagnostics grouped by file */ interface DiagnosticResponse { /** * Diagnostics grouped by file path */ file_to_diagnostics: { [key: string]: Array; }; } /** * Diagnostics split into requested and other groups */ interface PartitionedDiagnosticResponse { /** * Diagnostics that match the requested fix types */ requested?: DiagnosticResponse | null; /** * Diagnostics that do not match the requested fix types */ not_requested?: DiagnosticResponse | null; } } /** * The error from the API query */ interface Error { /** * The error code */ code: string; /** * The error message */ message: string; /** * Details about what caused the error */ details?: { [key: string]: unknown; }; } /** * Meta information */ interface Meta { /** * Customer tracking identifier */ external_id?: string | null; /** * Unique trace identifier for the request */ trace_id?: string | null; } } export interface FixerRunParams { /** * Whether to bundle the project (experimental) */ bundle?: boolean; /** * Unique identifier for the event */ event_id?: string; /** * List of files to process (JSON format with inline contents). For large projects, * use multipart/form-data with manifest + bundle instead. */ files?: Array | null; /** * Base64-encoded tar.zst archive containing all files (multipart format). Preferred * over the files array for better performance with large projects. * Can be a string (base64) or File/Blob object for multipart uploads. */ files_data?: string | File | Blob; /** * Manifest describing the contents of files_data (required when using multipart format). * Simple array of file metadata objects. * Can be a Manifest array (converted to JSON) or File/Blob object for multipart uploads. */ files_manifest?: FixerRunParams.FileManifest[] | File | Blob; /** * JSON string containing request parameters when using multipart format. * Should include: response_format, response_encoding, bundle, fixes, mode, etc. */ request?: string; /** * Configuration for which fix types to apply */ fixes?: Array<'dependency' | 'parsing' | 'css' | 'ai_fallback' | 'types' | 'ui' | 'sql'>; /** * Meta information for the request */ meta?: FixerRunParams.Meta | null; /** * Fixer operating mode */ mode?: 'project' | 'files'; /** * Response encoding: "json" for inline file contents in JSON, "multipart" for * multipart/form-data with tar.zst bundle + manifest */ response_encoding?: 'json' | 'multipart'; /** * Format for the response (diff, changed_files, or all_files) */ response_format?: 'DIFF' | 'CHANGED_FILES' | 'ALL_FILES'; /** * ID of the template to use */ template_id?: string | null; /** * Full path to the template */ template_path?: string; } export declare namespace FixerRunParams { interface File { /** * File contents */ contents: string; /** * Path to the file */ path: string; } /** * Meta information for the request */ interface Meta { /** * Customer tracking identifier */ external_id?: string | null; } /** * Simple file manifest entry for multipart format */ interface FileManifest { /** * Path to the file */ path: string; /** * Size of the file in bytes */ size: number; /** * SHA-256 digest of the file contents (optional) */ digest?: string; /** * File type (typically "file") */ type?: 'file' | 'dir'; /** * File permissions (e.g., "0644") */ mode?: string; } } export declare namespace Fixer { export { type FixerRunResponse as FixerRunResponse, type FixerRunParams as FixerRunParams }; } export type File = FixerRunParams.File; //# sourceMappingURL=fixer.d.ts.map