🎉 first commit

This commit is contained in:
LIlGG
2025-09-24 13:06:25 +08:00
commit 1f4fb103e9
409 changed files with 61222 additions and 0 deletions

84
app/types/1panel.ts Normal file
View File

@@ -0,0 +1,84 @@
import type { ApiResponse } from './global';
export interface _1PanelResponse<T> {
code: number;
data: T;
message: string;
}
export interface _1PanelPaginationResponse<T> {
items: T[];
total: number;
}
export interface _1PanelWebsiteDomain {
createdAt: string;
domain: string;
id: number;
port: number;
ssl: boolean;
updatedAt: string;
websiteId: number;
}
export interface _1PanelWebsite {
IPV6: boolean;
accessLog: boolean;
accessLogPath: string;
alias: string;
appInstallId: number;
appName: string;
createdAt: string;
dbID: number;
dbType: string;
defaultServer: boolean;
domains: _1PanelWebsiteDomain[];
errorLog: boolean;
errorLogPath: string;
expireDate: string;
favorite: boolean;
ftpId: number;
group: string;
httpConfig: string;
id: number;
parentWebsiteID: number;
primaryDomain: string;
protocol: string;
proxy: string;
proxyType: string;
remark: string;
rewrite: string;
runtimeID: number;
runtimeName: string;
runtimeType: string;
siteDir: string;
sitePath: string;
status: string;
type: string;
updatedAt: string;
user: string;
webSiteGroupId: number;
}
export interface _1PanelStats {
websites: _1PanelWebsite[];
totalWebsites: number;
lastUpdated: string;
}
export interface _1PanelWebsiteInfo {
id: number;
domain: string;
sitePath: string;
url: string;
chatId: string;
alias: string;
}
export type _1PanelDeployResponse = ApiResponse<{
deploy?: {
id: number;
domain: string;
url: string;
};
}>;

51
app/types/actions.ts Normal file
View File

@@ -0,0 +1,51 @@
import type { Change } from 'diff';
export interface Page {
name: string;
title: string;
content?: string;
actionIds: string[];
}
export interface Section {
id: string;
action: 'add' | 'update' | 'remove';
pageName: string;
content: string;
domId: string;
rootDomId: string;
sort?: number;
}
export interface BaseAction {
content: string;
}
/**
* UPageAction 是 UPage 的 action 类型,由 AI 返回的结构化数据。
*/
export interface UPageAction extends Section {
validRootDomId: boolean;
}
export type UPageActionData = UPageAction | BaseAction;
export interface ActionAlert {
type: string;
title: string;
description: string;
content: string;
source?: 'preview';
}
export interface PageHistory {
originalContent: string;
lastModified: number;
changes: Change[];
versions: {
timestamp: number;
content: string;
}[];
// 记录变更来源
changeSource?: 'user' | 'auto-save' | 'external';
}

12
app/types/artifact.ts Normal file
View File

@@ -0,0 +1,12 @@
/**
* UPageArtifactData 是 UPage 的 artifact 类型,由 AI 返回的结构化数据。
* 最终对应 editor 的 Page 数据。
*/
export interface UPageArtifactData {
// artifact id唯一
id: string;
// 页面名称,最终渲染为页面文件名,如 `index.html`,不包含后缀。唯一
name: string;
// 页面标题,最终渲染为页面标题
title: string;
}

10
app/types/chat.ts Normal file
View File

@@ -0,0 +1,10 @@
import type { Chat, Message, Page, Section } from '@prisma/client';
export type ChatMessage = Message & {
sections: Section[];
page: Page;
};
export type ChatWithMessages = Chat & {
messages: ChatMessage[];
};

29
app/types/deployment.ts Normal file
View File

@@ -0,0 +1,29 @@
export enum DeploymentPlatformEnum {
_1PANEL = '1panel',
NETLIFY = 'netlify',
VERCEL = 'vercel',
}
export type DeploymentPlatform = (typeof DeploymentPlatformEnum)[keyof typeof DeploymentPlatformEnum];
export enum DeploymentStatusEnum {
SUCCESS = 'success',
PENDING = 'pending',
DEPLOYING = 'deploying',
DEPLOYED = 'deployed',
FAILED = 'failed',
INACTIVE = 'inactive',
}
export type DeploymentStatus = (typeof DeploymentStatusEnum)[keyof typeof DeploymentStatusEnum];
// 按平台分类的部署统计数据
export interface DeploymentStatsByPlatform {
totalSites: number;
sitesByPlatform: Record<string, number>;
totalDays?: number;
totalVisits?: number;
availableVisits?: number;
totalBytes?: number;
lastAccess?: string | null;
}

25
app/types/editor.ts Normal file
View File

