@max1874/feishu 0.2.18 → 0.2.20

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/package.json +1 -1
  2. package/src/docx.ts +22 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@max1874/feishu",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "type": "module",
5
5
  "description": "OpenClaw Feishu/Lark channel plugin",
6
6
  "license": "MIT",
package/src/docx.ts CHANGED
@@ -508,6 +508,19 @@ async function grantFullAccess(client: Lark.Client, docToken: string, memberId:
508
508
  return res.data;
509
509
  }
510
510
 
511
+ const DEFAULT_COVER_TOKEN = "KeMcb0lJdosqhtx4aAglZjaWgug";
512
+
513
+ async function setDocCover(client: Lark.Client, docId: string, coverToken: string) {
514
+ // SDK lacks document.patch — use client.request() which auto-injects tenant_access_token and domain
515
+ await (client as any).request({
516
+ method: "PATCH",
517
+ url: `/open-apis/docx/v1/documents/${docId}`,
518
+ data: {
519
+ cover: { token: coverToken, offset_ratio_x: 0, offset_ratio_y: 0 },
520
+ },
521
+ });
522
+ }
523
+
511
524
  async function createDoc(
512
525
  client: Lark.Client,
513
526
  title: string,
@@ -539,6 +552,15 @@ async function createDoc(
539
552
  }
540
553
  }
541
554
 
555
+ // Set default cover
556
+ if (docId) {
557
+ try {
558
+ await setDocCover(client, docId, DEFAULT_COVER_TOKEN);
559
+ } catch (e) {
560
+ console.warn("[docx] setDocCover failed:", e);
561
+ }
562
+ }
563
+
542
564
  return {
543
565
  document_id: docId,
544
566
  title: doc?.title,