@feishux/api
Advanced tools
Comparing version 0.1.0-beta.0 to 0.1.0-beta.1
/// <reference types="node" /> | ||
import { FeiShuConfig } from './types'; | ||
import { IBlock } from '@feishux/shared'; | ||
import { IBlock, IFolderData } from '@feishux/shared'; | ||
/** | ||
@@ -18,5 +18,4 @@ * FeiShu API | ||
* @param pageId | ||
* @param page_token | ||
*/ | ||
getPageBlocks(pageId: string, page_token?: string): Promise<IBlock[]>; | ||
getPageBlocks(pageId: string): Promise<IBlock[]>; | ||
/** | ||
@@ -27,2 +26,7 @@ * 获取素材 | ||
getResourceItem(file_token: string): Promise<Buffer>; | ||
/** | ||
* 获取文件夹下的文档树 | ||
* @param folder_token | ||
*/ | ||
getFolderTree(folder_token: string): Promise<IFolderData[]>; | ||
} |
@@ -52,5 +52,4 @@ 'use strict'; | ||
* @param pageId | ||
* @param page_token | ||
*/ | ||
getPageBlocks(pageId, page_token) { | ||
getPageBlocks(pageId) { | ||
return tslib_es6.__awaiter(this, void 0, void 0, function* () { | ||
@@ -64,2 +63,3 @@ yield this.initPromise; | ||
page_token, | ||
page_size: 200, | ||
}, | ||
@@ -73,3 +73,3 @@ }); | ||
}); | ||
return getData(pageId, page_token); | ||
return getData(pageId); | ||
}); | ||
@@ -90,2 +90,35 @@ } | ||
} | ||
/** | ||
* 获取文件夹下的文档树 | ||
* @param folder_token | ||
*/ | ||
getFolderTree(folder_token) { | ||
return tslib_es6.__awaiter(this, void 0, void 0, function* () { | ||
yield this.initPromise; | ||
const getData = (folder_token, page_token, result = []) => tslib_es6.__awaiter(this, void 0, void 0, function* () { | ||
// https://open.feishu.cn/document/server-docs/docs/drive-v1/folder/list | ||
const res = yield this._fetch('drive/v1/files', { | ||
method: 'get', | ||
data: { | ||
page_token, | ||
page_size: 200, | ||
folder_token, | ||
}, | ||
}); | ||
result.push(...res.files); | ||
if (res.has_more) { | ||
yield getData(folder_token, res.page_token, result); | ||
} | ||
return result; | ||
}); | ||
const data = yield getData(folder_token); | ||
for (const item of data) { | ||
if (item.type === 'folder') { | ||
// 重新getData获取文件夹下的文档 | ||
item.children = yield getData(item.token); | ||
} | ||
} | ||
return data; | ||
}); | ||
} | ||
} | ||
@@ -92,0 +125,0 @@ |
{ | ||
"name": "@feishux/api", | ||
"version": "0.1.0-beta.0", | ||
"version": "0.1.0-beta.1", | ||
"description": "FeiShu API", | ||
@@ -30,3 +30,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@feishux/shared": "0.1.0-beta.0" | ||
"@feishux/shared": "0.1.0-beta.1" | ||
}, | ||
@@ -33,0 +33,0 @@ "scripts": { |
<div align="center"> | ||
<h1>FlowUs Client</h1> | ||
<p>FeiShu API</p> | ||
<h1>FeiShuX</h1> | ||
<p>FeiShu Doc API</p> | ||
<a href="http://makeapullrequest.com"> | ||
@@ -5,0 +5,0 @@ <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs Welcome"> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34642
189
+ Added@feishux/shared@0.1.0-beta.1(transitive)
- Removed@feishux/shared@0.1.0-beta.0(transitive)
Updated@feishux/shared@0.1.0-beta.1