Skip to content

Commit 5210450

Browse files
committed
refactor(api)!: rename topic to topics
1 parent 9a3d7b1 commit 5210450

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ setApiConfig({
2727
deviceId: '<device-id>', // 请自行替换
2828
})
2929

30-
api.topic
30+
api.topics
3131
.getTabsSquareFeed('562dfeb0daf87d13002cad92', {
3232
limit: 10,
3333
})
@@ -62,13 +62,13 @@ export const config = {
6262
}
6363
```
6464

65-
2. 新建测试文件, 如 `tests/api/topic.test.ts`, 编写测试代码
65+
2. 新建测试文件, 如 `tests/api/topics.test.ts`, 编写测试代码
6666

6767
3. 执行测试用例
6868

6969
```shell
7070
pnpm run test
7171

72-
# 测试指定的测试文件, 如只测试新增的 topic.test.ts
73-
pnpm run test topic
74-
```
72+
# 测试指定的测试文件, 如只测试新增的 topics.test.ts
73+
pnpm run test topics
74+
```

src/api/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as comments from './comments'
88
import * as upload from './upload'
99
import * as stories from './stories'
1010
import * as mediaMeta from './media-meta'
11-
import * as topic from './topic'
11+
import * as topics from './topics'
1212

1313
/**
1414
* API
@@ -21,7 +21,7 @@ import * as topic from './topic'
2121
* - {@link api/comments | `comments`}: 评论
2222
* - {@link api/upload | `upload`}: 上传
2323
* - {@link api/stories | `stories`}: 日记
24-
* - {@link api/topic | `topic`}: 圈子
24+
* - {@link api/topics | `topics`}: 圈子
2525
*/
2626
export const api = {
2727
users,
@@ -34,7 +34,7 @@ export const api = {
3434
upload,
3535
stories,
3636
mediaMeta,
37-
topic,
37+
topics,
3838
}
3939
/**
4040
* API 集合

src/api/topic.ts renamed to src/api/topics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { request, toResponse } from '../request'
2-
import type { Topic } from '../types/api-responses'
2+
import type { Topics } from '../types/api-responses'
33
import type { PaginationOption } from '../types/options'
44

55
/**
66
* 获取圈子动态
77
* @param topicId 圈子 id
88
* @param option 选项
99
*/
10-
export const getTabsSquareFeed = <T = Topic.GetTabsSquareFeedResponse>(
10+
export const getTabsSquareFeed = <T = Topics.GetTabsSquareFeedResponse>(
1111
topicId: string,
1212
// NOTE: suppressed 应该传 false,但不知道这个参数是什么意思
1313
option: PaginationOption<{ lastId: string; suppressed: boolean }> = {}
@@ -27,7 +27,7 @@ export const getTabsSquareFeed = <T = Topic.GetTabsSquareFeedResponse>(
2727
* @param topicId 圈子 id
2828
* @param option 选项
2929
*/
30-
export const getTabsSelectedFeed = <T = Topic.GetTabsSelectedFeedResponse>(
30+
export const getTabsSelectedFeed = <T = Topics.GetTabsSelectedFeedResponse>(
3131
topicId: string,
3232
option: PaginationOption<{ offset: number }> = {}
3333
) =>

src/types/api-responses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export interface InteractiveResponse {
211211
url: string
212212
}
213213

214-
export namespace Topic {
214+
export namespace Topics {
215215
// 圈子动态
216216
export interface GetTabsSquareFeedResponse {
217217
data: SquareFeed[]

src/types/entity/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export * from './notification'
33
export * from './other'
44
export * from './post'
55
export * from './profile'
6-
export * from './topic'
7-
export * from './user'
86
export * from './story'
97
export * from './topic'
8+
export * from './user'

tests/api/topic.test.ts renamed to tests/api/topics.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ import { describe, expect, it } from 'vitest'
22
import { api, isSuccess, setApiConfig } from '../../src'
33
import { config } from '../config'
44

5-
describe('topic should work', () => {
5+
describe('topics should work', () => {
66
setApiConfig(config)
77

88
const topicId = '562dfeb0daf87d13002cad92' // 深圳吃喝玩乐圈子
99
const limit = 10
1010

1111
it('getTabsSquareFeed should work', async () => {
12-
const result = await api.topic.getTabsSquareFeed(topicId, { limit })
12+
const result = await api.topics.getTabsSquareFeed(topicId, { limit })
1313
expect(isSuccess(result)).toBe(true)
1414
expect(result.data.data.length).toBe(limit)
1515
})
1616

1717
it('getTabsSelectedFeed should work', async () => {
18-
const result = await api.topic.getTabsSelectedFeed(topicId, { limit })
18+
const result = await api.topics.getTabsSelectedFeed(topicId, { limit })
1919
expect(isSuccess(result)).toBe(true)
2020
expect(result.data.data.length).toBe(limit)
2121
})

typedoc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"src/api/upload.ts",
1212
"src/api/stories.ts",
1313
"src/api/media-meta.ts",
14-
"src/api/topic.ts"
14+
"src/api/topics.ts"
1515
],
1616
"out": "docs",
1717
"name": "Ⓙ Jike SDK",

0 commit comments

Comments
 (0)