scoootscooob 4540c6b3bc
refactor(signal): move Signal channel code to extensions/signal/src/ (#45531)
Move all Signal channel implementation files from src/signal/ to
extensions/signal/src/ and replace originals with re-export shims.
This continues the channel plugin migration pattern used by other
extensions, keeping backward compatibility via shims while the real
code lives in the extension.

- Copy 32 .ts files (source + tests) to extensions/signal/src/
- Transform all relative import paths for the new location
- Create 2-line re-export shims in src/signal/ for each moved file
- Preserve existing extension files (channel.ts, runtime.ts, etc.)
- Change tsconfig.plugin-sdk.dts.json rootDir from "src" to "."
  to support cross-boundary re-exports from extensions/
2026-03-14 02:42:48 -07:00

57 lines
1.5 KiB
TypeScript

import type { BaseProbeResult } from "../../../src/channels/plugins/types.js";
import { signalCheck, signalRpcRequest } from "./client.js";
export type SignalProbe = BaseProbeResult & {
status?: number | null;
elapsedMs: number;
version?: string | null;
};
function parseSignalVersion(value: unknown): string | null {
if (typeof value === "string" && value.trim()) {
return value.trim();
}
if (typeof value === "object" && value !== null) {
const version = (value as { version?: unknown }).version;
if (typeof version === "string" && version.trim()) {
return version.trim();
}
}
return null;
}
export async function probeSignal(baseUrl: string, timeoutMs: number): Promise<SignalProbe> {
const started = Date.now();
const result: SignalProbe = {
ok: false,
status: null,
error: null,
elapsedMs: 0,
version: null,
};
const check = await signalCheck(baseUrl, timeoutMs);
if (!check.ok) {
return {
...result,
status: check.status ?? null,
error: check.error ?? "unreachable",
elapsedMs: Date.now() - started,
};
}
try {
const version = await signalRpcRequest("version", undefined, {
baseUrl,
timeoutMs,
});
result.version = parseSignalVersion(version);
} catch (err) {
result.error = err instanceof Error ? err.message : String(err);
}
return {
...result,
ok: true,
status: check.status ?? null,
elapsedMs: Date.now() - started,
};
}