Skip to content

Commit

Permalink
perf(api): 调整 API /api/block/getDocInfo | Adjust API `/api/block/ge…
Browse files Browse the repository at this point in the history
…tDocInfo`
  • Loading branch information
Zuoqiu-Yingyi committed Mar 19, 2024
1 parent 1954fb0 commit cdb892f
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- 完善 API `/api/system/getConf` | Perfect API `/api/system/getConf`
- 调整 API `/api/block/transferBlockRef` | Adjust API `/api/block/transferBlockRef`
- 调整 API `/api/filetree/listDocsByPath` 的测试用例 | Adjust the test cases of API `/api/filetree/listDocsByPath`
- 调整 API `/api/block/getDocInfo` | Adjust API `/api/block/getDocInfo`

## v0.3.7 / 2024-01-24

Expand Down
22 changes: 21 additions & 1 deletion node/src/types/kernel/api/block/getDocInfo/response.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export interface IResponse {
* document information
*/
export interface IData {
ial: Ial;
/**
* Attribute view reference list
*/
attrViews: IAttrView[];
ial: Ial;
/**
* document icon
*/
Expand Down Expand Up @@ -66,6 +70,22 @@ export interface IData {
subFileCount: number;
}

/**
* Attribute view
*/
export interface IAttrView {
/**
* Attribute view ID
*/
id: string;
/**
* Attribute view name
*/
name: ID;
}

export type ID = "Untitled";

/**
* Inline Attribute List (IAL) of document block
*/
Expand Down
4 changes: 2 additions & 2 deletions node/tests/api/block/getDocInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ describe.concurrent(pathname, async () => {
payload: {
id: context.document,
},
debug: false,
debug: true,
},
{
name: "id: block",
payload: {
id: context.block,
},
debug: false,
debug: true,
},
];
cases.forEach(item => {
Expand Down
49 changes: 48 additions & 1 deletion schemas/kernel/api/block/getDocInfo/response.schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/response.schema.json",
"$comment": "v",
"$comment": "v3.0.4",
"$ref": "#/$defs/root",
"$defs": {
"root": {
Expand Down Expand Up @@ -34,6 +34,7 @@
"type": "object",
"additionalProperties": false,
"required": [
"attrViews",
"ial",
"icon",
"id",
Expand All @@ -44,6 +45,13 @@
"subFileCount"
],
"properties": {
"attrViews": {
"type": "array",
"description": "Attribute view reference list",
"items": {
"$ref": "#/$defs/attrView"
}
},
"id": {
"type": "string",
"description": "block ID",
Expand Down Expand Up @@ -84,6 +92,45 @@
}
}
},
"attrView": {
"title": "IAttrView",
"description": "Attribute view",
"type": "object",
"additionalProperties": false,
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "string",
"description": "Attribute view ID"
},
"name": {
"type": "string",
"description": "Attribute view name"
}
},
"oneOf": [
{
"properties": {
"id": {
"const": ""
},
"name": {
"const": "Untitled"
}
}
},
{
"properties": {
"id": {
"pattern": "^\\d{14}-[0-9a-z]{7}$"
}
}
}
]
},
"ial": {
"title": "IAL",
"description": "Inline Attribute List (IAL) of document block",
Expand Down
55 changes: 51 additions & 4 deletions schemas/kernel/api/block/getDocInfo/response.schema.json5
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* schemas/kernel/api/block/getDocInfo/response.schema.json5
* 获取文档信息
* REF: https://github.com/siyuan-note/siyuan/blob/v2.9.9/kernel/api/block.go#L212-L229
* REF: https://github.com/siyuan-note/siyuan/blob/v3.0.4/kernel/api/block.go#L236-L253
* @pathname: /api/block/getDocInfo
* @version: 2.9.9
* @version: 3.0.4
*/
{
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/block/getDocInfo/response.schema.json5',
$comment: 'v',
$comment: 'v3.0.4',
$ref: '#/$defs/root',
$defs: {
root: {
Expand Down Expand Up @@ -38,8 +38,16 @@

type: 'object',
additionalProperties: false,
required: ['ial', 'icon', 'id', 'name', 'refCount', 'refIDs', 'rootID', 'subFileCount'],
required: ['attrViews', 'ial', 'icon', 'id', 'name', 'refCount', 'refIDs', 'rootID', 'subFileCount'],
properties: {
attrViews: {
// 属性视图引用列表
type: 'array',
description: 'Attribute view reference list',
items: {
$ref: '#/$defs/attrView',
},
},
id: {
// 块 ID
type: 'string',
Expand Down Expand Up @@ -88,6 +96,45 @@
},
},
},
attrView: {
title: 'IAttrView',
description: 'Attribute view',

type: 'object',
additionalProperties: false,
required: ['id', 'name'],
properties: {
id: {
// 属性视图 ID
type: 'string',
description: 'Attribute view ID',
},
name: {
// 属性视图名称
type: 'string',
description: 'Attribute view name',
},
},
oneOf: [
{
properties: {
id: {
const: '',
},
name: {
const: 'Untitled',
},
},
},
{
properties: {
id: {
pattern: '^\\d{14}-[0-9a-z]{7}$',
},
},
},
],
},
ial: {
// 文档块的内联属性表
title: 'IAL',
Expand Down

0 comments on commit cdb892f

Please sign in to comment.