Initial commit with Email Import Wizard and Task Processor updates
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import api from './client';
|
||||
import type { BarcodeActionType } from './barcode-templates';
|
||||
|
||||
export type InboxSource = 'all' | 'user';
|
||||
|
||||
export interface InboxBarcode {
|
||||
page: number;
|
||||
value: string;
|
||||
templateId: number | null;
|
||||
templateName: string | null;
|
||||
splitBefore: boolean;
|
||||
actions: BarcodeActionType[];
|
||||
}
|
||||
|
||||
export interface InboxFile {
|
||||
id: string;
|
||||
name: string;
|
||||
source: InboxSource;
|
||||
pageCount: number;
|
||||
deletedPages: number[];
|
||||
rotations: Record<string, number>;
|
||||
barcodes: InboxBarcode[];
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface Client {
|
||||
Id: number;
|
||||
Name: string;
|
||||
PaperlessUserId: number;
|
||||
}
|
||||
|
||||
export const inboxApi = {
|
||||
list: () => api.get<InboxFile[]>('/api/inbox').then((r) => r.data),
|
||||
|
||||
rescan: () =>
|
||||
api
|
||||
.post<{ scanned: number; failed: number }>('/api/inbox/rescan', {}, { timeout: 600000 })
|
||||
.then((r) => r.data),
|
||||
|
||||
previewBlob: (id: string) =>
|
||||
api
|
||||
.get<Blob>(`/api/inbox/${encodeURIComponent(id)}/preview`, { responseType: 'blob' })
|
||||
.then((r) => r.data),
|
||||
|
||||
thumbnailBlob: (id: string, page: number) =>
|
||||
api
|
||||
.get<Blob>(
|
||||
`/api/inbox/${encodeURIComponent(id)}/pages/${page}/thumbnail`,
|
||||
{ responseType: 'blob' },
|
||||
)
|
||||
.then((r) => r.data),
|
||||
|
||||
pagePreviewBlob: (id: string, page: number) =>
|
||||
api
|
||||
.get<Blob>(
|
||||
`/api/inbox/${encodeURIComponent(id)}/pages/${page}/preview`,
|
||||
{ responseType: 'blob' },
|
||||
)
|
||||
.then((r) => r.data),
|
||||
|
||||
remove: (id: string) =>
|
||||
api.delete(`/api/inbox/${encodeURIComponent(id)}`).then((r) => r.data),
|
||||
|
||||
removePage: (id: string, page: number) =>
|
||||
api
|
||||
.delete(`/api/inbox/${encodeURIComponent(id)}/pages/${page}`)
|
||||
.then((r) => r.data),
|
||||
|
||||
resetEdits: (id: string) =>
|
||||
api
|
||||
.post(`/api/inbox/${encodeURIComponent(id)}/reset-edits`)
|
||||
.then((r) => r.data),
|
||||
|
||||
setPageRotation: (id: string, page: number, rotation: number) =>
|
||||
api
|
||||
.put(
|
||||
`/api/inbox/${encodeURIComponent(id)}/pages/${page}/rotation`,
|
||||
{ rotation },
|
||||
)
|
||||
.then((r) => r.data),
|
||||
|
||||
postprocess: (
|
||||
id: string,
|
||||
opts?: { sectionOffset?: number; processOnlyOne?: boolean; replaceDuplicate?: boolean },
|
||||
) =>
|
||||
api
|
||||
.post<{ results: PostprocessActionResult[]; totalSections: number }>(
|
||||
`/api/inbox/${encodeURIComponent(id)}/postprocess`,
|
||||
opts ?? {},
|
||||
)
|
||||
.then((r) => r.data),
|
||||
};
|
||||
|
||||
export interface PostprocessActionResult {
|
||||
sectionIndex: number;
|
||||
actionId: number;
|
||||
actionType: string;
|
||||
ok: boolean;
|
||||
skipped?: boolean;
|
||||
message?: string;
|
||||
duplicateOfDocumentId?: number;
|
||||
}
|
||||
|
||||
export const clientsApi = {
|
||||
getMyClients: () => api.get<Client[]>('/api/clients').then((r) => r.data),
|
||||
};
|
||||
Reference in New Issue
Block a user