@wetoria/siyuan-sdk 0.0.5 → 1.0.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.
Files changed (199) hide show
  1. package/README.md +34 -25
  2. package/dist/api/_demo/index.d.ts +15 -0
  3. package/dist/api/_demo/index.d.ts.map +1 -0
  4. package/dist/api/_demo/index.js +5 -0
  5. package/dist/api/_demo/index.js.map +1 -0
  6. package/dist/api/account/index.d.ts +47 -0
  7. package/dist/api/account/index.d.ts.map +1 -0
  8. package/dist/api/account/index.js +18 -0
  9. package/dist/api/account/index.js.map +1 -0
  10. package/dist/api/ai/index.d.ts +26 -0
  11. package/dist/api/ai/index.d.ts.map +1 -0
  12. package/dist/api/ai/index.js +9 -0
  13. package/dist/api/ai/index.js.map +1 -0
  14. package/dist/api/archive/index.d.ts +10 -0
  15. package/dist/api/archive/index.d.ts.map +1 -1
  16. package/dist/api/archive/index.js +3 -0
  17. package/dist/api/archive/index.js.map +1 -1
  18. package/dist/api/asset/index.d.ts +161 -0
  19. package/dist/api/asset/index.d.ts.map +1 -1
  20. package/dist/api/asset/index.js +51 -0
  21. package/dist/api/asset/index.js.map +1 -1
  22. package/dist/api/attr/index.d.ts +15 -0
  23. package/dist/api/attr/index.d.ts.map +1 -1
  24. package/dist/api/attr/index.js +6 -0
  25. package/dist/api/attr/index.js.map +1 -1
  26. package/dist/api/av/index.d.ts +479 -0
  27. package/dist/api/av/index.d.ts.map +1 -0
  28. package/dist/api/av/index.js +110 -0
  29. package/dist/api/av/index.js.map +1 -0
  30. package/dist/api/av/types.d.ts +129 -0
  31. package/dist/api/av/types.d.ts.map +1 -0
  32. package/dist/api/av/types.js +2 -0
  33. package/dist/api/av/types.js.map +1 -0
  34. package/dist/api/bazaar/index.d.ts +293 -0
  35. package/dist/api/bazaar/index.d.ts.map +1 -0
  36. package/dist/api/bazaar/index.js +72 -0
  37. package/dist/api/bazaar/index.js.map +1 -0
  38. package/dist/api/block/index.d.ts +346 -0
  39. package/dist/api/block/index.d.ts.map +1 -1
  40. package/dist/api/block/index.js +118 -0
  41. package/dist/api/block/index.js.map +1 -1
  42. package/dist/api/bookmark/index.d.ts +30 -0
  43. package/dist/api/bookmark/index.d.ts.map +1 -0
  44. package/dist/api/bookmark/index.js +12 -0
  45. package/dist/api/bookmark/index.js.map +1 -0
  46. package/dist/api/broadcast/index.d.ts +54 -0
  47. package/dist/api/broadcast/index.d.ts.map +1 -0
  48. package/dist/api/broadcast/index.js +15 -0
  49. package/dist/api/broadcast/index.js.map +1 -0
  50. package/dist/api/clipboard/index.d.ts +12 -0
  51. package/dist/api/clipboard/index.d.ts.map +1 -0
  52. package/dist/api/clipboard/index.js +6 -0
  53. package/dist/api/clipboard/index.js.map +1 -0
  54. package/dist/api/cloud/index.d.ts +27 -0
  55. package/dist/api/cloud/index.d.ts.map +1 -0
  56. package/dist/api/cloud/index.js +6 -0
  57. package/dist/api/cloud/index.js.map +1 -0
  58. package/dist/api/export/index.d.ts +344 -4
  59. package/dist/api/export/index.d.ts.map +1 -1
  60. package/dist/api/export/index.js +83 -2
  61. package/dist/api/export/index.js.map +1 -1
  62. package/dist/api/extension/index.d.ts +12 -0
  63. package/dist/api/extension/index.d.ts.map +1 -0
  64. package/dist/api/extension/index.js +6 -0
  65. package/dist/api/extension/index.js.map +1 -0
  66. package/dist/api/file/index.d.ts +40 -0
  67. package/dist/api/file/index.d.ts.map +1 -1
  68. package/dist/api/file/index.js +12 -0
  69. package/dist/api/file/index.js.map +1 -1
  70. package/dist/api/filetree/index.d.ts +303 -0
  71. package/dist/api/filetree/index.d.ts.map +1 -1
  72. package/dist/api/filetree/index.js +69 -0
  73. package/dist/api/filetree/index.js.map +1 -1
  74. package/dist/api/format/index.d.ts +34 -0
  75. package/dist/api/format/index.d.ts.map +1 -0
  76. package/dist/api/format/index.js +12 -0
  77. package/dist/api/format/index.js.map +1 -0
  78. package/dist/api/graph/index.d.ts +59 -0
  79. package/dist/api/graph/index.d.ts.map +1 -0
  80. package/dist/api/graph/index.js +15 -0
  81. package/dist/api/graph/index.js.map +1 -0
  82. package/dist/api/history/index.d.ts +120 -0
  83. package/dist/api/history/index.d.ts.map +1 -0
  84. package/dist/api/history/index.js +30 -0
  85. package/dist/api/history/index.js.map +1 -0
  86. package/dist/api/icon/index.d.ts +23 -0
  87. package/dist/api/icon/index.d.ts.map +1 -0
  88. package/dist/api/icon/index.js +17 -0
  89. package/dist/api/icon/index.js.map +1 -0
  90. package/dist/api/import/index.d.ts +34 -0
  91. package/dist/api/import/index.d.ts.map +1 -0
  92. package/dist/api/import/index.js +21 -0
  93. package/dist/api/import/index.js.map +1 -0
  94. package/dist/api/inbox/index.d.ts +32 -0
  95. package/dist/api/inbox/index.d.ts.map +1 -0
  96. package/dist/api/inbox/index.js +12 -0
  97. package/dist/api/inbox/index.js.map +1 -0
  98. package/dist/api/index.d.ts +61 -3
  99. package/dist/api/index.d.ts.map +1 -1
  100. package/dist/api/index.js +30 -1
  101. package/dist/api/index.js.map +1 -1
  102. package/dist/api/lute/index.d.ts +42 -0
  103. package/dist/api/lute/index.d.ts.map +1 -0
  104. package/dist/api/lute/index.js +12 -0
  105. package/dist/api/lute/index.js.map +1 -0
  106. package/dist/api/notebook/index.d.ts +28 -0
  107. package/dist/api/notebook/index.d.ts.map +1 -1
  108. package/dist/api/notebook/index.js +9 -0
  109. package/dist/api/notebook/index.js.map +1 -1
  110. package/dist/api/outline/index.d.ts +18 -0
  111. package/dist/api/outline/index.d.ts.map +1 -0
  112. package/dist/api/outline/index.js +6 -0
  113. package/dist/api/outline/index.js.map +1 -0
  114. package/dist/api/petal/index.d.ts +29 -0
  115. package/dist/api/petal/index.d.ts.map +1 -0
  116. package/dist/api/petal/index.js +9 -0
  117. package/dist/api/petal/index.js.map +1 -0
  118. package/dist/api/{sql → query}/index.d.ts +3 -2
  119. package/dist/api/query/index.d.ts.map +1 -0
  120. package/dist/api/{sql → query}/index.js +1 -0
  121. package/dist/api/query/index.js.map +1 -0
  122. package/dist/api/ref/index.d.ts +108 -0
  123. package/dist/api/ref/index.d.ts.map +1 -0
  124. package/dist/api/ref/index.js +18 -0
  125. package/dist/api/ref/index.js.map +1 -0
  126. package/dist/api/repo/index.d.ts +212 -0
  127. package/dist/api/repo/index.d.ts.map +1 -0
  128. package/dist/api/repo/index.js +69 -0
  129. package/dist/api/repo/index.js.map +1 -0
  130. package/dist/api/riff/index.d.ts +218 -0
  131. package/dist/api/riff/index.d.ts.map +1 -0
  132. package/dist/api/riff/index.js +54 -0
  133. package/dist/api/riff/index.js.map +1 -0
  134. package/dist/api/search/index.d.ts +269 -0
  135. package/dist/api/search/index.d.ts.map +1 -0
  136. package/dist/api/search/index.js +45 -0
  137. package/dist/api/search/index.js.map +1 -0
  138. package/dist/api/setting/index.d.ts +150 -0
  139. package/dist/api/setting/index.d.ts.map +1 -0
  140. package/dist/api/setting/index.js +66 -0
  141. package/dist/api/setting/index.js.map +1 -0
  142. package/dist/api/snippet/index.d.ts +42 -0
  143. package/dist/api/snippet/index.d.ts.map +1 -0
  144. package/dist/api/snippet/index.js +12 -0
  145. package/dist/api/snippet/index.js.map +1 -0
  146. package/dist/api/storage/index.d.ts +122 -0
  147. package/dist/api/storage/index.d.ts.map +1 -0
  148. package/dist/api/storage/index.js +45 -0
  149. package/dist/api/storage/index.js.map +1 -0
  150. package/dist/api/sync/index.d.ts +176 -0
  151. package/dist/api/sync/index.d.ts.map +1 -0
  152. package/dist/api/sync/index.js +70 -0
  153. package/dist/api/sync/index.js.map +1 -0
  154. package/dist/api/system/index.d.ts +264 -4
  155. package/dist/api/system/index.d.ts.map +1 -1
  156. package/dist/api/system/index.js +109 -4
  157. package/dist/api/system/index.js.map +1 -1
  158. package/dist/api/tag/index.d.ts +37 -0
  159. package/dist/api/tag/index.d.ts.map +1 -0
  160. package/dist/api/tag/index.js +12 -0
  161. package/dist/api/tag/index.js.map +1 -0
  162. package/dist/api/template/index.d.ts +12 -0
  163. package/dist/api/template/index.d.ts.map +1 -1
  164. package/dist/api/template/index.js +3 -0
  165. package/dist/api/template/index.js.map +1 -1
  166. package/dist/api/transactions/index.d.ts +18 -0
  167. package/dist/api/transactions/index.d.ts.map +1 -0
  168. package/dist/api/transactions/index.js +6 -0
  169. package/dist/api/transactions/index.js.map +1 -0
  170. package/dist/api/ui/index.d.ts +44 -0
  171. package/dist/api/ui/index.d.ts.map +1 -0
  172. package/dist/api/ui/index.js +21 -0
  173. package/dist/api/ui/index.js.map +1 -0
  174. package/dist/types/index.d.ts +4 -0
  175. package/dist/types/index.d.ts.map +1 -1
  176. package/package.json +6 -4
  177. package/dist/api/sql/index.d.ts.map +0 -1
  178. package/dist/api/sql/index.js.map +0 -1
  179. package/src/api/archive/index.ts +0 -26
  180. package/src/api/asset/index.ts +0 -26
  181. package/src/api/attr/index.ts +0 -72
  182. package/src/api/block/index.ts +0 -285
  183. package/src/api/convert/index.ts +0 -18
  184. package/src/api/export/index.ts +0 -36
  185. package/src/api/file/index.ts +0 -77
  186. package/src/api/filetree/index.ts +0 -129
  187. package/src/api/index.ts +0 -56
  188. package/src/api/network/index.ts +0 -32
  189. package/src/api/notebook/index.ts +0 -102
  190. package/src/api/notification/index.ts +0 -33
  191. package/src/api/sql/index.ts +0 -65
  192. package/src/api/sqlite/index.ts +0 -20
  193. package/src/api/system/index.ts +0 -46
  194. package/src/api/template/index.ts +0 -32
  195. package/src/core/index.ts +0 -287
  196. package/src/index.ts +0 -16
  197. package/src/types/index.ts +0 -201
  198. package/src/types/transaction/index.ts +0 -45
  199. package/src/utils/index.ts +0 -3