@@ -0,0 +1,25 @@
export interface DocumentProperties {
name: string;
title: string;
content: string;
}
export interface Editor {
appendContent: (query: string, newHTML: string, sort?: number) => void;
updateContent: (query: string, newHTML: string, sort?: number) => void;
deleteContent: (query: string) => void;
getContent: (query?: string) => string;
setContent: (newHTML: string) => void;
scrollToElement: (query: string) => void;
}
export interface EditorData {
html?: string;
element?: HTMLElement;
query?: string;
}
export interface EditorControllerProps {
getContentElement: () => HTMLElement | null;
getIframeElement: () => HTMLIFrameElement | null;
}

133
app/types/github.ts Normal file
View File

@@ -0,0 +1,133 @@
export interface GitHubUserResponse {
login: string;
avatar_url: string;
html_url: string;
name: string;
bio: string;
public_repos: number;
followers: number;
following: number;
public_gists: number;
created_at: string;
updated_at: string;
}
export interface GitHubRepoInfo {
name: string;
full_name: string;
html_url: string;
description: string;
stargazers_count: number;
forks_count: number;
default_branch: string;
updated_at: string;
language: string;
languages_url: string;
}
export interface GitHubContent {
name: string;
path: string;
sha: string;
size: number;
url: string;
html_url: string;
git_url: string;
download_url: string;
type: string;
content: string;
encoding: string;
}
export interface GitHubBranch {
name: string;
commit: {
sha: string;
url: string;
};
}
export interface GitHubBlobResponse {
content: string;
encoding: string;
sha: string;
size: number;
url: string;
}
export interface GitHubOrganization {
login: string;
avatar_url: string;
description: string;
html_url: string;
}
export interface GitHubEvent {
id: string;
type: string;
created_at: string;
repo: {
name: string;
url: string;
};
payload: {
action?: string;
ref?: string;
ref_type?: string;
description?: string;
};
}
export interface GitHubLanguageStats {
[key: string]: number;
}
export interface GitHubStats {
repos: GitHubRepoInfo[];
totalStars: number;
totalForks: number;
organizations: GitHubOrganization[];
recentActivity: GitHubEvent[];
languages: GitHubLanguageStats;
totalGists: number;
}
export interface GitHubConnection {
user: GitHubUserResponse | null;
token: string;
tokenType: 'classic' | 'fine-grained';
stats?: GitHubStats;
}
export interface GitHubTokenInfo {
token: string;
scope: string[];
avatar_url: string;
name: string | null;
created_at: string;
followers: number;
}
export interface GitHubRateLimits {
limit: number;
remaining: number;
reset: Date;
used: number;
}
export interface GitHubAuthState {
username: string;
tokenInfo: GitHubTokenInfo | null;
isConnected: boolean;
isVerifying: boolean;
isLoadingRepos: boolean;
rateLimits?: GitHubRateLimits;
}
export interface RepositoryStats {
totalFiles: number;
totalSize: number;
languages: Record<string, number>;
hasPackageJson: boolean;
hasDependencies: boolean;
}

40
app/types/global.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
// 全局 API 响应接口
/**
* 标准 API 响应接口
* 遵循 RESTful API 最佳实践,结合 HTTP 状态码和业务处理结果
*/
export interface ApiResponse<T = any> {
/** 请求是否成功 */
success: boolean;
/** 响应消息 */
message?: string;
/** 响应数据 */
data?: T;
}
declare global {
interface Window {
webkitSpeechRecognition: typeof SpeechRecognition;
SpeechRecognition: typeof SpeechRecognition;
ENV: {
OPERATING_ENV: 'production' | 'development' | 'test';
MAX_UPLOAD_SIZE_MB: number;
};
}
interface Performance {
memory?: {
jsHeapSizeLimit: number;
totalJSHeapSize: number;
usedJSHeapSize: number;
};
}
// 扩展 Request 接口,使 json 方法支持泛型
interface Request {
json<T = any>(): Promise<T>;
}
}
// 确保文件被视为模块
export {};

61
app/types/logto.ts Normal file
View File

@@ -0,0 +1,61 @@
// Logto 用户身份信息
export interface LogtoUserIdentity {
userId: string;
details: Record<string, any>;
}
export interface LogtoUserAddress {
formatted?: string;
streetAddress?: string;
locality?: string;
region?: string;
postalCode?: string;
country?: string;
}
export interface LogtoUserProfile {
familyName?: string;
givenName?: string;
middleName?: string;
nickname?: string;
preferredUsername?: string;
profile?: string;
website?: string;
gender?: string;
birthdate?: string;
zoneinfo?: string;
locale?: string;
address?: LogtoUserAddress;
}
// Logto SSO 身份信息
export interface LogtoSsoIdentity {
tenantId: string;
id: string;
userId: string;
issuer: string;
identityId: string;
detail: Record<string, any>;
createdAt: number;
updatedAt: number;
ssoConnectorId: string;
}
export interface LogtoUser {
id: string;
username: string | null;
primaryEmail: string | null;
primaryPhone: string | null;
name: string | null;
avatar: string | null;
customData: Record<string, any>;
identities: Record<string, LogtoUserIdentity>;
lastSignInAt: number | null;
createdAt: number;
updatedAt: number;
profile: LogtoUserProfile;
applicationId: string | null;
isSuspended: boolean;
hasPassword?: boolean;
ssoIdentities?: LogtoSsoIdentity[];
}

