@wetoria/siyuan-sdk 0.0.4 → 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 +22 -1
  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 -69
  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
@@ -0,0 +1,44 @@
1
+ import type { SyApiMethodResponse } from '../../core/index.js';
2
+ import type { SiyuanID } from '../../types/index.js';
3
+ /**
4
+ * UI API 类型定义
5
+ */
6
+ export interface UIAPI {
7
+ /**
8
+ * 重新加载 UI
9
+ * @path /api/ui/reloadUI
10
+ */
11
+ reloadUI: () => SyApiMethodResponse<any>;
12
+ /**
13
+ * 重新加载图标
14
+ * @path /api/ui/reloadIcon
15
+ */
16
+ reloadIcon: () => SyApiMethodResponse<any>;
17
+ /**
18
+ * 重新加载属性视图
19
+ * @path /api/ui/reloadAttributeView
20
+ */
21
+ reloadAttributeView: (data: {
22
+ /** 属性视图 ID(必需) */
23
+ id: SiyuanID;
24
+ }) => SyApiMethodResponse<any>;
25
+ /**
26
+ * 重新加载编辑器
27
+ * @path /api/ui/reloadProtyle
28
+ */
29
+ reloadProtyle: (data: {
30
+ /** 块 ID(必需) */
31
+ id: SiyuanID;
32
+ }) => SyApiMethodResponse<any>;
33
+ /**
34
+ * 重新加载文件树
35
+ * @path /api/ui/reloadFiletree
36
+ */
37
+ reloadFiletree: () => SyApiMethodResponse<any>;
38
+ /**
39
+ * 重新加载标签
40
+ * @path /api/ui/reloadTag
41
+ */
42
+ reloadTag: () => SyApiMethodResponse<any>;
43
+ }
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAGpD;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,QAAQ,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAExC;;;OAGG;IACH,UAAU,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAE1C;;;OAGG;IACH,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAC1B,kBAAkB;QAClB,EAAE,EAAE,QAAQ,CAAA;KACb,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAE9B;;;OAGG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE;QACpB,eAAe;QACf,EAAE,EAAE,QAAQ,CAAA;KACb,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAE9B;;;OAGG;IACH,cAAc,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAE9C;;;OAGG;IACH,SAAS,EAAE,MAAM,mBAAmB,CAAC,GAAG,CAAC,CAAA;CAC1C"}
@@ -0,0 +1,21 @@
1
+ import { SiYuanAPI } from '../../core/index.js';
2
+ // 实现部分
3
+ SiYuanAPI.prototype.reloadUI = function () {
4
+ return this.request('/api/ui/reloadUI', {});
5
+ };
6
+ SiYuanAPI.prototype.reloadIcon = function () {
7
+ return this.request('/api/ui/reloadIcon', {});
8
+ };
9
+ SiYuanAPI.prototype.reloadAttributeView = function (data) {
10
+ return this.request('/api/ui/reloadAttributeView', data);
11
+ };
12
+ SiYuanAPI.prototype.reloadProtyle = function (data) {
13
+ return this.request('/api/ui/reloadProtyle', data);
14
+ };
15
+ SiYuanAPI.prototype.reloadFiletree = function () {
16
+ return this.request('/api/ui/reloadFiletree', {});
17
+ };
18
+ SiYuanAPI.prototype.reloadTag = function () {
19
+ return this.request('/api/ui/reloadTag', {});
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/ui/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAiD/C,OAAO;AACP,SAAS,CAAC,SAAS,CAAC,QAAQ,GAAG;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,UAAU,GAAG;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAU,IAEnD;IACC,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE,IAAI,CAAC,CAAA;AAC1D,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,IAE7C;IACC,OAAO,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAA;AACpD,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,cAAc,GAAG;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,SAAS,GAAG;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAA;AAC9C,CAAC,CAAA"}
@@ -2,6 +2,10 @@ export * from './transaction';
2
2
  /**
3
3
  * Frequently used data structures in SiYuan
4
4
  */
5
+ /**
6
+ * siyuan ID like 20241107110211-someHash
7
+ */
8
+ export type SiyuanID = string;
5
9
  export type DocumentId = string;
6
10
  export type BlockId = string;
7
11
  export type NotebookId = string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAC/B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAA;AAC5B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAC/B,MAAM,MAAM,UAAU,GAAG,OAAO,CAAA;AAChC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,UAAU,CAAA;AAC3C,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,KAAK,CAAA;AAEzC,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,UAAU,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAA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AA;IACd,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,YAAY,CAAA;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAID,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,GAAG,CAAA;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,WAAW,EAAE,CAAA;IACzB,MAAM,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,OAAO,CAAA;IACX,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAA;IACX,EAAE,EAAE,OAAO,CAAA;CACZ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wetoria/siyuan-sdk",
3
- "version": "0.0.4",
3
+ "version": "1.0.0",
4
4
  "description": "SiYuan SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,9 +8,11 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.js"
11
+ "types": "./src/index.ts",
12
+ "development": "./src/index.ts",
13
+ "import": "./src/index.ts",
14
+ "require": "./src/index.ts",
15
+ "default": "./dist/index.js"
14
16
  }
