Skip to content

Commit

Permalink
docs: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 11, 2023
1 parent 415c2e3 commit b90fdf1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- [ ] [zhi-yuque-api](https://github.com/terwer/zhi/tree/main/libs/zhi-yuque-api)
- [ ] [zhi-liandi-api](https://github.com/terwer/zhi/tree/main/libs/zhi-liandi-api)
- [ ] [zhi-kms-api](https://github.com/terwer/zhi/tree/main/libs/zhi-kms-api)
- [ ] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api)
- [X] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api)
- [ ] [zhi-wechat-api](https://github.com/terwer/zhi/tree/main/libs/zhi-wechat-api)
- [ ] [zhi-http-api](https://github.com/terwer/zhi/tree/main/libs/zhi-http-api)
- [ ] [zhi-zhihu-api](https://github.com/terwer/zhi/tree/main/libs/zhi-zhihu-api)
Expand Down Expand Up @@ -66,4 +66,5 @@
- [siyuan-plugin-custom-slug](https://github.com/terwer/siyuan-plugin-custom-slug) - Document alias, a new alias index for document titles, convenient for quick search <sup>Available</sup>
- [siyuan-plugin-code-block](https://github.com/terwer/siyuan-plugin-code-block) - Code block beautification, imitating Mac style code block style <sup>Available</sup>
- [siyuan-plugin-2md](https://github.com/terwer/siyuan-plugin-2md) - Markdown batch conversion, batch conversion of documents of Siyuan notes into Markdown files, support conversion properties for Hexo, HUGO, Vitepress, Obsidian and other platforms corresponding to FrontFormatter <sup>In progress</sup>
- [siyuan-plugin-random-doc](https://github.com/terwer/siyuan-plugin-random-doc) - Random Doc <sup>In progress</sup>
- [siyuan-plugin-random-doc](https://github.com/terwer/siyuan-plugin-random-doc) - Random Doc <sup>In progress</sup>
- [siyuan-plugin-picgo](https://github.com/terwer/siyuan-plugin-picgo) - PocGo <sup>In progress</sup>
3 changes: 2 additions & 1 deletion README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- [ ] [zhi-yuque-api](https://github.com/terwer/zhi/tree/main/libs/zhi-yuque-api)
- [ ] [zhi-liandi-api](https://github.com/terwer/zhi/tree/main/libs/zhi-liandi-api)
- [ ] [zhi-kms-api](https://github.com/terwer/zhi/tree/main/libs/zhi-kms-api)
- [ ] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api)
- [X] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api)
- [ ] [zhi-wechat-api](https://github.com/terwer/zhi/tree/main/libs/zhi-wechat-api)
- [ ] [zhi-http-api](https://github.com/terwer/zhi/tree/main/libs/zhi-http-api)
- [ ] [zhi-zhihu-api](https://github.com/terwer/zhi/tree/main/libs/zhi-zhihu-api)
Expand Down Expand Up @@ -67,3 +67,4 @@
- [siyuan-plugin-code-block](https://github.com/terwer/siyuan-plugin-code-block) - 代码块美化,模仿Mac风格的代码块风格 <sup>已上架</sup>
- [siyuan-plugin-2md](https://github.com/terwer/siyuan-plugin-2md) - Markdown批量转换,将思源笔记的文档批量转换为Markdown文件,支持转换属性为Hexo、HUGO、Vitepress、Obsidian等平台对应的FrontFormatter <sup>进行中</sup>
- [siyuan-plugin-random-doc](https://github.com/terwer/siyuan-plugin-random-doc) - 文档漫游 <sup>进行中</sup>
- [siyuan-plugin-picgo](https://github.com/terwer/siyuan-plugin-picgo) - PocGo图床 <sup>进行中</sup>
12 changes: 12 additions & 0 deletions libs/zhi-siyuan-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# zhi-siyuan-api

## 1.9.1

### Patch Changes

- add get image blocks

## 1.9.0

### Minor Changes

- remove unused appinstance

## 1.8.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion libs/zhi-siyuan-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zhi-siyuan-api",
"version": "1.8.0",
"version": "1.9.1",
"type": "module",
"description": "a siyuan-note api including both kernel and client",
"main": "./dist/index.js",
Expand Down
33 changes: 13 additions & 20 deletions libs/zhi-siyuan-api/src/lib/kernel/siyuanKernelApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,84 +26,77 @@
import { describe, it } from "vitest"
import SiyuanKernelApi from "./siyuanKernelApi"
import SiyuanConfig from "../config/siyuanConfig"
import path from "path"

describe("SiyuanKernelApi", async () => {
// appInstance
const appInstance: any = {}
const projectBase = path.resolve(__dirname, "../../..")
const moduleBase = path.resolve(__dirname, "../../../../..")
console.log(path.join(moduleBase, "libs/zhi-common/dist/index.js"))

// lute
// require(path.join(moduleBase, "libs/zhi-common/public/libs/lute/lute-1.7.5-20230410.min.cjs"))

it("sql using siyuanConfig", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.sql("select 1 from blocks limit 1")
console.log("result=>", result)
})

it("getRootBlocksCount", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.getRootBlocksCount("")
console.log("result=>", result)
})

it("lsNotebooks", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.lsNotebooks()
console.log("result=>", result)
})

it("openNotebook", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.openNotebook("20220718062546-2nbmy21")
console.log("result=>", result)
})

it("closeNotebook", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.closeNotebook("20220718062546-2nbmy21")
console.log("result=>", result)
})

it("renameNotebook", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.renameNotebook("20220621105123-dlyn6nl", "临时文档")
console.log("result=>", result)
})

it("createNotebook", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.createNotebook("临时文档3")
console.log("result=>", result)
})

it("removeNotebook", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.removeNotebook("20230401225851-4zgh677")
console.log("result=>", result)
})

it("getNotebookConf", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.getNotebookConf("20220621105123-dlyn6nl")
console.log("result=>", result)
})

it("setNotebookConf", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.setNotebookConf({
notebook: "20220621105123-dlyn6nl",
conf: {
Expand All @@ -120,7 +113,7 @@ describe("SiyuanKernelApi", async () => {

it("pushMsg", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.pushMsg({
msg: "测试消息",
})
Expand All @@ -129,7 +122,7 @@ describe("SiyuanKernelApi", async () => {

it("pushErrMsg", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.pushErrMsg({
msg: "测试错误消息",
})
Expand All @@ -138,7 +131,7 @@ describe("SiyuanKernelApi", async () => {

it("getRootBlocks", async () => {
const siyuanConfig = new SiyuanConfig("http://127.0.0.1:6806", "")
const kernelApi = new SiyuanKernelApi(appInstance, siyuanConfig)
const kernelApi = new SiyuanKernelApi(siyuanConfig)
const result = await kernelApi.getRootBlocks(0, 10, "")
console.log("result=>", result)
})
Expand Down
19 changes: 17 additions & 2 deletions libs/zhi-siyuan-api/src/lib/kernel/siyuanKernelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ class SiyuanKernelApi implements ISiyuanKernelApi {
/**
* 初始化思源服务端 API
*
* @param appInstance - 应用实例
* @param cfg -配置项
*/
constructor(appInstance: any, cfg: SiyuanConfig) {
constructor(cfg: SiyuanConfig) {
this.VERSION = "1.0.0"

this.siyuanConfig = cfg
Expand Down Expand Up @@ -515,6 +514,22 @@ class SiyuanKernelApi implements ISiyuanKernelApi {
public async uploadAsset(formData: any): Promise<SiyuanData> {
return await this.siyuanRequestForm("/api/asset/upload", formData)
}

/**
* 以id获取所有图片块
*
* @param blockId - 块ID
*/
public async getImageBlocksByID(blockId: string): Promise<any[]> {
const stmt = `select *
from blocks
where root_id = '${blockId}' and markdown like '%![%'`
const data = await this.sql(stmt)
if (!data) {
throw new Error("通过ID查询图片块信息失败")
}
return data as any[]
}
}

export default SiyuanKernelApi

0 comments on commit b90fdf1

Please sign in to comment.