import { buildWorkflowTriggerOutboxEvent } from "@hivegrid/queue"; import { buildCalendarCreatedWorkflowEvent } from "~/services/automation/automation.producer-events.server"; export { buildCalendarCreatedWorkflowEvent } from "~/services/automation/automation.producer-events.server"; export function buildBookingBookedWorkflowEvents(input: { readonly tenantId: string; readonly appointmentId: string; readonly bookingPageId: string; readonly bookingPageSlug: string; readonly providerUserId: string; readonly calendarEventId: string; readonly startAt: Date; readonly endAt: Date; readonly kontaktId: string | null; }) { return [ buildWorkflowTriggerOutboxEvent({ tenantId: input.tenantId, event: "booking.appointment_booked", data: { appointmentId: input.appointmentId, bookingPageId: input.bookingPageId, bookingPageSlug: input.bookingPageSlug, appointmentType: input.bookingPageSlug, terminart: input.bookingPageSlug, providerUserId: input.providerUserId, mitarbeiter: input.providerUserId, startAt: input.startAt.toISOString(), endAt: input.endAt.toISOString(), kontaktId: input.kontaktId, }, userId: null, sourceId: `booking:${input.appointmentId}:booked`, }), buildCalendarCreatedWorkflowEvent({ tenantId: input.tenantId, calendarEventId: input.calendarEventId, userId: input.providerUserId, calendarKey: "hauptkalender", eventKind: "termin", source: "booking", sourceEntityId: input.appointmentId, startsAt: input.startAt, endsAt: input.endAt, }), ] as const; } export function buildBookingCancelledWorkflowEvent(input: { readonly tenantId: string; readonly appointmentId: string; readonly bookingPageId: string; readonly bookingPageSlug: string; readonly providerUserId: string; readonly cancelledByKind: "customer" | "provider" | "system"; readonly cancellationReason: string; readonly cancelledAt: Date; readonly actorUserId: string | null; }) { return buildWorkflowTriggerOutboxEvent({ tenantId: input.tenantId, event: "booking.appointment_cancelled", data: { appointmentId: input.appointmentId, bookingPageId: input.bookingPageId, bookingPageSlug: input.bookingPageSlug, appointmentType: input.bookingPageSlug, terminart: input.bookingPageSlug, providerUserId: input.providerUserId, cancelledByKind: input.cancelledByKind, cancellationReason: input.cancellationReason, cancelledAt: input.cancelledAt.toISOString(), }, userId: input.actorUserId, sourceId: `booking:${input.appointmentId}:cancelled:${input.cancelledAt.getTime()}`, }); }