@mx-space/api-client 1.12.0 → 1.13.0
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.
- package/controllers/ack.ts +2 -4
- package/controllers/activity.ts +6 -2
- package/controllers/aggregate.ts +3 -4
- package/controllers/ai.ts +2 -3
- package/controllers/base.ts +1 -2
- package/controllers/category.ts +4 -6
- package/controllers/comment.ts +1 -2
- package/controllers/link.ts +2 -4
- package/controllers/note.ts +1 -2
- package/controllers/page.ts +1 -2
- package/controllers/post.ts +1 -2
- package/controllers/project.ts +2 -4
- package/controllers/recently.ts +1 -2
- package/controllers/say.ts +2 -4
- package/controllers/search.ts +1 -2
- package/controllers/severless.ts +1 -2
- package/controllers/snippet.ts +1 -2
- package/controllers/subscribe.ts +1 -2
- package/controllers/topic.ts +2 -4
- package/controllers/user.ts +3 -4
- package/dist/adapter-4fDtRx9o.d.cts +23 -0
- package/dist/adapter-4fDtRx9o.d.ts +23 -0
- package/dist/adaptors/axios.d.cts +1 -1
- package/dist/adaptors/axios.d.ts +1 -1
- package/dist/adaptors/fetch.d.cts +1 -1
- package/dist/adaptors/fetch.d.ts +1 -1
- package/dist/adaptors/umi-request.d.cts +1 -1
- package/dist/adaptors/umi-request.d.ts +1 -1
- package/dist/index.cjs +14 -11
- package/dist/index.d.cts +60 -31
- package/dist/index.d.ts +60 -31
- package/dist/index.global.js +14 -11
- package/dist/index.js +14 -11
- package/esm/packages/api-client/adaptors/ky.d.ts +10 -10
- package/esm/packages/api-client/controllers/category.d.ts +1 -1
- package/esm/packages/api-client/controllers/link.d.ts +1 -1
- package/esm/packages/api-client/controllers/project.d.ts +1 -1
- package/esm/packages/api-client/controllers/say.d.ts +1 -1
- package/esm/packages/api-client/controllers/topic.d.ts +1 -1
- package/esm/packages/api-client/interfaces/adapter.d.ts +5 -5
- package/esm/packages/api-client/interfaces/request.d.ts +7 -7
- package/interfaces/adapter.ts +10 -10
- package/interfaces/request.ts +26 -26
- package/models/activity.ts +30 -0
- package/models/comment.ts +1 -2
- package/package.json +2 -2
- package/tsup.config.ts +2 -2
- package/dist/adapter-29diOMCR.d.cts +0 -23
- package/dist/adapter-29diOMCR.d.ts +0 -23
package/controllers/ack.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
2
|
+
import type { HTTPClient } from '../core'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { IController } from '~/interfaces/controller'
|
|
3
5
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
6
|
|
|
5
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
6
|
-
|
|
7
|
-
import { HTTPClient } from '../core'
|
|
8
|
-
|
|
9
7
|
declare module '../core/client' {
|
|
10
8
|
interface HTTPClient<
|
|
11
9
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/activity.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type {
|
|
5
6
|
ActivityPresence,
|
|
7
|
+
LastYearPublication,
|
|
6
8
|
RecentActivities,
|
|
7
9
|
RoomsData,
|
|
8
10
|
} from '~/models/activity'
|
|
9
11
|
import type { HTTPClient } from '../core'
|
|
10
12
|
|
|
11
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
12
|
-
|
|
13
13
|
declare module '../core/client' {
|
|
14
14
|
interface HTTPClient<
|
|
15
15
|
T extends IRequestAdapter = IRequestAdapter,
|
|
@@ -95,4 +95,8 @@ export class ActivityController<ResponseWrapper> implements IController {
|
|
|
95
95
|
async getRecentActivities() {
|
|
96
96
|
return this.proxy.recent.get<RecentActivities>()
|
|
97
97
|
}
|
|
98
|
+
|
|
99
|
+
async getLastYearPublication(): Promise<LastYearPublication> {
|
|
100
|
+
return this.proxy(`last-year`).publication.get<LastYearPublication>()
|
|
101
|
+
}
|
|
98
102
|
}
|
package/controllers/aggregate.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { sortOrderToNumber } from '~/utils'
|
|
2
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { IController } from '~/interfaces/controller'
|
|
3
5
|
import type { SortOrder } from '~/interfaces/options'
|
|
@@ -10,10 +12,7 @@ import type {
|
|
|
10
12
|
TimelineType,
|
|
11
13
|
} from '~/models/aggregate'
|
|
12
14
|
|
|
13
|
-
import {
|
|
14
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
15
|
-
|
|
16
|
-
import { HTTPClient } from '../core'
|
|
15
|
+
import type { HTTPClient } from '../core'
|
|
17
16
|
|
|
18
17
|
declare module '../core/client' {
|
|
19
18
|
interface HTTPClient<
|
package/controllers/ai.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { HTTPClient } from '../core'
|
|
5
6
|
import type { AISummaryModel } from '../models/ai'
|
|
6
7
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
8
|
declare module '../core/client' {
|
|
10
9
|
interface HTTPClient<
|
|
11
10
|
T extends IRequestAdapter = IRequestAdapter,
|
|
@@ -48,7 +47,7 @@ export class AIController<ResponseWrapper> implements IController {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
async generateSummary(articleId: string, lang = 'zh-CN', token = '') {
|
|
51
|
-
return this.proxy
|
|
50
|
+
return this.proxy.summaries.generate.post<AISummaryModel>({
|
|
52
51
|
params: {
|
|
53
52
|
token,
|
|
54
53
|
},
|
package/controllers/base.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|
2
3
|
import type { PaginateResult } from '~/models/base'
|
|
3
4
|
import type { HTTPClient } from '../core'
|
|
4
5
|
|
|
5
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
6
|
-
|
|
7
6
|
export type SortOptions = {
|
|
8
7
|
sortBy?: string
|
|
9
8
|
sortOrder?: 1 | -1 | 'asc' | 'desc'
|
package/controllers/category.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { attachRawFromOneToAnthor, destructureData } from '~/utils'
|
|
2
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
3
|
+
import { RequestError } from '../core/error'
|
|
4
|
+
import { CategoryType } from '../models/category'
|
|
1
5
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
6
|
import type { IController } from '~/interfaces/controller'
|
|
3
7
|
import type {
|
|
@@ -14,12 +18,6 @@ import type {
|
|
|
14
18
|
} from '../models/category'
|
|
15
19
|
import type { PostModel } from '../models/post'
|
|
16
20
|
|
|
17
|
-
import { attachRawFromOneToAnthor, destructureData } from '~/utils'
|
|
18
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
19
|
-
|
|
20
|
-
import { RequestError } from '../core/error'
|
|
21
|
-
import { CategoryType } from '../models/category'
|
|
22
|
-
|
|
23
21
|
declare module '../core/client' {
|
|
24
22
|
interface HTTPClient<
|
|
25
23
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/comment.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { PaginationParams } from '~/interfaces/params'
|
|
@@ -7,8 +8,6 @@ import type { CommentModel } from '~/models/comment'
|
|
|
7
8
|
import type { HTTPClient } from '../core'
|
|
8
9
|
import type { CommentDto } from '../dtos/comment'
|
|
9
10
|
|
|
10
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
11
|
-
|
|
12
11
|
declare module '../core/client' {
|
|
13
12
|
interface HTTPClient<
|
|
14
13
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/link.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
2
|
+
import { BaseCrudController } from './base'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { LinkModel } from '~/models/link'
|
|
3
5
|
import type { HTTPClient } from '../core'
|
|
4
6
|
|
|
5
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
6
|
-
|
|
7
|
-
import { BaseCrudController } from './base'
|
|
8
|
-
|
|
9
7
|
declare module '../core/client' {
|
|
10
8
|
interface HTTPClient<
|
|
11
9
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/note.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|
@@ -11,8 +12,6 @@ import type {
|
|
|
11
12
|
import type { HTTPClient } from '../core/client'
|
|
12
13
|
import type { SortOptions } from './base'
|
|
13
14
|
|
|
14
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
15
|
-
|
|
16
15
|
declare module '../core/client' {
|
|
17
16
|
interface HTTPClient<
|
|
18
17
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/page.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
@@ -6,8 +7,6 @@ import type { PaginateResult } from '~/models/base'
|
|
|
6
7
|
import type { PageModel } from '~/models/page'
|
|
7
8
|
import type { HTTPClient } from '../core'
|
|
8
9
|
|
|
9
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
10
|
-
|
|
11
10
|
declare module '../core/client' {
|
|
12
11
|
interface HTTPClient<
|
|
13
12
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/post.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|
@@ -6,8 +7,6 @@ import type { ModelWithLiked, PaginateResult } from '~/models/base'
|
|
|
6
7
|
import type { PostModel } from '~/models/post'
|
|
7
8
|
import type { HTTPClient } from '../core/client'
|
|
8
9
|
|
|
9
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
10
|
-
|
|
11
10
|
declare module '../core/client' {
|
|
12
11
|
interface HTTPClient<
|
|
13
12
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/project.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
2
|
+
import { BaseCrudController } from './base'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { ProjectModel } from '~/models/project'
|
|
3
5
|
import type { HTTPClient } from '../core'
|
|
4
6
|
|
|
5
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
6
|
-
|
|
7
|
-
import { BaseCrudController } from './base'
|
|
8
|
-
|
|
9
7
|
declare module '../core/client' {
|
|
10
8
|
interface HTTPClient<
|
|
11
9
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/recently.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { RecentlyModel } from '~/models/recently'
|
|
5
6
|
import type { HTTPClient } from '../core'
|
|
6
7
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
8
|
declare module '../core/client' {
|
|
10
9
|
interface HTTPClient<
|
|
11
10
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/say.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
2
|
+
import { BaseCrudController } from './base'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { IController } from '~/interfaces/controller'
|
|
3
5
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
6
|
import type { SayModel } from '~/models/say'
|
|
5
7
|
import type { HTTPClient } from '../core'
|
|
6
8
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
|
-
import { BaseCrudController } from './base'
|
|
10
|
-
|
|
11
9
|
declare module '../core/client' {
|
|
12
10
|
interface HTTPClient<
|
|
13
11
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/search.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler, RequestProxyResult } from '~/interfaces/request'
|
|
@@ -7,8 +8,6 @@ import type { PostModel } from '~/models/post'
|
|
|
7
8
|
import type { PageModel } from '..'
|
|
8
9
|
import type { HTTPClient } from '../core'
|
|
9
10
|
|
|
10
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
11
|
-
|
|
12
11
|
declare module '../core/client' {
|
|
13
12
|
interface HTTPClient<
|
|
14
13
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/severless.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { HTTPClient } from '../core'
|
|
5
6
|
|
|
6
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
7
|
-
|
|
8
7
|
declare module '../core/client' {
|
|
9
8
|
interface HTTPClient<
|
|
10
9
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/snippet.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { HTTPClient } from '../core'
|
|
5
6
|
|
|
6
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
7
|
-
|
|
8
7
|
declare module '../core/client' {
|
|
9
8
|
interface HTTPClient<
|
|
10
9
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/subscribe.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { SubscribeType } from '~/models/subscribe'
|
|
5
6
|
import type { HTTPClient } from '../core'
|
|
6
7
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
8
|
declare module '../core/client' {
|
|
10
9
|
interface HTTPClient<
|
|
11
10
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/topic.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
2
|
+
import { BaseCrudController } from './base'
|
|
1
3
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
4
|
import type { IController } from '~/interfaces/controller'
|
|
3
5
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
6
|
import type { TopicModel } from '~/models/topic'
|
|
5
7
|
import type { HTTPClient } from '../core'
|
|
6
8
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
|
-
import { BaseCrudController } from './base'
|
|
10
|
-
|
|
11
9
|
declare module '../core/client' {
|
|
12
10
|
interface HTTPClient<
|
|
13
11
|
T extends IRequestAdapter = IRequestAdapter,
|
package/controllers/user.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { autoBind } from '~/utils/auto-bind'
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter'
|
|
2
3
|
import type { IController } from '~/interfaces/controller'
|
|
3
4
|
import type { IRequestHandler } from '~/interfaces/request'
|
|
4
5
|
import type { TLogin, UserModel } from '~/models/user'
|
|
5
6
|
import type { HTTPClient } from '../core'
|
|
6
7
|
|
|
7
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
8
|
-
|
|
9
8
|
declare module '../core/client' {
|
|
10
9
|
interface HTTPClient<
|
|
11
10
|
T extends IRequestAdapter = IRequestAdapter,
|
|
@@ -46,7 +45,7 @@ export class UserController<ResponseWrapper> implements IController {
|
|
|
46
45
|
return this.proxy.login.put<{ token: string }>({
|
|
47
46
|
params: token
|
|
48
47
|
? {
|
|
49
|
-
token: `bearer ${token.replace(/^
|
|
48
|
+
token: `bearer ${token.replace(/^bearer\s/i, '')}`,
|
|
50
49
|
}
|
|
51
50
|
: undefined,
|
|
52
51
|
})
|
|
@@ -55,7 +54,7 @@ export class UserController<ResponseWrapper> implements IController {
|
|
|
55
54
|
checkTokenValid(token: string) {
|
|
56
55
|
return this.proxy.check_logged.get<{ ok: number; isGuest: boolean }>({
|
|
57
56
|
params: {
|
|
58
|
-
token: `bearer ${token.replace(/^
|
|
57
|
+
token: `bearer ${token.replace(/^bearer\s/i, '')}`,
|
|
59
58
|
},
|
|
60
59
|
})
|
|
61
60
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface RequestOptions {
|
|
2
|
+
method?: string;
|
|
3
|
+
data?: Record<string, any>;
|
|
4
|
+
params?: Record<string, any> | URLSearchParams;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type IAdaptorRequestResponseType<P> = Promise<Record<string, any> & {
|
|
10
|
+
data: P;
|
|
11
|
+
}>;
|
|
12
|
+
type IRequestAdapter<T = any, Response = undefined> = Readonly<(Response extends undefined ? {} : {
|
|
13
|
+
responseWrapper: Response;
|
|
14
|
+
}) & {
|
|
15
|
+
default: T;
|
|
16
|
+
get: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
17
|
+
post: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
18
|
+
patch: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
19
|
+
delete: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
20
|
+
put: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
export type { IRequestAdapter as I, RequestOptions as R, IAdaptorRequestResponseType as a };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface RequestOptions {
|
|
2
|
+
method?: string;
|
|
3
|
+
data?: Record<string, any>;
|
|
4
|
+
params?: Record<string, any> | URLSearchParams;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type IAdaptorRequestResponseType<P> = Promise<Record<string, any> & {
|
|
10
|
+
data: P;
|
|
11
|
+
}>;
|
|
12
|
+
type IRequestAdapter<T = any, Response = undefined> = Readonly<(Response extends undefined ? {} : {
|
|
13
|
+
responseWrapper: Response;
|
|
14
|
+
}) & {
|
|
15
|
+
default: T;
|
|
16
|
+
get: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
17
|
+
post: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
18
|
+
patch: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
19
|
+
delete: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
20
|
+
put: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
export type { IRequestAdapter as I, RequestOptions as R, IAdaptorRequestResponseType as a };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IRequestAdapter } from '../adapter-
|
|
1
|
+
import { I as IRequestAdapter } from '../adapter-4fDtRx9o.cjs';
|
|
2
2
|
import { AxiosInstance, AxiosResponse } from 'axios';
|
|
3
3
|
|
|
4
4
|
declare const axiosAdaptor: IRequestAdapter<AxiosInstance, AxiosResponse<unknown>>;
|
package/dist/adaptors/axios.d.ts
CHANGED
package/dist/adaptors/fetch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IRequestAdapter } from '../adapter-
|
|
1
|
+
import { I as IRequestAdapter } from '../adapter-4fDtRx9o.cjs';
|
|
2
2
|
import { RequestMethod, RequestResponse } from 'umi-request';
|
|
3
3
|
|
|
4
4
|
declare const umiAdaptor: IRequestAdapter<RequestMethod<true>, RequestResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as IRequestAdapter } from '../adapter-
|
|
1
|
+
import { I as IRequestAdapter } from '../adapter-4fDtRx9o.js';
|
|
2
2
|
import { RequestMethod, RequestResponse } from 'umi-request';
|
|
3
3
|
|
|
4
4
|
declare const umiAdaptor: IRequestAdapter<RequestMethod<true>, RequestResponse>;
|
package/dist/index.cjs
CHANGED
|
@@ -120,11 +120,11 @@ var camelcaseKeys = (obj) => {
|
|
|
120
120
|
return obj;
|
|
121
121
|
};
|
|
122
122
|
function camelcase(str) {
|
|
123
|
-
return str.replace(/^_+/, "").
|
|
123
|
+
return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
|
|
124
124
|
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
var isMongoId = (id) => id.length === 24 && /^[
|
|
127
|
+
var isMongoId = (id) => id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id);
|
|
128
128
|
|
|
129
129
|
// utils/path.ts
|
|
130
130
|
var resolveFullPath = (endpoint, path) => {
|
|
@@ -250,6 +250,9 @@ var ActivityController = class {
|
|
|
250
250
|
async getRecentActivities() {
|
|
251
251
|
return this.proxy.recent.get();
|
|
252
252
|
}
|
|
253
|
+
async getLastYearPublication() {
|
|
254
|
+
return this.proxy(`last-year`).publication.get();
|
|
255
|
+
}
|
|
253
256
|
};
|
|
254
257
|
|
|
255
258
|
// controllers/aggregate.ts
|
|
@@ -321,7 +324,7 @@ var AIController = class {
|
|
|
321
324
|
});
|
|
322
325
|
}
|
|
323
326
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
324
|
-
return this.proxy
|
|
327
|
+
return this.proxy.summaries.generate.post({
|
|
325
328
|
params: {
|
|
326
329
|
token
|
|
327
330
|
},
|
|
@@ -892,14 +895,14 @@ var UserController = class {
|
|
|
892
895
|
loginWithToken(token) {
|
|
893
896
|
return this.proxy.login.put({
|
|
894
897
|
params: token ? {
|
|
895
|
-
token: `bearer ${token.replace(/^
|
|
898
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
896
899
|
} : void 0
|
|
897
900
|
});
|
|
898
901
|
}
|
|
899
902
|
checkTokenValid(token) {
|
|
900
903
|
return this.proxy.check_logged.get({
|
|
901
904
|
params: {
|
|
902
|
-
token: `bearer ${token.replace(/^
|
|
905
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
903
906
|
}
|
|
904
907
|
});
|
|
905
908
|
}
|
|
@@ -1094,15 +1097,15 @@ var HTTPClient = class {
|
|
|
1094
1097
|
...options,
|
|
1095
1098
|
url
|
|
1096
1099
|
});
|
|
1097
|
-
} catch (
|
|
1098
|
-
let message =
|
|
1099
|
-
let code =
|
|
1100
|
+
} catch (error) {
|
|
1101
|
+
let message = error.message;
|
|
1102
|
+
let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
|
|
1100
1103
|
if (that.options.getCodeMessageFromException) {
|
|
1101
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1104
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1102
1105
|
message = errorInfo.message || message;
|
|
1103
1106
|
code = errorInfo.code || code;
|
|
1104
1107
|
}
|
|
1105
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1108
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1106
1109
|
}
|
|
1107
1110
|
const data = that.options.getDataFromResponse(res);
|
|
1108
1111
|
if (!data) {
|
|
@@ -1235,7 +1238,7 @@ var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
|
|
|
1235
1238
|
})(SnippetType || {});
|
|
1236
1239
|
|
|
1237
1240
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1238
|
-
var SubscribePostCreateBit = 1
|
|
1241
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1239
1242
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1240
1243
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1241
1244
|
var SubscribeRecentCreateBit = 1 << 3;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestOptions, I as IRequestAdapter, a as IAdaptorRequestResponseType } from './adapter-
|
|
1
|
+
import { R as RequestOptions, I as IRequestAdapter, a as IAdaptorRequestResponseType } from './adapter-4fDtRx9o.cjs';
|
|
2
2
|
|
|
3
3
|
interface IController {
|
|
4
4
|
base: string;
|
|
@@ -29,13 +29,13 @@ type NoStringIndex<T> = {
|
|
|
29
29
|
};
|
|
30
30
|
interface IRequestHandler<ResponseWrapper> {
|
|
31
31
|
(path?: string | number): IRequestHandler<ResponseWrapper>;
|
|
32
|
-
get<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
33
|
-
post<P = unknown>(options?: RequestOptions)
|
|
34
|
-
patch<P = unknown>(options?: RequestOptions)
|
|
35
|
-
delete<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
36
|
-
put<P = unknown>(options?: RequestOptions)
|
|
37
|
-
toString(withBase?: boolean)
|
|
38
|
-
valueOf(withBase?: boolean)
|
|
32
|
+
get: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
33
|
+
post: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
34
|
+
patch: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
35
|
+
delete: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
36
|
+
put: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
37
|
+
toString: (withBase?: boolean) => string;
|
|
38
|
+
valueOf: (withBase?: boolean) => string;
|
|
39
39
|
[key: string]: IRequestHandler<ResponseWrapper>;
|
|
40
40
|
}
|
|
41
41
|
type RequestProxyResult<T, ResponseWrapper, R = ResponseWrapper extends unknown ? {
|
|
@@ -294,6 +294,34 @@ interface RecentRecent {
|
|
|
294
294
|
down: number;
|
|
295
295
|
created: string;
|
|
296
296
|
}
|
|
297
|
+
interface LastYearPublication {
|
|
298
|
+
posts: PostsItem[];
|
|
299
|
+
notes: NotesItem[];
|
|
300
|
+
}
|
|
301
|
+
interface PostsItem {
|
|
302
|
+
id: string;
|
|
303
|
+
created: string;
|
|
304
|
+
title: string;
|
|
305
|
+
slug: string;
|
|
306
|
+
categoryId: string;
|
|
307
|
+
category: Category;
|
|
308
|
+
}
|
|
309
|
+
interface Category {
|
|
310
|
+
id: string;
|
|
311
|
+
type: number;
|
|
312
|
+
name: string;
|
|
313
|
+
slug: string;
|
|
314
|
+
created: string;
|
|
315
|
+
}
|
|
316
|
+
interface NotesItem {
|
|
317
|
+
id: string;
|
|
318
|
+
created: string;
|
|
319
|
+
title: string;
|
|
320
|
+
mood: string;
|
|
321
|
+
weather: string;
|
|
322
|
+
nid: number;
|
|
323
|
+
bookmark: boolean;
|
|
324
|
+
}
|
|
297
325
|
|
|
298
326
|
declare module '../core/client' {
|
|
299
327
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
@@ -420,6 +448,7 @@ declare class ActivityController<ResponseWrapper> implements IController {
|
|
|
420
448
|
};
|
|
421
449
|
$serialized: RecentActivities;
|
|
422
450
|
}>;
|
|
451
|
+
getLastYearPublication(): Promise<LastYearPublication>;
|
|
423
452
|
}
|
|
424
453
|
|
|
425
454
|
type SortOrder = 'asc' | 'desc';
|
|
@@ -1025,28 +1054,6 @@ declare class CommentController<ResponseWrapper> implements IController {
|
|
|
1025
1054
|
}>;
|
|
1026
1055
|
}
|
|
1027
1056
|
|
|
1028
|
-
declare enum LinkType {
|
|
1029
|
-
Friend = 0,
|
|
1030
|
-
Collection = 1
|
|
1031
|
-
}
|
|
1032
|
-
declare enum LinkState {
|
|
1033
|
-
Pass = 0,
|
|
1034
|
-
Audit = 1,
|
|
1035
|
-
Outdate = 2,
|
|
1036
|
-
Banned = 3,
|
|
1037
|
-
Reject = 4
|
|
1038
|
-
}
|
|
1039
|
-
interface LinkModel extends BaseModel {
|
|
1040
|
-
name: string;
|
|
1041
|
-
url: string;
|
|
1042
|
-
avatar: string;
|
|
1043
|
-
description?: string;
|
|
1044
|
-
type: LinkType;
|
|
1045
|
-
state: LinkState;
|
|
1046
|
-
hide: boolean;
|
|
1047
|
-
email: string;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
1057
|
type SortOptions = {
|
|
1051
1058
|
sortBy?: string;
|
|
1052
1059
|
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
@@ -1088,6 +1095,28 @@ declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
|
1088
1095
|
}>;
|
|
1089
1096
|
}
|
|
1090
1097
|
|
|
1098
|
+
declare enum LinkType {
|
|
1099
|
+
Friend = 0,
|
|
1100
|
+
Collection = 1
|
|
1101
|
+
}
|
|
1102
|
+
declare enum LinkState {
|
|
1103
|
+
Pass = 0,
|
|
1104
|
+
Audit = 1,
|
|
1105
|
+
Outdate = 2,
|
|
1106
|
+
Banned = 3,
|
|
1107
|
+
Reject = 4
|
|
1108
|
+
}
|
|
1109
|
+
interface LinkModel extends BaseModel {
|
|
1110
|
+
name: string;
|
|
1111
|
+
url: string;
|
|
1112
|
+
avatar: string;
|
|
1113
|
+
description?: string;
|
|
1114
|
+
type: LinkType;
|
|
1115
|
+
state: LinkState;
|
|
1116
|
+
hide: boolean;
|
|
1117
|
+
email: string;
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1091
1120
|
declare module '../core/client' {
|
|
1092
1121
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1093
1122
|
link: LinkController<ResponseWrapper>;
|
|
@@ -1826,4 +1855,4 @@ interface SnippetModel<T = unknown> extends BaseModel {
|
|
|
1826
1855
|
*/
|
|
1827
1856
|
declare const camelcaseKeys: <T = any>(obj: any) => T;
|
|
1828
1857
|
|
|
1829
|
-
export { AIController, type AISummaryModel, AckController, ActivityController, type ActivityPresence, AdminExtraModel, AggregateController, type AggregateRoot, type AggregateRootWithTheme, type AggregateStat, type AggregateTop, type AggregateTopNote, type AggregateTopPost, AlgoliaSearchOptionsModel, BackupOptionsModel, BaiduSearchOptionsModel, type BaseCommentIndexModel, type BaseModel, CategoryController, type CategoryEntries, type CategoryModel, CategoryType, type CategoryWithChildrenModel, CollectionRefTypes, CommentController, type CommentDto, type CommentModel, CommentOptionsModel, type CommentRef, CommentState, type Coordinate, type Count, EnumPageType, HTTPClient, type IConfig, type IConfigKeys, IRequestAdapter, type Image, LinkController, type LinkModel, LinkState, LinkType, MailOptionsModel, type ModelWithLiked, NoteController, type NoteModel, type NoteWrappedPayload, type NoteWrappedWithLikedPayload, PageController, type PageModel, type Pager, type PaginateResult, PostController, type PostModel, ProjectController, type ProjectModel, type RecentActivities, type RecentComment, type RecentLike, type RecentNote, type RecentPost, type RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, type RecentlyModel, type RecentlyRefType, RecentlyRefTypes, RequestError, type RoomOmittedNote, type RoomOmittedPage, type RoomOmittedPost, type RoomsData, SayController, type SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, type SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, type SubscribeType, SubscribeTypeToBitMap, type TLogin, type TagModel, type TextBaseModel, type TimelineData, TimelineType, TopicController, type TopicModel, type Url, UrlOptionModel, UserController, type UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
|
|
1858
|
+
export { AIController, type AISummaryModel, AckController, ActivityController, type ActivityPresence, AdminExtraModel, AggregateController, type AggregateRoot, type AggregateRootWithTheme, type AggregateStat, type AggregateTop, type AggregateTopNote, type AggregateTopPost, AlgoliaSearchOptionsModel, BackupOptionsModel, BaiduSearchOptionsModel, type BaseCommentIndexModel, type BaseModel, CategoryController, type CategoryEntries, type CategoryModel, CategoryType, type CategoryWithChildrenModel, CollectionRefTypes, CommentController, type CommentDto, type CommentModel, CommentOptionsModel, type CommentRef, CommentState, type Coordinate, type Count, EnumPageType, HTTPClient, type IConfig, type IConfigKeys, IRequestAdapter, type Image, type LastYearPublication, LinkController, type LinkModel, LinkState, LinkType, MailOptionsModel, type ModelWithLiked, NoteController, type NoteModel, type NoteWrappedPayload, type NoteWrappedWithLikedPayload, PageController, type PageModel, type Pager, type PaginateResult, PostController, type PostModel, ProjectController, type ProjectModel, type RecentActivities, type RecentComment, type RecentLike, type RecentNote, type RecentPost, type RecentRecent, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, type RecentlyModel, type RecentlyRefType, RecentlyRefTypes, RequestError, type RoomOmittedNote, type RoomOmittedPage, type RoomOmittedPost, type RoomsData, SayController, type SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, type SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, type SubscribeType, SubscribeTypeToBitMap, type TLogin, type TagModel, type TextBaseModel, type TimelineData, TimelineType, TopicController, type TopicModel, type Url, UrlOptionModel, UserController, type UserModel, allControllerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
|