dingtalk-wiki 1.2.13 → 1.2.15
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/index.js +51 -22
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1523,11 +1523,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
|
|
1525
1525
|
// Step 9: 递归遍历目录树查找文档 + 存储API下载内容
|
|
1526
|
+
let foundDentry = null;
|
|
1527
|
+
let foundSpaceId = null;
|
|
1526
1528
|
if (effectiveWsId) {
|
|
1527
1529
|
try {
|
|
1528
1530
|
// BFS 遍历目录树查找 dentry
|
|
1529
|
-
let foundDentry = null;
|
|
1530
|
-
let foundSpaceId = null;
|
|
1531
1531
|
const queue = [''];
|
|
1532
1532
|
const visited = new Set();
|
|
1533
1533
|
while (queue.length > 0 && !foundDentry) {
|
|
@@ -1633,30 +1633,59 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1633
1633
|
}
|
|
1634
1634
|
}
|
|
1635
1635
|
|
|
1636
|
-
// Step 10:
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1636
|
+
// Step 10: 存储 API - 文件下载(.md 文件内容 = 文件下载)
|
|
1637
|
+
if (foundSpaceId) {
|
|
1638
|
+
// 方式1: storage/spaces/files/{dentryUuid}
|
|
1639
|
+
for (const path of [
|
|
1640
|
+
`/v2.0/storage/spaces/files/${input}/downloadInfos/query`,
|
|
1641
|
+
`/v2.0/storage/spaces/files/${foundDentry.dentryId}/downloadInfos/query`,
|
|
1642
|
+
]) {
|
|
1643
|
+
try {
|
|
1644
|
+
const dlRes = await axios({
|
|
1645
|
+
method: 'POST',
|
|
1646
|
+
url: `${DINGTALK_API_V2}${path}`,
|
|
1647
|
+
headers: { 'x-acs-dingtalk-access-token': token, 'Content-Type': 'application/json' },
|
|
1648
|
+
params: { operatorId: opId },
|
|
1649
|
+
data: {}
|
|
1650
|
+
});
|
|
1651
|
+
steps.push({
|
|
1652
|
+
step: `存储下载 (POST ${path})`,
|
|
1653
|
+
result: '成功',
|
|
1654
|
+
raw: dlRes.data
|
|
1655
|
+
});
|
|
1656
|
+
} catch (e) {
|
|
1653
1657
|
steps.push({
|
|
1654
|
-
step:
|
|
1658
|
+
step: `存储下载 (POST ${path})`,
|
|
1659
|
+
result: '失败',
|
|
1660
|
+
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
// 方式2: storage/spaces/download 的 GET 变体
|
|
1665
|
+
for (const path of [
|
|
1666
|
+
`/v2.0/storage/spaces/files/${input}/downloadInfo`,
|
|
1667
|
+
`/v2.0/storage/spaces/${foundSpaceId}/files/${input}/downloadInfos/query`,
|
|
1668
|
+
`/v2.0/storage/spaces/${foundSpaceId}/files/${foundDentry.dentryId}/downloadInfos/query`,
|
|
1669
|
+
]) {
|
|
1670
|
+
try {
|
|
1671
|
+
const dlRes = await axios({
|
|
1672
|
+
method: 'POST',
|
|
1673
|
+
url: `${DINGTALK_API_V2}${path}`,
|
|
1674
|
+
headers: { 'x-acs-dingtalk-access-token': token, 'Content-Type': 'application/json' },
|
|
1675
|
+
params: { operatorId: opId },
|
|
1676
|
+
data: {}
|
|
1677
|
+
});
|
|
1678
|
+
steps.push({
|
|
1679
|
+
step: `存储下载 (POST ${path})`,
|
|
1680
|
+
result: '成功',
|
|
1681
|
+
raw: dlRes.data
|
|
1682
|
+
});
|
|
1683
|
+
} catch (e) {
|
|
1684
|
+
steps.push({
|
|
1685
|
+
step: `存储下载 (POST ${path})`,
|
|
1655
1686
|
result: '失败',
|
|
1656
1687
|
raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
|
|
1657
1688
|
});
|
|
1658
|
-
} else {
|
|
1659
|
-
await new Promise(r => setTimeout(r, 1000));
|
|
1660
1689
|
}
|
|
1661
1690
|
}
|
|
1662
1691
|
}
|