feat(project): init
This commit is contained in:
156
lib/types.ts
Normal file
156
lib/types.ts
Normal file
@@ -0,0 +1,156 @@
|
||||
export type UserRole = "admin" | "user";
|
||||
|
||||
export type GenerationJobStatus = "success" | "error";
|
||||
|
||||
export interface UserRecord {
|
||||
id: string;
|
||||
username: string;
|
||||
passwordHash: string;
|
||||
role: UserRole;
|
||||
monthlyQuota: number | null;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface PublicUser {
|
||||
id: string;
|
||||
username: string;
|
||||
role: UserRole;
|
||||
monthlyQuota: number | null;
|
||||
isActive: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface UserUsageSummary extends UserRecord {
|
||||
usedThisPeriod: number;
|
||||
}
|
||||
|
||||
export interface SettingsSnapshot {
|
||||
defaultMonthlyQuota: number;
|
||||
}
|
||||
|
||||
export interface QuotaSnapshot {
|
||||
periodKey: string;
|
||||
limit: number | null;
|
||||
used: number;
|
||||
remaining: number | null;
|
||||
isUnlimited: boolean;
|
||||
}
|
||||
|
||||
export interface AdminUserSummary extends PublicUser {
|
||||
usedThisPeriod: number;
|
||||
limit: number | null;
|
||||
remaining: number | null;
|
||||
isUnlimited: boolean;
|
||||
}
|
||||
|
||||
export interface AdminSnapshot {
|
||||
settings: SettingsSnapshot;
|
||||
periodKey: string;
|
||||
users: AdminUserSummary[];
|
||||
}
|
||||
|
||||
export type GenerateSize = "auto" | "1024x1024" | "1536x1024" | "1024x1536";
|
||||
|
||||
export type GenerateQuality = "auto" | "low" | "medium" | "high";
|
||||
|
||||
export type GenerateOutputFormat = "png" | "jpeg" | "webp";
|
||||
|
||||
export type GenerateBackground = "auto" | "transparent" | "opaque";
|
||||
|
||||
export type GenerateModeration = "auto" | "low";
|
||||
|
||||
export interface GeneratePayload {
|
||||
model: string;
|
||||
prompt: string;
|
||||
size: GenerateSize;
|
||||
quality: GenerateQuality;
|
||||
n: number;
|
||||
moderation: GenerateModeration;
|
||||
output_format: GenerateOutputFormat;
|
||||
background: GenerateBackground;
|
||||
output_compression?: number;
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface GeneratedImage {
|
||||
id: string;
|
||||
base64: string;
|
||||
mimeType: string;
|
||||
fileName: string;
|
||||
revisedPrompt: string | null;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface GenerateMeta {
|
||||
model: string;
|
||||
size: GenerateSize;
|
||||
quality: GenerateQuality;
|
||||
outputFormat: GenerateOutputFormat;
|
||||
background: GenerateBackground;
|
||||
moderation: GenerateModeration;
|
||||
outputCompression?: number;
|
||||
count: number;
|
||||
durationMs: number;
|
||||
created: number | null;
|
||||
usage: unknown;
|
||||
}
|
||||
|
||||
export interface GenerateResult {
|
||||
images: GeneratedImage[];
|
||||
meta: GenerateMeta;
|
||||
}
|
||||
|
||||
export interface SessionRecord {
|
||||
sessionId: string;
|
||||
userId: string;
|
||||
expiresAt: string;
|
||||
}
|
||||
|
||||
export interface StoredGeneratedImageInput {
|
||||
id: string;
|
||||
fileName: string;
|
||||
storageKey: string;
|
||||
mimeType: string;
|
||||
fileSize: number;
|
||||
revisedPrompt: string | null;
|
||||
}
|
||||
|
||||
export interface ImageHistoryItem {
|
||||
id: string;
|
||||
jobId: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
prompt: string;
|
||||
revisedPrompt: string | null;
|
||||
model: string | null;
|
||||
size: string | null;
|
||||
quality: string | null;
|
||||
outputFormat: string | null;
|
||||
background: string | null;
|
||||
moderation: string | null;
|
||||
fileName: string;
|
||||
mimeType: string;
|
||||
fileSize: number;
|
||||
createdAt: string;
|
||||
imageUrl: string;
|
||||
downloadUrl: string;
|
||||
}
|
||||
|
||||
export interface StoredImageAsset {
|
||||
id: string;
|
||||
userId: string;
|
||||
fileName: string;
|
||||
mimeType: string;
|
||||
fileSize: number;
|
||||
storageKey: string;
|
||||
}
|
||||
|
||||
export type UsageEventMeta = Record<string, unknown>;
|
||||
|
||||
export interface HttpError extends Error {
|
||||
statusCode?: number;
|
||||
detail?: unknown;
|
||||
}
|
||||
Reference in New Issue
Block a user