mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 15:58:27 +00:00
fix: dedupe probe/token base types (#16986) (thanks @iyoda)
This commit is contained in:
46
src/channels/plugins/base-types-assignability.test.ts
Normal file
46
src/channels/plugins/base-types-assignability.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, it, expectTypeOf } from "vitest";
|
||||
import type { DiscordProbe } from "../../discord/probe.js";
|
||||
import type { DiscordTokenResolution } from "../../discord/token.js";
|
||||
import type { IMessageProbe } from "../../imessage/probe.js";
|
||||
import type { LineProbeResult } from "../../line/types.js";
|
||||
import type { SignalProbe } from "../../signal/probe.js";
|
||||
import type { SlackProbe } from "../../slack/probe.js";
|
||||
import type { TelegramProbe } from "../../telegram/probe.js";
|
||||
import type { TelegramTokenResolution } from "../../telegram/token.js";
|
||||
import type { BaseProbeResult, BaseTokenResolution } from "./types.js";
|
||||
|
||||
describe("BaseProbeResult assignability", () => {
|
||||
it("TelegramProbe satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<TelegramProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
|
||||
it("DiscordProbe satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<DiscordProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
|
||||
it("SlackProbe satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<SlackProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
|
||||
it("SignalProbe satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<SignalProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
|
||||
it("IMessageProbe satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<IMessageProbe>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
|
||||
it("LineProbeResult satisfies BaseProbeResult", () => {
|
||||
expectTypeOf<LineProbeResult>().toMatchTypeOf<BaseProbeResult>();
|
||||
});
|
||||
});
|
||||
|
||||
describe("BaseTokenResolution assignability", () => {
|
||||
it("TelegramTokenResolution satisfies BaseTokenResolution", () => {
|
||||
expectTypeOf<TelegramTokenResolution>().toMatchTypeOf<BaseTokenResolution>();
|
||||
});
|
||||
|
||||
it("DiscordTokenResolution satisfies BaseTokenResolution", () => {
|
||||
expectTypeOf<DiscordTokenResolution>().toMatchTypeOf<BaseTokenResolution>();
|
||||
});
|
||||
});
|
||||
@@ -347,3 +347,15 @@ export type ChannelPollContext = {
|
||||
silent?: boolean;
|
||||
isAnonymous?: boolean;
|
||||
};
|
||||
|
||||
/** Minimal base for all channel probe results. Channel-specific probes extend this. */
|
||||
export type BaseProbeResult<TError = string | null> = {
|
||||
ok: boolean;
|
||||
error?: TError;
|
||||
};
|
||||
|
||||
/** Minimal base for token resolution results. */
|
||||
export type BaseTokenResolution = {
|
||||
token: string;
|
||||
source: string;
|
||||
};
|
||||
|
||||
@@ -58,6 +58,8 @@ export type {
|
||||
ChannelThreadingContext,
|
||||
ChannelThreadingToolContext,
|
||||
ChannelToolSend,
|
||||
BaseProbeResult,
|
||||
BaseTokenResolution,
|
||||
} from "./types.core.js";
|
||||
|
||||
export type { ChannelPlugin } from "./types.plugin.js";
|
||||
|
||||
Reference in New Issue
Block a user