@mx-space/api-client 0.6.3 → 0.7.0-alpha.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/build/index.cjs.js +18 -0
- package/build/index.cjs.js.map +1 -1
- package/build/index.cjs.min.js.map +1 -1
- package/build/index.d.ts +42 -18
- package/build/index.esm.js +18 -0
- package/build/index.esm.js.map +1 -1
- package/build/index.esm.min.js.map +1 -1
- package/build/index.umd.js +18 -0
- package/build/index.umd.js.map +1 -1
- package/build/index.umd.min.js.map +1 -1
- package/esm/controllers/aggregate.d.ts +5 -0
- package/esm/controllers/aggregate.js.map +1 -1
- package/esm/controllers/category.d.ts +5 -0
- package/esm/controllers/category.js.map +1 -1
- package/esm/controllers/comment.d.ts +5 -0
- package/esm/controllers/comment.js.map +1 -1
- package/esm/controllers/link.d.ts +6 -0
- package/esm/controllers/link.js.map +1 -1
- package/esm/controllers/note.d.ts +5 -0
- package/esm/controllers/note.js.map +1 -1
- package/esm/controllers/page.d.ts +5 -0
- package/esm/controllers/page.js.map +1 -1
- package/esm/controllers/post.d.ts +5 -0
- package/esm/controllers/post.js.map +1 -1
- package/esm/controllers/project.d.ts +5 -0
- package/esm/controllers/project.js.map +1 -1
- package/esm/controllers/recently.d.ts +6 -0
- package/esm/controllers/recently.js.map +1 -1
- package/esm/controllers/say.d.ts +5 -0
- package/esm/controllers/say.js.map +1 -1
- package/esm/controllers/search.d.ts +7 -2
- package/esm/controllers/search.js.map +1 -1
- package/esm/controllers/snippet.d.ts +5 -0
- package/esm/controllers/snippet.js.map +1 -1
- package/esm/controllers/user.d.ts +6 -0
- package/esm/controllers/user.js.map +1 -1
- package/esm/core/client.d.ts +0 -19
- package/esm/core/client.js +19 -1
- package/esm/core/client.js.map +1 -1
- package/lib/controllers/aggregate.d.ts +5 -0
- package/lib/controllers/aggregate.js.map +1 -1
- package/lib/controllers/category.d.ts +5 -0
- package/lib/controllers/category.js.map +1 -1
- package/lib/controllers/comment.d.ts +5 -0
- package/lib/controllers/comment.js.map +1 -1
- package/lib/controllers/link.d.ts +6 -0
- package/lib/controllers/link.js.map +1 -1
- package/lib/controllers/note.d.ts +5 -0
- package/lib/controllers/note.js.map +1 -1
- package/lib/controllers/page.d.ts +5 -0
- package/lib/controllers/page.js.map +1 -1
- package/lib/controllers/post.d.ts +5 -0
- package/lib/controllers/post.js.map +1 -1
- package/lib/controllers/project.d.ts +5 -0
- package/lib/controllers/project.js.map +1 -1
- package/lib/controllers/recently.d.ts +6 -0
- package/lib/controllers/recently.js.map +1 -1
- package/lib/controllers/say.d.ts +5 -0
- package/lib/controllers/say.js.map +1 -1
- package/lib/controllers/search.d.ts +7 -2
- package/lib/controllers/search.js.map +1 -1
- package/lib/controllers/snippet.d.ts +5 -0
- package/lib/controllers/snippet.js.map +1 -1
- package/lib/controllers/user.d.ts +6 -0
- package/lib/controllers/user.js.map +1 -1
- package/lib/core/client.d.ts +0 -19
- package/lib/core/client.js +18 -0
- package/lib/core/client.js.map +1 -1
- package/package.json +11 -4
- package/src/adaptors/axios.ts +36 -0
- package/src/adaptors/umi-request.ts +30 -0
- package/src/controllers/aggregate.ts +65 -0
- package/src/controllers/base.ts +32 -0
- package/src/controllers/category.ts +107 -0
- package/src/controllers/comment.ts +64 -0
- package/src/controllers/index.ts +66 -0
- package/src/controllers/link.ts +21 -0
- package/src/controllers/note.ts +92 -0
- package/src/controllers/page.ts +59 -0
- package/src/controllers/post.ts +87 -0
- package/src/controllers/project.ts +20 -0
- package/src/controllers/recently.ts +48 -0
- package/src/controllers/say.ts +35 -0
- package/src/controllers/search.ts +101 -0
- package/src/controllers/snippet.ts +31 -0
- package/src/controllers/user.ts +46 -0
- package/src/core/attach-request.ts +43 -0
- package/src/core/client.ts +249 -0
- package/src/core/error.ts +10 -0
- package/src/core/index.ts +2 -0
- package/src/dtos/comment.ts +9 -0
- package/src/index.ts +12 -0
- package/src/interfaces/adapter.ts +30 -0
- package/src/interfaces/client.ts +6 -0
- package/src/interfaces/controller.ts +5 -0
- package/src/interfaces/instance.ts +8 -0
- package/src/interfaces/options.ts +1 -0
- package/src/interfaces/params.ts +4 -0
- package/src/interfaces/request.ts +57 -0
- package/src/models/aggregate.ts +71 -0
- package/src/models/base.ts +43 -0
- package/src/models/category.ts +25 -0
- package/src/models/comment.ts +37 -0
- package/src/models/index.ts +14 -0
- package/src/models/link.ts +23 -0
- package/src/models/note.ts +37 -0
- package/src/models/page.ts +20 -0
- package/src/models/post.ts +16 -0
- package/src/models/project.ts +12 -0
- package/src/models/recently.ts +7 -0
- package/src/models/say.ts +7 -0
- package/src/models/setting.ts +68 -0
- package/src/models/snippet.ts +18 -0
- package/src/models/user.ts +27 -0
- package/src/tsconfig.build.json +6 -0
- package/src/tsconfig.cjs.json +7 -0
- package/src/tsconfig.json +12 -0
- package/src/types/helper.d.ts +3 -0
- package/src/utils/auto-bind.ts +48 -0
- package/src/utils/index.ts +53 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TextBaseModel } from './base'
|
|
2
|
+
|
|
3
|
+
export interface NoteModel extends TextBaseModel {
|
|
4
|
+
hide: boolean
|
|
5
|
+
count: {
|
|
6
|
+
read: number
|
|
7
|
+
like: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
mood?: string
|
|
11
|
+
weather?: string
|
|
12
|
+
hasMemory?: boolean
|
|
13
|
+
|
|
14
|
+
secret?: Date
|
|
15
|
+
password?: string | null
|
|
16
|
+
nid: number
|
|
17
|
+
music?: NoteMusicRecord[]
|
|
18
|
+
location?: string
|
|
19
|
+
|
|
20
|
+
coordinates?: Coordinate
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface NoteMusicRecord {
|
|
24
|
+
type: string
|
|
25
|
+
id: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface Coordinate {
|
|
29
|
+
latitude: number
|
|
30
|
+
longitude: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface NoteWrappedPayload {
|
|
34
|
+
data: NoteModel
|
|
35
|
+
next?: Partial<NoteModel>
|
|
36
|
+
prev?: Partial<NoteModel>
|
|
37
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TextBaseModel } from './base'
|
|
2
|
+
|
|
3
|
+
export enum EnumPageType {
|
|
4
|
+
'md' = 'md',
|
|
5
|
+
'html' = 'html',
|
|
6
|
+
'frame' = 'frame',
|
|
7
|
+
}
|
|
8
|
+
export interface PageModel extends TextBaseModel {
|
|
9
|
+
created: string
|
|
10
|
+
|
|
11
|
+
slug: string
|
|
12
|
+
|
|
13
|
+
subtitle?: string
|
|
14
|
+
|
|
15
|
+
order?: number
|
|
16
|
+
|
|
17
|
+
type?: EnumPageType
|
|
18
|
+
|
|
19
|
+
options?: object
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Count, Image, TextBaseModel } from './base'
|
|
2
|
+
import { CategoryModel } from './category'
|
|
3
|
+
|
|
4
|
+
export interface PostModel extends TextBaseModel {
|
|
5
|
+
summary?: string
|
|
6
|
+
hide: boolean
|
|
7
|
+
copyright: boolean
|
|
8
|
+
tags: string[]
|
|
9
|
+
count: Count
|
|
10
|
+
text: string
|
|
11
|
+
title: string
|
|
12
|
+
slug: string
|
|
13
|
+
categoryId: string
|
|
14
|
+
images: Image[]
|
|
15
|
+
category: CategoryModel
|
|
16
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare class SeoOptionModel {
|
|
2
|
+
title: string
|
|
3
|
+
description: string
|
|
4
|
+
icon?: string
|
|
5
|
+
keywords?: string[]
|
|
6
|
+
}
|
|
7
|
+
export declare class UrlOptionModel {
|
|
8
|
+
webUrl: string
|
|
9
|
+
adminUrl: string
|
|
10
|
+
serverUrl: string
|
|
11
|
+
wsUrl: string
|
|
12
|
+
}
|
|
13
|
+
declare class MailOptionModel {
|
|
14
|
+
port: number
|
|
15
|
+
host: string
|
|
16
|
+
}
|
|
17
|
+
export declare class MailOptionsModel {
|
|
18
|
+
enable: boolean
|
|
19
|
+
user: string
|
|
20
|
+
pass: string
|
|
21
|
+
options?: MailOptionModel
|
|
22
|
+
}
|
|
23
|
+
export declare class CommentOptionsModel {
|
|
24
|
+
antiSpam: boolean
|
|
25
|
+
spamKeywords?: string[]
|
|
26
|
+
blockIps?: string[]
|
|
27
|
+
disableNoChinese?: boolean
|
|
28
|
+
}
|
|
29
|
+
export declare class BackupOptionsModel {
|
|
30
|
+
enable: boolean
|
|
31
|
+
secretId?: string
|
|
32
|
+
secretKey?: string
|
|
33
|
+
bucket?: string
|
|
34
|
+
region: string
|
|
35
|
+
}
|
|
36
|
+
export declare class BaiduSearchOptionsModel {
|
|
37
|
+
enable: boolean
|
|
38
|
+
token?: string
|
|
39
|
+
}
|
|
40
|
+
export declare class AlgoliaSearchOptionsModel {
|
|
41
|
+
enable: boolean
|
|
42
|
+
apiKey?: string
|
|
43
|
+
appId?: string
|
|
44
|
+
indexName?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export declare class AdminExtraModel {
|
|
48
|
+
background?: string
|
|
49
|
+
|
|
50
|
+
gaodemapKey?: string
|
|
51
|
+
title?: string
|
|
52
|
+
/**
|
|
53
|
+
* 是否开启后台反代访问
|
|
54
|
+
*/
|
|
55
|
+
enableAdminProxy?: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface IConfig {
|
|
59
|
+
seo: SeoOptionModel
|
|
60
|
+
url: UrlOptionModel
|
|
61
|
+
mailOptions: MailOptionsModel
|
|
62
|
+
commentOptions: CommentOptionsModel
|
|
63
|
+
backupOptions: BackupOptionsModel
|
|
64
|
+
baiduSearchOptions: BaiduSearchOptionsModel
|
|
65
|
+
algoliaSearchOptions: AlgoliaSearchOptionsModel
|
|
66
|
+
adminExtra: AdminExtraModel
|
|
67
|
+
}
|
|
68
|
+
export declare type IConfigKeys = keyof IConfig
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseModel } from './base'
|
|
2
|
+
export enum SnippetType {
|
|
3
|
+
JSON = 'json',
|
|
4
|
+
// Function = 'function',
|
|
5
|
+
Text = 'text',
|
|
6
|
+
YAML = 'yaml',
|
|
7
|
+
}
|
|
8
|
+
export interface SnippetModel<T = unknown> extends BaseModel {
|
|
9
|
+
type: SnippetType
|
|
10
|
+
private: boolean
|
|
11
|
+
raw: string
|
|
12
|
+
name: string
|
|
13
|
+
reference: string
|
|
14
|
+
comment?: string
|
|
15
|
+
metatype?: string
|
|
16
|
+
|
|
17
|
+
data: T
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseModel } from './base'
|
|
2
|
+
|
|
3
|
+
export interface UserModel extends BaseModel {
|
|
4
|
+
introduce: string
|
|
5
|
+
mail: string
|
|
6
|
+
url: string
|
|
7
|
+
name: string
|
|
8
|
+
socialIds: Record<string, string>
|
|
9
|
+
username: string
|
|
10
|
+
modified: string
|
|
11
|
+
v: number
|
|
12
|
+
lastLoginTime: string
|
|
13
|
+
lastLoginIp?: string
|
|
14
|
+
avatar: string
|
|
15
|
+
postID: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type TLogin = {
|
|
19
|
+
token: string
|
|
20
|
+
expiresIn: number
|
|
21
|
+
// 登陆足迹
|
|
22
|
+
lastLoginTime: null | string
|
|
23
|
+
lastLoginIp?: null | string
|
|
24
|
+
} & Pick<
|
|
25
|
+
UserModel,
|
|
26
|
+
'name' | 'username' | 'created' | 'url' | 'mail' | 'avatar' | 'id'
|
|
27
|
+
>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// @copy: https://github.com/sindresorhus/auto-bind/blob/main/index.js
|
|
3
|
+
|
|
4
|
+
// Gets all non-builtin properties up the prototype chain.
|
|
5
|
+
const getAllProperties = (object) => {
|
|
6
|
+
const properties = new Set()
|
|
7
|
+
|
|
8
|
+
do {
|
|
9
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
10
|
+
properties.add([object, key])
|
|
11
|
+
}
|
|
12
|
+
} while (
|
|
13
|
+
(object = Reflect.getPrototypeOf(object)) &&
|
|
14
|
+
object !== Object.prototype
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
return properties
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function autoBind(self, { include, exclude } = {}) {
|
|
21
|
+
const filter = (key) => {
|
|
22
|
+
const match = (pattern) =>
|
|
23
|
+
typeof pattern === 'string' ? key === pattern : pattern.test(key)
|
|
24
|
+
|
|
25
|
+
if (include) {
|
|
26
|
+
return include.some(match)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (exclude) {
|
|
30
|
+
return !exclude.some(match)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const [object, key] of getAllProperties(self.constructor.prototype)) {
|
|
37
|
+
if (key === 'constructor' || !filter(key)) {
|
|
38
|
+
continue
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(object, key)
|
|
42
|
+
if (descriptor && typeof descriptor.value === 'function') {
|
|
43
|
+
self[key] = self[key].bind(self)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return self
|
|
48
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SortOrder } from '~/interfaces/options'
|
|
2
|
+
|
|
3
|
+
export const isPlainObject = (obj: any) =>
|
|
4
|
+
isObject(obj) &&
|
|
5
|
+
Object.prototype.toString.call(obj) === '[object Object]' &&
|
|
6
|
+
Object.getPrototypeOf(obj) === Object.prototype
|
|
7
|
+
|
|
8
|
+
export const sortOrderToNumber = (order: SortOrder) => {
|
|
9
|
+
return (
|
|
10
|
+
{
|
|
11
|
+
asc: 1,
|
|
12
|
+
desc: -1,
|
|
13
|
+
}[order] || 1
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
const isObject = (obj: any) => obj && typeof obj === 'object'
|
|
17
|
+
export const destructureData = (payload: any) => {
|
|
18
|
+
if (typeof payload !== 'object') {
|
|
19
|
+
return payload
|
|
20
|
+
}
|
|
21
|
+
if (payload === null) {
|
|
22
|
+
return payload
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const data = payload.data
|
|
26
|
+
|
|
27
|
+
const dataIsPlainObject = isPlainObject(data)
|
|
28
|
+
|
|
29
|
+
if (dataIsPlainObject && Object.keys(payload).length === 1) {
|
|
30
|
+
const d = Object.assign({}, data)
|
|
31
|
+
// attach raw onto new data
|
|
32
|
+
attachRawFromOneToAnthor(payload, d)
|
|
33
|
+
return d
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return payload
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const attachRawFromOneToAnthor = (from: any, to: any) => {
|
|
40
|
+
if (!from || !isObject(to)) {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
from.$raw &&
|
|
44
|
+
Object.defineProperty(to, '$raw', {
|
|
45
|
+
value: { ...from.$raw },
|
|
46
|
+
enumerable: false,
|
|
47
|
+
})
|
|
48
|
+
from.$request &&
|
|
49
|
+
Object.defineProperty(to, '$request', {
|
|
50
|
+
value: { ...from.$request },
|
|
51
|
+
enumerable: false,
|
|
52
|
+
})
|
|
53
|
+
}
|