dingtalk-wiki 1.2.3 → 1.2.4

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 +22 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1561,7 +1561,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1561
1561
  if (operator_id) {
1562
1562
  dingtalk.setOperatorId(operator_id);
1563
1563
  }
1564
- const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${docKey}/blocks`, { operatorId: operator_id || null });
1564
+
1565
+ // nodeId 可能不等于 docKey,先尝试解析
1566
+ let realDocKey = docKey;
1567
+ try {
1568
+ const nodeInfo = await dingtalk.docRequest('GET', `/v2.0/wiki/nodes/${docKey}`, { operatorId: operator_id || null });
1569
+ if (nodeInfo.document?.docKey) {
1570
+ realDocKey = nodeInfo.document.docKey;
1571
+ }
1572
+ } catch (e) { /* 非 nodeId,直接用原始值 */ }
1573
+
1574
+ const result = await dingtalk.docRequest('GET', `/v1.0/doc/suites/documents/${realDocKey}/blocks`, { operatorId: operator_id || null });
1565
1575
  const blocks = result.result?.data || [];
1566
1576
  let output = '';
1567
1577
  blocks.forEach((block) => {
@@ -1584,7 +1594,17 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1584
1594
  if (operator_id) {
1585
1595
  dingtalk.setOperatorId(operator_id);
1586
1596
  }
1587
- await dingtalk.docRequest('POST', `/v1.0/doc/suites/documents/${docKey}/overwriteContent`, {
1597
+
1598
+ // nodeId 可能不等于 docKey,先尝试解析
1599
+ let realDocKey = docKey;
1600
+ try {
1601
+ const nodeInfo = await dingtalk.docRequest('GET', `/v2.0/wiki/nodes/${docKey}`, { operatorId: operator_id || null });
1602
+ if (nodeInfo.document?.docKey) {
1603
+ realDocKey = nodeInfo.document.docKey;
1604
+ }
1605
+ } catch (e) { /* 非 nodeId,直接用原始值 */ }
1606
+
1607
+ await dingtalk.docRequest('POST', `/v1.0/doc/suites/documents/${realDocKey}/overwriteContent`, {
1588
1608
  operatorId: operator_id || null,
1589
1609
  data: { content, contentType: 'markdown' }
1590
1610
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dingtalk-wiki",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
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": {