35
app/types/message.ts Normal file
View File

@@ -0,0 +1,35 @@
import type { UIMessage } from 'ai';
export type UPageUIMessage = UIMessage<UPageMessageMetadata, UPageDataParts>;
export type ElementInfoMetadata = {
tagName: string;
className?: string;
id?: string;
innerHTML?: string;
outerHTML?: string;
};
export type UPageMessageMetadata = {
isHidden?: boolean;
elementInfo?: ElementInfoMetadata;
};
// 自定义的 parts, 用于在前端显示进度条。
export type ProgressAnnotation = {
label: string;
status: 'in-progress' | 'complete' | 'stopped' | 'warning';
order: number;
message: string;
};
// 自定义的 parts, 用于在前端显示摘要。
export type SummaryAnnotation = {
chatId: string;
summary: string;
};
export type UPageDataParts = {
progress: ProgressAnnotation;
summary: SummaryAnnotation;
};

24
app/types/model.ts Normal file
View File

@@ -0,0 +1,24 @@
import type { ModelInfo } from '~/lib/modules/llm/types';
export type ProviderInfo = {
staticModels: ModelInfo[];
name: string;
getDynamicModels?: (
providerName: string,
apiKeys?: Record<string, string>,
providerSettings?: IProviderSetting,
serverEnv?: Record<string, string>,
) => Promise<ModelInfo[]>;
getApiKeyLink?: string;
labelForGetApiKey?: string;
icon?: string;
};
export interface IProviderSetting {
enabled?: boolean;
baseUrl?: string;
}
export type IProviderConfig = ProviderInfo & {
settings: IProviderSetting;
};

89
app/types/netlify.ts Normal file
View File

@@ -0,0 +1,89 @@
export interface NetlifySite {
id: string;
name: string;
url: string;
ssl_url?: string;
admin_url: string;
screenshot_url?: string;
created_at: string;
updated_at: string;
state?: string;
branch?: string;
custom_domain?: string;
build_settings: {
provider: string;
repo_url: string;
repo_branch?: string;
cmd: string;
};
published_deploy: {
id?: string;
published_at: string;
deploy_time: number;
state?: string;
branch?: string;
commit_ref?: string;
commit_url?: string;
error_message?: string;
framework?: string;
};
}
export interface NetlifyDeploy {
id: string;
site_id: string;
state: string;
name: string;
url: string;
ssl_url?: string;
admin_url?: string;
deploy_url: string;
deploy_ssl_url?: string;
screenshot_url?: string;
branch: string;
commit_ref?: string;
commit_url?: string;
created_at: string;
updated_at: string;
published_at?: string;
title?: string;
framework?: string;
error_message?: string;
}
export interface NetlifyBuild {
id: string;
deploy_id: string;
sha?: string;
done: boolean;
error?: string;
created_at: string;
}
export interface NetlifyUser {
id: string;
slug: string;
email: string;
full_name: string;
avatar_url: string;
}
export interface NetlifyStats {
sites: NetlifySite[];
totalSites: number;
deploys?: NetlifyDeploy[];
builds?: NetlifyBuild[];
lastDeployTime?: string;
}
export interface NetlifyConnection {
isConnect: boolean;
stats?: NetlifyStats;
}
export interface NetlifySiteInfo {
id: string;
name: string;
url: string;
chatId: string;
}

0
app/types/settings.ts Normal file
View File

1
app/types/theme.ts Normal file
View File

@@ -0,0 +1 @@
export type Theme = 'dark' | 'light';

40
app/types/vercel.ts Normal file
View File

@@ -0,0 +1,40 @@
export interface VercelUser {
user: any;
id: string;
username: string;
email: string;
name: string;
avatar?: string;
}
export interface VercelProject {
createdAt: string | number | Date;
targets: any;
id: string;
name: string;
framework?: string;
latestDeployments?: Array<{
id: string;
url: string;
created: number;
state: string;
}>;
}
export interface VercelStats {
projects: VercelProject[];
totalProjects: number;
}
export interface VercelConnection {
isConnect: boolean;
user: VercelUser | null;
stats?: VercelStats;
}
export interface VercelProjectInfo {
id: string;
name: string;
url: string;
chatId: string;
}