feat: expenses, report and day log commands

This commit is contained in:
2025-01-18 21:21:26 +01:00
parent a28d392342
commit 8681914be2
30 changed files with 5614 additions and 1 deletions

57
utils/types.ts Normal file
View File

@@ -0,0 +1,57 @@
import { Category, Expense } from '@prisma/client';
import { z } from 'zod';
interface Flag {
name: string;
type: 'string' | 'number' | 'boolean' | 'date';
required: boolean;
alias?: string;
}
export interface CommandDefinition {
name: string;
flags: Flag[];
hasId?: boolean;
}
export const RequestSchema = z.object({
command: z.string(),
parameters: z.record(z.string()).optional(),
apiKey: z.string()
});
export type ShortcutsRequest = z.infer<typeof RequestSchema>;
export interface ShortcutsResponse {
success: boolean;
message: string;
data?: unknown;
action?: {
type: 'notification' | 'openUrl' | 'runShortcut' | 'wait';
payload: unknown;
};
}
const ExpenseSchema = z.object({
description: z.string().min(1),
cost: z.number().positive(),
categoryName: z.string()
});
export type ExpenseType = z.infer<typeof ExpenseSchema>;
export interface ReportData {
expenses: (Expense & { category: Category })[];
summary: {
totalExpenses: number;
byCategory: {
category: string;
total: number;
count: number;
}[];
};
dateRange: {
from: Date;
to: Date;
};
}