Skip to content

Commit b388209

Browse files
committed
refactor: trim feishu helper exports
1 parent d0e83b0 commit b388209

25 files changed

Lines changed: 39 additions & 53 deletions

extensions/feishu/src/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const RACE_TIMEOUT = Symbol("race-timeout");
22
const RACE_ABORT = Symbol("race-abort");
33

4-
export type RaceWithTimeoutAndAbortResult<T> =
4+
type RaceWithTimeoutAndAbortResult<T> =
55
| { status: "resolved"; value: T }
66
| { status: "timeout" }
77
| { status: "aborted" };

extensions/feishu/src/bot-content.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { parsePostContent } from "./post.js";
77
import { getFeishuRuntime } from "./runtime.js";
88
import type { FeishuChatType, FeishuMediaInfo } from "./types.js";
99

10-
export type FeishuMention = {
10+
type FeishuMention = {
1111
key: string;
1212
id: {
1313
open_id?: string;
@@ -37,11 +37,11 @@ type FeishuMessageLike = {
3737
};
3838
};
3939

40-
export type GroupSessionScope = "group" | "group_sender" | "group_topic" | "group_topic_sender";
40+
type GroupSessionScope = "group" | "group_sender" | "group_topic" | "group_topic_sender";
4141

4242
type FeishuLogger = (...args: unknown[]) => void;
4343

44-
export type ResolvedFeishuGroupSession = {
44+
type ResolvedFeishuGroupSession = {
4545
peerId: string;
4646
parentPeer: { kind: "group"; id: string } | null;
4747
groupSessionScope: GroupSessionScope;
@@ -299,7 +299,7 @@ export function normalizeFeishuCommandProbeBody(text: string): string {
299299
.trim();
300300
}
301301

302-
export function parseMediaKeys(
302+
function parseMediaKeys(
303303
content: string,
304304
messageType: string,
305305
): { imageKey?: string; fileKey?: string; fileName?: string } {

extensions/feishu/src/card-interaction.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,10 @@ import { isRecord } from "./comment-shared.js";
22

33
export const FEISHU_CARD_INTERACTION_VERSION = "ocf1";
44

5-
export type FeishuCardInteractionKind = "button" | "quick" | "meta";
6-
export type FeishuCardInteractionReason =
7-
| "malformed"
8-
| "stale"
9-
| "wrong_user"
10-
| "wrong_conversation";
11-
12-
export type FeishuCardInteractionMetadata = Record<
13-
string,
14-
string | number | boolean | null | undefined
15-
>;
5+
type FeishuCardInteractionKind = "button" | "quick" | "meta";
6+
type FeishuCardInteractionReason = "malformed" | "stale" | "wrong_user" | "wrong_conversation";
7+
8+
type FeishuCardInteractionMetadata = Record<string, string | number | boolean | null | undefined>;
169

1710
export type FeishuCardInteractionEnvelope = {
1811
oc: typeof FEISHU_CARD_INTERACTION_VERSION;
@@ -29,7 +22,7 @@ export type FeishuCardInteractionEnvelope = {
2922
};
3023
};
3124

32-
export type FeishuCardActionEventLike = {
25+
type FeishuCardActionEventLike = {
3326
operator: {
3427
open_id?: string;
3528
};
@@ -41,7 +34,7 @@ export type FeishuCardActionEventLike = {
4134
};
4235
};
4336

44-
export type DecodedFeishuCardAction =
37+
type DecodedFeishuCardAction =
4538
| {
4639
kind: "structured";
4740
envelope: FeishuCardInteractionEnvelope;

extensions/feishu/src/card-ux-launcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { FEISHU_APPROVAL_REQUEST_ACTION } from "./card-ux-approval.js";
55
import { buildFeishuCardButton, buildFeishuCardInteractionContext } from "./card-ux-shared.js";
66
import { sendCardFeishu } from "./send.js";
77

8-
export const FEISHU_QUICK_ACTION_CARD_TTL_MS = 10 * 60_000;
8+
const FEISHU_QUICK_ACTION_CARD_TTL_MS = 10 * 60_000;
99

1010
const QUICK_ACTION_MENU_KEYS = new Set(["quick-actions", "quick_actions", "launcher"]);
1111

extensions/feishu/src/comment-dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { CommentFileType } from "./comment-target.js";
1212
import { deliverCommentThreadText } from "./drive.js";
1313
import { getFeishuRuntime } from "./runtime.js";
1414

15-
export type CreateFeishuCommentReplyDispatcherParams = {
15+
type CreateFeishuCommentReplyDispatcherParams = {
1616
cfg: ClawdbotConfig;
1717
agentId: string;
1818
runtime: RuntimeEnv;

extensions/feishu/src/comment-shared.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
hasNonEmptyString as sharedHasNonEmptyString,
32
isRecord as sharedIsRecord,
43
normalizeOptionalString,
54
readStringValue,
@@ -24,8 +23,6 @@ export const normalizeString = normalizeOptionalString;
2423

2524
export const isRecord = sharedIsRecord;
2625

27-
export const hasNonEmptyString = sharedHasNonEmptyString;
28-
2926
export function formatFeishuApiError(
3027
error: unknown,
3128
options: {
@@ -64,26 +61,26 @@ export function formatFeishuApiError(
6461
});
6562
}
6663

67-
export type ParsedCommentDocumentRef = {
64+
type ParsedCommentDocumentRef = {
6865
fileType?: CommentFileType;
6966
fileToken?: string;
7067
};
7168

72-
export type ParsedCommentMention = {
69+
type ParsedCommentMention = {
7370
userId: string;
7471
displayText: string;
7572
isBotMention: boolean;
7673
};
7774

78-
export type ParsedCommentLinkedDocumentKind =
75+
type ParsedCommentLinkedDocumentKind =
7976
| CommentFileType
8077
| "wiki"
8178
| "mindnote"
8279
| "bitable"
8380
| "base"
8481
| "unknown";
8582

86-
export type ParsedCommentResolvedDocumentType = Exclude<
83+
type ParsedCommentResolvedDocumentType = Exclude<
8784
ParsedCommentLinkedDocumentKind,
8885
"wiki" | "unknown"
8986
>;

extensions/feishu/src/comment-target.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function normalizeCommentFileType(value: unknown): CommentFileType | unde
99
: undefined;
1010
}
1111

12-
export type FeishuCommentTarget = {
12+
type FeishuCommentTarget = {
1313
fileType: CommentFileType;
1414
fileToken: string;
1515
commentId: string;

extensions/feishu/src/docx-color-text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type DocxTextElement = NonNullable<
5959
* [bold]text[/bold] → bold
6060
* [green bold]text[/green] → green + bold
6161
*/
62-
export function parseColorMarkup(content: string): Segment[] {
62+
function parseColorMarkup(content: string): Segment[] {
6363
const segments: Segment[] = [];
6464
// Only [known_tag]...[/...] pairs are treated as markup. Using an open
6565
// pattern like \[([^\]]+)\] would match any bracket token — e.g. [Q1] —

extensions/feishu/src/docx-table-ops.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ function createDescendantTable(
6161
};
6262
}
6363

64-
export function calculateAdaptiveColumnWidths(
65-
blocks: FeishuDocxBlock[],
66-
tableBlockId: string,
67-
): number[] {
64+
function calculateAdaptiveColumnWidths(blocks: FeishuDocxBlock[], tableBlockId: string): number[] {
6865
// Find the table block
6966
const tableBlock = blocks.find((b) => b.block_id === tableBlockId && b.block_type === 31);
7067

extensions/feishu/src/docx-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export type FeishuBlockText = {
1+
type FeishuBlockText = {
22
elements?: Array<{
33
text_run?: {
44
content?: string;
55
};
66
}>;
77
};
88

9-
export type FeishuBlockTableProperty = {
9+
type FeishuBlockTableProperty = {
1010
row_size?: number;
1111
column_size?: number;
1212
column_width?: number[];

0 commit comments

Comments
 (0)