164 lines
4.2 KiB
TypeScript
164 lines
4.2 KiB
TypeScript
export interface SplitExcelPayload {
|
|
paths: string[]
|
|
selected_columns: string[]
|
|
split_mode: 'rows_per_file' | 'parts'
|
|
rows_per_file?: number
|
|
parts?: number
|
|
output_dir?: string
|
|
}
|
|
|
|
export interface SplitExcelResultItem {
|
|
result_id?: number
|
|
source_path: string
|
|
output_path?: string
|
|
success: boolean
|
|
error?: string
|
|
row_count?: number
|
|
}
|
|
|
|
export interface SplitExcelSummary {
|
|
total: number
|
|
success_count: number
|
|
failed_count: number
|
|
output_dir?: string
|
|
}
|
|
|
|
export interface SplitExcelResponse {
|
|
success: boolean
|
|
summary?: SplitExcelSummary
|
|
items?: SplitExcelResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface ExcelInfoResponse {
|
|
success: boolean
|
|
headers?: string[]
|
|
total_rows?: number
|
|
error?: string
|
|
}
|
|
|
|
export interface CleanExcelPayload {
|
|
paths: string[]
|
|
selected_columns: string[]
|
|
keep_integer_ids?: boolean
|
|
keep_underscore_ids?: boolean
|
|
output_dir?: string
|
|
}
|
|
|
|
export interface CleanExcelResultItem {
|
|
result_id?: number
|
|
source_path: string
|
|
output_path?: string
|
|
success: boolean
|
|
error?: string
|
|
}
|
|
|
|
export interface ConvertTxtPayload {
|
|
paths: string[]
|
|
output_dir?: string
|
|
template_id: string
|
|
}
|
|
|
|
export interface ConvertTxtTemplateItem {
|
|
id: string
|
|
label: string
|
|
output_filename: string
|
|
is_default?: boolean
|
|
built_in?: boolean
|
|
}
|
|
|
|
export interface ConvertTxtResultItem {
|
|
result_id?: number
|
|
source_path: string
|
|
output_path?: string
|
|
success: boolean
|
|
error?: string
|
|
}
|
|
|
|
export interface ConvertTxtSummary {
|
|
total: number
|
|
success_count: number
|
|
failed_count: number
|
|
output_dir?: string
|
|
}
|
|
|
|
export interface ConvertTxtResponse {
|
|
success: boolean
|
|
summary?: ConvertTxtSummary
|
|
items?: ConvertTxtResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface CleanExcelSummary {
|
|
total: number
|
|
success_count: number
|
|
failed_count: number
|
|
output_dir?: string
|
|
}
|
|
|
|
export interface CleanExcelResponse {
|
|
success: boolean
|
|
summary?: CleanExcelSummary
|
|
items?: CleanExcelResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface ConvertTxtHistoryResponse {
|
|
success: boolean
|
|
items?: ConvertTxtResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface SplitExcelHistoryResponse {
|
|
success: boolean
|
|
items?: SplitExcelResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface CleanExcelHistoryResponse {
|
|
success: boolean
|
|
items?: CleanExcelResultItem[]
|
|
error?: string
|
|
}
|
|
|
|
export interface PywebviewApi {
|
|
select_brand_xlsx_files?: () => Promise<string[]>
|
|
select_clean_xlsx_files?: () => Promise<string[]>
|
|
select_brand_folder?: () => Promise<string | null>
|
|
select_clean_folder?: () => Promise<string | null>
|
|
select_folder?: () => Promise<string | null>
|
|
get_excel_headers?: (filePath: string) => Promise<{ success: boolean; headers?: string[]; error?: string }>
|
|
get_dedupe_history?: () => Promise<CleanExcelHistoryResponse>
|
|
get_convert_history?: () => Promise<ConvertTxtHistoryResponse>
|
|
get_split_history?: () => Promise<SplitExcelHistoryResponse>
|
|
delete_history_item?: (moduleType: string, resultId: number) => Promise<{ success: boolean; error?: string }>
|
|
get_excel_info?: (filePath: string) => Promise<ExcelInfoResponse>
|
|
clean_excel_files?: (payload: CleanExcelPayload) => Promise<CleanExcelResponse>
|
|
split_excel_files?: (payload: SplitExcelPayload) => Promise<SplitExcelResponse>
|
|
list_txt_templates?: () => Promise<ConvertTxtTemplateItem[]>
|
|
import_txt_template?: (name?: string) => Promise<{ success: boolean; template?: ConvertTxtTemplateItem; error?: string }>
|
|
set_default_txt_template?: (templateId: string) => Promise<{ success: boolean; error?: string }>
|
|
delete_txt_template?: (templateId: string) => Promise<{ success: boolean; error?: string }>
|
|
convert_excel_to_uk_txt?: (payload: ConvertTxtPayload) => Promise<ConvertTxtResponse>
|
|
open_path?: (path: string) => Promise<{ success: boolean; error?: string }>
|
|
save_template_xlsx?: () => Promise<{ success: boolean; path?: string; error?: string }>
|
|
save_template_zip?: () => Promise<{ success: boolean; path?: string; error?: string }>
|
|
save_file_from_url?: (url: string, filename: string) => Promise<{ success: boolean; path?: string; error?: string }>
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
pywebview?: {
|
|
api?: PywebviewApi
|
|
}
|
|
}
|
|
}
|
|
|
|
export function getPywebviewApi() {
|
|
return window.pywebview?.api
|
|
}
|
|
|
|
export function hasPywebview() {
|
|
return Boolean(getPywebviewApi())
|
|
}
|