@mx-space/api-client 1.12.1 → 1.13.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.
- package/controllers/ack.ts +2 -4
- package/controllers/activity.ts +1 -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 +12 -12
- package/dist/index.d.cts +30 -30
- package/dist/index.d.ts +30 -30
- package/dist/index.global.js +12 -12
- package/dist/index.js +12 -12
- 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/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,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'
|
|
@@ -9,8 +10,6 @@ import type {
|
|
|
9
10
|
} from '~/models/activity'
|
|
10
11
|
import type { HTTPClient } from '../core'
|
|
11
12
|
|
|
12
|
-
import { autoBind } from '~/utils/auto-bind'
|
|
13
|
-
|
|
14
13
|
declare module '../core/client' {
|
|
15
14
|
interface HTTPClient<
|
|
16
15
|
T extends IRequestAdapter = IRequestAdapter,
|
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) => {
|
|
@@ -324,7 +324,7 @@ var AIController = class {
|
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
326
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
327
|
-
return this.proxy
|
|
327
|
+
return this.proxy.summaries.generate.post({
|
|
328
328
|
params: {
|
|
329
329
|
token
|
|
330
330
|
},
|
|
@@ -895,14 +895,14 @@ var UserController = class {
|
|
|
895
895
|
loginWithToken(token) {
|
|
896
896
|
return this.proxy.login.put({
|
|
897
897
|
params: token ? {
|
|
898
|
-
token: `bearer ${token.replace(/^
|
|
898
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
899
899
|
} : void 0
|
|
900
900
|
});
|
|
901
901
|
}
|
|
902
902
|
checkTokenValid(token) {
|
|
903
903
|
return this.proxy.check_logged.get({
|
|
904
904
|
params: {
|
|
905
|
-
token: `bearer ${token.replace(/^
|
|
905
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
906
906
|
}
|
|
907
907
|
});
|
|
908
908
|
}
|
|
@@ -1097,15 +1097,15 @@ var HTTPClient = class {
|
|
|
1097
1097
|
...options,
|
|
1098
1098
|
url
|
|
1099
1099
|
});
|
|
1100
|
-
} catch (
|
|
1101
|
-
let message =
|
|
1102
|
-
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;
|
|
1103
1103
|
if (that.options.getCodeMessageFromException) {
|
|
1104
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1104
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1105
1105
|
message = errorInfo.message || message;
|
|
1106
1106
|
code = errorInfo.code || code;
|
|
1107
1107
|
}
|
|
1108
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1108
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1109
1109
|
}
|
|
1110
1110
|
const data = that.options.getDataFromResponse(res);
|
|
1111
1111
|
if (!data) {
|
|
@@ -1114,7 +1114,7 @@ var HTTPClient = class {
|
|
|
1114
1114
|
const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
|
|
1115
1115
|
let nextObject = cameledObject;
|
|
1116
1116
|
if (cameledObject && typeof cameledObject === "object") {
|
|
1117
|
-
nextObject = { ...cameledObject };
|
|
1117
|
+
nextObject = Array.isArray(cameledObject) ? [...cameledObject] : { ...cameledObject };
|
|
1118
1118
|
Object.defineProperty(nextObject, "$raw", {
|
|
1119
1119
|
get() {
|
|
1120
1120
|
return res;
|
|
@@ -1238,7 +1238,7 @@ var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
|
|
|
1238
1238
|
})(SnippetType || {});
|
|
1239
1239
|
|
|
1240
1240
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1241
|
-
var SubscribePostCreateBit = 1
|
|
1241
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1242
1242
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1243
1243
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1244
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 ? {
|
|
@@ -1054,28 +1054,6 @@ declare class CommentController<ResponseWrapper> implements IController {
|
|
|
1054
1054
|
}>;
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
|
-
declare enum LinkType {
|
|
1058
|
-
Friend = 0,
|
|
1059
|
-
Collection = 1
|
|
1060
|
-
}
|
|
1061
|
-
declare enum LinkState {
|
|
1062
|
-
Pass = 0,
|
|
1063
|
-
Audit = 1,
|
|
1064
|
-
Outdate = 2,
|
|
1065
|
-
Banned = 3,
|
|
1066
|
-
Reject = 4
|
|
1067
|
-
}
|
|
1068
|
-
interface LinkModel extends BaseModel {
|
|
1069
|
-
name: string;
|
|
1070
|
-
url: string;
|
|
1071
|
-
avatar: string;
|
|
1072
|
-
description?: string;
|
|
1073
|
-
type: LinkType;
|
|
1074
|
-
state: LinkState;
|
|
1075
|
-
hide: boolean;
|
|
1076
|
-
email: string;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
1057
|
type SortOptions = {
|
|
1080
1058
|
sortBy?: string;
|
|
1081
1059
|
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
@@ -1117,6 +1095,28 @@ declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
|
1117
1095
|
}>;
|
|
1118
1096
|
}
|
|
1119
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
|
+
|
|
1120
1120
|
declare module '../core/client' {
|
|
1121
1121
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1122
1122
|
link: LinkController<ResponseWrapper>;
|
package/dist/index.d.ts
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.js';
|
|
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 ? {
|
|
@@ -1054,28 +1054,6 @@ declare class CommentController<ResponseWrapper> implements IController {
|
|
|
1054
1054
|
}>;
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
|
-
declare enum LinkType {
|
|
1058
|
-
Friend = 0,
|
|
1059
|
-
Collection = 1
|
|
1060
|
-
}
|
|
1061
|
-
declare enum LinkState {
|
|
1062
|
-
Pass = 0,
|
|
1063
|
-
Audit = 1,
|
|
1064
|
-
Outdate = 2,
|
|
1065
|
-
Banned = 3,
|
|
1066
|
-
Reject = 4
|
|
1067
|
-
}
|
|
1068
|
-
interface LinkModel extends BaseModel {
|
|
1069
|
-
name: string;
|
|
1070
|
-
url: string;
|
|
1071
|
-
avatar: string;
|
|
1072
|
-
description?: string;
|
|
1073
|
-
type: LinkType;
|
|
1074
|
-
state: LinkState;
|
|
1075
|
-
hide: boolean;
|
|
1076
|
-
email: string;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
1057
|
type SortOptions = {
|
|
1080
1058
|
sortBy?: string;
|
|
1081
1059
|
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
@@ -1117,6 +1095,28 @@ declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
|
1117
1095
|
}>;
|
|
1118
1096
|
}
|
|
1119
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
|
+
|
|
1120
1120
|
declare module '@mx-space/api-client' {
|
|
1121
1121
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1122
1122
|
link: LinkController<ResponseWrapper>;
|
package/dist/index.global.js
CHANGED
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
return obj;
|
|
56
56
|
};
|
|
57
57
|
function camelcase(str) {
|
|
58
|
-
return str.replace(/^_+/, "").
|
|
58
|
+
return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
|
|
59
59
|
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
var isMongoId = (id) => id.length === 24 && /^[
|
|
62
|
+
var isMongoId = (id) => id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id);
|
|
63
63
|
|
|
64
64
|
// utils/path.ts
|
|
65
65
|
var resolveFullPath = (endpoint, path) => {
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
261
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
262
|
-
return this.proxy
|
|
262
|
+
return this.proxy.summaries.generate.post({
|
|
263
263
|
params: {
|
|
264
264
|
token
|
|
265
265
|
},
|
|
@@ -830,14 +830,14 @@
|
|
|
830
830
|
loginWithToken(token) {
|
|
831
831
|
return this.proxy.login.put({
|
|
832
832
|
params: token ? {
|
|
833
|
-
token: `bearer ${token.replace(/^
|
|
833
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
834
834
|
} : void 0
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
837
|
checkTokenValid(token) {
|
|
838
838
|
return this.proxy.check_logged.get({
|
|
839
839
|
params: {
|
|
840
|
-
token: `bearer ${token.replace(/^
|
|
840
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
}
|
|
@@ -1032,15 +1032,15 @@
|
|
|
1032
1032
|
...options,
|
|
1033
1033
|
url
|
|
1034
1034
|
});
|
|
1035
|
-
} catch (
|
|
1036
|
-
let message =
|
|
1037
|
-
let code =
|
|
1035
|
+
} catch (error) {
|
|
1036
|
+
let message = error.message;
|
|
1037
|
+
let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
|
|
1038
1038
|
if (that.options.getCodeMessageFromException) {
|
|
1039
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1039
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1040
1040
|
message = errorInfo.message || message;
|
|
1041
1041
|
code = errorInfo.code || code;
|
|
1042
1042
|
}
|
|
1043
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1043
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1044
1044
|
}
|
|
1045
1045
|
const data = that.options.getDataFromResponse(res);
|
|
1046
1046
|
if (!data) {
|
|
@@ -1049,7 +1049,7 @@
|
|
|
1049
1049
|
const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
|
|
1050
1050
|
let nextObject = cameledObject;
|
|
1051
1051
|
if (cameledObject && typeof cameledObject === "object") {
|
|
1052
|
-
nextObject = { ...cameledObject };
|
|
1052
|
+
nextObject = Array.isArray(cameledObject) ? [...cameledObject] : { ...cameledObject };
|
|
1053
1053
|
Object.defineProperty(nextObject, "$raw", {
|
|
1054
1054
|
get() {
|
|
1055
1055
|
return res;
|
|
@@ -1173,7 +1173,7 @@
|
|
|
1173
1173
|
})(SnippetType || {});
|
|
1174
1174
|
|
|
1175
1175
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1176
|
-
var SubscribePostCreateBit = 1
|
|
1176
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1177
1177
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1178
1178
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1179
1179
|
var SubscribeRecentCreateBit = 1 << 3;
|
package/dist/index.js
CHANGED
|
@@ -53,11 +53,11 @@ var camelcaseKeys = (obj) => {
|
|
|
53
53
|
return obj;
|
|
54
54
|
};
|
|
55
55
|
function camelcase(str) {
|
|
56
|
-
return str.replace(/^_+/, "").
|
|
56
|
+
return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
|
|
57
57
|
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
var isMongoId = (id) => id.length === 24 && /^[
|
|
60
|
+
var isMongoId = (id) => id.length === 24 && /^[\dA-Fa-f]{24}$/.test(id);
|
|
61
61
|
|
|
62
62
|
// utils/path.ts
|
|
63
63
|
var resolveFullPath = (endpoint, path) => {
|
|
@@ -257,7 +257,7 @@ var AIController = class {
|
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
259
|
async generateSummary(articleId, lang = "zh-CN", token = "") {
|
|
260
|
-
return this.proxy
|
|
260
|
+
return this.proxy.summaries.generate.post({
|
|
261
261
|
params: {
|
|
262
262
|
token
|
|
263
263
|
},
|
|
@@ -828,14 +828,14 @@ var UserController = class {
|
|
|
828
828
|
loginWithToken(token) {
|
|
829
829
|
return this.proxy.login.put({
|
|
830
830
|
params: token ? {
|
|
831
|
-
token: `bearer ${token.replace(/^
|
|
831
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
832
832
|
} : void 0
|
|
833
833
|
});
|
|
834
834
|
}
|
|
835
835
|
checkTokenValid(token) {
|
|
836
836
|
return this.proxy.check_logged.get({
|
|
837
837
|
params: {
|
|
838
|
-
token: `bearer ${token.replace(/^
|
|
838
|
+
token: `bearer ${token.replace(/^bearer\s/i, "")}`
|
|
839
839
|
}
|
|
840
840
|
});
|
|
841
841
|
}
|
|
@@ -1030,15 +1030,15 @@ var HTTPClient = class {
|
|
|
1030
1030
|
...options,
|
|
1031
1031
|
url
|
|
1032
1032
|
});
|
|
1033
|
-
} catch (
|
|
1034
|
-
let message =
|
|
1035
|
-
let code =
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
let message = error.message;
|
|
1035
|
+
let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
|
|
1036
1036
|
if (that.options.getCodeMessageFromException) {
|
|
1037
|
-
const errorInfo = that.options.getCodeMessageFromException(
|
|
1037
|
+
const errorInfo = that.options.getCodeMessageFromException(error);
|
|
1038
1038
|
message = errorInfo.message || message;
|
|
1039
1039
|
code = errorInfo.code || code;
|
|
1040
1040
|
}
|
|
1041
|
-
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(
|
|
1041
|
+
throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
|
|
1042
1042
|
}
|
|
1043
1043
|
const data = that.options.getDataFromResponse(res);
|
|
1044
1044
|
if (!data) {
|
|
@@ -1047,7 +1047,7 @@ var HTTPClient = class {
|
|
|
1047
1047
|
const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
|
|
1048
1048
|
let nextObject = cameledObject;
|
|
1049
1049
|
if (cameledObject && typeof cameledObject === "object") {
|
|
1050
|
-
nextObject = { ...cameledObject };
|
|
1050
|
+
nextObject = Array.isArray(cameledObject) ? [...cameledObject] : { ...cameledObject };
|
|
1051
1051
|
Object.defineProperty(nextObject, "$raw", {
|
|
1052
1052
|
get() {
|
|
1053
1053
|
return res;
|
|
@@ -1171,7 +1171,7 @@ var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
|
|
|
1171
1171
|
})(SnippetType || {});
|
|
1172
1172
|
|
|
1173
1173
|
// ../../apps/core/src/modules/subscribe/subscribe.constant.ts
|
|
1174
|
-
var SubscribePostCreateBit = 1
|
|
1174
|
+
var SubscribePostCreateBit = Math.trunc(1);
|
|
1175
1175
|
var SubscribeNoteCreateBit = 1 << 1;
|
|
1176
1176
|
var SubscribeSayCreateBit = 1 << 2;
|
|
1177
1177
|
var SubscribeRecentCreateBit = 1 << 3;
|
|
@@ -4,20 +4,20 @@ export declare const createKyAdaptor: (ky: KyInstance) => Readonly<{
|
|
|
4
4
|
responseWrapper: ResponsePromise;
|
|
5
5
|
} & {
|
|
6
6
|
default: KyInstance;
|
|
7
|
-
get<P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
8
|
-
post<P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
9
|
-
patch<P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
10
|
-
delete<P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
11
|
-
put<P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
7
|
+
get: <P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P>;
|
|
8
|
+
post: <P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_1>;
|
|
9
|
+
patch: <P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_2>;
|
|
10
|
+
delete: <P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_3>;
|
|
11
|
+
put: <P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_4>;
|
|
12
12
|
}>;
|
|
13
13
|
export declare const defaultKyAdaptor: Readonly<{
|
|
14
14
|
responseWrapper: ResponsePromise;
|
|
15
15
|
} & {
|
|
16
16
|
default: KyInstance;
|
|
17
|
-
get<P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
18
|
-
post<P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
19
|
-
patch<P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
20
|
-
delete<P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined)
|
|
21
|
-
put<P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>)
|
|
17
|
+
get: <P = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P>;
|
|
18
|
+
post: <P_1 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_1>;
|
|
19
|
+
patch: <P_2 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_2>;
|
|
20
|
+
delete: <P_3 = unknown>(url: string, options?: Omit<import("../interfaces/instance").RequestOptions, "data"> | undefined) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_3>;
|
|
21
|
+
put: <P_4 = unknown>(url: string, options: Partial<import("../interfaces/instance").RequestOptions>) => import("~/interfaces/adapter").IAdaptorRequestResponseType<P_4>;
|
|
22
22
|
}>;
|
|
23
23
|
export default defaultKyAdaptor;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { CategoryType } from '../models/category';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { IController } from '~/interfaces/controller';
|
|
3
4
|
import type { IRequestHandler, RequestProxyResult, ResponseProxyExtraRaw } from '~/interfaces/request';
|
|
4
5
|
import type { HTTPClient } from '../core/client';
|
|
5
6
|
import type { CategoryModel, CategoryWithChildrenModel, TagModel } from '../models/category';
|
|
6
7
|
import type { PostModel } from '../models/post';
|
|
7
|
-
import { CategoryType } from '../models/category';
|
|
8
8
|
declare module '../core/client' {
|
|
9
9
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
10
10
|
category: CategoryController<ResponseWrapper>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { LinkModel } from '~/models/link';
|
|
3
4
|
import type { HTTPClient } from '../core';
|
|
4
|
-
import { BaseCrudController } from './base';
|
|
5
5
|
declare module '../core/client' {
|
|
6
6
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
7
|
link: LinkController<ResponseWrapper>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
1
2
|
import type { IRequestAdapter } from '~/interfaces/adapter';
|
|
2
3
|
import type { ProjectModel } from '~/models/project';
|
|
3
4
|
import type { HTTPClient } from '../core';
|
|
4
|
-
import { BaseCrudController } from './base';
|
|
5
5
|
declare module '../core/client' {
|
|
6
6
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
7
7
|
project: ProjectController<ResponseWrapper>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
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 { SayModel } from '~/models/say';
|
|
5
6
|
import type { HTTPClient } from '../core';
|
|
6
|
-
import { BaseCrudController } from './base';
|
|
7
7
|
declare module '../core/client' {
|
|
8
8
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
9
|
say: SayController<ResponseWrapper>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { BaseCrudController } from './base';
|
|
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 { TopicModel } from '~/models/topic';
|
|
5
6
|
import type { HTTPClient } from '../core';
|
|
6
|
-
import { BaseCrudController } from './base';
|
|
7
7
|
declare module '../core/client' {
|
|
8
8
|
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
9
9
|
topic: TopicController<ResponseWrapper>;
|
|
@@ -6,9 +6,9 @@ export type IRequestAdapter<T = any, Response = undefined> = Readonly<(Response
|
|
|
6
6
|
responseWrapper: Response;
|
|
7
7
|
}) & {
|
|
8
8
|
default: T;
|
|
9
|
-
get<P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>)
|
|
10
|
-
post<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
11
|
-
patch<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
12
|
-
delete<P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>)
|
|
13
|
-
put<P = unknown>(url: string, options: Partial<RequestOptions>)
|
|
9
|
+
get: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
10
|
+
post: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
11
|
+
patch: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
12
|
+
delete: <P = unknown>(url: string, options?: Omit<RequestOptions, 'data'>) => IAdaptorRequestResponseType<P>;
|
|
13
|
+
put: <P = unknown>(url: string, options: Partial<RequestOptions>) => IAdaptorRequestResponseType<P>;
|
|
14
14
|
}>;
|
|
@@ -5,13 +5,13 @@ type NoStringIndex<T> = {
|
|
|
5
5
|
export type Method = 'get' | 'delete' | 'post' | 'put' | 'patch';
|
|
6
6
|
export interface IRequestHandler<ResponseWrapper> {
|
|
7
7
|
(path?: string | number): IRequestHandler<ResponseWrapper>;
|
|
8
|
-
get<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
9
|
-
post<P = unknown>(options?: RequestOptions)
|
|
10
|
-
patch<P = unknown>(options?: RequestOptions)
|
|
11
|
-
delete<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>)
|
|
12
|
-
put<P = unknown>(options?: RequestOptions)
|
|
13
|
-
toString(withBase?: boolean)
|
|
14
|
-
valueOf(withBase?: boolean)
|
|
8
|
+
get: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
9
|
+
post: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
10
|
+
patch: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
11
|
+
delete: <P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>) => RequestProxyResult<P, ResponseWrapper>;
|
|
12
|
+
put: <P = unknown>(options?: RequestOptions) => RequestProxyResult<P, ResponseWrapper>;
|
|
13
|
+
toString: (withBase?: boolean) => string;
|
|
14
|
+
valueOf: (withBase?: boolean) => string;
|
|
15
15
|
[key: string]: IRequestHandler<ResponseWrapper>;
|
|
16
16
|
}
|
|
17
17
|
export type RequestProxyResult<T, ResponseWrapper, R = ResponseWrapper extends unknown ? {
|
package/interfaces/adapter.ts
CHANGED
|
@@ -8,29 +8,29 @@ export type IRequestAdapter<T = any, Response = undefined> = Readonly<
|
|
|
8
8
|
(Response extends undefined ? {} : { responseWrapper: Response }) & {
|
|
9
9
|
default: T
|
|
10
10
|
|
|
11
|
-
get<P = unknown>(
|
|
11
|
+
get: <P = unknown>(
|
|
12
12
|
url: string,
|
|
13
13
|
options?: Omit<RequestOptions, 'data'>,
|
|
14
|
-
)
|
|
14
|
+
) => IAdaptorRequestResponseType<P>
|
|
15
15
|
|
|
16
|
-
post<P = unknown>(
|
|
16
|
+
post: <P = unknown>(
|
|
17
17
|
url: string,
|
|
18
18
|
options: Partial<RequestOptions>,
|
|
19
|
-
)
|
|
19
|
+
) => IAdaptorRequestResponseType<P>
|
|
20
20
|
|
|
21
|
-
patch<P = unknown>(
|
|
21
|
+
patch: <P = unknown>(
|
|
22
22
|
url: string,
|
|
23
23
|
options: Partial<RequestOptions>,
|
|
24
|
-
)
|
|
24
|
+
) => IAdaptorRequestResponseType<P>
|
|
25
25
|
|
|
26
|
-
delete<P = unknown>(
|
|
26
|
+
delete: <P = unknown>(
|
|
27
27
|
url: string,
|
|
28
28
|
options?: Omit<RequestOptions, 'data'>,
|
|
29
|
-
)
|
|
29
|
+
) => IAdaptorRequestResponseType<P>
|
|
30
30
|
|
|
31
|
-
put<P = unknown>(
|
|
31
|
+
put: <P = unknown>(
|
|
32
32
|
url: string,
|
|
33
33
|
options: Partial<RequestOptions>,
|
|
34
|
-
)
|
|
34
|
+
) => IAdaptorRequestResponseType<P>
|
|
35
35
|
}
|
|
36
36
|
>
|
package/interfaces/request.ts
CHANGED
|
@@ -7,29 +7,29 @@ export type Method = 'get' | 'delete' | 'post' | 'put' | 'patch'
|
|
|
7
7
|
export interface IRequestHandler<ResponseWrapper> {
|
|
8
8
|
(path?: string | number): IRequestHandler<ResponseWrapper>
|
|
9
9
|
// @ts-ignore
|
|
10
|
-
get<P = unknown>(
|
|
10
|
+
get: <P = unknown>(
|
|
11
11
|
options?: Omit<NoStringIndex<RequestOptions>, 'data'>,
|
|
12
|
-
)
|
|
12
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
post<P = unknown>(
|
|
14
|
+
post: <P = unknown>(
|
|
15
15
|
options?: RequestOptions,
|
|
16
|
-
)
|
|
16
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
patch<P = unknown>(
|
|
18
|
+
patch: <P = unknown>(
|
|
19
19
|
options?: RequestOptions,
|
|
20
|
-
)
|
|
20
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
21
21
|
// @ts-ignore
|
|
22
|
-
delete<P = unknown>(
|
|
22
|
+
delete: <P = unknown>(
|
|
23
23
|
options?: Omit<NoStringIndex<RequestOptions>, 'data'>,
|
|
24
|
-
)
|
|
24
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
25
25
|
// @ts-ignore
|
|
26
|
-
put<P = unknown>(
|
|
26
|
+
put: <P = unknown>(
|
|
27
27
|
options?: RequestOptions,
|
|
28
|
-
)
|
|
28
|
+
) => RequestProxyResult<P, ResponseWrapper>
|
|
29
29
|
// @ts-ignore
|
|
30
|
-
toString(withBase?: boolean)
|
|
30
|
+
toString: (withBase?: boolean) => string
|
|
31
31
|
// @ts-ignore
|
|
32
|
-
valueOf(withBase?: boolean)
|
|
32
|
+
valueOf: (withBase?: boolean) => string
|
|
33
33
|
[key: string]: IRequestHandler<ResponseWrapper>
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -39,18 +39,18 @@ export type RequestProxyResult<
|
|
|
39
39
|
R = ResponseWrapper extends unknown
|
|
40
40
|
? { data: T; [key: string]: any }
|
|
41
41
|
: ResponseWrapper extends { data: T }
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
? ResponseWrapper
|
|
43
|
+
: Omit<ResponseWrapper, 'data'> & { data: T },
|
|
44
44
|
> = Promise<ResponseProxyExtraRaw<T, R, ResponseWrapper>>
|
|
45
45
|
|
|
46
46
|
type CamelToSnake<T extends string, P extends string = ''> = string extends T
|
|
47
47
|
? string
|
|
48
48
|
: T extends `${infer C0}${infer R}`
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
? CamelToSnake<
|
|
50
|
+
R,
|
|
51
|
+
`${P}${C0 extends Lowercase<C0> ? '' : '_'}${Lowercase<C0>}`
|
|
52
|
+
>
|
|
53
|
+
: P
|
|
54
54
|
|
|
55
55
|
type CamelKeysToSnake<T> = {
|
|
56
56
|
[K in keyof T as CamelToSnake<Extract<K, string>>]: T[K]
|
|
@@ -60,11 +60,11 @@ type ResponseWrapperType<Response, RawData, T> = {
|
|
|
60
60
|
$raw: Response extends { data: infer T }
|
|
61
61
|
? Response
|
|
62
62
|
: Response extends unknown
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
? {
|
|
64
|
+
[i: string]: any
|
|
65
|
+
data: RawData extends unknown ? CamelKeysToSnake<T> : RawData
|
|
66
|
+
}
|
|
67
|
+
: Response
|
|
68
68
|
$request: {
|
|
69
69
|
path: string
|
|
70
70
|
method: string
|
|
@@ -81,5 +81,5 @@ export type ResponseProxyExtraRaw<
|
|
|
81
81
|
> = T extends object
|
|
82
82
|
? T & ResponseWrapperType<Response, RawData, T>
|
|
83
83
|
: T extends unknown
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
? T & ResponseWrapperType<Response, RawData, T>
|
|
85
|
+
: unknown
|
package/models/comment.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { CollectionRefTypes } from '@core/constants/db.constant'
|
|
1
2
|
import type { BaseModel } from './base'
|
|
2
3
|
import type { CategoryModel } from './category'
|
|
3
4
|
|
|
4
|
-
import { CollectionRefTypes } from '@core/constants/db.constant'
|
|
5
|
-
|
|
6
5
|
export { CollectionRefTypes }
|
|
7
6
|
export interface CommentModel extends BaseModel {
|
|
8
7
|
refType: CollectionRefTypes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A api client for mx-space server@next",
|
|
6
6
|
"author": "Innei",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/cors": "2.8.17",
|
|
48
48
|
"@types/express": "4.17.21",
|
|
49
|
-
"@types/lodash": "4.17.
|
|
49
|
+
"@types/lodash": "4.17.1",
|
|
50
50
|
"abort-controller": "3.0.0",
|
|
51
51
|
"axios": "^1.6.7",
|
|
52
52
|
"camelcase-keys": "^9.1.3",
|
package/tsup.config.ts
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
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,23 +0,0 @@
|
|
|
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 };
|