* feat: cal ai self serve architecture * chore: add package * chore: update evnet controller * refactor: improvements * chore: rename * chore: type error and naming * chore: just set it to nul * chore: just set it to nul * chore: some more improvements * chore: packate version * fix: API v2 * chore: change name of files * chore: add select * chore: add missing teamId * chore: save progress * refactor: split into multiple services * refactor: make schema provider agonistic * chore: improvements * chore: * chore: remove duplicate files * chore: semicolon * chore: formatting * refactor: logging and error handling * chore: rename variable * refactor: use trpc error * chore: replace with HttpError * chore: remove from option * We need the enum and not just the type --------- Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import type { TFunction } from "i18next";
|
|
|
|
import { WorkflowActions } from "@calcom/prisma/enums";
|
|
import { WorkflowTemplates, WorkflowTriggerEvents } from "@calcom/prisma/enums";
|
|
|
|
import { isSMSOrWhatsappAction, isWhatsappAction, isEmailToAttendeeAction } from "./actionHelperFunctions";
|
|
import {
|
|
WHATSAPP_WORKFLOW_TEMPLATES,
|
|
WORKFLOW_ACTIONS,
|
|
BASIC_WORKFLOW_TEMPLATES,
|
|
WORKFLOW_TRIGGER_EVENTS,
|
|
ATTENDEE_WORKFLOW_TEMPLATES,
|
|
} from "./constants";
|
|
|
|
export function getWorkflowActionOptions(t: TFunction, isOrgsPlan?: boolean) {
|
|
return WORKFLOW_ACTIONS.filter((action) => action !== WorkflowActions.CAL_AI_PHONE_CALL).map((action) => {
|
|
const actionString = t(`${action.toLowerCase()}_action`);
|
|
|
|
return {
|
|
label: actionString.charAt(0).toUpperCase() + actionString.slice(1),
|
|
value: action,
|
|
needsCredits: !isOrgsPlan && isSMSOrWhatsappAction(action),
|
|
};
|
|
});
|
|
}
|
|
|
|
export function getWorkflowTriggerOptions(t: TFunction) {
|
|
// TODO: remove this after workflows are supported
|
|
const filterdWorkflowTriggerEvents = WORKFLOW_TRIGGER_EVENTS.filter(
|
|
(event) =>
|
|
event !== WorkflowTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW &&
|
|
event !== WorkflowTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW
|
|
);
|
|
|
|
return filterdWorkflowTriggerEvents.map((triggerEvent) => {
|
|
const triggerString = t(`${triggerEvent.toLowerCase()}_trigger`);
|
|
|
|
return { label: triggerString.charAt(0).toUpperCase() + triggerString.slice(1), value: triggerEvent };
|
|
});
|
|
}
|
|
|
|
export function getWorkflowTemplateOptions(
|
|
t: TFunction,
|
|
action: WorkflowActions | undefined,
|
|
hasPaidPlan: boolean
|
|
) {
|
|
const TEMPLATES =
|
|
action && isWhatsappAction(action)
|
|
? WHATSAPP_WORKFLOW_TEMPLATES
|
|
: action && isEmailToAttendeeAction(action)
|
|
? ATTENDEE_WORKFLOW_TEMPLATES
|
|
: BASIC_WORKFLOW_TEMPLATES;
|
|
return TEMPLATES.map((template) => {
|
|
return {
|
|
label: t(`${template.toLowerCase()}`),
|
|
value: template,
|
|
needsTeamsUpgrade: !hasPaidPlan && template == WorkflowTemplates.CUSTOM,
|
|
};
|
|
}) as { label: string; value: any; needsTeamsUpgrade: boolean }[];
|
|
}
|