mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
chore: Emit TypeScript declaration files so that we can type-check the extensions folder soon.
This commit is contained in:
@@ -418,7 +418,7 @@ export function createDiscordNativeCommand(params: {
|
|||||||
accountId: string;
|
accountId: string;
|
||||||
sessionPrefix: string;
|
sessionPrefix: string;
|
||||||
ephemeralDefault: boolean;
|
ephemeralDefault: boolean;
|
||||||
}) {
|
}): Command {
|
||||||
const { command, cfg, discordConfig, accountId, sessionPrefix, ephemeralDefault } = params;
|
const { command, cfg, discordConfig, accountId, sessionPrefix, ephemeralDefault } = params;
|
||||||
const commandDefinition =
|
const commandDefinition =
|
||||||
findCommandByNativeName(command.name, "discord") ??
|
findCommandByNativeName(command.name, "discord") ??
|
||||||
@@ -449,6 +449,7 @@ export function createDiscordNativeCommand(params: {
|
|||||||
},
|
},
|
||||||
] satisfies CommandOptions)
|
] satisfies CommandOptions)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return new (class extends Command {
|
return new (class extends Command {
|
||||||
name = command.name;
|
name = command.name;
|
||||||
description = command.description;
|
description = command.description;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
|||||||
import fsSync from "node:fs";
|
import fsSync from "node:fs";
|
||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { vi } from "vitest";
|
import { Mock, vi } from "vitest";
|
||||||
|
|
||||||
import type { ChannelPlugin, ChannelOutboundAdapter } from "../channels/plugins/types.js";
|
import type { ChannelPlugin, ChannelOutboundAdapter } from "../channels/plugins/types.js";
|
||||||
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
||||||
@@ -199,8 +199,8 @@ export const setTestConfigRoot = (root: string) => {
|
|||||||
export const testTailnetIPv4 = hoisted.testTailnetIPv4;
|
export const testTailnetIPv4 = hoisted.testTailnetIPv4;
|
||||||
export const piSdkMock = hoisted.piSdkMock;
|
export const piSdkMock = hoisted.piSdkMock;
|
||||||
export const cronIsolatedRun = hoisted.cronIsolatedRun;
|
export const cronIsolatedRun = hoisted.cronIsolatedRun;
|
||||||
export const agentCommand = hoisted.agentCommand;
|
export const agentCommand: Mock<() => void> = hoisted.agentCommand;
|
||||||
export const getReplyFromConfig = hoisted.getReplyFromConfig;
|
export const getReplyFromConfig: Mock<() => void> = hoisted.getReplyFromConfig;
|
||||||
|
|
||||||
export const testState = {
|
export const testState = {
|
||||||
agentConfig: undefined as Record<string, unknown> | undefined,
|
agentConfig: undefined as Record<string, unknown> | undefined,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { WebhookRequestBody } from "@line/bot-sdk";
|
import type { WebhookRequestBody } from "@line/bot-sdk";
|
||||||
|
import type { Request, Response, NextFunction } from "express";
|
||||||
import type { OpenClawConfig } from "../config/config.js";
|
import type { OpenClawConfig } from "../config/config.js";
|
||||||
import { loadConfig } from "../config/config.js";
|
import { loadConfig } from "../config/config.js";
|
||||||
import { logVerbose } from "../globals.js";
|
import { logVerbose } from "../globals.js";
|
||||||
@@ -71,7 +72,7 @@ export function createLineWebhookCallback(
|
|||||||
bot: LineBot,
|
bot: LineBot,
|
||||||
channelSecret: string,
|
channelSecret: string,
|
||||||
path = "/line/webhook",
|
path = "/line/webhook",
|
||||||
) {
|
): { path: string; handler: (req: Request, res: Response, _next: NextFunction) => Promise<void> } {
|
||||||
const { handler } = startLineWebhook({
|
const { handler } = startLineWebhook({
|
||||||
channelSecret,
|
channelSecret,
|
||||||
onEvents: bot.handleWebhook,
|
onEvents: bot.handleWebhook,
|
||||||
|
|||||||
@@ -31,7 +31,9 @@ function parseWebhookBody(req: Request, rawBody: string): WebhookRequestBody | n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createLineWebhookMiddleware(options: LineWebhookOptions) {
|
export function createLineWebhookMiddleware(
|
||||||
|
options: LineWebhookOptions,
|
||||||
|
): (req: Request, res: Response, _next: NextFunction) => Promise<void> {
|
||||||
const { channelSecret, onEvents, runtime } = options;
|
const { channelSecret, onEvents, runtime } = options;
|
||||||
|
|
||||||
return async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
return async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||||
@@ -87,7 +89,10 @@ export interface StartLineWebhookOptions {
|
|||||||
path?: string;
|
path?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startLineWebhook(options: StartLineWebhookOptions) {
|
export function startLineWebhook(options: StartLineWebhookOptions): {
|
||||||
|
path: string;
|
||||||
|
handler: (req: Request, res: Response, _next: NextFunction) => Promise<void>;
|
||||||
|
} {
|
||||||
const path = options.path ?? "/line/webhook";
|
const path = options.path ?? "/line/webhook";
|
||||||
const middleware = createLineWebhookMiddleware({
|
const middleware = createLineWebhookMiddleware({
|
||||||
channelSecret: options.channelSecret,
|
channelSecret: options.channelSecret,
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import { vi } from "vitest";
|
import { Mock, vi } from "vitest";
|
||||||
|
|
||||||
type SlackHandler = (args: unknown) => Promise<void>;
|
type SlackHandler = (args: unknown) => Promise<void>;
|
||||||
|
|
||||||
const slackTestState = vi.hoisted(() => ({
|
const slackTestState: {
|
||||||
|
config: Record<string, unknown>;
|
||||||
|
sendMock: Mock<(...args: unknown[]) => Promise<unknown>>;
|
||||||
|
replyMock: Mock<(...args: unknown[]) => unknown>;
|
||||||
|
updateLastRouteMock: Mock<(...args: unknown[]) => unknown>;
|
||||||
|
reactMock: Mock<(...args: unknown[]) => unknown>;
|
||||||
|
readAllowFromStoreMock: Mock<(...args: unknown[]) => Promise<unknown>>;
|
||||||
|
upsertPairingRequestMock: Mock<(...args: unknown[]) => Promise<unknown>>;
|
||||||
|
} = vi.hoisted(() => ({
|
||||||
config: {} as Record<string, unknown>,
|
config: {} as Record<string, unknown>,
|
||||||
sendMock: vi.fn(),
|
sendMock: vi.fn(),
|
||||||
replyMock: vi.fn(),
|
replyMock: vi.fn(),
|
||||||
@@ -12,7 +20,7 @@ const slackTestState = vi.hoisted(() => ({
|
|||||||
upsertPairingRequestMock: vi.fn(),
|
upsertPairingRequestMock: vi.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const getSlackTestState = () => slackTestState;
|
export const getSlackTestState: () => void = () => slackTestState;
|
||||||
|
|
||||||
export const getSlackHandlers = () =>
|
export const getSlackHandlers = () =>
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export async function createWaSocket(
|
|||||||
printQr: boolean,
|
printQr: boolean,
|
||||||
verbose: boolean,
|
verbose: boolean,
|
||||||
opts: { authDir?: string; onQr?: (qr: string) => void } = {},
|
opts: { authDir?: string; onQr?: (qr: string) => void } = {},
|
||||||
) {
|
): Promise<ReturnType<typeof makeWASocket>> {
|
||||||
const baseLogger = getChildLogger(
|
const baseLogger = getChildLogger(
|
||||||
{ module: "baileys" },
|
{ module: "baileys" },
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"moduleResolution": "NodeNext",
|
"moduleResolution": "NodeNext",
|
||||||
"lib": ["DOM", "DOM.Iterable", "ES2023", "ScriptHost"],
|
"lib": ["DOM", "DOM.Iterable", "ES2023", "ScriptHost"],
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
"declaration": true,
|
||||||
"noEmitOnError": true,
|
"noEmitOnError": true,
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user