import { MockupSignalPipelineProvider } from '../provider/MockupSignalPipelineProvider'
import type { PipelineState, AuditTrailEntry, GateType } from '../domain/signalPipeline'
import type { ItemResponse, ListResponse } from './types'

const provider = MockupSignalPipelineProvider

export const signalPipelineService = {
  async getPipelineState(signalId: string): Promise<ItemResponse<PipelineState | null>> {
    const data = await provider.getPipelineState(signalId)
    return { data }
  },
  async evaluateGate(signalId: string, gateType: GateType): Promise<ItemResponse<PipelineState>> {
    const data = await provider.evaluateGate(signalId, gateType)
    return { data }
  },
  async getAuditTrail(signalId: string): Promise<ListResponse<AuditTrailEntry>> {
    const data = await provider.getAuditTrail(signalId)
    return { data, meta: { total: data.length, page: 1, pageSize: data.length, hasMore: false } }
  },
  async publishToFutureAvailability(signalId: string): Promise<ItemResponse<PipelineState>> {
    const data = await provider.publishToFutureAvailability(signalId)
    return { data }
  },
}
