Files
pi-ntfy/types.ts
T
杨豪 6fc9f228a8 feat: default to all modes, switch mode filter from whitelist to excludedModes blacklist
- NotifyConfig.modes (whitelist) → excludedModes (blacklist, default [] = push everywhere)
- valid modes are tui/json/rpc/print (pi ExtensionMode); invalid entries ignored with warning
- legacy "modes" key is ignored with a deprecation warning
- /ntfy status shows 模式: 全部(排除: json)
- migrate local config: modes array → excludedModes: []
2026-10-08 14:16:48 +08:00

79 lines
1.4 KiB
TypeScript

/** pi-ntfy shared types. */
export type NotifyEvent =
| "idle"
| "interrupted"
| "needInput"
| "exit"
| "test";
export interface EventToggles {
idle?: boolean;
interrupted?: boolean;
needInput?: boolean;
exit?: boolean;
}
export interface NtfyChannel {
type: "ntfy";
name?: string;
enabled?: boolean;
events?: EventToggles;
timeoutMs?: number;
topic: string;
server?: string;
token?: string;
priority?: string | number;
tags?: string | string[];
clickUrl?: string;
icon?: string;
email?: string;
}
export type ChannelConfig = NtfyChannel;
export interface NotifyConfig {
enabled: boolean;
/** Modes that must stay quiet; all others push. Empty array = push everywhere. */
excludedModes: string[];
timeoutMs: number;
shutdownTimeoutMs: number;
dedupeMs: number;
minDurationSec: number;
maxTextChars: number;
titleTemplate: string;
template: string;
events: Required<EventToggles>;
needInputTools: string[];
debug: boolean;
channels: NtfyChannel[];
warnings: string[];
path: string;
exists: boolean;
}
export const ALL_MODES = [
"tui",
"json",
"rpc",
"print",
] as const;
export type KnownMode = (typeof ALL_MODES)[number];
export interface NotifyPayload {
event: NotifyEvent;
status: string;
reason: string;
title: string;
text: string;
vars: Record<string, string>;
}
export interface ChannelResult {
channel: string;
ok: boolean;
status: number;
error?: string;
ms: number;
}