import { RPCExporter } from "rpclibrary"
import { FrontworkAdmin } from "../../Admin/Admin"
import { TableDefiniton } from "../../Types/Types"
import { PrivilegedRPCExporter } from "../../Types/PrivilegedRPCExporter"
import { FrontworkComponent } from "../../Types/FrontworkComponent"

export class Debugger 
implements FrontworkComponent<any,any>{
    public admin: FrontworkAdmin
    name = "Debugger" 
    

    constructor(private exporters: PrivilegedRPCExporter[]){
    }

    exportRPCs(){
        
        return [{
            name: 'getTable',
            call: async(table:string) => this.admin.knex.select('*').from(table)
        }, 
        ...this.exporters.flatMap(e => e.exportRPCs()),
        ...this.exporters.flatMap(e => e.exportRPCFeatures().flatMap(e => e.exportRPCs()))]
    }

    exportRPCFeatures(): RPCExporter<any, any, {}>[] {
        return []
    }

    getTableDefinitions(): TableDefiniton[] {
        return []
    }

}