15
17
  },
16
18
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/sql/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACR,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAEL,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAG5B;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;OASG;IACH,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,EACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,KACE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAA;IAC7B;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;CACtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/sql/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,GAEV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAiCnD,SAAS,CAAC,SAAS,CAAC,GAAG,GAAG,UACxB,IAAY,EACZ,UAEI,EAAE;IAEN,MAAM,EACJ,IAAI,GAAG,IAAI,GACZ,GAAG,OAAO,CAAA;IACX,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IAClD,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;QACpC,IAAI,EAAE,SAAS;KAChB,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,WAAW,OAAe;IAChE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,mCAAmC,OAAO,GAAG,CAAC,CAAA;IACzE,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI;KAC5B,CAAA;AACH,CAAC,CAAA"}
@@ -1,26 +0,0 @@
1
- import {
2
- SiYuanAPI,
3
- SyApiMethodResponse,
4
- } from '../../core/index.js'
5
-
6
- /**
7
- * Archive API 类型定义
8
- */
9
- export interface ArchiveAPI {
10
- /**
11
- * 解压 ZIP 文件
12
- * @path /api/archive/unzip
13
- */
14
- unzip: <T = any>(
15
- zipPath: string,
16
- path: string
17
- ) => SyApiMethodResponse<T>
18
- }
19
-
20
- SiYuanAPI.prototype.unzip = function <T = any>(zipPath: string, path: string): SyApiMethodResponse<T> {
21
- return this.request('/api/archive/unzip', {
22
- zipPath,
23
- path,
24
- })
25
- }
26
-
@@ -1,26 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import { SiYuanAPI } from '../../core/index.js'
3
-
4
- /**
5
- * Asset Files API 类型定义
6
- */
7
- export interface AssetAPI {
8
- /**
9
- * 上传资源文件
10
- * @path /api/asset/upload
11
- */
12
- upload: (
13
- assetsDirPath: string,
14
- files: any[]
15
- ) => SyApiMethodResponse<any>
16
- }
17
-
18
- SiYuanAPI.prototype.upload = function (assetsDirPath: string, files: any[]) {
19
- const form = new FormData()
20
- form.append('assetsDirPath', assetsDirPath)
21
- for (const file of files) {
22
- form.append('file[]', file)
23
- }
24
- return this.request('/api/asset/upload', form)
25
- }
26
-
@@ -1,72 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import type {
3
- BlockId,
4
- IBlockAttrs,
5
- ISettableBlockAttrs,
6
- } from '../../types/index.js'
7
- import { SiYuanAPI } from '../../core/index.js'
8
-
9
- /**
10
- * Attributes API 类型定义
11
- */
12
- export interface AttrAPI {
13
- /**
14
- * 设置块属性
15
- * @path /api/attr/setBlockAttrs
16
- * @param id - The ID of the block
17
- * @param attrs - The attributes to set. System properties (id, updated, type, status, refcount, parent-heading, embed-content, scroll) are not allowed to be modified
18
- * @returns - Promise<{ code: number, msg: string, data: null }>
19
- */
20
- setBlockAttrs: (
21
- id: BlockId,
22
- attrs: Partial<ISettableBlockAttrs>
23
- ) => SyApiMethodResponse<null>
24
- /**
25
- * 获取块属性
26
- * @path /api/attr/getBlockAttrs
27
- * @param id - The ID of the block
28
- * @returns - Promise<{ code: number, msg: string, data: IBlockAttrs }>
29
- */
30
- getBlockAttrs: (id: BlockId) => SyApiMethodResponse<IBlockAttrs>
31
- /**
32
- * 批量设置块属性
33
- * @path /api/attr/batchSetBlockAttrs
34
- * @param blockAttrs - Array of block attributes to set
35
- * @param blockAttrs[].id - The ID of the block
36
- * @param blockAttrs[].attrs - The attributes to set. System properties (id, updated, type, status, refcount, parent-heading, embed-content, scroll) are not allowed to be modified
37
- * @returns - Promise<{ code: number, msg: string, data: null }>
38
- */
39
- batchSetBlockAttrs: (blockAttrs: Array<{
40
- id: BlockId
41
- attrs: Partial<ISettableBlockAttrs>
42
- }>) => SyApiMethodResponse<null>
43
- /**
44
- * 批量获取块属性
45
- * @path /api/attr/batchGetBlockAttrs
46
- * @param ids - The IDs of the blocks
47
- * @returns - Promise<{ code: number, msg: string, data: { [key: string]: IBlockAttrs } }>
48
- */
49
- batchGetBlockAttrs: (ids: BlockId[]) => SyApiMethodResponse<{
50
- [key: string]: IBlockAttrs
51
- }>
52
- }
53
-
54
- SiYuanAPI.prototype.setBlockAttrs = function (id: string, attrs: Partial<ISettableBlockAttrs>) {
55
- return this.request('/api/attr/setBlockAttrs', {
56
- id,
57
- attrs,
58
- })
59
- }
60
-
61
- SiYuanAPI.prototype.getBlockAttrs = function (id: string) {
62
- return this.request('/api/attr/getBlockAttrs', { id })
63
- }
64
-
65
- SiYuanAPI.prototype.batchSetBlockAttrs = function (blockAttrs: Array<{ id: string, attrs: Partial<ISettableBlockAttrs> }>) {
66
- return this.request('/api/attr/batchSetBlockAttrs', { blockAttrs })
67
- }
68
-
69
- SiYuanAPI.prototype.batchGetBlockAttrs = function (ids: string[]) {
70
- return this.request('/api/attr/batchGetBlockAttrs', { ids })
71
- }
72
-
@@ -1,285 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import type {
3
- Block,
4
- BlockDOM,
5
- BlockId,
6
- ChildBlock,
7
- NotebookId,
8
- TransactionItem,
9
- } from '../../types/index.js'
10
- import { SiYuanAPI } from '../../core/index.js'
11
-
12
- /**
13
- * Block API 类型定义
14
- */
15
- export interface BlockAPI {
16
- /**
17
- * 插入块
18
- * @path /api/block/insertBlock
19
- * @param data - The data for the block
20
- * @param data.dataType - The type of the data(markdown, dom), default is 'markdown'
21
- * @param data.data - The data for the block
22
- * @param data.nextID - The next ID of the block
23
- * @param data.previousID - The previous ID of the block
24
- * @param data.parentID - The parent ID of the block
25
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
26
- */
27
- insertBlock: (data: {
28
- dataType?: 'markdown' | 'dom'
29
- data: string
30
- nextID?: BlockId
31
- previousID?: BlockId
32
- parentID?: BlockId
33
- }) => SyApiMethodResponse<TransactionItem[]>
34
- /**
35
- * 在块的开头插入内容
36
- * @path /api/block/prependBlock
37
- * @param dataType - The type of the data(markdown, dom)
38
- * @param data - The data for the block
39
- * @param parentID - The parent ID of the block
40
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
41
- */
42
- prependBlock: (
43
- dataType: 'markdown' | 'dom',
44
- data: string,
45
- parentID: BlockId
46
- ) => SyApiMethodResponse<TransactionItem[]>
47
- /**
48
- * 在块的末尾追加内容
49
- * @path /api/block/appendBlock
50
- * @param dataType - The type of the data(markdown, dom), default is 'markdown'
51
- * @param data - The data for the block
52
- * @param parentID - The parent ID of the block
53
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
54
- */
55
- appendBlock: (
56
- dataType: 'markdown' | 'dom',
57
- data: string,
58
- parentID: BlockId
59
- ) => SyApiMethodResponse<TransactionItem[]>
60
- /**
61
- * 追加 Markdown 内容到块(便捷方法)
62
- * @path wrapper: uses appendBlock
63
- * @param params - The parameters for appending markdown content
64
- * @param params.data - The markdown data for the block
65
- * @param params.parentID - The parent ID of the block
66
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
67
- */
68
- appendMDToBlock: (params: {
69
- data: string
70
- parentID: BlockId
71
- }) => SyApiMethodResponse<TransactionItem[]>
72
- /**
73
- * 追加 Markdown 内容到块并返回块 ID(便捷方法)
74
- * @path wrapper: uses appendBlock
75
- */
76
- appendMDToBlockAndGetBlockId: (params: {
77
- data: string
78
- parentID: BlockId
79
- }) => SyApiMethodResponse<string | undefined>
80
- /**
81
- * 追加内容到日记
82
- * @path /api/block/appendDailyNoteBlock
83
- */
84
- appendDailyNoteBlock: (
85
- dataType: 'markdown' | 'dom',
86
- data: string,
87
- notebook: NotebookId
88
- ) => SyApiMethodResponse<any[]>
89
- /**
90
- * 更新块内容
91
- * @path /api/block/updateBlock
92
- * @param dataType - The type of the data(markdown, dom)
93
- * @param data - The data for the block
94
- * @param id - The ID of the block to update
95
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
96
- */
97
- updateBlock: (
98
- dataType: 'markdown' | 'dom',
99
- data: string,
100
- id: BlockId
101
- ) => SyApiMethodResponse<TransactionItem[]>
102
- batchUpdateBlock: (
103
- blocks: Array<{
104
- id: string
105
- data: string
106
- dataType?: "markdown" | "dom"
107
- }>
108
- ) => SyApiMethodResponse<TransactionItem[]>
109
- /**
110
- * 删除块
111
- * @path /api/block/deleteBlock
112
- * @param id - The ID of the block to delete
113
- * @returns - Promise<{ code: number, msg: string, data: TransactionItem[] }>
114
- */
115
- deleteBlock: (id: BlockId) => SyApiMethodResponse<TransactionItem[]>
116
- /**
117
- * 移动块
118
- * @path /api/block/moveBlock
119
- */
120
- moveBlock: (
121
- id: BlockId,
122
- previousID?: BlockId,
123
- parentID?: BlockId
124
- ) => SyApiMethodResponse<any[]>
125
- /**
126
- * 获取块的 Kramdown 格式
127
- * @path /api/block/getBlockKramdown
128
- */
129
- getBlockKramdown: (id: BlockId) => SyApiMethodResponse<any>
130
- /**
131
- * 获取子块列表
132
- * @path /api/block/getChildBlocks
133
- * @param id - The ID of the parent block
134
- * @returns - Promise<{ code: number, msg: string, data: ChildBlock[] }>
135
- */
136
- getChildBlocks: (id: BlockId) => SyApiMethodResponse<ChildBlock[]>
137
- /**
138
- * 获取块的索引位置
139
- * @path /api/block/getBlocksIndexes
140
- */
141
- getBlocksIndexes: (ids: BlockId[]) => SyApiMethodResponse<{
142
- [key: string]: number
143
- }>
144
- /**
145
- * 转移块引用
146
- * @path /api/block/transferBlockRef
147
- */
148
- transferBlockRef: (
149
- fromID: BlockId,
150
- toID: BlockId,
151
- refIDs: BlockId[]
152
- ) => SyApiMethodResponse<any>
153
- /**
154
- * 获取块信息(通过 SQL 查询)
155
- * @path wrapper: uses sql
156
- */
157
- getBlockInfo: (id: BlockId) => SyApiMethodResponse<Block>
158
- /**
159
- * 获取块的 DOM 结构
160
- * @path /api/block/getBlockDOM
161
- * @param id - The ID of the block
162
- * @returns - Promise<{ code: number, msg: string, data: BlockDOM }>
163
- */
164
- getBlockDOM: (id: BlockId) => SyApiMethodResponse<BlockDOM>
165
- /**
166
- * 批量获取块的 DOM 结构
167
- * @path /api/block/getBlockDOMs
168
- * @param ids - The IDs of the blocks
169
- * @returns - Promise<{ code: number, msg: string, data: BlockDOM[] }>
170
- */
171
- getBlockDOMs: (ids: BlockId[]) => SyApiMethodResponse<BlockDOM[]>
172
- }
173
-
174
-
175
- SiYuanAPI.prototype.insertBlock = function (data: {
176
- dataType?: 'markdown' | 'dom'
177
- data: string
178
- nextID?: string
179
- previousID?: string
180
- parentID?: string
181
- }) {
182
- return this.request('/api/block/insertBlock', {
183
- ...data,
184
- dataType: data.dataType || 'markdown',
185
- })
186
- }
187
-
188
- SiYuanAPI.prototype.prependBlock = function (dataType: 'markdown' | 'dom', data: string, parentID: string) {
189
- return this.request('/api/block/prependBlock', {
190
- dataType,
191
- data,
192
- parentID,
193
- })
194
- }
195
-
196
- SiYuanAPI.prototype.appendBlock = function (dataType: 'markdown' | 'dom' = 'markdown', data: string, parentID: string) {
197
- return this.request('/api/block/appendBlock', {
198
- dataType,
199
- data,
200
- parentID,
201
- })
202
- }
203
-
204
- SiYuanAPI.prototype.appendMDToBlock = function (params: { data: string, parentID: string }) {
205
- return this.appendBlock('markdown', params.data, params.parentID)
206
- }
207
-
208
- SiYuanAPI.prototype.appendMDToBlockAndGetBlockId = async function (params: { data: string, parentID: string }) {
209
- const res = await this.appendBlock('markdown', params.data, params.parentID)
210
- return {
211
- code: res.code,
212
- msg: res.msg,
213
- data: res.data?.[0]?.doOperations?.[0]?.id,
214
- }
215
- }
216
-
217
- SiYuanAPI.prototype.appendDailyNoteBlock = function (dataType: 'markdown' | 'dom', data: string, notebook: string) {
218
- return this.request('/api/block/appendDailyNoteBlock', {
219
- dataType,
220
- data,
221
- notebook,
222
- })
223
- }
224
-
225
- SiYuanAPI.prototype.updateBlock = function (dataType: 'markdown' | 'dom', data: string, id: string) {
226
- return this.request('/api/block/updateBlock', {
227
- dataType,
228
- data,
229
- id,
230
- })
231
- }
232
-
233
- SiYuanAPI.prototype.batchUpdateBlock = function (blocks: Array<{ id: string, data: string, dataType?: "markdown" | "dom" }>) {
234
- return this.request('/api/block/batchUpdateBlock', { blocks })
235
- }
236
-
237
- SiYuanAPI.prototype.deleteBlock = function (id: string) {
238
- return this.request('/api/block/deleteBlock', { id })
239
- }
240
-
241
- SiYuanAPI.prototype.moveBlock = function (id: string, previousID?: string, parentID?: string) {
242
- return this.request('/api/block/moveBlock', {
243
- id,
244
- previousID,
245
- parentID,
246
- })
247
- }
248
-
249
- SiYuanAPI.prototype.getBlockKramdown = function (id: string) {
250
- return this.request('/api/block/getBlockKramdown', { id })
251
- }
252
-
253
- SiYuanAPI.prototype.getChildBlocks = function (id: string) {
254
- return this.request('/api/block/getChildBlocks', { id })
255
- }
256
-
257
- SiYuanAPI.prototype.getBlocksIndexes = function (ids: string[]) {
258
- return this.request('/api/block/getBlocksIndexes', { ids })
259
- }
260
-
261
- SiYuanAPI.prototype.transferBlockRef = function (fromID: string, toID: string, refIDs: string[]) {
262
- return this.request('/api/block/transferBlockRef', {
263
- fromID,
264
- toID,
265
- refIDs,
266
- })
267
- }
268
-
269
- SiYuanAPI.prototype.getBlockInfo = async function (id: string) {
270
- const res = await this.sql(`select * from blocks where id = '${id}'`)
271
- return {
272
- code: res.code,
273
- msg: res.msg,
274
- data: res.data?.[0],
275
- }
276
- }
277
-
278
- SiYuanAPI.prototype.getBlockDOM = function (id: string) {
279
- return this.request('/api/block/getBlockDOM', { id })
280
- }
281
-
282
- SiYuanAPI.prototype.getBlockDOMs = function (ids: string[]) {
283
- return this.request('/api/block/getBlockDOMs', { ids })
284
- }
285
-
@@ -1,18 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import { SiYuanAPI } from '../../core/index.js'
3
-
4
- /**
5
- * Convert API 类型定义
6
- */
7
- export interface ConvertAPI {
8
- /**
9
- * 使用 Pandoc 转换文档
10
- * @path /api/convert/pandoc
11
- */
12
- pandoc: (args: string[]) => SyApiMethodResponse<any>
13
- }
14
-
15
- SiYuanAPI.prototype.pandoc = function (args: string[]) {
16
- return this.request('/api/convert/pandoc', { args })
17
- }
18
-
@@ -1,36 +0,0 @@
1
- import type { SyApiMethodResponse } from '../../core/index.js'
2
- import type { DocumentId } from '../../types/index.js'
3
-
4
- // 实现
5
- import { SiYuanAPI } from '../../core/index.js'
6
-
7
- /**
8
- * Export API 类型定义
9
- */
10
- export interface ExportAPI {
11
- /**
12
- * 导出 Markdown 内容
13
- * @path /api/export/exportMdContent
14
- */
15
- exportMdContent: (id: DocumentId) => SyApiMethodResponse<any>
16
- /**
17
- * 导出资源文件
18
- * @path /api/export/exportResources
19
- */
20
- exportResources: (
21
- paths: string[],
22
- name: string
23
- ) => SyApiMethodResponse<any>
24
- }
25
-
26
- SiYuanAPI.prototype.exportMdContent = function (id: string) {
27
- return this.request('/api/export/exportMdContent', { id })
28
- }
29
-
30
- SiYuanAPI.prototype.exportResources = function (paths: string[], name: string) {
31
- return this.request('/api/export/exportResources', {
32
- paths,
33
- name,
34
- })
35
- }
36
-
@@ -1,69 +0,0 @@
1
- import {
2
- SiYuanAPI,
3
- SyApiMethodResponse,
4
- SyApiResponse,
5
- } from '../../core/index.js'
6
-
7
- /**
8
- * File API 类型定义
9
- */
10
- export interface FileAPI {
11
- /**
12
- * 获取文件内容
13
- * @path /api/file/getFile
14
- * @param path - The file path
15
- * @returns - Promise<string | SyApiResponse<string | null>>
16
- * 返回值可能是:
17
- * - 文件存在时:直接返回文件内容(字符串)
18
- * - 文件不存在或出错时:标准结构 { code: number, msg: string, data: null }
19
- * - code: 404 表示文件不存在
20
- * - code: 403 表示路径无效或权限不足
21
- * - code: 405 表示路径是目录
22
- * - code: 500 表示读取文件失败
23
- */
24
- getFile: (path: string) => Promise<string | SyApiResponse<string | null>>
25
- /**
26
- * 上传/创建文件
27
- * @path /api/file/putFile
28
- */
29
- putFile: (path: string, isDir: boolean, file: any) => SyApiMethodResponse<any>
30
- /**
31
- * 删除文件
32
- * @path /api/file/removeFile
33
- */
34
- removeFile: (path: string) => SyApiMethodResponse<any>
35
- /**
36
- * 读取目录
37
- * @path /api/file/readDir
38
- */
39
- readDir: (path: string) => SyApiMethodResponse<any>
40
- }
41
-
42
- SiYuanAPI.prototype.getFile = async function (path: string) {
43
- try {
44
- return await this.request('/api/file/getFile', { path })
45
- } catch {
46
- return {
47
- code: -1,
48
- msg: 'Failed to get file',
49
- data: null,
50
- }
51
- }
52
- }
53
-
54
- SiYuanAPI.prototype.putFile = function (path: string, isDir: boolean, file: any) {
55
- const form = new FormData()
56
- form.append('path', path)
57
- form.append('isDir', isDir.toString())
58
- form.append('file', file)
59
- return this.request('/api/file/putFile', form)
60
- }
61
-
62
- SiYuanAPI.prototype.removeFile = function (path: string) {
63
- return this.request('/api/file/removeFile', { path })
64
- }
65
-
66
- SiYuanAPI.prototype.readDir = function (path: string) {
67
- return this.request('/api/file/readDir', { path })
68
- }
69
-