/api/history
getDocHistoryContent
- 🛠 获取历史文档内容
/api/history/getDocHistoryContent
请求
ts
/**
* Get document history content from history document file absolute path
*/
export interface IPayload {
/**
* Absolute path of history document file
*/
readonly historyPath: string;
/**
* Highlight keyword
*/
readonly k?: string;
}
json5
/**
* schemas/kernel/api/history/getDocHistoryContent/payload.schema.json5
* 从历史文档文件绝对路径获取文档历史
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.7/kernel/api/history.go#L135-L163
* @pathname: /api/history/getDocHistoryContent
* @version: 2.9.7
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getDocHistoryContent/payload.schema.json5',
$comment: 'v2.9.7',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Get document history content from history document file absolute path',
type: 'object',
additionalProperties: false,
required: [
'historyPath',
],
properties: {
historyPath: {
// 历史文档文件的绝对路径
type: 'string',
description: 'Absolute path of history document file',
},
k: {
// 高亮的关键词
type: 'string',
description: 'Highlight keyword',
default: '',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getDocHistoryContent/payload.schema.json",
"$comment": "v2.9.7",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Get document history content from history document file absolute path",
"type": "object",
"additionalProperties": false,
"required": [
"historyPath"
],
"properties": {
"historyPath": {
"type": "string",
"description": "Absolute path of history document file"
},
"k": {
"type": "string",
"description": "Highlight keyword",
"default": ""
}
}
}
}
}
响应
ts
/**
* Get document history content from history document file absolute path
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
/**
* document content
*/
readonly content: string;
/**
* Block ID
*/
readonly id: string;
/**
* is a large document?
* large document return markdown
* others return block DOM
*/
readonly isLargeDoc: boolean;
/**
* Document block ID
*/
readonly rootID: string;
}
json5
/**
* schemas/kernel/api/history/getDocHistoryContent/response.schema.json5
* 从历史文档文件绝对路径获取文档历史
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.7/kernel/api/history.go#L135-L163
* @pathname: /api/history/getDocHistoryContent
* @version: 2.9.7
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getDocHistoryContent/response.schema.json5',
$comment: 'v2.9.7',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Get document history content from history document file absolute path',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'id',
'rootID',
'isLargeDoc',
'content',
],
properties: {
id: {
// 块 ID
type: 'string',
description: 'Block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
rootID: {
// 文档块 ID
type: 'string',
description: 'Document block ID',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
isLargeDoc: {
// 是否为大文档, 大文档返回 markdown, 其他返回块 DOM
type: 'boolean',
description: 'is a large document?\nlarge document return markdown\nothers return block DOM',
},
content: {
// 文档内容
type: 'string',
description: 'document content',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getDocHistoryContent/response.schema.json",
"$comment": "v2.9.7",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Get document history content from history document file absolute path",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"rootID",
"isLargeDoc",
"content"
],
"properties": {
"id": {
"type": "string",
"description": "Block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"rootID": {
"type": "string",
"description": "Document block ID",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"isLargeDoc": {
"type": "boolean",
"description": "is a large document?\nlarge document return markdown\nothers return block DOM"
},
"content": {
"type": "string",
"description": "document content"
}
}
}
}
}
getHistoryItems
- 🛠 查询历史项
/api/history/getHistoryItems
请求
ts
/**
* Query the list of historical items
*/
export interface IPayload {
/**
* The timestamp of history item creation
*/
readonly created: string;
/**
* The notebook ID of the query
*/
readonly notebook?: string;
/**
* Operation type
* Filter based on the reason established by the history
*/
readonly op?: TOperationType;
/**
* Query keywords, which can be document block IDs
*/
readonly query: string;
/**
* Query scheme
* 0: Search docs by doc name
* 1: Search docs by doc name and content
* 2: Search assets
* 3: Search docs by doc id
*/
readonly type?: number;
}
/**
* Operation type
* Filter based on the reason established by the history
*/
export type TOperationType = "all" | "clean" | "delete" | "format" | "replace" | "sync" | "update";
json5
/**
* schemas/kernel/api/history/getHistoryItems/payload.schema.json5
* 查询历史项列表
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.7/kernel/api/history.go#L64-L93
* @pathname: /api/history/getHistoryItems
* @version: 2.9.7
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getHistoryItems/payload.schema.json5',
$comment: 'v2.9.7',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'payload body',
description: 'Query the list of historical items',
type: 'object',
additionalProperties: false,
required: [
'query',
'created',
],
properties: {
query: {
// 查询关键词, 可以是文档块 ID
type: 'string',
description: 'Query keywords, which can be document block IDs',
},
created: {
// 历史项创建时间戳
type: 'string',
description: 'The timestamp of history item creation',
pattern: '^\\d{10}$',
examples: [
'1690304916',
],
},
notebook: {
// 查询的笔记本 ID
type: 'string',
description: 'The notebook ID of the query',
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
op: {
// 待查询的操作类型 (过滤器, 根据历史记录建立的原因进行过滤)
title: 'TOperationType',
type: 'string',
description: 'Operation type\nFilter based on the reason established by the history',
default: 'all',
enum: [
'all', // 查询所有操作生成的历史
'clean', // 查询清理操作生成的历史
'update', // 查询更改操作生成的历史
'delete', // 查询删除操作生成的历史
'format', // 查询格式化操作生成的历史
'sync', // 查询通过操作生成的历史
'replace', // 查询替换操作生成的历史
],
},
type: {
// 查询方案
type: 'integer',
description: 'Query scheme\n0: Search docs by doc name\n1: Search docs by doc name and content\n2: Search assets\n3: Search docs by doc id',
default: 1,
enum: [
0, // 通过文档名搜索文档
1, // 通过文件名与文档内容搜索文档
2, // 搜索资源
3, // 通过文档 ID 搜索文档
],
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getHistoryItems/payload.schema.json",
"$comment": "v2.9.7",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "payload body",
"description": "Query the list of historical items",
"type": "object",
"additionalProperties": false,
"required": [
"query",
"created"
],
"properties": {
"query": {
"type": "string",
"description": "Query keywords, which can be document block IDs"
},
"created": {
"type": "string",
"description": "The timestamp of history item creation",
"pattern": "^\\d{10}$",
"examples": [
"1690304916"
]
},
"notebook": {
"type": "string",
"description": "The notebook ID of the query",
"pattern": "^\\d{14}-[0-9a-z]{7}$"
},
"op": {
"title": "TOperationType",
"type": "string",
"description": "Operation type\nFilter based on the reason established by the history",
"default": "all",
"enum": [
"all",
"clean",
"update",
"delete",
"format",
"sync",
"replace"
]
},
"type": {
"type": "integer",
"description": "Query scheme\n0: Search docs by doc name\n1: Search docs by doc name and content\n2: Search assets\n3: Search docs by doc id",
"default": 1,
"enum": [
0,
1,
2,
3
]
}
}
}
}
}
响应
ts
/**
* Query the list of historical items
*/
export interface IResponse {
/**
* status code
*/
readonly code: number;
readonly data: IData;
/**
* status message
*/
readonly msg: string;
}
/**
* Response information
*/
export interface IData {
readonly items: IItem[];
}
/**
* History item
*/
export interface IItem {
/**
* Absolute path of the historical document file
*/
readonly path: string;
/**
* Historical document title
*/
readonly title: string;
}
json5
/**
* schemas/kernel/api/history/getHistoryItems/response.schema.json5
* 查询历史项列表
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.7/kernel/api/history.go#L64-L93
* @pathname: /api/history/getHistoryItems
* @version: 2.9.7
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getHistoryItems/response.schema.json5',
$comment: 'v2.9.7',
$ref: '#/$defs/root',
$defs: {
root: {
title: 'response body',
description: 'Query the list of historical items',
type: 'object',
additionalProperties: false,
required: [
'code',
'msg',
'data',
],
properties: {
code: {
type: 'integer',
description: 'status code',
},
msg: {
type: 'string',
description: 'status message',
},
data: {
$ref: '#/$defs/data',
},
},
},
data: {
title: 'IData',
description: 'Response information',
type: 'object',
additionalProperties: false,
required: [
'items',
],
properties: {
items: {
// 历史项列表
type: 'array',
items: {
$ref: '#/$defs/item',
},
},
},
},
item: {
// 历史项
title: 'IItem',
description: 'History item',
type: 'object',
additionalProperties: false,
required: [
'title',
'path',
],
properties: {
title: {
// 历史文档标题
type: 'string',
description: 'Historical document title',
},
path: {
// 历史文档文件的绝对路径
type: 'string',
description: 'Absolute path of the historical document file',
},
},
},
},
}
json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/history/getHistoryItems/response.schema.json",
"$comment": "v2.9.7",
"$ref": "#/$defs/root",
"$defs": {
"root": {
"title": "response body",
"description": "Query the list of historical items",
"type": "object",
"additionalProperties": false,
"required": [
"code",
"msg",
"data"
],
"properties": {
"code": {
"type": "integer",
"description": "status code"
},
"msg": {
"type": "string",
"description": "status message"
},
"data": {
"$ref": "#/$defs/data"
}
}
},
"data": {
"title": "IData",
"description": "Response information",
"type": "object",
"additionalProperties": false,
"required": [
"items"
],
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/$defs/item"
}
}
}
},
"item": {
"title": "IItem",
"description": "History item",
"type": "object",
"additionalProperties": false,
"required": [
"title",
"path"
],
"properties": {
"title": {
"type": "string",
"description": "Historical document title"
},
"path": {
"type": "string",
"description": "Absolute path of the historical document file"
}
}
}
}
}