Initial Commit
This commit is contained in:
commit
d0417339c1
158 files changed
+31368
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface Account {
|
||||
id: string; // UUID
|
||||
name: string;
|
||||
email: string;
|
||||
backup_file?: string;
|
||||
avatar_url?: string;
|
||||
created_at: string;
|
||||
last_used: string;
|
||||
}
|
||||
|
||||
export interface AccountBackupData {
|
||||
version: string; // Backup format version
|
||||
account: Account;
|
||||
data: {
|
||||
// Key-value pairs from Antigravity database
|
||||
antigravityAuthStatus?: string;
|
||||
'jetskiStateSync.agentManagerInitState'?: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
export interface AccountInfo {
|
||||
email: string;
|
||||
name?: string;
|
||||
isAuthenticated: boolean;
|
||||
}
|
||||
|
||||
// Zod Schemas for validation
|
||||
|
||||
export const AccountSchema = z.object({
|
||||
id: z.string(), // Relaxed from .uuid()
|
||||
name: z.string(), // Relaxed from .min(1)
|
||||
email: z.string(), // Relaxed from .email()
|
||||
backup_file: z.string().optional(),
|
||||
avatar_url: z.string().optional(),
|
||||
created_at: z.string(),
|
||||
last_used: z.string(),
|
||||
});
|
||||
|
||||
export const AccountBackupDataSchema = z.object({
|
||||
version: z.string(),
|
||||
account: AccountSchema,
|
||||
data: z.record(z.string(), z.any()),
|
||||
});
|
||||
|
||||
export const AccountInfoSchema = z.object({
|
||||
email: z.string(), // Allow empty string for unauthenticated state
|
||||
name: z.string().optional(),
|
||||
isAuthenticated: z.boolean(),
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export interface CloudTokenData {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
expires_in: number;
|
||||
expiry_timestamp: number;
|
||||
token_type: string;
|
||||
email?: string;
|
||||
project_id?: string;
|
||||
session_id?: string;
|
||||
}
|
||||
|
||||
export interface CloudQuotaData {
|
||||
models: Record<
|
||||
string,
|
||||
{
|
||||
percentage: number;
|
||||
resetTime: string;
|
||||
}
|
||||
>;
|
||||
}
|
||||
|
||||
export interface CloudAccount {
|
||||
id: string; // UUID
|
||||
provider: 'google' | 'anthropic';
|
||||
email: string;
|
||||
name?: string | null;
|
||||
avatar_url?: string | null;
|
||||
token: CloudTokenData;
|
||||
quota?: CloudQuotaData;
|
||||
created_at: number;
|
||||
last_used: number; // Unix timestamp
|
||||
status?: 'active' | 'rate_limited' | 'expired';
|
||||
is_active?: boolean;
|
||||
}
|
||||
|
||||
// Zod Schemas
|
||||
export const CloudTokenDataSchema = z.object({
|
||||
access_token: z.string(),
|
||||
refresh_token: z.string(),
|
||||
expires_in: z.number(),
|
||||
expiry_timestamp: z.number(),
|
||||
token_type: z.string(),
|
||||
email: z.string().optional(),
|
||||
project_id: z.string().optional(),
|
||||
session_id: z.string().optional(),
|
||||
});
|
||||
|
||||
export const CloudQuotaDataSchema = z.object({
|
||||
models: z.record(
|
||||
z.string(),
|
||||
z.object({
|
||||
percentage: z.number(),
|
||||
resetTime: z.string(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export const CloudAccountSchema = z.object({
|
||||
id: z.string(),
|
||||
provider: z.enum(['google', 'anthropic']),
|
||||
email: z.string(), // Relaxed: was z.string().email() but caused validation issues with some formats
|
||||
name: z.string().optional().nullable(),
|
||||
avatar_url: z.string().optional().nullable(),
|
||||
token: CloudTokenDataSchema,
|
||||
quota: CloudQuotaDataSchema.optional(),
|
||||
created_at: z.number(),
|
||||
last_used: z.number(),
|
||||
status: z.enum(['active', 'rate_limited', 'expired']).optional(),
|
||||
is_active: z.boolean().optional(),
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpstreamProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(),
|
||||
url: z.string(),
|
||||
});
|
||||
|
||||
export const ProxyConfigSchema = z.object({
|
||||
enabled: z.boolean(), // 是否启用
|
||||
port: z.number(), // 监听端口
|
||||
api_key: z.string(), // API 密钥
|
||||
auto_start: z.boolean(), // 是否自动启动
|
||||
anthropic_mapping: z.record(z.string(), z.string()), // 映射表
|
||||
request_timeout: z.number().default(120), // 超时秒数
|
||||
upstream_proxy: UpstreamProxyConfigSchema,
|
||||
});
|
||||
|
||||
export const AppConfigSchema = z.object({
|
||||
language: z.string(),
|
||||
theme: z.string(),
|
||||
auto_refresh: z.boolean(),
|
||||
refresh_interval: z.number(), // minutes
|
||||
auto_sync: z.boolean(), // 是否自动同步
|
||||
sync_interval: z.number(), // minutes
|
||||
default_export_path: z.string().nullable().optional(), // 导出路径
|
||||
proxy: ProxyConfigSchema,
|
||||
});
|
||||
|
||||
export type UpstreamProxyConfig = z.infer<typeof UpstreamProxyConfigSchema>;
|
||||
export type ProxyConfig = z.infer<typeof ProxyConfigSchema>;
|
||||
export type AppConfig = z.infer<typeof AppConfigSchema>;
|
||||
|
||||
export const DEFAULT_APP_CONFIG: AppConfig = {
|
||||
language: 'zh-CN',
|
||||
theme: 'system',
|
||||
auto_refresh: false,
|
||||
refresh_interval: 15,
|
||||
auto_sync: false,
|
||||
sync_interval: 5,
|
||||
default_export_path: null,
|
||||
proxy: {
|
||||
enabled: false,
|
||||
port: 8045,
|
||||
api_key: '', // Generated dynamically if default needed
|
||||
auto_start: false,
|
||||
anthropic_mapping: {},
|
||||
request_timeout: 120,
|
||||
upstream_proxy: {
|
||||
enabled: false,
|
||||
url: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export type ThemeMode = "dark" | "light" | "system";
|
||||
Reference in new issue
Block a user