@wetoria/siyuan-sdk 0.0.2
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/README.md +44 -0
- package/dist/api/archive/index.d.ts +12 -0
- package/dist/api/archive/index.d.ts.map +1 -0
- package/dist/api/archive/index.js +8 -0
- package/dist/api/archive/index.js.map +1 -0
- package/dist/api/asset/index.d.ts +12 -0
- package/dist/api/asset/index.d.ts.map +1 -0
- package/dist/api/asset/index.js +10 -0
- package/dist/api/asset/index.js.map +1 -0
- package/dist/api/attr/index.d.ts +39 -0
- package/dist/api/attr/index.d.ts.map +1 -0
- package/dist/api/attr/index.js +17 -0
- package/dist/api/attr/index.js.map +1 -0
- package/dist/api/block/index.d.ts +91 -0
- package/dist/api/block/index.d.ts.map +1 -0
- package/dist/api/block/index.js +87 -0
- package/dist/api/block/index.js.map +1 -0
- package/dist/api/convert/index.d.ts +12 -0
- package/dist/api/convert/index.d.ts.map +1 -0
- package/dist/api/convert/index.js +5 -0
- package/dist/api/convert/index.js.map +1 -0
- package/dist/api/export/index.d.ts +18 -0
- package/dist/api/export/index.d.ts.map +1 -0
- package/dist/api/export/index.js +12 -0
- package/dist/api/export/index.js.map +1 -0
- package/dist/api/file/index.d.ts +27 -0
- package/dist/api/file/index.d.ts.map +1 -0
- package/dist/api/file/index.js +27 -0
- package/dist/api/file/index.js.map +1 -0
- package/dist/api/filetree/index.d.ts +50 -0
- package/dist/api/filetree/index.d.ts.map +1 -0
- package/dist/api/filetree/index.js +47 -0
- package/dist/api/filetree/index.js.map +1 -0
- package/dist/api/index.d.ts +38 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +17 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/network/index.d.ts +12 -0
- package/dist/api/network/index.d.ts.map +1 -0
- package/dist/api/network/index.js +12 -0
- package/dist/api/network/index.js.map +1 -0
- package/dist/api/notebook/index.d.ts +48 -0
- package/dist/api/notebook/index.d.ts.map +1 -0
- package/dist/api/notebook/index.js +32 -0
- package/dist/api/notebook/index.js.map +1 -0
- package/dist/api/notification/index.d.ts +17 -0
- package/dist/api/notification/index.d.ts.map +1 -0
- package/dist/api/notification/index.js +14 -0
- package/dist/api/notification/index.js.map +1 -0
- package/dist/api/sql/index.d.ts +29 -0
- package/dist/api/sql/index.d.ts.map +1 -0
- package/dist/api/sql/index.js +18 -0
- package/dist/api/sql/index.js.map +1 -0
- package/dist/api/sqlite/index.d.ts +12 -0
- package/dist/api/sqlite/index.d.ts.map +1 -0
- package/dist/api/sqlite/index.js +5 -0
- package/dist/api/sqlite/index.js.map +1 -0
- package/dist/api/system/index.d.ts +27 -0
- package/dist/api/system/index.d.ts.map +1 -0
- package/dist/api/system/index.js +14 -0
- package/dist/api/system/index.js.map +1 -0
- package/dist/api/template/index.d.ts +18 -0
- package/dist/api/template/index.d.ts.map +1 -0
- package/dist/api/template/index.js +11 -0
- package/dist/api/template/index.js.map +1 -0
- package/dist/core/index.d.ts +103 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +152 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +88 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +42 -0
- package/src/api/archive/index.ts +26 -0
- package/src/api/asset/index.ts +26 -0
- package/src/api/attr/index.ts +59 -0
- package/src/api/block/index.ts +226 -0
- package/src/api/convert/index.ts +18 -0
- package/src/api/export/index.ts +36 -0
- package/src/api/file/index.ts +59 -0
- package/src/api/filetree/index.ts +129 -0
- package/src/api/index.ts +56 -0
- package/src/api/network/index.ts +32 -0
- package/src/api/notebook/index.ts +93 -0
- package/src/api/notification/index.ts +33 -0
- package/src/api/sql/index.ts +65 -0
- package/src/api/sqlite/index.ts +20 -0
- package/src/api/system/index.ts +46 -0
- package/src/api/template/index.ts +32 -0
- package/src/core/index.ts +237 -0
- package/src/index.ts +9 -0
- package/src/types/index.ts +140 -0
- package/src/utils/index.ts +3 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
import type {
|
|
3
|
+
BlockId,
|
|
4
|
+
NotebookId,
|
|
5
|
+
} from '../../types/index.js'
|
|
6
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* File Tree API 类型定义
|
|
10
|
+
*/
|
|
11
|
+
export interface FileTreeAPI {
|
|
12
|
+
/**
|
|
13
|
+
* 创建日记
|
|
14
|
+
* @path /api/filetree/createDailyNote
|
|
15
|
+
*/
|
|
16
|
+
createDailyNote: (notebook: NotebookId) => SyApiMethodResponse<{
|
|
17
|
+
id: string
|
|
18
|
+
}>
|
|
19
|
+
/**
|
|
20
|
+
* 使用 Markdown 创建文档
|
|
21
|
+
* @path /api/filetree/createDocWithMd
|
|
22
|
+
*/
|
|
23
|
+
createDocWithMd: (
|
|
24
|
+
notebook: NotebookId,
|
|
25
|
+
path: string,
|
|
26
|
+
markdown: string
|
|
27
|
+
) => SyApiMethodResponse<string>
|
|
28
|
+
/**
|
|
29
|
+
* 重命名文档
|
|
30
|
+
* @path /api/filetree/renameDoc
|
|
31
|
+
*/
|
|
32
|
+
renameDoc: (
|
|
33
|
+
notebook: NotebookId,
|
|
34
|
+
path: string,
|
|
35
|
+
title: string
|
|
36
|
+
) => SyApiMethodResponse<string>
|
|
37
|
+
/**
|
|
38
|
+
* 删除文档
|
|
39
|
+
* @path /api/filetree/removeDoc
|
|
40
|
+
*/
|
|
41
|
+
removeDoc: (
|
|
42
|
+
notebook: NotebookId,
|
|
43
|
+
path: string
|
|
44
|
+
) => SyApiMethodResponse<any>
|
|
45
|
+
/**
|
|
46
|
+
* 移动文档
|
|
47
|
+
* @path /api/filetree/moveDocs
|
|
48
|
+
*/
|
|
49
|
+
moveDocs: (
|
|
50
|
+
fromPaths: string[],
|
|
51
|
+
toNotebook: NotebookId,
|
|
52
|
+
toPath: string
|
|
53
|
+
) => SyApiMethodResponse<any>
|
|
54
|
+
/**
|
|
55
|
+
* 根据路径获取人类可读路径
|
|
56
|
+
* @path /api/filetree/getHPathByPath
|
|
57
|
+
*/
|
|
58
|
+
getHPathByPath: (
|
|
59
|
+
notebook: NotebookId,
|
|
60
|
+
path: string
|
|
61
|
+
) => SyApiMethodResponse<string>
|
|
62
|
+
/**
|
|
63
|
+
* 根据块 ID 获取人类可读路径
|
|
64
|
+
* @path /api/filetree/getHPathByID
|
|
65
|
+
*/
|
|
66
|
+
getHPathByID: (id: BlockId) => SyApiMethodResponse<string>
|
|
67
|
+
/**
|
|
68
|
+
* 根据人类可读路径获取块 ID 列表
|
|
69
|
+
* @path /api/filetree/getIDsByHPath
|
|
70
|
+
*/
|
|
71
|
+
getIDsByHPath: (
|
|
72
|
+
notebook: NotebookId,
|
|
73
|
+
path: string
|
|
74
|
+
) => SyApiMethodResponse<string[]>
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
SiYuanAPI.prototype.createDailyNote = function (notebook: string) {
|
|
78
|
+
return this.request('/api/filetree/createDailyNote', { notebook })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
SiYuanAPI.prototype.createDocWithMd = function (notebook: string, path: string, markdown: string) {
|
|
82
|
+
return this.request('/api/filetree/createDocWithMd', {
|
|
83
|
+
notebook,
|
|
84
|
+
path,
|
|
85
|
+
markdown,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
SiYuanAPI.prototype.renameDoc = function (notebook: string, path: string, title: string) {
|
|
90
|
+
return this.request('/api/filetree/renameDoc', {
|
|
91
|
+
doc: notebook,
|
|
92
|
+
path,
|
|
93
|
+
title,
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
SiYuanAPI.prototype.removeDoc = function (notebook: string, path: string) {
|
|
98
|
+
return this.request('/api/filetree/removeDoc', {
|
|
99
|
+
notebook,
|
|
100
|
+
path,
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
SiYuanAPI.prototype.moveDocs = function (fromPaths: string[], toNotebook: string, toPath: string) {
|
|
105
|
+
return this.request('/api/filetree/moveDocs', {
|
|
106
|
+
fromPaths,
|
|
107
|
+
toNotebook,
|
|
108
|
+
toPath,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
SiYuanAPI.prototype.getHPathByPath = function (notebook: string, path: string) {
|
|
113
|
+
return this.request('/api/filetree/getHPathByPath', {
|
|
114
|
+
notebook,
|
|
115
|
+
path,
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
SiYuanAPI.prototype.getHPathByID = function (id: string) {
|
|
120
|
+
return this.request('/api/filetree/getHPathByID', { id })
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
SiYuanAPI.prototype.getIDsByHPath = function (notebook: string, path: string) {
|
|
124
|
+
return this.request('/api/filetree/getIDsByHPath', {
|
|
125
|
+
notebook,
|
|
126
|
+
path,
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ArchiveAPI } from './archive/index.js'
|
|
2
|
+
import type { AssetAPI } from './asset/index.js'
|
|
3
|
+
import type { AttrAPI } from './attr/index.js'
|
|
4
|
+
import type { BlockAPI } from './block/index.js'
|
|
5
|
+
import type { ConvertAPI } from './convert/index.js'
|
|
6
|
+
import type { ExportAPI } from './export/index.js'
|
|
7
|
+
import type { FileAPI } from './file/index.js'
|
|
8
|
+
import type { FileTreeAPI } from './filetree/index.js'
|
|
9
|
+
import type { NetworkAPI } from './network/index.js'
|
|
10
|
+
import type { NotebookAPI } from './notebook/index.js'
|
|
11
|
+
import type { NotificationAPI } from './notification/index.js'
|
|
12
|
+
import type { SqlAPI } from './sql/index.js'
|
|
13
|
+
import type { SqliteAPI } from './sqlite/index.js'
|
|
14
|
+
import type { SystemAPI } from './system/index.js'
|
|
15
|
+
import type { TemplateAPI } from './template/index.js'
|
|
16
|
+
|
|
17
|
+
// 导入所有 API 实现
|
|
18
|
+
import './archive/index.js'
|
|
19
|
+
import './asset/index.js'
|
|
20
|
+
import './attr/index.js'
|
|
21
|
+
import './block/index.js'
|
|
22
|
+
import './convert/index.js'
|
|
23
|
+
import './export/index.js'
|
|
24
|
+
import './file/index.js'
|
|
25
|
+
import './filetree/index.js'
|
|
26
|
+
import './network/index.js'
|
|
27
|
+
import './notebook/index.js'
|
|
28
|
+
import './notification/index.js'
|
|
29
|
+
import './sql/index.js'
|
|
30
|
+
import './sqlite/index.js'
|
|
31
|
+
import './system/index.js'
|
|
32
|
+
import './template/index.js'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Api types
|
|
36
|
+
*/
|
|
37
|
+
declare module '@wetoria/siyuan-sdk' {
|
|
38
|
+
interface SiYuanAPI
|
|
39
|
+
extends
|
|
40
|
+
ArchiveAPI,
|
|
41
|
+
AssetAPI,
|
|
42
|
+
AttrAPI,
|
|
43
|
+
BlockAPI,
|
|
44
|
+
ConvertAPI,
|
|
45
|
+
ExportAPI,
|
|
46
|
+
FileAPI,
|
|
47
|
+
FileTreeAPI,
|
|
48
|
+
NetworkAPI,
|
|
49
|
+
NotebookAPI,
|
|
50
|
+
NotificationAPI,
|
|
51
|
+
SqlAPI,
|
|
52
|
+
SqliteAPI,
|
|
53
|
+
SystemAPI,
|
|
54
|
+
TemplateAPI
|
|
55
|
+
{}
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Network API 类型定义
|
|
6
|
+
*/
|
|
7
|
+
export interface NetworkAPI {
|
|
8
|
+
/**
|
|
9
|
+
* 转发代理请求
|
|
10
|
+
* @path /api/network/forwardProxy
|
|
11
|
+
*/
|
|
12
|
+
forwardProxy: (
|
|
13
|
+
url: string,
|
|
14
|
+
method?: string,
|
|
15
|
+
payload?: any,
|
|
16
|
+
headers?: any[],
|
|
17
|
+
timeout?: number,
|
|
18
|
+
contentType?: string
|
|
19
|
+
) => SyApiMethodResponse<any>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SiYuanAPI.prototype.forwardProxy = function (url: string, method: string = 'GET', payload: any = {}, headers: any[] = [], timeout: number = 7000, contentType: string = 'text/html') {
|
|
23
|
+
return this.request('/api/network/forwardProxy', {
|
|
24
|
+
url,
|
|
25
|
+
method,
|
|
26
|
+
timeout,
|
|
27
|
+
contentType,
|
|
28
|
+
headers,
|
|
29
|
+
payload,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
import type { NotebookId } from '../../types/index.js'
|
|
3
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Notebook API 类型定义
|
|
7
|
+
*/
|
|
8
|
+
export interface NotebookAPI {
|
|
9
|
+
/**
|
|
10
|
+
* 列出所有笔记本
|
|
11
|
+
* @path /api/notebook/lsNotebooks
|
|
12
|
+
*/
|
|
13
|
+
lsNotebooks: () => SyApiMethodResponse<any>
|
|
14
|
+
/**
|
|
15
|
+
* 打开笔记本
|
|
16
|
+
* @path /api/notebook/openNotebook
|
|
17
|
+
*/
|
|
18
|
+
openNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
|
|
19
|
+
/**
|
|
20
|
+
* 关闭笔记本
|
|
21
|
+
* @path /api/notebook/closeNotebook
|
|
22
|
+
*/
|
|
23
|
+
closeNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
|
|
24
|
+
/**
|
|
25
|
+
* 重命名笔记本
|
|
26
|
+
* @path /api/notebook/renameNotebook
|
|
27
|
+
*/
|
|
28
|
+
renameNotebook: (
|
|
29
|
+
notebook: NotebookId,
|
|
30
|
+
name: string
|
|
31
|
+
) => SyApiMethodResponse<any>
|
|
32
|
+
/**
|
|
33
|
+
* 创建笔记本
|
|
34
|
+
* @path /api/notebook/createNotebook
|
|
35
|
+
*/
|
|
36
|
+
createNotebook: (name: string) => SyApiMethodResponse<any>
|
|
37
|
+
/**
|
|
38
|
+
* 删除笔记本
|
|
39
|
+
* @path /api/notebook/removeNotebook
|
|
40
|
+
*/
|
|
41
|
+
removeNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
|
|
42
|
+
/**
|
|
43
|
+
* 获取笔记本配置
|
|
44
|
+
* @path /api/notebook/getNotebookConf
|
|
45
|
+
*/
|
|
46
|
+
getNotebookConf: (notebook: NotebookId) => SyApiMethodResponse<any>
|
|
47
|
+
/**
|
|
48
|
+
* 设置笔记本配置
|
|
49
|
+
* @path /api/notebook/setNotebookConf
|
|
50
|
+
*/
|
|
51
|
+
setNotebookConf: (
|
|
52
|
+
notebook: NotebookId,
|
|
53
|
+
conf: any
|
|
54
|
+
) => SyApiMethodResponse<any>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
SiYuanAPI.prototype.lsNotebooks = function () {
|
|
58
|
+
return this.request('/api/notebook/lsNotebooks', '')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
SiYuanAPI.prototype.openNotebook = function (notebook: string) {
|
|
62
|
+
return this.request('/api/notebook/openNotebook', { notebook })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
SiYuanAPI.prototype.closeNotebook = function (notebook: string) {
|
|
66
|
+
return this.request('/api/notebook/closeNotebook', { notebook })
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
SiYuanAPI.prototype.renameNotebook = function (notebook: string, name: string) {
|
|
70
|
+
return this.request('/api/notebook/renameNotebook', {
|
|
71
|
+
notebook,
|
|
72
|
+
name,
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
SiYuanAPI.prototype.createNotebook = function (name: string) {
|
|
77
|
+
return this.request('/api/notebook/createNotebook', { name })
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
SiYuanAPI.prototype.removeNotebook = function (notebook: string) {
|
|
81
|
+
return this.request('/api/notebook/removeNotebook', { notebook })
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
SiYuanAPI.prototype.getNotebookConf = function (notebook: string) {
|
|
85
|
+
return this.request('/api/notebook/getNotebookConf', { notebook })
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
SiYuanAPI.prototype.setNotebookConf = function (notebook: string, conf: any) {
|
|
89
|
+
return this.request('/api/notebook/setNotebookConf', {
|
|
90
|
+
notebook,
|
|
91
|
+
conf,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Notification API 类型定义
|
|
6
|
+
*/
|
|
7
|
+
export interface NotificationAPI {
|
|
8
|
+
/**
|
|
9
|
+
* 推送消息通知
|
|
10
|
+
* @path /api/notification/pushMsg
|
|
11
|
+
*/
|
|
12
|
+
pushMsg: (msg: string, timeout?: number) => SyApiMethodResponse<any>
|
|
13
|
+
/**
|
|
14
|
+
* 推送错误消息通知
|
|
15
|
+
* @path /api/notification/pushErrMsg
|
|
16
|
+
*/
|
|
17
|
+
pushErrMsg: (msg: string, timeout?: number) => SyApiMethodResponse<any>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
SiYuanAPI.prototype.pushMsg = function (msg: string, timeout: number = 7000) {
|
|
21
|
+
return this.request('/api/notification/pushMsg', {
|
|
22
|
+
msg,
|
|
23
|
+
timeout,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
SiYuanAPI.prototype.pushErrMsg = function (msg: string, timeout: number = 7000) {
|
|
28
|
+
return this.request('/api/notification/pushErrMsg', {
|
|
29
|
+
msg,
|
|
30
|
+
timeout,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Block,
|
|
3
|
+
BlockId,
|
|
4
|
+
} from '../../types/index.js'
|
|
5
|
+
import {
|
|
6
|
+
SiYuanAPI,
|
|
7
|
+
SyApiMethodResponse,
|
|
8
|
+
} from '../../core/index.js'
|
|
9
|
+
import { trimSqlBlank } from '../../utils/index.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SQL API 类型定义
|
|
13
|
+
*/
|
|
14
|
+
export interface SqlAPI {
|
|
15
|
+
/**
|
|
16
|
+
* Execute SQL query
|
|
17
|
+
*
|
|
18
|
+
* @path /api/query/sql
|
|
19
|
+
* @param stmt - SQL statement to execute
|
|
20
|
+
* @param options - The options for the SQL query
|
|
21
|
+
* @param options.trim - Whether to trim the SQL string
|
|
22
|
+
* @default true
|
|
23
|
+
* @returns {T[]} result of the SQL query
|
|
24
|
+
*/
|
|
25
|
+
sql: <T = any>(
|
|
26
|
+
stmt: string,
|
|
27
|
+
options?: {
|
|
28
|
+
trim?: boolean
|
|
29
|
+
}
|
|
30
|
+
) => SyApiMethodResponse<T[]>
|
|
31
|
+
/**
|
|
32
|
+
* Get block by block_id (through SQL query)
|
|
33
|
+
*
|
|
34
|
+
* @path wrapper: uses sql
|
|
35
|
+
* @param {BlockId} blockId - block_id
|
|
36
|
+
* @returns {Block | null} block data - Block or null
|
|
37
|
+
*/
|
|
38
|
+
getBlockByID: (blockId: BlockId) => SyApiMethodResponse<Block | null>
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
SiYuanAPI.prototype.sql = function <T = any>(
|
|
43
|
+
stmt: string,
|
|
44
|
+
options: {
|
|
45
|
+
trim?: boolean
|
|
46
|
+
} = {},
|
|
47
|
+
): SyApiMethodResponse<T[]> {
|
|
48
|
+
const {
|
|
49
|
+
trim = true,
|
|
50
|
+
} = options
|
|
51
|
+
const finalStmt = trim ? trimSqlBlank(stmt) : stmt
|
|
52
|
+
return this.request('/api/query/sql', {
|
|
53
|
+
stmt: finalStmt,
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
SiYuanAPI.prototype.getBlockByID = async function (blockId: string) {
|
|
58
|
+
const res = await this.sql(`select * from blocks where id ='${blockId}'`)
|
|
59
|
+
return {
|
|
60
|
+
code: res.code,
|
|
61
|
+
msg: res.msg,
|
|
62
|
+
data: res.data?.[0] ?? null,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SyApiMethodResponse,
|
|
3
|
+
} from '../../core/index.js'
|
|
4
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sqlite API 类型定义
|
|
8
|
+
*/
|
|
9
|
+
export interface SqliteAPI {
|
|
10
|
+
/**
|
|
11
|
+
* 刷新事务
|
|
12
|
+
* @path /api/sqlite/flushTransaction
|
|
13
|
+
*/
|
|
14
|
+
flushTransactions: () => SyApiMethodResponse<any>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
SiYuanAPI.prototype.flushTransactions = function () {
|
|
18
|
+
return this.request('/api/sqlite/flushTransaction', {})
|
|
19
|
+
}
|
|
20
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
|
|
3
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* System API 类型定义
|
|
7
|
+
*/
|
|
8
|
+
export interface SystemAPI {
|
|
9
|
+
/**
|
|
10
|
+
* 获取启动进度
|
|
11
|
+
* @path /api/system/bootProgress
|
|
12
|
+
*/
|
|
13
|
+
bootProgress: () => SyApiMethodResponse<any>
|
|
14
|
+
/**
|
|
15
|
+
* 获取版本号
|
|
16
|
+
* @path /api/system/version
|
|
17
|
+
*/
|
|
18
|
+
version: () => SyApiMethodResponse<string>
|
|
19
|
+
/**
|
|
20
|
+
* 获取当前时间戳
|
|
21
|
+
* @path /api/system/currentTime
|
|
22
|
+
*/
|
|
23
|
+
currentTime: () => SyApiMethodResponse<number>
|
|
24
|
+
/**
|
|
25
|
+
* 执行同步
|
|
26
|
+
* @path /api/sync/performSync
|
|
27
|
+
*/
|
|
28
|
+
performSync: () => SyApiMethodResponse<number>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SiYuanAPI.prototype.bootProgress = function () {
|
|
32
|
+
return this.request('/api/system/bootProgress', {})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
SiYuanAPI.prototype.version = function () {
|
|
36
|
+
return this.request('/api/system/version', {})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
SiYuanAPI.prototype.currentTime = function () {
|
|
40
|
+
return this.request('/api/system/currentTime', {})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
SiYuanAPI.prototype.performSync = function () {
|
|
44
|
+
return this.request('/api/sync/performSync', {})
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js'
|
|
2
|
+
import type { DocumentId } from '../../types/index.js'
|
|
3
|
+
|
|
4
|
+
import { SiYuanAPI } from '../../core/index.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Template API 类型定义
|
|
8
|
+
*/
|
|
9
|
+
export interface TemplateAPI {
|
|
10
|
+
/**
|
|
11
|
+
* 渲染模板
|
|
12
|
+
* @path /api/template/render
|
|
13
|
+
*/
|
|
14
|
+
render: (id: DocumentId, path: string) => SyApiMethodResponse<any>
|
|
15
|
+
/**
|
|
16
|
+
* 渲染 Sprig 模板
|
|
17
|
+
* @path /api/template/renderSprig
|
|
18
|
+
*/
|
|
19
|
+
renderSprig: (template: string) => SyApiMethodResponse<string>
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SiYuanAPI.prototype.render = function (id: string, path: string) {
|
|
23
|
+
return this.request('/api/template/render', {
|
|
24
|
+
id,
|
|
25
|
+
path,
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
SiYuanAPI.prototype.renderSprig = function (template: string) {
|
|
30
|
+
return this.request('/api/template/renderSprig', { template })
|
|
31
|
+
}
|
|
32
|
+
|