chore: prettier format pass on branch files
Auto-format all files modified during the documents-hub-split feature branch that were not yet aligned with the project's Prettier config (single quotes, semicolons, trailing commas). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,10 +52,11 @@ export interface AuthContext {
|
||||
*/
|
||||
export type RouteParams = Record<string, string | string[]>;
|
||||
|
||||
export type RouteHandler<
|
||||
TParams extends RouteParams = Record<string, string>,
|
||||
T = unknown,
|
||||
> = (req: NextRequest, ctx: AuthContext, params: TParams) => Promise<NextResponse<T>>;
|
||||
export type RouteHandler<TParams extends RouteParams = Record<string, string>, T = unknown> = (
|
||||
req: NextRequest,
|
||||
ctx: AuthContext,
|
||||
params: TParams,
|
||||
) => Promise<NextResponse<T>>;
|
||||
|
||||
// ─── deepMerge ───────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -104,10 +105,7 @@ export function deepMerge(
|
||||
*/
|
||||
export function withAuth<TParams extends RouteParams = Record<string, string>>(
|
||||
handler: RouteHandler<TParams>,
|
||||
): (
|
||||
req: NextRequest,
|
||||
routeContext: { params: Promise<TParams> },
|
||||
) => Promise<NextResponse> {
|
||||
): (req: NextRequest, routeContext: { params: Promise<TParams> }) => Promise<NextResponse> {
|
||||
return async (req, routeContext) => {
|
||||
// Mint or accept a request id BEFORE entering the ALS frame so every
|
||||
// log line + the response header reference the same value. Clients
|
||||
|
||||
@@ -15,7 +15,9 @@ import { files } from './documents';
|
||||
export const emailAccounts = pgTable(
|
||||
'email_accounts',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
userId: text('user_id').notNull(), // references Better Auth user ID
|
||||
portId: text('port_id')
|
||||
.notNull()
|
||||
@@ -33,16 +35,15 @@ export const emailAccounts = pgTable(
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
index('idx_ea_user').on(table.userId),
|
||||
index('idx_ea_port').on(table.portId),
|
||||
],
|
||||
(table) => [index('idx_ea_user').on(table.userId), index('idx_ea_port').on(table.portId)],
|
||||
);
|
||||
|
||||
export const emailThreads = pgTable(
|
||||
'email_threads',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
portId: text('port_id')
|
||||
.notNull()
|
||||
.references(() => ports.id),
|
||||
@@ -53,16 +54,15 @@ export const emailThreads = pgTable(
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => [
|
||||
index('idx_et_client').on(table.clientId),
|
||||
index('idx_et_port').on(table.portId),
|
||||
],
|
||||
(table) => [index('idx_et_client').on(table.clientId), index('idx_et_port').on(table.portId)],
|
||||
);
|
||||
|
||||
export const emailMessages = pgTable(
|
||||
'email_messages',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
threadId: text('thread_id')
|
||||
.notNull()
|
||||
.references(() => emailThreads.id, { onDelete: 'cascade' }),
|
||||
@@ -81,9 +81,9 @@ export const emailMessages = pgTable(
|
||||
},
|
||||
(table) => [
|
||||
index('idx_em_thread').on(table.threadId),
|
||||
uniqueIndex('idx_em_message_id').on(table.messageIdHeader).where(
|
||||
sql`${table.messageIdHeader} IS NOT NULL`
|
||||
),
|
||||
uniqueIndex('idx_em_message_id')
|
||||
.on(table.messageIdHeader)
|
||||
.where(sql`${table.messageIdHeader} IS NOT NULL`),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ export type PortBranding = {
|
||||
export const ports = pgTable(
|
||||
'ports',
|
||||
{
|
||||
id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
|
||||
id: text('id')
|
||||
.primaryKey()
|
||||
.$defaultFn(() => crypto.randomUUID()),
|
||||
name: text('name').notNull(),
|
||||
slug: text('slug').notNull(),
|
||||
logoUrl: text('logo_url'),
|
||||
|
||||
@@ -13,9 +13,7 @@ import { db } from './index';
|
||||
* return result;
|
||||
* });
|
||||
*/
|
||||
export async function withTransaction<T>(
|
||||
callback: (tx: typeof db) => Promise<T>,
|
||||
): Promise<T> {
|
||||
export async function withTransaction<T>(callback: (tx: typeof db) => Promise<T>): Promise<T> {
|
||||
return db.transaction(callback as unknown as Parameters<typeof db.transaction>[0]) as Promise<T>;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,7 @@ export function buildActivityInputs(
|
||||
data: ActivityData,
|
||||
portName?: string,
|
||||
): Record<string, string>[] {
|
||||
const summaryLines = [
|
||||
`Activity Summary (${data.logs.length} events)`,
|
||||
'─────────────────────',
|
||||
];
|
||||
const summaryLines = [`Activity Summary (${data.logs.length} events)`, '─────────────────────'];
|
||||
|
||||
const sortedSummary = Object.entries(data.summary).sort((a, b) => b[1] - a[1]);
|
||||
if (sortedSummary.length === 0) {
|
||||
|
||||
@@ -62,13 +62,12 @@ export function buildOccupancyInputs(
|
||||
|
||||
const breakdownLines = ['Berth Status Breakdown', '─────────────────────'];
|
||||
const allStatuses = ['available', 'under_offer', 'sold'];
|
||||
const unknownStatuses = Object.keys(data.statusCounts).filter(
|
||||
(s) => !allStatuses.includes(s),
|
||||
);
|
||||
const unknownStatuses = Object.keys(data.statusCounts).filter((s) => !allStatuses.includes(s));
|
||||
|
||||
for (const status of [...allStatuses, ...unknownStatuses]) {
|
||||
const cnt = data.statusCounts[status] ?? 0;
|
||||
const label = statusLabels[status] ?? status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
const label =
|
||||
statusLabels[status] ?? status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
const pct = data.totalBerths > 0 ? ((cnt / data.totalBerths) * 100).toFixed(1) : '0.0';
|
||||
breakdownLines.push(`${label}: ${cnt} berth(s) (${pct}%)`);
|
||||
}
|
||||
|
||||
@@ -541,10 +541,7 @@ async function fetchGroupRows(
|
||||
signedFromDocumentId: documents.id,
|
||||
})
|
||||
.from(files)
|
||||
.leftJoin(
|
||||
documents,
|
||||
and(eq(documents.signedFileId, files.id), eq(documents.portId, portId)),
|
||||
)
|
||||
.leftJoin(documents, and(eq(documents.signedFileId, files.id), eq(documents.portId, portId)))
|
||||
.where(and(eq(files.portId, portId), predicate))
|
||||
.orderBy(desc(files.createdAt))
|
||||
.limit(limit);
|
||||
|
||||
@@ -12,10 +12,7 @@ interface ScanResult {
|
||||
confidence: number;
|
||||
}
|
||||
|
||||
export async function scanReceipt(
|
||||
imageBuffer: Buffer,
|
||||
mimeType: string,
|
||||
): Promise<ScanResult> {
|
||||
export async function scanReceipt(imageBuffer: Buffer, mimeType: string): Promise<ScanResult> {
|
||||
try {
|
||||
const base64 = imageBuffer.toString('base64');
|
||||
const response = await openai.chat.completions.create({
|
||||
|
||||
@@ -7,10 +7,7 @@ import type { CreateSavedViewInput, UpdateSavedViewInput } from '@/lib/validator
|
||||
|
||||
export const savedViewsService = {
|
||||
async list(portId: string, userId: string, entityType?: string) {
|
||||
const conditions = [
|
||||
eq(savedViews.portId, portId),
|
||||
eq(savedViews.userId, userId),
|
||||
];
|
||||
const conditions = [eq(savedViews.portId, portId), eq(savedViews.userId, userId)];
|
||||
if (entityType) {
|
||||
conditions.push(eq(savedViews.entityType, entityType));
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ export function generateStorageKey(
|
||||
|
||||
export function sanitizeFilename(name: string): string {
|
||||
return name
|
||||
.replace(/[/\\:]/g, '') // strip path chars
|
||||
.replace(/\x00/g, '') // strip null bytes
|
||||
.replace(/[/\\:]/g, '') // strip path chars
|
||||
.replace(/\x00/g, '') // strip null bytes
|
||||
.replace(/[\x01-\x1f\x7f]/g, '') // strip control chars
|
||||
.trim()
|
||||
.slice(0, 255);
|
||||
|
||||
Reference in New Issue
Block a user