@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
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @wetoria/siyuan-sdk
|
|
2
|
+
|
|
3
|
+
SiYuan SDK for TypeScript
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @wetoria/siyuan-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createClient } from '@wetoria/siyuan-sdk'
|
|
15
|
+
|
|
16
|
+
// Create a client instance
|
|
17
|
+
const client = createClient({
|
|
18
|
+
baseURL: 'http://localhost:6806',
|
|
19
|
+
token: 'your-token',
|
|
20
|
+
timeout: 30000,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
// Make API requests
|
|
24
|
+
const response = await client.request('/api/notebook/lsNotebooks')
|
|
25
|
+
console.log(response.data)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Build
|
|
32
|
+
pnpm build
|
|
33
|
+
|
|
34
|
+
# Watch mode
|
|
35
|
+
pnpm dev
|
|
36
|
+
|
|
37
|
+
# Clean
|
|
38
|
+
pnpm clean
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
|
44
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Archive API 类型定义
|
|
4
|
+
*/
|
|
5
|
+
export interface ArchiveAPI {
|
|
6
|
+
/**
|
|
7
|
+
* 解压 ZIP 文件
|
|
8
|
+
* @path /api/archive/unzip
|
|
9
|
+
*/
|
|
10
|
+
unzip: <T = any>(zipPath: string, path: string) => SyApiMethodResponse<T>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/archive/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAE5B;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAC,GAAG,GAAG,EACb,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,KACT,mBAAmB,CAAC,CAAC,CAAC,CAAA;CAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/archive/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAEV,MAAM,qBAAqB,CAAA;AAgB5B,SAAS,CAAC,SAAS,CAAC,KAAK,GAAG,UAAmB,OAAe,EAAE,IAAY;IAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE;QACxC,OAAO;QACP,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Asset Files API 类型定义
|
|
4
|
+
*/
|
|
5
|
+
export interface AssetAPI {
|
|
6
|
+
/**
|
|
7
|
+
* 上传资源文件
|
|
8
|
+
* @path /api/asset/upload
|
|
9
|
+
*/
|
|
10
|
+
upload: (assetsDirPath: string, files: any[]) => SyApiMethodResponse<any>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/asset/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,MAAM,EAAE,CACN,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,GAAG,EAAE,KACT,mBAAmB,CAAC,GAAG,CAAC,CAAA;CAC9B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SiYuanAPI } from '../../core/index.js';
|
|
2
|
+
SiYuanAPI.prototype.upload = function (assetsDirPath, files) {
|
|
3
|
+
const form = new FormData();
|
|
4
|
+
form.append('assetsDirPath', assetsDirPath);
|
|
5
|
+
for (const file of files) {
|
|
6
|
+
form.append('file[]', file);
|
|
7
|
+
}
|
|
8
|
+
return this.request('/api/asset/upload', form);
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/asset/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAgB/C,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,aAAqB,EAAE,KAAY;IACxE,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC3B,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,aAAa,CAAC,CAAA;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC7B,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAA;AAChD,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
import type { BlockId } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Attributes API 类型定义
|
|
5
|
+
*/
|
|
6
|
+
export interface AttrAPI {
|
|
7
|
+
/**
|
|
8
|
+
* 设置块属性
|
|
9
|
+
* @path /api/attr/setBlockAttrs
|
|
10
|
+
*/
|
|
11
|
+
setBlockAttrs: (id: BlockId, attrs: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
}) => SyApiMethodResponse<any>;
|
|
14
|
+
/**
|
|
15
|
+
* 获取块属性
|
|
16
|
+
* @path /api/attr/getBlockAttrs
|
|
17
|
+
*/
|
|
18
|
+
getBlockAttrs: (id: BlockId) => SyApiMethodResponse<{
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* 批量设置块属性
|
|
23
|
+
* @path /api/attr/batchSetBlockAttrs
|
|
24
|
+
*/
|
|
25
|
+
batchSetBlockAttrs: (blockAttrs: Array<{
|
|
26
|
+
id: BlockId;
|
|
27
|
+
attrs: {
|
|
28
|
+
[key: string]: string;
|
|
29
|
+
};
|
|
30
|
+
}>) => SyApiMethodResponse<any>;
|
|
31
|
+
/**
|
|
32
|
+
* 批量获取块属性
|
|
33
|
+
* @path /api/attr/batchGetBlockAttrs
|
|
34
|
+
*/
|
|
35
|
+
batchGetBlockAttrs: (ids: BlockId[]) => SyApiMethodResponse<{
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/attr/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAGnD;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,aAAa,EAAE,CACb,EAAE,EAAE,OAAO,EACX,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,KAC7B,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC7B;;;OAGG;IACH,aAAa,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC;QAClD,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAC,CAAA;IACF;;;OAGG;IACH,kBAAkB,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;QACrC,EAAE,EAAE,OAAO,CAAA;QACX,KAAK,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KACjC,CAAC,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC/B;;;OAGG;IACH,kBAAkB,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,mBAAmB,CAAC;QAC1D,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAC,CAAA;CACH"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SiYuanAPI } from '../../core/index.js';
|
|
2
|
+
SiYuanAPI.prototype.setBlockAttrs = function (id, attrs) {
|
|
3
|
+
return this.request('/api/attr/setBlockAttrs', {
|
|
4
|
+
id,
|
|
5
|
+
attrs,
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
SiYuanAPI.prototype.getBlockAttrs = function (id) {
|
|
9
|
+
return this.request('/api/attr/getBlockAttrs', { id });
|
|
10
|
+
};
|
|
11
|
+
SiYuanAPI.prototype.batchSetBlockAttrs = function (blockAttrs) {
|
|
12
|
+
return this.request('/api/attr/batchSetBlockAttrs', { blockAttrs });
|
|
13
|
+
};
|
|
14
|
+
SiYuanAPI.prototype.batchGetBlockAttrs = function (ids) {
|
|
15
|
+
return this.request('/api/attr/batchGetBlockAttrs', { ids });
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/attr/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAsC/C,SAAS,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,EAAU,EAAE,KAAgC;IACxF,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE;QAC7C,EAAE;QACF,KAAK;KACN,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,aAAa,GAAG,UAAU,EAAU;IACtD,OAAO,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACxD,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,UAAmE;IACpH,OAAO,IAAI,CAAC,OAAO,CAAC,8BAA8B,EAAE,EAAE,UAAU,EAAE,CAAC,CAAA;AACrE,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,kBAAkB,GAAG,UAAU,GAAa;IAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,8BAA8B,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;AAC9D,CAAC,CAAA"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
import type { BlockId, NotebookId } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Block API 类型定义
|
|
5
|
+
*/
|
|
6
|
+
export interface BlockAPI {
|
|
7
|
+
/**
|
|
8
|
+
* 插入块
|
|
9
|
+
* @path /api/block/insertBlock
|
|
10
|
+
*/
|
|
11
|
+
insertBlock: (dataType: 'markdown' | 'dom', data: string, nextID?: BlockId, previousID?: BlockId, parentID?: BlockId) => SyApiMethodResponse<any[]>;
|
|
12
|
+
/**
|
|
13
|
+
* 在块的开头插入内容
|
|
14
|
+
* @path /api/block/prependBlock
|
|
15
|
+
*/
|
|
16
|
+
prependBlock: (dataType: 'markdown' | 'dom', data: string, parentID: BlockId) => SyApiMethodResponse<any[]>;
|
|
17
|
+
/**
|
|
18
|
+
* 在块的末尾追加内容
|
|
19
|
+
* @path /api/block/appendBlock
|
|
20
|
+
*/
|
|
21
|
+
appendBlock: (dataType: 'markdown' | 'dom', data: string, parentID: BlockId) => SyApiMethodResponse<any[]>;
|
|
22
|
+
/**
|
|
23
|
+
* 追加 Markdown 内容到块(便捷方法)
|
|
24
|
+
* @path wrapper: uses appendBlock
|
|
25
|
+
*/
|
|
26
|
+
appendMDToBlock: (params: {
|
|
27
|
+
data: string;
|
|
28
|
+
parentID: BlockId;
|
|
29
|
+
}) => SyApiMethodResponse<any[]>;
|
|
30
|
+
/**
|
|
31
|
+
* 追加 Markdown 内容到块并返回块 ID(便捷方法)
|
|
32
|
+
* @path wrapper: uses appendBlock
|
|
33
|
+
*/
|
|
34
|
+
appendMDToBlockAndGetBlockId: (params: {
|
|
35
|
+
data: string;
|
|
36
|
+
parentID: BlockId;
|
|
37
|
+
}) => SyApiMethodResponse<string | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* 追加内容到日记
|
|
40
|
+
* @path /api/block/appendDailyNoteBlock
|
|
41
|
+
*/
|
|
42
|
+
appendDailyNoteBlock: (dataType: 'markdown' | 'dom', data: string, notebook: NotebookId) => SyApiMethodResponse<any[]>;
|
|
43
|
+
/**
|
|
44
|
+
* 更新块内容
|
|
45
|
+
* @path /api/block/updateBlock
|
|
46
|
+
*/
|
|
47
|
+
updateBlock: (dataType: 'markdown' | 'dom', data: string, id: BlockId) => SyApiMethodResponse<any[]>;
|
|
48
|
+
/**
|
|
49
|
+
* 删除块
|
|
50
|
+
* @path /api/block/deleteBlock
|
|
51
|
+
*/
|
|
52
|
+
deleteBlock: (id: BlockId) => SyApiMethodResponse<any[]>;
|
|
53
|
+
/**
|
|
54
|
+
* 移动块
|
|
55
|
+
* @path /api/block/moveBlock
|
|
56
|
+
*/
|
|
57
|
+
moveBlock: (id: BlockId, previousID?: BlockId, parentID?: BlockId) => SyApiMethodResponse<any[]>;
|
|
58
|
+
/**
|
|
59
|
+
* 获取块的 Kramdown 格式
|
|
60
|
+
* @path /api/block/getBlockKramdown
|
|
61
|
+
*/
|
|
62
|
+
getBlockKramdown: (id: BlockId) => SyApiMethodResponse<any>;
|
|
63
|
+
/**
|
|
64
|
+
* 获取子块列表
|
|
65
|
+
* @path /api/block/getChildBlocks
|
|
66
|
+
*/
|
|
67
|
+
getChildBlocks: (id: BlockId) => SyApiMethodResponse<any[]>;
|
|
68
|
+
/**
|
|
69
|
+
* 获取块的索引位置
|
|
70
|
+
* @path /api/block/getBlocksIndexes
|
|
71
|
+
*/
|
|
72
|
+
getBlocksIndexes: (ids: BlockId[]) => SyApiMethodResponse<{
|
|
73
|
+
[key: string]: number;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* 转移块引用
|
|
77
|
+
* @path /api/block/transferBlockRef
|
|
78
|
+
*/
|
|
79
|
+
transferBlockRef: (fromID: BlockId, toID: BlockId, refIDs: BlockId[]) => SyApiMethodResponse<any>;
|
|
80
|
+
/**
|
|
81
|
+
* 获取块信息(通过 SQL 查询)
|
|
82
|
+
* @path wrapper: uses sql
|
|
83
|
+
*/
|
|
84
|
+
getBlockInfo: (id: BlockId) => SyApiMethodResponse<any>;
|
|
85
|
+
/**
|
|
86
|
+
* 获取块的 DOM 结构
|
|
87
|
+
* @path /api/block/getBlockDOM
|
|
88
|
+
*/
|
|
89
|
+
getBlockDOM: (id: BlockId) => SyApiMethodResponse<any>;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/block/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBA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AAK,EAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,OAAO,KACR,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/B;;;OAGG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAA;IACxD;;;OAGG;IACH,SAAS,EAAE,CACT,EAAE,EAAE,OAAO,EACX,UAAU,CAAC,EAAE,OAAO,EACpB,QAAQ,CAAC,EAAE,OAAO,KACf,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/B;;;OAGG;IACH,gBAAgB,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC3D;;;OAGG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,GAAG,EAAE,CAAC,CAAA;IAC3D;;;OAGG;IACH,gBAAgB,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,mBAAmB,CAAC;QACxD,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAC,CAAA;IACF;;;OAGG;IACH,gBAAgB,EAAE,CAChB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,EAAE,KACd,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC7B;;;OAGG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACvD;;;OAGG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;CACvD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { SiYuanAPI } from '../../core/index.js';
|
|
2
|
+
SiYuanAPI.prototype.insertBlock = function (dataType, data, nextID, previousID, parentID) {
|
|
3
|
+
return this.request('/api/block/insertBlock', {
|
|
4
|
+
dataType,
|
|
5
|
+
data,
|
|
6
|
+
nextID,
|
|
7
|
+
previousID,
|
|
8
|
+
parentID,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
SiYuanAPI.prototype.prependBlock = function (dataType, data, parentID) {
|
|
12
|
+
return this.request('/api/block/prependBlock', {
|
|
13
|
+
dataType,
|
|
14
|
+
data,
|
|
15
|
+
parentID,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
SiYuanAPI.prototype.appendBlock = function (dataType = 'markdown', data, parentID) {
|
|
19
|
+
return this.request('/api/block/appendBlock', {
|
|
20
|
+
dataType,
|
|
21
|
+
data,
|
|
22
|
+
parentID,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
SiYuanAPI.prototype.appendMDToBlock = function (params) {
|
|
26
|
+
return this.appendBlock('markdown', params.data, params.parentID);
|
|
27
|
+
};
|
|
28
|
+
SiYuanAPI.prototype.appendMDToBlockAndGetBlockId = async function (params) {
|
|
29
|
+
const res = await this.appendBlock('markdown', params.data, params.parentID);
|
|
30
|
+
return {
|
|
31
|
+
code: res.code,
|
|
32
|
+
msg: res.msg,
|
|
33
|
+
data: res.data?.[0]?.doOperations?.[0]?.id,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
SiYuanAPI.prototype.appendDailyNoteBlock = function (dataType, data, notebook) {
|
|
37
|
+
return this.request('/api/block/appendDailyNoteBlock', {
|
|
38
|
+
dataType,
|
|
39
|
+
data,
|
|
40
|
+
notebook,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
SiYuanAPI.prototype.updateBlock = function (dataType, data, id) {
|
|
44
|
+
return this.request('/api/block/updateBlock', {
|
|
45
|
+
dataType,
|
|
46
|
+
data,
|
|
47
|
+
id,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
SiYuanAPI.prototype.deleteBlock = function (id) {
|
|
51
|
+
return this.request('/api/block/deleteBlock', { id });
|
|
52
|
+
};
|
|
53
|
+
SiYuanAPI.prototype.moveBlock = function (id, previousID, parentID) {
|
|
54
|
+
return this.request('/api/block/moveBlock', {
|
|
55
|
+
id,
|
|
56
|
+
previousID,
|
|
57
|
+
parentID,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
SiYuanAPI.prototype.getBlockKramdown = function (id) {
|
|
61
|
+
return this.request('/api/block/getBlockKramdown', { id });
|
|
62
|
+
};
|
|
63
|
+
SiYuanAPI.prototype.getChildBlocks = function (id) {
|
|
64
|
+
return this.request('/api/block/getChildBlocks', { id });
|
|
65
|
+
};
|
|
66
|
+
SiYuanAPI.prototype.getBlocksIndexes = function (ids) {
|
|
67
|
+
return this.request('/api/block/getBlocksIndexes', { ids });
|
|
68
|
+
};
|
|
69
|
+
SiYuanAPI.prototype.transferBlockRef = function (fromID, toID, refIDs) {
|
|
70
|
+
return this.request('/api/block/transferBlockRef', {
|
|
71
|
+
fromID,
|
|
72
|
+
toID,
|
|
73
|
+
refIDs,
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
SiYuanAPI.prototype.getBlockInfo = async function (id) {
|
|
77
|
+
const res = await this.sql(`select * from blocks where id = '${id}'`);
|
|
78
|
+
return {
|
|
79
|
+
code: res.code,
|
|
80
|
+
msg: res.msg,
|
|
81
|
+
data: res.data?.[0],
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
SiYuanAPI.prototype.getBlockDOM = function (id) {
|
|
85
|
+
return this.request('/api/block/getBlockDOM', { id });
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/block/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAyH/C,SAAS,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,QAA4B,EAAE,IAAY,EAAE,MAAe,EAAE,UAAmB,EAAE,QAAiB;IAC7I,OAAO,IAAI,CAAC,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6B,EAAE;QACjD,MAAM;QACN,IAAI;QACJ,MAAM;KACP,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,YAAY,GAAG,KAAK,WAAW,EAAU;IAC3D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;IACrE,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;KACpB,CAAA;AACH,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,WAAW,GAAG,UAAU,EAAU;IACpD,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert API 类型定义
|
|
4
|
+
*/
|
|
5
|
+
export interface ConvertAPI {
|
|
6
|
+
/**
|
|
7
|
+
* 使用 Pandoc 转换文档
|
|
8
|
+
* @path /api/convert/pandoc
|
|
9
|
+
*/
|
|
10
|
+
pandoc: (args: string[]) => SyApiMethodResponse<any>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/convert/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/convert/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAa/C,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,IAAc;IACnD,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
import type { DocumentId } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Export API 类型定义
|
|
5
|
+
*/
|
|
6
|
+
export interface ExportAPI {
|
|
7
|
+
/**
|
|
8
|
+
* 导出 Markdown 内容
|
|
9
|
+
* @path /api/export/exportMdContent
|
|
10
|
+
*/
|
|
11
|
+
exportMdContent: (id: DocumentId) => SyApiMethodResponse<any>;
|
|
12
|
+
/**
|
|
13
|
+
* 导出资源文件
|
|
14
|
+
* @path /api/export/exportResources
|
|
15
|
+
*/
|
|
16
|
+
exportResources: (paths: string[], name: string) => SyApiMethodResponse<any>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/export/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAKtD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,eAAe,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC7D;;;OAGG;IACH,eAAe,EAAE,CACf,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,MAAM,KACT,mBAAmB,CAAC,GAAG,CAAC,CAAA;CAC9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// 实现
|
|
2
|
+
import { SiYuanAPI } from '../../core/index.js';
|
|
3
|
+
SiYuanAPI.prototype.exportMdContent = function (id) {
|
|
4
|
+
return this.request('/api/export/exportMdContent', { id });
|
|
5
|
+
};
|
|
6
|
+
SiYuanAPI.prototype.exportResources = function (paths, name) {
|
|
7
|
+
return this.request('/api/export/exportResources', {
|
|
8
|
+
paths,
|
|
9
|
+
name,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/export/index.ts"],"names":[],"mappings":"AAGA,KAAK;AACL,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAqB/C,SAAS,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,EAAU;IACxD,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAC5D,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,KAAe,EAAE,IAAY;IAC3E,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE;QACjD,KAAK;QACL,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* File API 类型定义
|
|
4
|
+
*/
|
|
5
|
+
export interface FileAPI {
|
|
6
|
+
/**
|
|
7
|
+
* 获取文件内容
|
|
8
|
+
* @path /api/file/getFile
|
|
9
|
+
*/
|
|
10
|
+
getFile: (path: string) => SyApiMethodResponse<any>;
|
|
11
|
+
/**
|
|
12
|
+
* 上传/创建文件
|
|
13
|
+
* @path /api/file/putFile
|
|
14
|
+
*/
|
|
15
|
+
putFile: (path: string, isDir: boolean, file: any) => SyApiMethodResponse<any>;
|
|
16
|
+
/**
|
|
17
|
+
* 删除文件
|
|
18
|
+
* @path /api/file/removeFile
|
|
19
|
+
*/
|
|
20
|
+
removeFile: (path: string) => SyApiMethodResponse<any>;
|
|
21
|
+
/**
|
|
22
|
+
* 读取目录
|
|
23
|
+
* @path /api/file/readDir
|
|
24
|
+
*/
|
|
25
|
+
readDir: (path: string) => SyApiMethodResponse<any>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAE5B;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACnD;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC9E;;;OAGG;IACH,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;IACtD;;;OAGG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,mBAAmB,CAAC,GAAG,CAAC,CAAA;CACpD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SiYuanAPI, } from '../../core/index.js';
|
|
2
|
+
SiYuanAPI.prototype.getFile = async function (path) {
|
|
3
|
+
try {
|
|
4
|
+
return await this.request('/api/file/getFile', { path });
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return {
|
|
8
|
+
code: -1,
|
|
9
|
+
msg: 'Failed to get file',
|
|
10
|
+
data: null,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
SiYuanAPI.prototype.putFile = function (path, isDir, file) {
|
|
15
|
+
const form = new FormData();
|
|
16
|
+
form.append('path', path);
|
|
17
|
+
form.append('isDir', isDir.toString());
|
|
18
|
+
form.append('file', file);
|
|
19
|
+
return this.request('/api/file/putFile', form);
|
|
20
|
+
};
|
|
21
|
+
SiYuanAPI.prototype.removeFile = function (path) {
|
|
22
|
+
return this.request('/api/file/removeFile', { path });
|
|
23
|
+
};
|
|
24
|
+
SiYuanAPI.prototype.readDir = function (path) {
|
|
25
|
+
return this.request('/api/file/readDir', { path });
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/file/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAEV,MAAM,qBAAqB,CAAA;AA4B5B,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,WAAW,IAAY;IACxD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,IAAI,EAAE,CAAC,CAAC;YACR,GAAG,EAAE,oBAAoB;YACzB,IAAI,EAAE,IAAI;SACX,CAAA;IACH,CAAC;AACH,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,IAAY,EAAE,KAAc,EAAE,IAAS;IAC7E,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAA;IAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IACtC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzB,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAA;AAChD,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,UAAU,GAAG,UAAU,IAAY;IACrD,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,IAAY;IAClD,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACpD,CAAC,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { SyApiMethodResponse } from '../../core/index.js';
|
|
2
|
+
import type { BlockId, NotebookId } from '../../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* File Tree API 类型定义
|
|
5
|
+
*/
|
|
6
|
+
export interface FileTreeAPI {
|
|
7
|
+
/**
|
|
8
|
+
* 创建日记
|
|
9
|
+
* @path /api/filetree/createDailyNote
|
|
10
|
+
*/
|
|
11
|
+
createDailyNote: (notebook: NotebookId) => SyApiMethodResponse<{
|
|
12
|
+
id: string;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* 使用 Markdown 创建文档
|
|
16
|
+
* @path /api/filetree/createDocWithMd
|
|
17
|
+
*/
|
|
18
|
+
createDocWithMd: (notebook: NotebookId, path: string, markdown: string) => SyApiMethodResponse<string>;
|
|
19
|
+
/**
|
|
20
|
+
* 重命名文档
|
|
21
|
+
* @path /api/filetree/renameDoc
|
|
22
|
+
*/
|
|
23
|
+
renameDoc: (notebook: NotebookId, path: string, title: string) => SyApiMethodResponse<string>;
|
|
24
|
+
/**
|
|
25
|
+
* 删除文档
|
|
26
|
+
* @path /api/filetree/removeDoc
|
|
27
|
+
*/
|
|
28
|
+
removeDoc: (notebook: NotebookId, path: string) => SyApiMethodResponse<any>;
|
|
29
|
+
/**
|
|
30
|
+
* 移动文档
|
|
31
|
+
* @path /api/filetree/moveDocs
|
|
32
|
+
*/
|
|
33
|
+
moveDocs: (fromPaths: string[], toNotebook: NotebookId, toPath: string) => SyApiMethodResponse<any>;
|
|
34
|
+
/**
|
|
35
|
+
* 根据路径获取人类可读路径
|
|
36
|
+
* @path /api/filetree/getHPathByPath
|
|
37
|
+
*/
|
|
38
|
+
getHPathByPath: (notebook: NotebookId, path: string) => SyApiMethodResponse<string>;
|
|
39
|
+
/**
|
|
40
|
+
* 根据块 ID 获取人类可读路径
|
|
41
|
+
* @path /api/filetree/getHPathByID
|
|
42
|
+
*/
|
|
43
|
+
getHPathByID: (id: BlockId) => SyApiMethodResponse<string>;
|
|
44
|
+
/**
|
|
45
|
+
* 根据人类可读路径获取块 ID 列表
|
|
46
|
+
* @path /api/filetree/getIDsByHPath
|
|
47
|
+
*/
|
|
48
|
+
getIDsByHPath: (notebook: NotebookId, path: string) => SyApiMethodResponse<string[]>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/filetree/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAC9D,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACX,MAAM,sBAAsB,CAAA;AAG7B;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,eAAe,EAAE,CAAC,QAAQ,EAAE,UAAU,KAAK,mBAAmB,CAAC;QAC7D,EAAE,EAAE,MAAM,CAAA;KACX,CAAC,CAAA;IACF;;;OAGG;IACH,eAAe,EAAE,CACf,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,KACb,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAChC;;;OAGG;IACH,SAAS,EAAE,CACT,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,KACV,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAChC;;;OAGG;IACH,SAAS,EAAE,CACT,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,KACT,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC7B;;;OAGG;IACH,QAAQ,EAAE,CACR,SAAS,EAAE,MAAM,EAAE,EACnB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,KACX,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC7B;;;OAGG;IACH,cAAc,EAAE,CACd,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,KACT,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAChC;;;OAGG;IACH,YAAY,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,mBAAmB,CAAC,MAAM,CAAC,CAAA;IAC1D;;;OAGG;IACH,aAAa,EAAE,CACb,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,MAAM,KACT,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAA;CACnC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SiYuanAPI } from '../../core/index.js';
|
|
2
|
+
SiYuanAPI.prototype.createDailyNote = function (notebook) {
|
|
3
|
+
return this.request('/api/filetree/createDailyNote', { notebook });
|
|
4
|
+
};
|
|
5
|
+
SiYuanAPI.prototype.createDocWithMd = function (notebook, path, markdown) {
|
|
6
|
+
return this.request('/api/filetree/createDocWithMd', {
|
|
7
|
+
notebook,
|
|
8
|
+
path,
|
|
9
|
+
markdown,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
SiYuanAPI.prototype.renameDoc = function (notebook, path, title) {
|
|
13
|
+
return this.request('/api/filetree/renameDoc', {
|
|
14
|
+
doc: notebook,
|
|
15
|
+
path,
|
|
16
|
+
title,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
SiYuanAPI.prototype.removeDoc = function (notebook, path) {
|
|
20
|
+
return this.request('/api/filetree/removeDoc', {
|
|
21
|
+
notebook,
|
|
22
|
+
path,
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
SiYuanAPI.prototype.moveDocs = function (fromPaths, toNotebook, toPath) {
|
|
26
|
+
return this.request('/api/filetree/moveDocs', {
|
|
27
|
+
fromPaths,
|
|
28
|
+
toNotebook,
|
|
29
|
+
toPath,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
SiYuanAPI.prototype.getHPathByPath = function (notebook, path) {
|
|
33
|
+
return this.request('/api/filetree/getHPathByPath', {
|
|
34
|
+
notebook,
|
|
35
|
+
path,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
SiYuanAPI.prototype.getHPathByID = function (id) {
|
|
39
|
+
return this.request('/api/filetree/getHPathByID', { id });
|
|
40
|
+
};
|
|
41
|
+
SiYuanAPI.prototype.getIDsByHPath = function (notebook, path) {
|
|
42
|
+
return this.request('/api/filetree/getIDsByHPath', {
|
|
43
|
+
notebook,
|
|
44
|
+
path,
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/filetree/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAuE/C,SAAS,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,QAAgB;IAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAA;AACpE,CAAC,CAAA;AAED,SAAS,CAAC,SAAS,CAAC,eAAe,GAAG,UAAU,QAAgB,EAAE,IAAY,EAAE,QAAgB;IAC9F,OAAO,IAAI,CAAC,OAAO,CAAC,+BAA+B,EAAE;QACnD,QAAQ;QACR,IAAI;QACJ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} 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
|
+
import './archive/index.js';
|
|
17
|
+
import './asset/index.js';
|
|
18
|
+
import './attr/index.js';
|
|
19
|
+
import './block/index.js';
|
|
20
|
+
import './convert/index.js';
|
|
21
|
+
import './export/index.js';
|
|
22
|
+
import './file/index.js';
|
|
23
|
+
import './filetree/index.js';
|
|
24
|
+
import './network/index.js';
|
|
25
|
+
import './notebook/index.js';
|
|
26
|
+
import './notification/index.js';
|
|
27
|
+
import './sql/index.js';
|
|
28
|
+
import './sqlite/index.js';
|
|
29
|
+
import './system/index.js';
|
|
30
|
+
import './template/index.js';
|
|
31
|
+
/**
|
|
32
|
+
* Api types
|
|
33
|
+
*/
|
|
34
|
+
declare module '@wetoria/siyuan-sdk' {
|
|
35
|
+
interface SiYuanAPI extends ArchiveAPI, AssetAPI, AttrAPI, BlockAPI, ConvertAPI, ExportAPI, FileAPI, FileTreeAPI, NetworkAPI, NotebookAPI, NotificationAPI, SqlAPI, SqliteAPI, SystemAPI, TemplateAPI {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|