import type { Plugin } from "vue"

import type { PluginApi } from "@racletteOrchestrator"
import type { PluginMetadata } from "@core"

// Plugin types
export enum PluginType {
  CORE = "core",
  NPM = "npm",
  APP = "app",
}

// Interface for discovered plugin info
export interface DiscoveredPlugin {
  configPath: string
  pluginPath: string
  frontendPath: string
  type: PluginType
  metadata: PluginMetadata
  pluginKey: string
}

export type RouteConfig = {
  method: string
  storeActionType?: string
  actionId?: string
  target?: string | ((params: any) => string)
  dataTypeName?: string
}

export type Operations = Record<string, RouteConfig>

export interface PluginSocketApi {
  registeredListeners: Array<{
    channelName: string
    handlerFn: Function
  }>
  on: (eventName: string, handlerFn: Function) => void
  off: (eventIdentity: string, handlerFn: Function) => void
  emit: (eventName: string, eventPayload: any) => void
  once: (eventName: string, handlerFn: Function) => void
}

export interface TranslationUpdate {
  [locale: string]: {
    [key: string]: any
  }
}

export interface OrchestratorPlugin {
  dependency: Plugin
  options: Record<string, string>
}

// Re-export types from dependencies
export type { PluginApi, PluginMetadata }
