dingtalk-wiki 1.2.14 → 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.
Files changed (2) hide show
  1. package/index.js +56 -28
  2. 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,32 +1633,60 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1633
1633
  }
1634
1634
  }
1635
1635
 
1636
- // Step 10: doc_2.0 API - DocContent + QueryDocContent
1637
- for (const cfg of [
1638
- { label: 'DocContent /v2.0/doc/dentries/{uuid}/contents', params: { operatorId: opId }, data: undefined },
1639
- { label: 'DocContent + targetFormat query', params: { operatorId: opId, targetFormat: 'markdown' }, data: undefined },
1640
- { label: 'QueryDocContent /v2.0/doc/query/{uuid}/contents', path: `/v2.0/doc/query/${input}/contents`, params: { operatorId: opId, targetFormat: 'markdown' }, data: undefined },
1641
- ]) {
1642
- try {
1643
- const path = cfg.path || `/v2.0/doc/dentries/${input}/contents`;
1644
- const docContentRes = await axios({
1645
- method: 'GET',
1646
- url: `${DINGTALK_API_V2}${path}`,
1647
- headers: { 'x-acs-dingtalk-access-token': token, 'Content-Type': 'application/json' },
1648
- params: cfg.params,
1649
- data: cfg.data
1650
- });
1651
- steps.push({
1652
- step: cfg.label,
1653
- result: '成功',
1654
- raw: docContentRes.data
1655
- });
1656
- } catch (e) {
1657
- steps.push({
1658
- step: cfg.label,
1659
- result: '失败',
1660
- raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
1661
- });
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) {
1657
+ steps.push({
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})`,
1686
+ result: '失败',
1687
+ raw: { message: e.response?.data?.message || e.message, code: e.response?.data?.code || '(无)', status: e.response?.status || '(无)' }
1688
+ });
1689
+ }
1662
1690
  }
1663
1691
  }
1664
1692
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dingtalk-wiki",
3
- "version": "1.2.14",
3
+ "version": "1.2.15",
4
4
  "description": "DingTalk Wiki / Docs read-write MCP server that fills the gap left by DingTalk official MCP.",
5
5
  "main": "index.js",
6
6
  "bin": {