File tree Expand file tree Collapse file tree 8 files changed +85
-43
lines changed
Expand file tree Collapse file tree 8 files changed +85
-43
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import * as notifications from './notifications'
77import * as comments from './comments'
88import * as upload from './upload'
99import * as stories from './stories'
10+ import * as mediaMeta from './media-meta'
1011
1112/**
1213 * API
@@ -30,6 +31,7 @@ export const api = {
3031 comments,
3132 upload,
3233 stories,
34+ mediaMeta,
3335}
3436/**
3537 * API 集合
Original file line number Diff line number Diff line change 1+ import { request , toResponse } from '../request'
2+ import type { LiteralUnion } from '../utils/typings'
3+ import type { InteractiveResponse } from '../types/api-responses'
4+
5+ /**
6+ * 获取视频地址
7+ * @param id 视频id
8+ * @param type 类型 如:STORY
9+ * @param trigger 触发 如:user
10+ */
11+ export const interactive = async < T = InteractiveResponse > (
12+ id : string ,
13+ type : LiteralUnion < 'STORY' > ,
14+ trigger : LiteralUnion < 'user' > = 'user'
15+ ) =>
16+ toResponse < T > (
17+ request . post ( '1.0/mediaMeta/interactive' , {
18+ searchParams : {
19+ id,
20+ type,
21+ trigger,
22+ } ,
23+ } )
24+ )
Original file line number Diff line number Diff line change @@ -194,3 +194,7 @@ export namespace Stories {
194194 data : Story [ ]
195195 }
196196}
197+
198+ export interface InteractiveResponse {
199+ url : string
200+ }
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ export * from './post'
55export * from './profile'
66export * from './topic'
77export * from './user'
8+ export * from './story'
Original file line number Diff line number Diff line change 1- import type { CommonImage } from './common'
21import type { Topic } from './topic'
32import type {
43 Picture ,
@@ -8,7 +7,6 @@ import type {
87 UrlsInText ,
98} from './post'
109import type { User } from './user'
11- import type { LiteralUnion } from '../../utils/typings'
1210
1311export type PostTypeRaw = 'ORIGINAL_POST' | 'REPOST'
1412export type TargetType = PostTypeRaw | 'STORY'
@@ -162,43 +160,3 @@ export interface RecommendPost {
162160 createdAt : Date
163161 type : string
164162}
165-
166- export interface StoryPicture extends CommonImage {
167- key : string
168- cropperPosX : number
169- cropperPosY : number
170- width : number
171- height : number
172- }
173-
174- export interface StoryVideo {
175- duration : number
176- height : number
177- type : string
178- width : number
179- image : {
180- format : string
181- picUrl : string
182- thumbnailUrl : string
183- }
184- }
185-
186- export interface Story {
187- type : 'STORY'
188- id : string
189- storyType : LiteralUnion < 'PICTURE' | 'VIDEO' >
190- status : LiteralUnion < 'PUBLIC' >
191- user : User
192- emoji ?: string
193- video ?: StoryVideo
194- thumbnailVideo ?: StoryVideo
195- picture ?: StoryPicture
196- liked : boolean
197- likeCount : number
198- commentCount : number
199- viewerCount : number
200- createdAt : string
201- likedUsers : User [ ]
202- enablePictureComments : boolean
203- isFeatured : boolean
204- }
Original file line number Diff line number Diff line change 1+ import type { CommonImage } from './common'
2+ import type { LiteralUnion } from '../../utils/typings'
3+ import type { User } from './user'
4+
5+ export interface StoryPicture extends CommonImage {
6+ key : string
7+ cropperPosX : number
8+ cropperPosY : number
9+ width : number
10+ height : number
11+ }
12+
13+ export interface StoryVideo {
14+ duration : number
15+ height : number
16+ type : string
17+ width : number
18+ image : {
19+ format : string
20+ picUrl : string
21+ thumbnailUrl : string
22+ }
23+ }
24+
25+ export interface Story {
26+ type : 'STORY'
27+ id : string
28+ storyType : LiteralUnion < 'PICTURE' | 'VIDEO' >
29+ status : LiteralUnion < 'PUBLIC' >
30+ user : User
31+ emoji ?: string
32+ video ?: StoryVideo
33+ thumbnailVideo ?: StoryVideo
34+ picture : StoryPicture
35+ liked : boolean
36+ likeCount : number
37+ commentCount : number
38+ viewerCount : number
39+ createdAt : string
40+ likedUsers : User [ ]
41+ enablePictureComments : boolean
42+ isFeatured : boolean
43+ }
Original file line number Diff line number Diff line change @@ -16,4 +16,13 @@ describe('stories should work', () => {
1616 )
1717 expect ( isSuccess ( result ) ) . toBe ( true )
1818 } )
19+
20+ it ( 'getVideo should word' , async ( ) => {
21+ const result = await api . mediaMeta . interactive (
22+ '627fcab1d505530011e9c7c4' ,
23+ 'STORY' ,
24+ 'user'
25+ )
26+ expect ( isSuccess ( result ) ) . toBe ( true )
27+ } )
1928} )
Original file line number Diff line number Diff line change 99 " src/api/users.ts" ,
1010 " src/api/comments.ts" ,
1111 " src/api/upload.ts" ,
12- " src/api/stories.ts"
12+ " src/api/stories.ts" ,
13+ " src/api/media-meta.ts"
1314 ],
1415 "out" : " docs" ,
1516 "name" : " Ⓙ Jike SDK" ,
You can’t perform that action at this time.
0 commit comments