mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-26 16:06:16 +00:00
fix(types): align rebased main helper contracts
This commit is contained in:
@@ -77,7 +77,7 @@ export const bluebubblesMessageActions: ChannelMessageActionAdapter = {
|
|||||||
if (!account.enabled || !account.configured) {
|
if (!account.enabled || !account.configured) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const gate = createActionGate(account.config.actions);
|
const gate = createActionGate(cfg.channels?.bluebubbles?.actions);
|
||||||
const actions = new Set<ChannelMessageActionName>();
|
const actions = new Set<ChannelMessageActionName>();
|
||||||
const macOS26 = isMacOS26OrHigher(account.accountId);
|
const macOS26 = isMacOS26OrHigher(account.accountId);
|
||||||
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId);
|
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import {
|
|||||||
formatDocsLink,
|
formatDocsLink,
|
||||||
hasConfiguredSecretInput,
|
hasConfiguredSecretInput,
|
||||||
mergeAllowFromEntries,
|
mergeAllowFromEntries,
|
||||||
patchChannelConfigForAccount,
|
|
||||||
patchTopLevelChannelConfigSection,
|
patchTopLevelChannelConfigSection,
|
||||||
promptSingleChannelSecretInput,
|
promptSingleChannelSecretInput,
|
||||||
splitSetupEntries,
|
splitSetupEntries,
|
||||||
@@ -33,11 +32,10 @@ function normalizeString(value: unknown): string | undefined {
|
|||||||
return trimmed || undefined;
|
return trimmed || undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScopedFeishuConfig(
|
type ScopedFeishuConfig = Partial<FeishuConfig> & Partial<FeishuAccountConfig>;
|
||||||
cfg: OpenClawConfig,
|
|
||||||
accountId: string,
|
function getScopedFeishuConfig(cfg: OpenClawConfig, accountId: string): ScopedFeishuConfig {
|
||||||
): FeishuConfig | FeishuAccountConfig {
|
const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined;
|
||||||
const feishuCfg = ((cfg.channels?.feishu as FeishuConfig | undefined) ?? {}) as FeishuConfig;
|
|
||||||
if (accountId === DEFAULT_ACCOUNT_ID) {
|
if (accountId === DEFAULT_ACCOUNT_ID) {
|
||||||
return feishuCfg;
|
return feishuCfg;
|
||||||
}
|
}
|
||||||
@@ -49,11 +47,30 @@ function patchFeishuConfig(
|
|||||||
accountId: string,
|
accountId: string,
|
||||||
patch: Record<string, unknown>,
|
patch: Record<string, unknown>,
|
||||||
): OpenClawConfig {
|
): OpenClawConfig {
|
||||||
return patchChannelConfigForAccount({
|
const feishuCfg = cfg.channels?.feishu as FeishuConfig | undefined;
|
||||||
|
if (accountId === DEFAULT_ACCOUNT_ID) {
|
||||||
|
return patchTopLevelChannelConfigSection({
|
||||||
|
cfg,
|
||||||
|
channel,
|
||||||
|
enabled: true,
|
||||||
|
patch,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const nextAccountPatch = {
|
||||||
|
...((feishuCfg?.accounts?.[accountId] as Record<string, unknown> | undefined) ?? {}),
|
||||||
|
enabled: true,
|
||||||
|
...patch,
|
||||||
|
};
|
||||||
|
return patchTopLevelChannelConfigSection({
|
||||||
cfg,
|
cfg,
|
||||||
channel,
|
channel,
|
||||||
accountId,
|
enabled: true,
|
||||||
patch,
|
patch: {
|
||||||
|
accounts: {
|
||||||
|
...(feishuCfg?.accounts ?? {}),
|
||||||
|
[accountId]: nextAccountPatch,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,22 @@
|
|||||||
import { vi } from "vitest";
|
import { vi, type Mock } from "vitest";
|
||||||
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
import type { OpenClawConfig } from "../../config/types.openclaw.js";
|
||||||
import type { GatewayRequestHandlerOptions } from "./types.js";
|
import type { GatewayRequestHandlerOptions } from "./types.js";
|
||||||
|
|
||||||
function createGatewayLog() {
|
type UnknownMock = Mock<(...args: unknown[]) => unknown>;
|
||||||
|
type GatewayLogMocks = {
|
||||||
|
error: UnknownMock;
|
||||||
|
warn: UnknownMock;
|
||||||
|
info: UnknownMock;
|
||||||
|
debug: UnknownMock;
|
||||||
|
};
|
||||||
|
type ConfigHandlerHarness = {
|
||||||
|
options: GatewayRequestHandlerOptions;
|
||||||
|
respond: UnknownMock;
|
||||||
|
logGateway: GatewayLogMocks;
|
||||||
|
disconnectClientsUsingSharedGatewayAuth: UnknownMock;
|
||||||
|
};
|
||||||
|
|
||||||
|
function createGatewayLog(): GatewayLogMocks {
|
||||||
return {
|
return {
|
||||||
error: vi.fn(),
|
error: vi.fn(),
|
||||||
warn: vi.fn(),
|
warn: vi.fn(),
|
||||||
@@ -37,7 +51,7 @@ export function createConfigHandlerHarness(args?: {
|
|||||||
params?: unknown;
|
params?: unknown;
|
||||||
overrides?: Partial<GatewayRequestHandlerOptions>;
|
overrides?: Partial<GatewayRequestHandlerOptions>;
|
||||||
contextOverrides?: Partial<GatewayRequestHandlerOptions["context"]>;
|
contextOverrides?: Partial<GatewayRequestHandlerOptions["context"]>;
|
||||||
}) {
|
}): ConfigHandlerHarness {
|
||||||
const logGateway = createGatewayLog();
|
const logGateway = createGatewayLog();
|
||||||
const disconnectClientsUsingSharedGatewayAuth = vi.fn();
|
const disconnectClientsUsingSharedGatewayAuth = vi.fn();
|
||||||
const respond = vi.fn();
|
const respond = vi.fn();
|
||||||
|
|||||||
Reference in New Issue
Block a user