initial commit
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
7
src/types/fastify.d.ts
vendored
Normal file
7
src/types/fastify.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { AuthData } from './index';
|
||||
|
||||
declare module 'fastify' {
|
||||
interface FastifyRequest {
|
||||
authData?: AuthData;
|
||||
}
|
||||
}
|
||||
129
src/types/index.ts
Normal file
129
src/types/index.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
// Re-export all Prisma-generated types
|
||||
export type {
|
||||
attendance,
|
||||
attendance_project_logs,
|
||||
audit_logs,
|
||||
bank_accounts,
|
||||
company_settings,
|
||||
customers,
|
||||
invoice_items,
|
||||
invoices,
|
||||
item_templates,
|
||||
leave_balances,
|
||||
leave_requests,
|
||||
number_sequences,
|
||||
order_items,
|
||||
order_sections,
|
||||
orders,
|
||||
permissions,
|
||||
project_notes,
|
||||
projects,
|
||||
quotation_items,
|
||||
quotations,
|
||||
received_invoices,
|
||||
refresh_tokens,
|
||||
role_permissions,
|
||||
roles,
|
||||
scope_sections,
|
||||
scope_template_sections,
|
||||
scope_templates,
|
||||
totp_login_tokens,
|
||||
trips,
|
||||
users,
|
||||
vehicles,
|
||||
} from '@prisma/client';
|
||||
|
||||
export {
|
||||
attendance_leave_type,
|
||||
leave_requests_leave_type,
|
||||
leave_requests_status,
|
||||
received_invoices_status,
|
||||
} from '@prisma/client';
|
||||
|
||||
// --- Auth types ---
|
||||
|
||||
export interface AuthData {
|
||||
userId: number;
|
||||
username: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
roleId: number | null;
|
||||
roleName: string | null;
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export interface JwtPayload {
|
||||
sub: number;
|
||||
username: string;
|
||||
role: string | null;
|
||||
iat: number;
|
||||
exp: number;
|
||||
}
|
||||
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
remember_me?: boolean;
|
||||
}
|
||||
|
||||
export interface TotpVerifyRequest {
|
||||
login_token: string;
|
||||
totp_code: string;
|
||||
}
|
||||
|
||||
// --- API response types ---
|
||||
|
||||
export interface ApiResponse<T = unknown> {
|
||||
success: boolean;
|
||||
data?: T;
|
||||
error?: string;
|
||||
pagination?: PaginationMeta;
|
||||
}
|
||||
|
||||
export interface PaginationMeta {
|
||||
page: number;
|
||||
limit: number;
|
||||
per_page: number;
|
||||
total: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export interface PaginationQuery {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
sort?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
search?: string;
|
||||
}
|
||||
|
||||
// --- Audit log types ---
|
||||
|
||||
export type AuditAction =
|
||||
| 'login'
|
||||
| 'logout'
|
||||
| 'login_failed'
|
||||
| 'create'
|
||||
| 'update'
|
||||
| 'delete'
|
||||
| 'activate'
|
||||
| 'deactivate'
|
||||
| 'password_change'
|
||||
| 'permission_change'
|
||||
| 'access_denied';
|
||||
|
||||
export type EntityType =
|
||||
| 'user'
|
||||
| 'role'
|
||||
| 'attendance'
|
||||
| 'leave_request'
|
||||
| 'invoice'
|
||||
| 'quotation'
|
||||
| 'order'
|
||||
| 'project'
|
||||
| 'customer'
|
||||
| 'trip'
|
||||
| 'vehicle'
|
||||
| 'bank_account'
|
||||
| 'company_settings'
|
||||
| 'leave_balance';
|
||||
Reference in New Issue
Block a user