import { Survey } from "../util/survey-utils/survey";
import { TRunAutofillOptions, assertAutofillSucceeded, runAutofill } from "./run-autofill";

/**
 * Runs the Autofill against the live RMS Survey, for Runnables. Rejects when the run couldn't start
 * or any question failed, so the Floating Action Bar shows the run as an error.
 */
export async function runAutofillOrThrow<TStorePreset>(
  options: Omit<TRunAutofillOptions<TStorePreset>, "survey">,
): Promise<void> {
  const result = await runAutofill({ survey: Survey.getInstance(), ...options });
  assertAutofillSucceeded(result);
}
