habit-export-center
Version:
habit's front end solution to export list
191 lines (165 loc) • 5.18 kB
TypeScript
import { default as default_2 } from 'react';
/**
* Builds a full API URL with the correct base URL for the current environment
*/
export declare function buildApiUrl(path: string): string;
/**
* Creates a new export
*/
export declare function createExport(userKey: string, req: ExportRequest, appId?: string, customEndpoint?: string): Promise<ExportResponse>;
/**
* Deletes an export by ID
*/
export declare function deleteExport(userKey: string, id: string, customEndpoint?: string): Promise<void>;
export declare const DownloadButton: default_2.FC<DownloadButtonProps>;
declare interface DownloadButtonProps {
state: ExtractionState;
fileUri?: string;
onClick?: () => void;
label?: string;
}
/**
* Downloads an export by ID
*/
export declare function downloadExport(userKey: string, id: string, customEndpoint?: string): Promise<Blob>;
export declare const EXPORT_ENDPOINTS: {
list: (userId?: string) => string;
create: (appId: string) => string;
download: (exportId: string) => string;
delete: (exportId: string) => string;
};
export declare interface ExportEntry {
id: string;
task_id: string;
state: ExtractionState;
created: string;
updated: string;
namespace: string;
name?: string;
tags?: string[];
classes?: string[];
file_uri?: string;
output?: {
file_size?: number;
filename?: string;
format?: string;
application?: {
id: string;
name: string;
};
};
}
export declare const ExportModal: default_2.FC<ExportModalProps>;
export declare interface ExportModalProps {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
title?: string;
description?: string;
downloadButtonLabel?: string;
emptyStateMessage?: string;
availableNamespaces?: NamespaceOption[];
emptyTable?: {
title: string;
subtitle: string;
};
entryStateLabels?: Record<ExtractionState | "all", string>;
tableHeaderLabels?: Record<TableHeadEntries, string>;
container?: HTMLElement;
userKey?: string;
listExportsEndpoint?: string;
downloadEndpoint?: string;
refreshInterval?: number;
onExportDownloaded?: (id: string) => void;
onError?: (error: Error) => void;
}
export declare interface ExportRequest {
namespace: string;
output: {
format: "csv" | "xlsx";
};
feedback?: {
email_alerts?: string;
};
tags?: string[];
}
export declare interface ExportResponse {
id: string;
state: ExtractionState;
}
export declare const ExportsFilter: default_2.FC<ExportsFilterProps>;
declare interface ExportsFilterProps {
availableNamespaces: NamespaceOption[];
selectedStatus: ExtractionState | "all";
selectedNamespace: NamespaceOption["value"];
entryStateLabels?: Record<ExtractionState | "all", string>;
onStatusChange: (state: ExtractionState | "all") => void;
onNamespaceChange: (namespace: NamespaceOption["value"]) => void;
}
export declare const ExportsTable: default_2.FC<ExportsTableProps>;
declare interface ExportsTableProps {
entries: ExportEntry[];
onDownload?: (id: string) => void;
onDelete?: (id: string) => void;
downloadButtonLabel?: string;
deleteButtonLabel?: string;
emptyTable?: {
title: string;
subtitle: string;
};
tableHeaderLabels?: Record<TableHeadEntries, string>;
entryStateLabels?: Record<ExtractionState | "all", string>;
}
export declare enum ExtractionState {
SCHEDULED = "scheduled",
STARTED = "started",
COMPLETED = "completed",
FAILED = "failed",
EXPIRED = "expired"
}
/**
* Determines the API base URL based on the current environment
*/
export declare function getBaseUrl(): string;
/**
* Fetches a list of exports from the API
*/
export declare function listExports(userKey: string, customEndpoint?: string): Promise<ExportEntry[]>;
declare interface NamespaceOption {
value: string;
label: string;
}
export declare const StatusBadge: ({ state, labels, }: {
state: ExtractionState;
labels: Record<ExtractionState | "all", string>;
}) => JSX.Element;
declare enum TableHeadEntries {
NAMESPACE = "namespace",
CREATED = "created",
FORMAT = "format",
SIZE = "size",
STATE = "state",
ACTION = "action"
}
/**
* Hook to create a new export
*/
export declare function useCreateExport(userKey: string, appId?: string, createEndpoint?: string, options?: {
onSuccess?: (data: ExportResponse) => void;
onError?: (error: Error) => void;
}): {
mutate: (req: ExportRequest) => Promise<ExportResponse>;
isPending: boolean;
};
/**
* Hook to fetch and manage exports list
*/
export declare function useListExports(userKey: string, listEndpoint?: string, options?: {
refetchInterval?: number;
enabled?: boolean;
}): {
data: ExportEntry[];
isLoading: boolean;
error: Error;
refetch: () => Promise<void>;
};
export { }