Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 77 additions & 21 deletions packages/client/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -706,18 +706,15 @@ components:
type: string
GroupTopic:
allOf:
- $ref: '#/components/schemas/TopicBase'
- $ref: '#/components/schemas/Topic'
- properties:
creator:
$ref: '#/components/schemas/SlimUser'
group:
$ref: '#/components/schemas/SlimGroup'
replies:
items:
$ref: '#/components/schemas/Reply'
type: array
required:
- creator
- group
- replies
type: object
Expand Down Expand Up @@ -2213,18 +2210,15 @@ components:
type: object
SubjectTopic:
allOf:
- $ref: '#/components/schemas/TopicBase'
- $ref: '#/components/schemas/Topic'
- properties:
creator:
$ref: '#/components/schemas/SlimUser'
replies:
items:
$ref: '#/components/schemas/Reply'
type: array
subject:
$ref: '#/components/schemas/SlimSubject'
required:
- creator
- subject
- replies
type: object
Expand Down Expand Up @@ -2509,22 +2503,12 @@ components:
modelAsString: false
name: TimelineSource
Topic:
allOf:
- $ref: '#/components/schemas/TopicBase'
- properties:
creator:
$ref: '#/components/schemas/SlimUser'
replies:
type: integer
required:
- replies
type: object
title: Topic
TopicBase:
properties:
createdAt:
description: 发帖时间,unix time stamp in seconds
type: integer
creator:
$ref: '#/components/schemas/SlimUser'
creatorID:
type: integer
display:
Expand All @@ -2534,6 +2518,8 @@ components:
parentID:
description: 小组/条目ID
type: integer
replyCount:
type: integer
state:
type: integer
title:
Expand All @@ -2546,11 +2532,12 @@ components:
- title
- creatorID
- parentID
- replyCount
- createdAt
- updatedAt
- state
- display
title: TopicBase
title: Topic
type: object
TrendingSubject:
properties:
Expand Down Expand Up @@ -4517,6 +4504,23 @@ paths:
default: 0
type: integer
responses:
'200':
content:
application/json:
schema:
properties:
data:
items:
$ref: '#/components/schemas/GroupTopic'
type: array
total:
description: limit+offset 为参数的请求表示总条数,page 为参数的请求表示总页数
type: integer
required:
- data
- total
type: object
description: Default Response
'500':
content:
application/json:
Expand Down Expand Up @@ -5865,6 +5869,58 @@ paths:
summary: 编辑条目讨论回复
tags:
- topic
/p1/subjects/-/topics:
get:
operationId: getRecentSubjectTopics
parameters:
- description: max 100
in: query
name: limit
required: false
schema:
default: 20
maximum: 100
minimum: 1
type: integer
- description: min 0
in: query
name: offset
required: false
schema:
default: 0
minimum: 0
type: integer
responses:
'200':
content:
application/json:
schema:
properties:
data:
items:
$ref: '#/components/schemas/SubjectTopic'
type: array
total:
description: limit+offset 为参数的请求表示总条数,page 为参数的请求表示总页数
type: integer
required:
- data
- total
type: object
description: Default Response
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
description: 意料之外的服务器错误
description: 意料之外的服务器错误
security:
- CookiesSession: []
HTTPBearer: []
summary: 获取最新的条目讨论
tags:
- subject
/p1/subjects/-/topics/{topicID}:
get:
operationId: getSubjectTopic
Expand Down
70 changes: 57 additions & 13 deletions packages/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,23 +320,21 @@
nsfw: boolean;
title: string;
};
export type TopicBase = {
export type Topic = {
/** 发帖时间,unix time stamp in seconds */
createdAt: number;
creator?: SlimUser;
creatorID: number;
display: number;
id: number;
/** 小组/条目ID */
parentID: number;
replyCount: number;
state: number;
title: string;
/** 最后回复时间,unix time stamp in seconds */
updatedAt: number;
};
export type Topic = TopicBase & {
creator?: SlimUser;
replies: number;
};
export type Post = {
content: string;
createdAt: number;
Expand All @@ -358,8 +356,7 @@
export type Reply = ReplyBase & {
replies: ReplyBase[];
};
export type GroupTopic = TopicBase & {
creator: SlimUser;
export type GroupTopic = Topic & {
group: SlimGroup;
replies: Reply[];
};
Expand Down Expand Up @@ -509,8 +506,7 @@
keyword: string;
sort?: SubjectSearchSort;
};
export type SubjectTopic = TopicBase & {
creator: SlimUser;
export type SubjectTopic = Topic & {
replies: Reply[];
subject: SlimSubject;
};
Expand Down Expand Up @@ -1835,10 +1831,20 @@
} = {},
opts?: Oazapfts.RequestOpts,
) {
return oazapfts.fetchJson<{
status: 500;
data: ErrorResponse;
}>(
return oazapfts.fetchJson<
| {
status: 200;
data: {
data: GroupTopic[];
/** limit+offset 为参数的请求表示总条数,page 为参数的请求表示总页数 */
total: number;
};
}
| {
status: 500;
data: ErrorResponse;
}
>(

Check warning on line 1847 in packages/client/client.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/client.ts#L1834-L1847

Added lines #L1834 - L1847 were not covered by tests
`/p1/groups/-/topics${QS.query(
QS.explode({
mode,
Expand Down Expand Up @@ -2682,6 +2688,44 @@
}),
);
}
/**
* 获取最新的条目讨论
*/
export function getRecentSubjectTopics(
{
limit,
offset,
}: {
limit?: number;
offset?: number;
} = {},
opts?: Oazapfts.RequestOpts,
) {
return oazapfts.fetchJson<
| {
status: 200;
data: {
data: SubjectTopic[];
/** limit+offset 为参数的请求表示总条数,page 为参数的请求表示总页数 */
total: number;
};
}
| {
status: 500;
data: ErrorResponse;
}
>(
`/p1/subjects/-/topics${QS.query(
QS.explode({
limit,
offset,
}),
)}`,
{
...opts,
},
);
}

Check warning on line 2728 in packages/client/client.ts

View check run for this annotation

Codecov / codecov/patch

packages/client/client.ts#L2695-L2728

Added lines #L2695 - L2728 were not covered by tests
/**
* 获取条目讨论详情
*/
Expand Down
Loading