import { IRuntimeTransformer, ITransformerOrchestrator } from "@apic/smith-transformer";

export class WMGWRuntimeTransformer implements IRuntimeTransformer {
    private orchestratorPromise: Promise<ITransformerOrchestrator> | null = null;

    private async loadOrchestrator() {
        if (!this.orchestratorPromise) {
            this.orchestratorPromise = import("@apic/wmgw-smith-transformer").then(
                async (module) => await module.createWmgwOrchestrator()
            );
        }
        return this.orchestratorPromise;
    }

    public async transform(zip: Buffer) {
        const orchestrator = await this.loadOrchestrator();
        return orchestrator.transform(zip);
    }
}