mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-22 07:20:59 +00:00
refactor: consolidate lazy runtime surfaces
This commit is contained in:
@@ -26,104 +26,22 @@ import {
|
||||
sendMessageFeishu as sendMessageFeishuImpl,
|
||||
} from "./send.js";
|
||||
|
||||
type ListFeishuDirectoryGroupsLive = typeof import("./directory.js").listFeishuDirectoryGroupsLive;
|
||||
type ListFeishuDirectoryPeersLive = typeof import("./directory.js").listFeishuDirectoryPeersLive;
|
||||
type FeishuOutbound = typeof import("./outbound.js").feishuOutbound;
|
||||
type CreatePinFeishu = typeof import("./pins.js").createPinFeishu;
|
||||
type ListPinsFeishu = typeof import("./pins.js").listPinsFeishu;
|
||||
type RemovePinFeishu = typeof import("./pins.js").removePinFeishu;
|
||||
type ProbeFeishu = typeof import("./probe.js").probeFeishu;
|
||||
type AddReactionFeishu = typeof import("./reactions.js").addReactionFeishu;
|
||||
type ListReactionsFeishu = typeof import("./reactions.js").listReactionsFeishu;
|
||||
type RemoveReactionFeishu = typeof import("./reactions.js").removeReactionFeishu;
|
||||
type GetChatInfo = typeof import("./chat.js").getChatInfo;
|
||||
type GetChatMembers = typeof import("./chat.js").getChatMembers;
|
||||
type GetFeishuMemberInfo = typeof import("./chat.js").getFeishuMemberInfo;
|
||||
type EditMessageFeishu = typeof import("./send.js").editMessageFeishu;
|
||||
type GetMessageFeishu = typeof import("./send.js").getMessageFeishu;
|
||||
type SendCardFeishu = typeof import("./send.js").sendCardFeishu;
|
||||
type SendMessageFeishu = typeof import("./send.js").sendMessageFeishu;
|
||||
|
||||
export function listFeishuDirectoryGroupsLive(
|
||||
...args: Parameters<ListFeishuDirectoryGroupsLive>
|
||||
): ReturnType<ListFeishuDirectoryGroupsLive> {
|
||||
return listFeishuDirectoryGroupsLiveImpl(...args);
|
||||
}
|
||||
|
||||
export function listFeishuDirectoryPeersLive(
|
||||
...args: Parameters<ListFeishuDirectoryPeersLive>
|
||||
): ReturnType<ListFeishuDirectoryPeersLive> {
|
||||
return listFeishuDirectoryPeersLiveImpl(...args);
|
||||
}
|
||||
|
||||
export const feishuOutbound: FeishuOutbound = { ...feishuOutboundImpl };
|
||||
|
||||
export function createPinFeishu(...args: Parameters<CreatePinFeishu>): ReturnType<CreatePinFeishu> {
|
||||
return createPinFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function listPinsFeishu(...args: Parameters<ListPinsFeishu>): ReturnType<ListPinsFeishu> {
|
||||
return listPinsFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function removePinFeishu(...args: Parameters<RemovePinFeishu>): ReturnType<RemovePinFeishu> {
|
||||
return removePinFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function probeFeishu(...args: Parameters<ProbeFeishu>): ReturnType<ProbeFeishu> {
|
||||
return probeFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function addReactionFeishu(
|
||||
...args: Parameters<AddReactionFeishu>
|
||||
): ReturnType<AddReactionFeishu> {
|
||||
return addReactionFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function listReactionsFeishu(
|
||||
...args: Parameters<ListReactionsFeishu>
|
||||
): ReturnType<ListReactionsFeishu> {
|
||||
return listReactionsFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function removeReactionFeishu(
|
||||
...args: Parameters<RemoveReactionFeishu>
|
||||
): ReturnType<RemoveReactionFeishu> {
|
||||
return removeReactionFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function getChatInfo(...args: Parameters<GetChatInfo>): ReturnType<GetChatInfo> {
|
||||
return getChatInfoImpl(...args);
|
||||
}
|
||||
|
||||
export function getChatMembers(...args: Parameters<GetChatMembers>): ReturnType<GetChatMembers> {
|
||||
return getChatMembersImpl(...args);
|
||||
}
|
||||
|
||||
export function getFeishuMemberInfo(
|
||||
...args: Parameters<GetFeishuMemberInfo>
|
||||
): ReturnType<GetFeishuMemberInfo> {
|
||||
return getFeishuMemberInfoImpl(...args);
|
||||
}
|
||||
|
||||
export function editMessageFeishu(
|
||||
...args: Parameters<EditMessageFeishu>
|
||||
): ReturnType<EditMessageFeishu> {
|
||||
return editMessageFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function getMessageFeishu(
|
||||
...args: Parameters<GetMessageFeishu>
|
||||
): ReturnType<GetMessageFeishu> {
|
||||
return getMessageFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function sendCardFeishu(...args: Parameters<SendCardFeishu>): ReturnType<SendCardFeishu> {
|
||||
return sendCardFeishuImpl(...args);
|
||||
}
|
||||
|
||||
export function sendMessageFeishu(
|
||||
...args: Parameters<SendMessageFeishu>
|
||||
): ReturnType<SendMessageFeishu> {
|
||||
return sendMessageFeishuImpl(...args);
|
||||
}
|
||||
export const feishuChannelRuntime = {
|
||||
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveImpl,
|
||||
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveImpl,
|
||||
feishuOutbound: { ...feishuOutboundImpl },
|
||||
createPinFeishu: createPinFeishuImpl,
|
||||
listPinsFeishu: listPinsFeishuImpl,
|
||||
removePinFeishu: removePinFeishuImpl,
|
||||
probeFeishu: probeFeishuImpl,
|
||||
addReactionFeishu: addReactionFeishuImpl,
|
||||
listReactionsFeishu: listReactionsFeishuImpl,
|
||||
removeReactionFeishu: removeReactionFeishuImpl,
|
||||
getChatInfo: getChatInfoImpl,
|
||||
getChatMembers: getChatMembersImpl,
|
||||
getFeishuMemberInfo: getFeishuMemberInfoImpl,
|
||||
editMessageFeishu: editMessageFeishuImpl,
|
||||
getMessageFeishu: getMessageFeishuImpl,
|
||||
sendCardFeishu: sendCardFeishuImpl,
|
||||
sendMessageFeishu: sendMessageFeishuImpl,
|
||||
};
|
||||
|
||||
@@ -28,22 +28,28 @@ vi.mock("./client.js", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("./channel.runtime.js", () => ({
|
||||
addReactionFeishu: addReactionFeishuMock,
|
||||
createPinFeishu: createPinFeishuMock,
|
||||
editMessageFeishu: editMessageFeishuMock,
|
||||
getChatInfo: getChatInfoMock,
|
||||
getChatMembers: getChatMembersMock,
|
||||
getFeishuMemberInfo: getFeishuMemberInfoMock,
|
||||
getMessageFeishu: getMessageFeishuMock,
|
||||
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveMock,
|
||||
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveMock,
|
||||
listPinsFeishu: listPinsFeishuMock,
|
||||
listReactionsFeishu: listReactionsFeishuMock,
|
||||
probeFeishu: probeFeishuMock,
|
||||
removePinFeishu: removePinFeishuMock,
|
||||
removeReactionFeishu: removeReactionFeishuMock,
|
||||
sendCardFeishu: sendCardFeishuMock,
|
||||
sendMessageFeishu: sendMessageFeishuMock,
|
||||
feishuChannelRuntime: {
|
||||
addReactionFeishu: addReactionFeishuMock,
|
||||
createPinFeishu: createPinFeishuMock,
|
||||
editMessageFeishu: editMessageFeishuMock,
|
||||
getChatInfo: getChatInfoMock,
|
||||
getChatMembers: getChatMembersMock,
|
||||
getFeishuMemberInfo: getFeishuMemberInfoMock,
|
||||
getMessageFeishu: getMessageFeishuMock,
|
||||
listFeishuDirectoryGroupsLive: listFeishuDirectoryGroupsLiveMock,
|
||||
listFeishuDirectoryPeersLive: listFeishuDirectoryPeersLiveMock,
|
||||
listPinsFeishu: listPinsFeishuMock,
|
||||
listReactionsFeishu: listReactionsFeishuMock,
|
||||
probeFeishu: probeFeishuMock,
|
||||
removePinFeishu: removePinFeishuMock,
|
||||
removeReactionFeishu: removeReactionFeishuMock,
|
||||
sendCardFeishu: sendCardFeishuMock,
|
||||
sendMessageFeishu: sendMessageFeishuMock,
|
||||
feishuOutbound: {
|
||||
sendText: vi.fn(),
|
||||
sendMedia: vi.fn(),
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
import { feishuPlugin } from "./channel.js";
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
} from "openclaw/plugin-sdk/feishu";
|
||||
import type { ChannelMessageActionName } from "openclaw/plugin-sdk/feishu";
|
||||
import { createLazyRuntimeSurface } from "../../../src/shared/lazy-runtime.js";
|
||||
import {
|
||||
resolveFeishuAccount,
|
||||
resolveFeishuCredentials,
|
||||
@@ -41,9 +42,12 @@ const meta: ChannelMeta = {
|
||||
order: 70,
|
||||
};
|
||||
|
||||
async function loadFeishuChannelRuntime() {
|
||||
return await import("./channel.runtime.js");
|
||||
}
|
||||
type FeishuChannelRuntime = typeof import("./channel.runtime.js").feishuChannelRuntime;
|
||||
|
||||
const loadFeishuChannelRuntime = createLazyRuntimeSurface(
|
||||
() => import("./channel.runtime.js"),
|
||||
({ feishuChannelRuntime }) => feishuChannelRuntime,
|
||||
);
|
||||
|
||||
function setFeishuNamedAccountEnabled(
|
||||
cfg: ClawdbotConfig,
|
||||
|
||||
Reference in New Issue
Block a user