import type { ClientAction } from "@/types/actions/client"; import type { ConversationAction } from "@/types/actions/conversation"; import type { ConversationsAction } from "@/types/actions/conversations"; import type { DebugInformationAction } from "@/types/actions/debugInformation"; import type { DmAction } from "@/types/actions/dm"; import type { GroupAction } from "@/types/actions/group"; import type { PreferencesAction } from "@/types/actions/preferences"; export type UnknownAction = { action: string; id: string; result: unknown; data: unknown; }; export type EndStreamAction = { action: "endStream"; id: string; result: undefined; data: { streamId: string; }; }; export type ClientWorkerAction = | EndStreamAction | ClientAction | ConversationAction | ConversationsAction | DmAction | GroupAction | PreferencesAction | DebugInformationAction; export type ActionName = T["action"]; export type ExtractAction< T extends UnknownAction, A extends ActionName, > = Extract; export type ExtractActionWithoutData< T extends UnknownAction, A extends ActionName, > = Omit, "data">; export type ExtractActionWithoutResult< T extends UnknownAction, A extends ActionName, > = Omit, "result">; export type ExtractActionData< T extends UnknownAction, A extends ActionName, > = ExtractAction["data"]; export type ExtractActionResult< T extends UnknownAction, A extends ActionName, > = ExtractAction["result"]; export type ActionWithoutData = { [A in T["action"]]: Omit, "data">; }[T["action"]]; export type ActionWithoutResult = { [A in T["action"]]: Omit, "result">; }[T["action"]]; export type ActionErrorData = { id: string; action: ActionName; error: Error; }; export type ExtractActionGroup< T extends UnknownAction, U extends string, > = Extract;