File tree Expand file tree Collapse file tree 6 files changed +103
-1
lines changed Expand file tree Collapse file tree 6 files changed +103
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import * as personalUpdate from './personal-update'
6
6
import * as notifications from './notifications'
7
7
import * as comments from './comments'
8
8
import * as upload from './upload'
9
+ import * as stories from './stories'
9
10
10
11
/**
11
12
* API
@@ -17,6 +18,7 @@ import * as upload from './upload'
17
18
* - {@link api/notifications | `notifications`}: 通知
18
19
* - {@link api/comments | `comments`}: 评论
19
20
* - {@link api/upload | `upload`}: 上传
21
+ * - {@link api/stories | `stories`}: 日记
20
22
*/
21
23
export const api = {
22
24
users,
@@ -27,6 +29,7 @@ export const api = {
27
29
notifications,
28
30
comments,
29
31
upload,
32
+ stories,
30
33
}
31
34
/**
32
35
* API 集合
Original file line number Diff line number Diff line change
1
+ import { request , toResponse } from '../request'
2
+ import type { Stories } from '../types/api-responses'
3
+
4
+ /**
5
+ * 获取关注用户日记列表
6
+ */
7
+ export const followingFeed = async < T = Stories . FollowingFeedResponse > ( ) =>
8
+ toResponse < T > ( request . get ( '1.0/stories/followingFeed' ) )
9
+
10
+ /**
11
+ * 获取用户的日记详情
12
+ * @param username 用户名
13
+ */
14
+ export const listUserStories = async < T = Stories . ListUserStoriesResponse > (
15
+ username : string
16
+ ) =>
17
+ toResponse < T > (
18
+ request . get ( '1.0/stories/listUserStories' , {
19
+ searchParams : {
20
+ username,
21
+ } ,
22
+ } )
23
+ )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type {
7
7
PostDetail ,
8
8
Profile as ProfileEntity ,
9
9
RecommendPost ,
10
+ StoryDetails ,
10
11
TabIcons ,
11
12
User ,
12
13
} from './entity'
@@ -179,3 +180,13 @@ export namespace RecommendFeed {
179
180
}
180
181
}
181
182
}
183
+
184
+ export namespace Stories {
185
+ export interface FollowingFeedResponse {
186
+ data : { type : 'USER_STORY' ; user : User } [ ]
187
+ }
188
+
189
+ export interface ListUserStoriesResponse {
190
+ data : StoryDetails [ ]
191
+ }
192
+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type {
7
7
UrlsInText ,
8
8
} from './post'
9
9
import type { User } from './user'
10
+ import type { LiteralUnion } from '../../utils/typings'
10
11
11
12
export type PostTypeRaw = 'ORIGINAL_POST' | 'REPOST'
12
13
export type TargetType = PostTypeRaw | 'STORY'
@@ -160,3 +161,47 @@ export interface RecommendPost {
160
161
createdAt : Date
161
162
type : string
162
163
}
164
+
165
+ export interface StoryPic {
166
+ key : string
167
+ thumbnailUrl : string
168
+ smallPicUrl : string
169
+ middlePicUrl : string
170
+ picUrl : string
171
+ format : string
172
+ cropperPosX : number
173
+ cropperPosY : number
174
+ width : number
175
+ height : number
176
+ }
177
+ export interface StoryVideo {
178
+ duration : number
179
+ height : number
180
+ type : string
181
+ width : number
182
+ image : {
183
+ format : string
184
+ picUrl : string
185
+ thumbnailUrl : string
186
+ }
187
+ }
188
+
189
+ export interface StoryDetails {
190
+ id : string
191
+ type : 'STORY'
192
+ storyType : LiteralUnion < 'PICTURE' | 'VIDEO' >
193
+ user : User
194
+ emoji ?: string
195
+ video ?: StoryVideo
196
+ thumbnailVideo ?: StoryVideo
197
+ status : string
198
+ picture : StoryPic
199
+ liked : boolean
200
+ likeCount : number
201
+ commentCount : number
202
+ viewerCount : number
203
+ createdAt : string
204
+ likedUsers : [ ]
205
+ enablePictureComments : boolean
206
+ isFeatured : boolean
207
+ }
Original file line number Diff line number Diff line change
1
+ import { describe , expect , it } from 'vitest'
2
+ import { api , isSuccess , setApiConfig } from '../../src'
3
+ import { config } from '../config'
4
+
5
+ describe ( 'stories should work' , ( ) => {
6
+ setApiConfig ( config )
7
+
8
+ it ( 'followingFeed should work' , async ( ) => {
9
+ const result = await api . stories . followingFeed ( )
10
+ expect ( isSuccess ( result ) ) . toBe ( true )
11
+ } )
12
+
13
+ it ( 'listUserStories should work' , async ( ) => {
14
+ const result = await api . stories . listUserStories (
15
+ 'c00cf715-b71b-464b-9dcc-d73e01878137'
16
+ )
17
+ expect ( isSuccess ( result ) ) . toBe ( true )
18
+ } )
19
+ } )
Original file line number Diff line number Diff line change 8
8
" src/api/user-relation.ts" ,
9
9
" src/api/users.ts" ,
10
10
" src/api/comments.ts" ,
11
- " src/api/upload.ts"
11
+ " src/api/upload.ts" ,
12
+ " src/api/stories.ts"
12
13
],
13
14
"out" : " docs" ,
14
15
"name" : " Ⓙ Jike SDK" ,
You can’t perform that action at this time.
0 commit comments