seahaven-ap/src/api/types.ts

120 lines
2.3 KiB
TypeScript

export type ErrorEnvelope = {
error: {
code: string;
message: string;
correlationId: string;
};
};
export type HealthResponse = {
stage: string;
sha: string;
};
export type MeResponse = {
id: string;
email: string;
name: string;
role: "admin" | "ap_processor" | "approver" | "viewer";
};
export type Vendor = {
id: string;
name: string;
email: string | null;
defaultPaymentMethod: "check" | "ach";
createdAt: string;
updatedAt: string;
};
export type GlAccount = {
id: string;
code: string;
name: string;
createdAt: string;
updatedAt: string;
};
export type Department = {
id: string;
code: string;
name: string;
createdAt: string;
updatedAt: string;
};
export type User = {
id: string;
email: string;
name: string;
role: MeResponse["role"];
createdAt: string;
updatedAt: string;
};
export type InvoiceLine = {
id: string;
invoiceId: string;
description: string;
amount: string;
glAccountId: string | null;
departmentId: string | null;
createdAt: string;
};
export type Invoice = {
id: string;
vendorId: string;
invoiceNumber: string;
amount: string;
amountDue: string;
dueDate: string;
payDate: string | null;
sendPaymentOn: string | null;
status: "pending_approval" | "approved" | "scheduled" | "paid" | "rejected" | "void";
paymentMethod: "check" | "ach";
memo: string;
createdAt: string;
updatedAt: string;
lines: InvoiceLine[];
};
export type Document = {
id: string;
invoiceId: string | null;
objectKey: string;
contentType: string;
fileName: string;
uploadedByUserId: string | null;
createdAt: string;
uploadUrl?: string;
uploadHeaders?: Record<string, string>;
downloadUrl?: string;
};
export type ApiPaths = {
"/api/health": {
get: { response: HealthResponse };
};
"/api/me": {
get: { response: MeResponse };
};
"/api/vendors": {
get: { response: { items: Vendor[] } };
};
"/api/gl-accounts": {
get: { response: { items: GlAccount[] } };
};
"/api/departments": {
get: { response: { items: Department[] } };
};
"/api/users": {
get: { response: { items: User[] } };
};
"/api/invoices": {
get: { response: { items: Invoice[] } };
};
"/api/documents/{id}": {
get: { response: Document };
};
};