import * as z from "zod" import { defineAction } from "../../../automation/actions" import { getGoogleFormsApi, normalizeForm, normalizeFormId, } from "@automate.ax/integration-contracts/google-forms" import { GOOGLE_FORMS_READ_REQUIREMENT } from "../lib/scopes" import { FORM_REFERENCE_SCHEMA, FORM_SCHEMA, } from "@automate.ax/integration-contracts/google-forms" /** Retrieves form metadata, settings, publishing state, and all items. */ export const getGoogleForm = defineAction("Get Google form") .describe("Gets a normalized Google Form with all questions and items.") .account("google", GOOGLE_FORMS_READ_REQUIREMENT) .input( z.object({ /** Form ID or standard Google Forms URL. */ form: FORM_REFERENCE_SCHEMA, }), ) .output(FORM_SCHEMA) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => normalizeForm( ( await getGoogleFormsApi(account.secret).forms.get({ formId: normalizeFormId(input.form), }) ).data, ), )