Fix all TypeScript errors: restore proper types and typed route casts
- Restore `as any` casts for Next.js typedRoutes on dynamic routes - Use proper types for PDF templates, invoice/expense data, DB schema - Fix PgColumn casts in sort helpers for expenses/invoices - Add null guards for optional port/client in record-export - Fix vitest config (remove invalid poolOptions) - Lint: 0 errors, TypeScript: 0 errors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { and, eq } from 'drizzle-orm';
|
||||
|
||||
import { db } from '@/lib/db';
|
||||
import { documentTemplates, documents, files } from '@/lib/db/schema/documents';
|
||||
import type { File as DbFile, Document as DbDocument } from '@/lib/db/schema/documents';
|
||||
import { clients, clientContacts } from '@/lib/db/schema/clients';
|
||||
import { interests } from '@/lib/db/schema/interests';
|
||||
import { berths } from '@/lib/db/schema/berths';
|
||||
@@ -562,7 +563,7 @@ export async function generateAndSign(
|
||||
portId,
|
||||
context,
|
||||
meta,
|
||||
);
|
||||
) as { document: DbDocument; file: DbFile };
|
||||
const template = await getTemplateById(templateId, portId);
|
||||
|
||||
// Fetch PDF bytes from MinIO to send to Documenso
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { eq, and, gte, lte, sql } from 'drizzle-orm';
|
||||
import type { PgColumn } from 'drizzle-orm/pg-core';
|
||||
|
||||
import { db } from '@/lib/db';
|
||||
import { expenses, invoices, invoiceExpenses } from '@/lib/db/schema/financial';
|
||||
@@ -58,7 +59,7 @@ export async function listExpenses(portId: string, query: ListExpensesInput) {
|
||||
includeArchived: query.includeArchived,
|
||||
archivedAtColumn: expenses.archivedAt,
|
||||
sort: query.sort
|
||||
? { column: expenses[query.sort as keyof typeof expenses] as unknown, direction: query.order }
|
||||
? { column: expenses[query.sort as keyof typeof expenses] as unknown as PgColumn, direction: query.order }
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { eq, and, desc, like, lt, sql, gte, lte, inArray, ne } from 'drizzle-orm';
|
||||
import type { PgColumn } from 'drizzle-orm/pg-core';
|
||||
|
||||
import { db } from '@/lib/db';
|
||||
import {
|
||||
@@ -96,7 +97,7 @@ export async function listInvoices(portId: string, query: ListInvoicesInput) {
|
||||
archivedAtColumn: invoices.archivedAt,
|
||||
sort: query.sort
|
||||
? {
|
||||
column: invoices[query.sort as keyof typeof invoices] as unknown,
|
||||
column: invoices[query.sort as keyof typeof invoices] as unknown as PgColumn,
|
||||
direction: query.order,
|
||||
}
|
||||
: undefined,
|
||||
@@ -465,7 +466,7 @@ export async function generateInvoicePdf(
|
||||
.where(eq(ports.id, portId))
|
||||
.limit(1);
|
||||
|
||||
const inputs = buildInvoiceInputs(invoice, invoice.lineItems, port);
|
||||
const inputs = buildInvoiceInputs(invoice, invoice.lineItems, port ?? {});
|
||||
|
||||
const pdfBytes = await generatePdf(invoiceTemplate, [inputs]);
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ export async function exportClientPdf(clientId: string, portId: string): Promise
|
||||
berthMooringNumber: i.berthId ? (berthsMap[i.berthId] ?? null) : null,
|
||||
}));
|
||||
|
||||
const inputs = buildClientSummaryInputs(client, contactList, enrichedInterests, activity, port);
|
||||
const inputs = buildClientSummaryInputs(client, contactList, enrichedInterests, activity, port ?? {});
|
||||
|
||||
return generatePdf(clientSummaryTemplate, [inputs]);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ export async function exportBerthPdf(berthId: string, portId: string): Promise<U
|
||||
.orderBy(desc(interests.updatedAt))
|
||||
.limit(20);
|
||||
|
||||
const inputs = buildBerthSpecInputs(berth, enrichedWaitingList, maintenance, linkedInterests, port);
|
||||
const inputs = buildBerthSpecInputs(berth, enrichedWaitingList, maintenance, linkedInterests, port ?? {});
|
||||
|
||||
return generatePdf(berthSpecTemplate, [inputs]);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ export async function exportInterestPdf(interestId: string, portId: string): Pro
|
||||
.orderBy(desc(auditLogs.createdAt))
|
||||
.limit(20);
|
||||
|
||||
const inputs = buildInterestSummaryInputs(interest, client, berth, timeline, port);
|
||||
const inputs = buildInterestSummaryInputs(interest, client ?? {}, berth ?? null, timeline, port ?? {});
|
||||
|
||||
return generatePdf(interestSummaryTemplate, [inputs]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user