import { CALENDLY_SCHEDULING_LINK_SCHEMA, CALENDLY_URI_SCHEMA, } from "@automate.ax/integration-contracts/calendly" import * as z from "zod" import { defineAction } from "../../../automation/actions" import { CALENDLY_ACCOUNT, calendlyAccountRequirement, getCalendlyApi, resourceResponse, } from "./lib" export const createCalendlySingleUseSchedulingLink = defineAction( "Create Calendly single-use scheduling link", ) .describe( "Creates a single-use link for one Calendly event type; unused links expire after 90 days.", ) .account( CALENDLY_ACCOUNT, calendlyAccountRequirement("scheduling_links:write"), ) .input( z.object({ maxEventCount: z.literal(1).prefault(1), owner: CALENDLY_URI_SCHEMA, ownerType: z.literal("EventType").prefault("EventType"), }), ) .output(CALENDLY_SCHEDULING_LINK_SCHEMA) .retry({ replaySafety: "unsafe" }) .handler(({ account, input }) => getCalendlyApi(account) .request("scheduling_links", { body: input, method: "POST", responseSchema: resourceResponse(CALENDLY_SCHEDULING_LINK_SCHEMA), }) .then(({ resource }) => resource), )