@mx-space/api-client 1.5.1 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ import type { IRequestAdapter } from '~/interfaces/adapter'
2
+ import type { IController } from '~/interfaces/controller'
3
+ import type { IRequestHandler } from '~/interfaces/request'
4
+
5
+ import { autoBind } from '~/utils/auto-bind'
6
+
7
+ import { HTTPClient } from '../core'
8
+
9
+ declare module '../core/client' {
10
+ interface HTTPClient<
11
+ T extends IRequestAdapter = IRequestAdapter,
12
+ ResponseWrapper = unknown,
13
+ > {
14
+ ack: AckController<ResponseWrapper>
15
+ }
16
+ }
17
+
18
+ /**
19
+ * @support core >= 4.4.0
20
+ */
21
+ export class AckController<ResponseWrapper> implements IController {
22
+ base = 'ack'
23
+ name = 'ack'
24
+
25
+ constructor(private client: HTTPClient) {
26
+ autoBind(this)
27
+ }
28
+
29
+ public get proxy(): IRequestHandler<ResponseWrapper> {
30
+ return this.client.proxy(this.base)
31
+ }
32
+
33
+ read(type: 'post' | 'note', id: string) {
34
+ return this.proxy.ack.post<never>({
35
+ data: {
36
+ type: 'read',
37
+ payload: {
38
+ type,
39
+ id,
40
+ },
41
+ },
42
+ })
43
+ }
44
+ }
@@ -1,3 +1,4 @@
1
+ import { AckController } from './ack'
1
2
  import { ActivityController } from './activity'
2
3
  import { AggregateController } from './aggregate'
3
4
  import { CategoryController } from './category'
@@ -21,6 +22,7 @@ import { TopicController } from './topic'
21
22
  import { UserController } from './user'
22
23
 
23
24
  export const allControllers = [
25
+ AckController,
24
26
  ActivityController,
25
27
  AggregateController,
26
28
  CategoryController,
@@ -40,7 +42,8 @@ export const allControllers = [
40
42
  UserController,
41
43
  ]
42
44
 
43
- export const allContollerNames = [
45
+ export const allControllerNames = [
46
+ 'ack',
44
47
  'activity',
45
48
  'aggregate',
46
49
  'category',
@@ -66,6 +69,7 @@ export const allContollerNames = [
66
69
  ] as const
67
70
 
68
71
  export {
72
+ AckController,
69
73
  ActivityController,
70
74
  AggregateController,
71
75
  CategoryController,
@@ -8,11 +8,12 @@ import type {
8
8
  NoteWrappedPayload,
9
9
  NoteWrappedWithLikedPayload,
10
10
  } from '~/models/note'
11
- import type { HTTPClient } from '../core/client'
12
11
  import type { SortOptions } from './base'
13
12
 
14
13
  import { autoBind } from '~/utils/auto-bind'
15
14
 
15
+ import { HTTPClient } from '../core/client'
16
+
16
17
  declare module '../core/client' {
17
18
  interface HTTPClient<
18
19
  T extends IRequestAdapter = IRequestAdapter,
@@ -110,13 +111,6 @@ export class NoteController<ResponseWrapper> implements IController {
110
111
  })
111
112
  }
112
113
 
113
- /**
114
- * 喜欢这篇日记
115
- */
116
- likeIt(id: string | number) {
117
- return this.proxy.like(id).get<never>()
118
- }
119
-
120
114
  /**
121
115
  * 获取专栏内的所有日记
122
116
  */
@@ -4,10 +4,11 @@ import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
4
4
  import type { SelectFields } from '~/interfaces/types'
5
5
  import type { ModelWithLiked, PaginateResult } from '~/models/base'
6
6
  import type { PostModel } from '~/models/post'
7
- import type { HTTPClient } from '../core/client'
8
7
 
9
8
  import { autoBind } from '~/utils/auto-bind'
10
9
 
10
+ import { HTTPClient } from '../core/client'
11
+
11
12
  declare module '../core/client' {
12
13
  interface HTTPClient<
13
14
  T extends IRequestAdapter = IRequestAdapter,
@@ -85,11 +86,4 @@ export class PostController<ResponseWrapper> implements IController {
85
86
  getLatest() {
86
87
  return this.proxy.latest.get<ModelWithLiked<PostModel>>()
87
88
  }
88
-
89
- /**
90
- * 点赞
91
- */
92
- thumbsUp(id: string) {
93
- return this.proxy('_thumbs-up').get<void>({ params: { id } })
94
- }
95
89
  }