diff --git a/packages/client/api.yaml b/packages/client/api.yaml index a7a94a33f..81644ed34 100644 --- a/packages/client/api.yaml +++ b/packages/client/api.yaml @@ -91,6 +91,60 @@ components: - permission type: object type: object + EpisodeWikiInfo: + properties: + date: + description: YYYY-MM-DD + examples: + - '2022-02-02' + pattern: ^\d{4}-\d{2}-\d{2}$ + type: string + duration: + examples: + - '24:53' + - 24m52s + type: string + ep: + type: number + id: + type: integer + name: + type: string + nameCN: + type: string + summary: + type: string + type: + anyOf: + - const: 0 + type: number + - enum: + - 1 + type: number + - enum: + - 2 + type: number + - enum: + - 3 + type: number + - enum: + - 4 + type: number + - enum: + - 5 + type: number + - enum: + - 6 + type: number + required: + - id + - name + - nameCN + - type + - ep + - duration + - summary + type: object ErrorResponse: description: default error response type properties: @@ -1613,6 +1667,173 @@ paths: description: 意料之外的服务器错误 tags: - topic + /p1/wiki/ep/{episodeID}: + get: + operationId: getEpisodeWikiInfo + parameters: + - example: 1148124 + in: path + name: episodeID + required: true + schema: + minimum: 0 + type: integer + responses: + '200': + content: + application/json: + example: + date: '2012-12-23' + duration: '00:23:37' + ep: 60 + id: 1148124 + name: キマリ×ト×ハジマリ + nameCN: 结末×与×开始 + summary: >- + ゴンとキルアはG.I.プレイヤー選考会にいよいよ挑戦する。審査を担当するツェズゲラから提示された合格の条件はただ一つ「練を見せる」こと。合格できる者は200人中32名という狭き門だが、ゴンとキルアはくぐり抜けることができるのか!? + type: 0 + schema: + $ref: '#/components/schemas/EpisodeWikiInfo' + description: Default Response + '404': + content: + application/json: + examples: + NOT_FOUND: + value: + code: NOT_FOUND + error: Not Found + message: episode not found + statusCode: 404 + schema: + $ref: '#/components/schemas/ErrorResponse' + description: Default Response + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + description: 意料之外的服务器错误 + description: 意料之外的服务器错误 + security: + - CookiesSession: [] + tags: + - wiki + patch: + operationId: patchEpisodeWikiInfo + parameters: + - example: 1148124 + in: path + name: episodeID + required: true + schema: + minimum: 0 + type: integer + requestBody: + content: + application/json: + example: + commitMessage: why this episode is edited + episode: + date: '2022-01-20' + duration: '24:53' + ep: 4 + name: name + nameCN: 中文名 + summary: a short description + type: 0 + schema: + properties: + commitMessage: + type: string + episode: + properties: + date: + description: YYYY-MM-DD + examples: + - '2022-02-02' + pattern: ^\d{4}-\d{2}-\d{2}$ + type: string + duration: + examples: + - '24:53' + - 24m52s + type: string + ep: + type: number + name: + type: string + nameCN: + type: string + summary: + type: string + type: + anyOf: + - const: 0 + type: number + - enum: + - 1 + type: number + - enum: + - 2 + type: number + - enum: + - 3 + type: number + - enum: + - 4 + type: number + - enum: + - 5 + type: number + - enum: + - 6 + type: number + type: object + required: + - commitMessage + - episode + type: object + required: true + responses: + '200': + content: + application/json: + schema: + properties: {} + type: object + description: Default Response + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + description: invalid input + description: invalid input + '404': + content: + application/json: + examples: + NOT_FOUND: + value: + code: NOT_FOUND + error: Not Found + message: episode 1 not found + statusCode: 404 + schema: + $ref: '#/components/schemas/ErrorResponse' + description: Default Response + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + description: 意料之外的服务器错误 + description: 意料之外的服务器错误 + security: + - CookiesSession: [] + tags: + - wiki /p1/wiki/subjects/{subjectID}: get: description: |- diff --git a/packages/client/client.ts b/packages/client/client.ts index 304b36660..a003dd5f2 100644 --- a/packages/client/client.ts +++ b/packages/client/client.ts @@ -173,6 +173,16 @@ export type Notice = { type: number; unread: boolean; }; +export type EpisodeWikiInfo = { + date?: string; + duration: string; + ep: number; + id: number; + name: string; + nameCN: string; + summary: string; + type: number | 1 | 2 | 3 | 4 | 5 | 6; +}; export type WikiPlatform = { id: number; text: string; @@ -703,6 +713,66 @@ export function getSubjectTopicsBySubjectId( }, ); } +export function getEpisodeWikiInfo(episodeId: number, opts?: Oazapfts.RequestOpts) { + return oazapfts.fetchJson< + | { + status: 200; + data: EpisodeWikiInfo; + } + | { + status: 404; + data: ErrorResponse; + } + | { + status: 500; + data: ErrorResponse; + } + >(`/p1/wiki/ep/${encodeURIComponent(episodeId)}`, { + ...opts, + }); +} +export function patchEpisodeWikiInfo( + episodeId: number, + body: { + commitMessage: string; + episode: { + date?: string; + duration?: string; + ep?: number; + name?: string; + nameCN?: string; + summary?: string; + type?: number | 1 | 2 | 3 | 4 | 5 | 6; + }; + }, + opts?: Oazapfts.RequestOpts, +) { + return oazapfts.fetchJson< + | { + status: 200; + data: {}; + } + | { + status: 400; + data: ErrorResponse; + } + | { + status: 404; + data: ErrorResponse; + } + | { + status: 500; + data: ErrorResponse; + } + >( + `/p1/wiki/ep/${encodeURIComponent(episodeId)}`, + oazapfts.json({ + ...opts, + method: 'PATCH', + body, + }), + ); +} /** * 获取当前的 wiki 信息 * diff --git a/packages/client/types/index.ts b/packages/client/types/index.ts index 7df3a4ea4..4f3da26fb 100644 --- a/packages/client/types/index.ts +++ b/packages/client/types/index.ts @@ -66,6 +66,10 @@ export interface paths { /** @description 获取帖子列表 */ get: operations['getSubjectTopicsBySubjectId']; }; + '/p1/wiki/ep/{episodeID}': { + get: operations['getEpisodeWikiInfo']; + patch: operations['patchEpisodeWikiInfo']; + }; '/p1/wiki/subjects/{subjectID}': { /** * @description 获取当前的 wiki 信息 @@ -143,6 +147,17 @@ export interface components { subjectWikiEdit: boolean; }; }; + EpisodeWikiInfo: { + /** @description YYYY-MM-DD */ + date?: string; + duration: string; + ep: number; + id: number; + name: string; + nameCN: string; + summary: string; + type: 0 | 1 | 2 | 3 | 4 | 5 | 6; + }; /** @description default error response type */ ErrorResponse: { code: string; @@ -907,6 +922,99 @@ export interface operations { }; }; }; + getEpisodeWikiInfo: { + parameters: { + path: { + /** @example 1148124 */ + episodeID: number; + }; + }; + responses: { + /** @description Default Response */ + 200: { + content: { + 'application/json': components['schemas']['EpisodeWikiInfo']; + }; + }; + /** @description Default Response */ + 404: { + content: { + 'application/json': components['schemas']['ErrorResponse']; + }; + }; + /** @description 意料之外的服务器错误 */ + 500: { + content: { + 'application/json': components['schemas']['ErrorResponse']; + }; + }; + }; + }; + patchEpisodeWikiInfo: { + parameters: { + path: { + /** @example 1148124 */ + episodeID: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "commitMessage": "why this episode is edited", + * "episode": { + * "date": "2022-01-20", + * "duration": "24:53", + * "ep": 4, + * "name": "name", + * "nameCN": "中文名", + * "summary": "a short description", + * "type": 0 + * } + * } + */ + 'application/json': { + commitMessage: string; + episode: { + /** @description YYYY-MM-DD */ + date?: string; + duration?: string; + ep?: number; + name?: string; + nameCN?: string; + summary?: string; + type?: 0 | 1 | 2 | 3 | 4 | 5 | 6; + }; + }; + }; + }; + responses: { + /** @description Default Response */ + 200: { + content: { + 'application/json': Record; + }; + }; + /** @description invalid input */ + 400: { + content: { + 'application/json': components['schemas']['ErrorResponse']; + }; + }; + /** @description Default Response */ + 404: { + content: { + 'application/json': components['schemas']['ErrorResponse']; + }; + }; + /** @description 意料之外的服务器错误 */ + 500: { + content: { + 'application/json': components['schemas']['ErrorResponse']; + }; + }; + }; + }; /** * @description 获取当前的 wiki 信息 *