@@ -1,129 +0,0 @@
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 DELETED
@@ -1,56 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
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
-
@@ -1,102 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import type {
3
- Notebook,
4
- NotebookId,
5
- } from '../../types/index.js'
6
- import { SiYuanAPI } from '../../core/index.js'
7
-
8
-
9
- export interface RespLsNotebooks {
10
- notebooks: Notebook[]
11
- }
12
-
13
- /**
14
- * Notebook API 类型定义
15
- */
16
- export interface NotebookAPI {
17
- /**
18
- * List all notebooks
19
- * @path /api/notebook/lsNotebooks
20
- * @returns - Promise<{ notebooks: Notebook[] }>
21
- */
22
- lsNotebooks: () => SyApiMethodResponse<RespLsNotebooks>
23
- /**
24
- * 打开笔记本
25
- * @path /api/notebook/openNotebook
26
- */
27
- openNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
28
- /**
29
- * 关闭笔记本
30
- * @path /api/notebook/closeNotebook
31
- */
32
- closeNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
33
- /**
34
- * 重命名笔记本
35
- * @path /api/notebook/renameNotebook
36
- */
37
- renameNotebook: (
38
- notebook: NotebookId,
39
- name: string
40
- ) => SyApiMethodResponse<any>
41
- /**
42
- * 创建笔记本
43
- * @path /api/notebook/createNotebook
44
- */
45
- createNotebook: (name: string) => SyApiMethodResponse<any>
46
- /**
47
- * 删除笔记本
48
- * @path /api/notebook/removeNotebook
49
- */
50
- removeNotebook: (notebook: NotebookId) => SyApiMethodResponse<any>
51
- /**
52
- * 获取笔记本配置
53
- * @path /api/notebook/getNotebookConf
54
- */
55
- getNotebookConf: (notebook: NotebookId) => SyApiMethodResponse<any>
56
- /**
57
- * 设置笔记本配置
58
- * @path /api/notebook/setNotebookConf
59
- */
60
- setNotebookConf: (
61
- notebook: NotebookId,
62
- conf: any
63
- ) => SyApiMethodResponse<any>
64
- }
65
-
66
- SiYuanAPI.prototype.lsNotebooks = function () {
67
- return this.request('/api/notebook/lsNotebooks', '')
68
- }
69
-
70
- SiYuanAPI.prototype.openNotebook = function (notebook: string) {
71
- return this.request('/api/notebook/openNotebook', { notebook })
72
- }
73
-
74
- SiYuanAPI.prototype.closeNotebook = function (notebook: string) {
75
- return this.request('/api/notebook/closeNotebook', { notebook })
76
- }
77
-
78
- SiYuanAPI.prototype.renameNotebook = function (notebook: string, name: string) {
79
- return this.request('/api/notebook/renameNotebook', {
80
- notebook,
81
- name,
82
- })
83
- }
84
-
85
- SiYuanAPI.prototype.createNotebook = function (name: string) {
86
- return this.request('/api/notebook/createNotebook', { name })
87
- }
88
-
89
- SiYuanAPI.prototype.removeNotebook = function (notebook: string) {
90
- return this.request('/api/notebook/removeNotebook', { notebook })
91
- }
92
-
93
- SiYuanAPI.prototype.getNotebookConf = function (notebook: string) {
94
- return this.request('/api/notebook/getNotebookConf', { notebook })
95
- }
96
-
97
- SiYuanAPI.prototype.setNotebookConf = function (notebook: string, conf: any) {
98
- return this.request('/api/notebook/setNotebookConf', {
99
- notebook,
100
- conf,
101
- })
102
- }
@@ -1,33 +0,0 @@
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
-
@@ -1,65 +0,0 @@
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
-
@@ -1,20 +0,0 @@
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
-
@@ -1,46 +0,0 @@
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
-
@@ -1,32 +0,0 @@
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
-