import { Request as ExpressRequest, Response as ExpressResponse } from "express"; import { ApiConfig } from "./config.js"; import { Result } from "./result.js"; import { ReadonlyDeep } from "./utils.js"; export type QueryFilter = { field: string; operator: "eq" | "ne" | "gt" | "gte" | "lt" | "lte" | "in" | "nin" | "contains" | "startsWith" | "endsWith"; value: unknown; caseSensitive?: boolean; }; export type QuerySort = { field: string; order: "asc" | "desc"; }; export type QueryOptions = { page?: number; perPage?: number; sort?: QuerySort[]; filters?: QueryFilter[]; expand?: string[]; fields?: string[]; }; export type DbRecord = Record; export type ResourceOperation = { findAll: (options?: QueryOptions) => Promise>; findById: (id: string | number) => Promise>; create: (data: Omit) => Promise>; update: (id: string | number, data: Partial) => Promise>; patch: (id: string | number, data: Partial) => Promise>; delete: (id: string | number) => Promise>; findRelated: (id: string | number, relationship: string, options?: QueryOptions) => Promise>; }; export type DatabaseService = { initialize: (config: ReadonlyDeep) => Promise>; getResource: (resourceName: string) => Result; reset: () => Promise>; backup: (path?: string) => Promise>; restore: (path: string) => Promise>; getStats?: () => Record; }; export type RouteHandler = (req: ExpressRequest, res: ExpressResponse) => Promise; export interface LogEntry { id: string; timestamp: string; method: string; url: string; status: number; responseTime: number; userAgent?: string; ip?: string; } export interface LogManager { getLogs: () => LogEntry[]; getFilteredLogs: (options: { method?: string; status?: number; url?: string; limit?: number; }) => LogEntry[]; clearLogs: () => void; } export type Server = { start: (port?: number) => Promise>; stop: () => Promise>; getUrl: () => string; logs: LogManager; };