import { type ActionType } from "@langfuse/shared"; import { type FieldValues } from "react-hook-form"; import { type BaseActionHandler } from "./BaseActionHandler"; import { WebhookActionHandler } from "./WebhookActionHandler"; import { SlackActionHandler } from "./SlackActionHandler"; export class ActionHandlerRegistry { private static handlers: Map> = new Map(); static { // Initialize handlers in static block this.handlers.set("WEBHOOK", new WebhookActionHandler()); this.handlers.set("SLACK", new SlackActionHandler()); } static getHandler( actionType: ActionType, ): BaseActionHandler { const handler = this.handlers.get(actionType); if (!handler) { throw new Error(`No handler registered for action type: ${actionType}`); } return handler as BaseActionHandler; } static getAllActionTypes(): ActionType[] { return Array.from(this.handlers.keys()); } static registerHandler( actionType: ActionType, handler: BaseActionHandler, ) { this.handlers.set(actionType, handler as BaseActionHandler); } static hasHandler(actionType: ActionType): boolean { return this.handlers.has(actionType); } }