From ae585edc9fded3f246ff69aabc3ab4832717fc01 Mon Sep 17 00:00:00 2001 From: ud2 Date: Wed, 12 Feb 2025 03:37:23 +0800 Subject: [PATCH] fix: update `/problem/:pid` response --- luogu-api.d.ts | 142 +++++++++++++++++++++++++++++++++++++------------ problems.md | 6 +-- teams.md | 2 +- 3 files changed, 111 insertions(+), 39 deletions(-) diff --git a/luogu-api.d.ts b/luogu-api.d.ts index 83e8d9d..8935417 100644 --- a/luogu-api.d.ts +++ b/luogu-api.d.ts @@ -191,7 +191,7 @@ export interface LentilleDataResponse { } export interface UpdateTestCasesSettingsResponse { - problem: ProblemDetails; + problem: LegacyProblemDetails; testCases: TestCase[]; scoringStrategy: ScoringStrategy; subtaskScoringStrategies: ScoringStrategy[]; @@ -357,6 +357,13 @@ export interface ConfigResponse { OpenIdPlatformType: { [id: number]: { type: string; id: number; name: string }; }; + ProblemDifficulty: { + type: string; + id: number; + name: string; + color: string; + }[]; + ProblemFlag: { [id: number]: { type: string; id: number; name: string } }; ProblemType: { [id: string]: { type: string; @@ -367,15 +374,40 @@ export interface ConfigResponse { searchable: boolean; }; }; + CodeLanguage: { + [id: number]: { + type: string; + id: number; + name: string; + order: number; + family: string | null; + disabled: boolean; + canO2: boolean; + fileExt: string[]; + hljs: string; + }; + }; + RecordStatus: { + [id: number]: { + type: string; + id: number; + name: string; + shortName: string; + color: string; + filterable: boolean; + }; + }; TeamJoinPermissionType: { type: string; id: number; name: string }[]; TeamJoinRequestStatusType: { type: string; id: number; name: string }[]; TeamMemberType: { [id: number]: { type: string; id: number; name: string } }; TeamType: { [id: number]: { type: string; id: number; name: string } }; + UserMessageReceiveMode: { type: string; id: number }[]; UserNotificationType: { [id: number]: { type: string; id: number; name: string }; }; + UserOfflinePrizeShowLevel: { type: string; id: number; name: string }[]; UserOpenSourceType: { [id: number]: { type: string; id: number } }; - UserRelationshipType: { [id: number]: { type: string; id: number } }; + UserRelationship: { [id: number]: { type: string; id: number } }; VoteType: { [id: number]: { type: string; id: number } }; route: { [id: string]: string }; routeAttr: { [id: string]: { instance: string } }; @@ -394,15 +426,16 @@ export interface TagsResponse { export interface ProblemData { problem: ProblemDetails & Maybe; - contest: ContestSummary | null; - discussions: LegacyPostSummary[]; + translations: { [locale: string]: ProblemContents }; bookmarked: boolean; + contest: ContestSummary | null; vjudgeUsername: string | null; - recommendations: (LegacyProblemSummary & Maybe)[]; - lastLanguage: number; - lastCode: string; - privilegedTeams: TeamSummary[]; - userTranslation: null; // TODO + lastLanguage: number | null; + lastCode: string | null; + recommendations: (ProblemSummary & Maybe)[]; + forum: Forum | null; + discussions: PostSummary[] | null; + canEdit: boolean; } export interface SolutionsData { @@ -453,13 +486,13 @@ export interface RecordData { export interface PostListData { forum: Forum | null; publicForums: Forum[]; - posts: List; + posts: List; canPost: boolean; } export interface PostData { forum: Forum; - post: Post; + post: PostDetails; replies: List; canReply: boolean; } @@ -662,7 +695,7 @@ export interface ProblemSummary { difficulty: number | null; } -export interface Problem extends LegacyProblemSummary { +export interface Problem extends ProblemSummary { tags: number[]; wantsTranslation: boolean; totalSubmit: number; @@ -671,27 +704,38 @@ export interface Problem extends LegacyProblemSummary { } export interface ProblemDetails extends Problem { + provider: (UserSummary & Maybe) | TeamSummary; + content: ProblemContents; + attachments: ProblemAttachment[]; + acceptSolution: boolean; + acceptLanguages: number[]; + samples: [input: string, output: string][]; + limits: { time: number[]; memory: number[] }; + stdCode: string; + showScore?: boolean; + score?: number | null; + vjudge?: { id: string; link: string }; + translation: string; +} + +export interface ProblemContents { + user: null; + version: 1; + name: string; background: string; description: string; - inputFormat: string; - outputFormat: string; - samples: [string, string][]; + formatI: string; + formatO: string; hint: string; - provider: UserSummary | TeamSummary; - attachments: { - size: number; - uploadTime: number; - downloadLink: string; - id: string; - fileName: string; - }[]; - canEdit: boolean; - limits: { time: number[]; memory: number[] }; - showScore: boolean; - score: number | null; - stdCode: string; - vjudge?: { origin: string; link: string; id: string }; - translation?: string; + locale: string; +} + +export interface ProblemAttachment { + id: string; + filename: string; + size: number; + uploadTime: number; + downloadLink: string; } export interface ProblemSettings { @@ -700,16 +744,16 @@ export interface ProblemSettings { description: string; inputFormat: string; outputFormat: string; - samples: [string, string][]; + samples: [input: string, output: string][]; hint: string; translation: string; needsTranslation: boolean; acceptSolution: boolean; allowDataDownload: boolean; - tags: number[]; difficulty: number; showScore: boolean; flag: number; + tags: number[]; } export interface ProblemStatus { @@ -730,7 +774,7 @@ export interface TestCase { export interface ScoringStrategy { type: number; - script: string; + script?: string; } export interface ProblemSet { @@ -747,7 +791,7 @@ export interface ProblemSet { export interface ProblemSetDetails extends ProblemSet { description: string; - problems: { problem: Problem }[]; + problems: { problem: LegacyProblem }[]; userScore: { user: UserSummary; totalScore: number; @@ -872,6 +916,9 @@ export interface PostSummary { title: string; author: UserSummary; time: number; +} + +export interface Post extends PostSummary { forum: Forum; topped: boolean; valid: boolean; @@ -880,7 +927,7 @@ export interface PostSummary { recentReply: ReplySummary | false; } -export interface Post extends PostSummary { +export interface PostDetails extends Post { content: string; pinnedReply: Reply | null; } @@ -1192,6 +1239,31 @@ export interface LegacyProblemSummary extends ProblemSummary { fullScore: number; } +/** @deprecated */ +export interface LegacyProblem extends LegacyProblemSummary { + tags: number[]; + wantsTranslation: boolean; + totalSubmit: number; + totalAccepted: number; + flag: number; +} + +/** @deprecated */ +export interface LegacyProblemDetails extends LegacyProblem { + background: string; + description: string; + inputFormat: string; + outputFormat: string; + samples: [input: string, output: string][]; + hint: string; + provider: UserSummary | TeamSummary; + attachments: ProblemAttachment[]; + canEdit: boolean; + limits: { time: number[]; memory: number[] }; + stdCode: string; + translation?: string; +} + /** @deprecated */ export interface LegacyPostSummary { id: number; diff --git a/problems.md b/problems.md index c14f361..ddd10c6 100644 --- a/problems.md +++ b/problems.md @@ -13,7 +13,7 @@ 响应主体 - application/json (DataResponse<{ problems: List<Problem & Maybe<ProblemStatus>>; page: number }>) + application/json (DataResponse<{ problems: List<LegacyProblem & Maybe<ProblemStatus>>; page: number }>) @@ -30,7 +30,7 @@ 响应主体 - application/json ({ problems: List<Problem> }) + application/json ({ problems: List<LegacyProblem> }) @@ -47,7 +47,7 @@ 响应主体 - application/json (DataResponse<ProblemData>) + application/json (LentilleDataResponse<ProblemData>) diff --git a/teams.md b/teams.md index cdd9b4c..aec3203 100644 --- a/teams.md +++ b/teams.md @@ -39,7 +39,7 @@ 响应主体 - application/json ({ problems: List<Problem> }) + application/json ({ problems: List<LegacyProblem> })