@mulutime/plugin-types
Version:
TypeScript types for the MuluTime plugin system
227 lines • 8.66 kB
TypeScript
/**
* System Events for Plugin Automation and Webhooks
* These events are triggered automatically by the booking system
* and plugins can subscribe to them for automatic actions
*/
import { BookingData } from "./core-types";
export declare enum SystemEventType {
BOOKING_CREATED = "booking.created",
BOOKING_UPDATED = "booking.updated",
BOOKING_CANCELLED = "booking.cancelled",
BOOKING_CONFIRMED = "booking.confirmed",
BOOKING_RESCHEDULED = "booking.rescheduled",
BOOKING_COMPLETED = "booking.completed",
BOOKING_NO_SHOW = "booking.no_show",
BOOKING_REMINDER = "booking.reminder",
USER_CREATED = "user.created",
USER_UPDATED = "user.updated",
USER_DELETED = "user.deleted",
USER_LOGIN = "user.login",
USER_PROFILE_UPDATED = "user.profile_updated",
SCHEDULE_CREATED = "schedule.created",
SCHEDULE_UPDATED = "schedule.updated",
SCHEDULE_DELETED = "schedule.deleted",
AVAILABILITY_CHANGED = "availability.changed",
WORKING_HOURS_UPDATED = "working_hours.updated",
EVENT_TYPE_CREATED = "event_type.created",
EVENT_TYPE_UPDATED = "event_type.updated",
EVENT_TYPE_DELETED = "event_type.deleted",
EVENT_TYPE_PUBLISHED = "event_type.published",
EVENT_TYPE_UNPUBLISHED = "event_type.unpublished",
ORGANIZATION_CREATED = "organization.created",
ORGANIZATION_UPDATED = "organization.updated",
ORGANIZATION_MEMBER_ADDED = "organization.member_added",
ORGANIZATION_MEMBER_REMOVED = "organization.member_removed",
ORGANIZATION_SETTINGS_UPDATED = "organization.settings_updated",
INTEGRATION_CONNECTED = "integration.connected",
INTEGRATION_DISCONNECTED = "integration.disconnected",
INTEGRATION_ERROR = "integration.error",
INTEGRATION_SYNC_COMPLETED = "integration.sync_completed",
CALENDAR_EVENT_CREATED = "calendar.event_created",
CALENDAR_EVENT_UPDATED = "calendar.event_updated",
CALENDAR_EVENT_DELETED = "calendar.event_deleted",
CALENDAR_SYNC_STARTED = "calendar.sync_started",
CALENDAR_SYNC_COMPLETED = "calendar.sync_completed",
PAYMENT_RECEIVED = "payment.received",
PAYMENT_FAILED = "payment.failed",
PAYMENT_REFUNDED = "payment.refunded",
PAYMENT_DISPUTED = "payment.disputed",
EMAIL_SENT = "email.sent",
EMAIL_FAILED = "email.failed",
SMS_SENT = "sms.sent",
SMS_FAILED = "sms.failed",
NOTIFICATION_SENT = "notification.sent",
DAILY_SUMMARY = "system.daily_summary",
WEEKLY_REPORT = "system.weekly_report",
MONTHLY_REPORT = "system.monthly_report",
SYSTEM_MAINTENANCE_START = "system.maintenance_start",
SYSTEM_MAINTENANCE_END = "system.maintenance_end",
SYSTEM_BACKUP_COMPLETED = "system.backup_completed",
PLUGIN_INSTALLED = "plugin.installed",
PLUGIN_UNINSTALLED = "plugin.uninstalled",
PLUGIN_ERROR = "plugin.error",
SCHEDULED_FUNCTION_TRIGGERED = "scheduled.function_triggered",
SCHEDULED_FUNCTION_COMPLETED = "scheduled.function_completed",
SCHEDULED_FUNCTION_FAILED = "scheduled.function_failed"
}
export interface SystemEventPayload {
eventType: SystemEventType;
eventId: string;
timestamp: string;
userId?: string;
organizationId?: string;
data: Record<string, any>;
metadata?: {
source: string;
version: string;
correlationId?: string;
};
}
export interface BookingEventPayload extends SystemEventPayload {
eventType: SystemEventType.BOOKING_CREATED | SystemEventType.BOOKING_UPDATED | SystemEventType.BOOKING_CANCELLED | SystemEventType.BOOKING_CONFIRMED | SystemEventType.BOOKING_RESCHEDULED | SystemEventType.BOOKING_COMPLETED | SystemEventType.BOOKING_NO_SHOW;
data: {
booking: BookingData;
};
}
export interface UserEventPayload extends SystemEventPayload {
eventType: SystemEventType.USER_CREATED | SystemEventType.USER_UPDATED | SystemEventType.USER_DELETED | SystemEventType.USER_LOGIN | SystemEventType.USER_PROFILE_UPDATED;
data: {
user: {
id: string;
name: string;
email: string;
role: string;
organizationId?: string;
profile?: Record<string, any>;
previousValues?: Record<string, any>;
};
};
}
export interface ScheduleEventPayload extends SystemEventPayload {
eventType: SystemEventType.SCHEDULE_CREATED | SystemEventType.SCHEDULE_UPDATED | SystemEventType.SCHEDULE_DELETED | SystemEventType.AVAILABILITY_CHANGED | SystemEventType.WORKING_HOURS_UPDATED;
data: {
schedule: {
id: string;
userId: string;
name: string;
timeZone: string;
workingHours: Array<{
day: number;
start: string;
end: string;
enabled: boolean;
}>;
availability: Array<{
date: string;
available: boolean;
slots?: Array<{
start: string;
end: string;
available: boolean;
}>;
}>;
previousValues?: Record<string, any>;
};
};
}
export interface EventTypeEventPayload extends SystemEventPayload {
eventType: SystemEventType.EVENT_TYPE_CREATED | SystemEventType.EVENT_TYPE_UPDATED | SystemEventType.EVENT_TYPE_DELETED | SystemEventType.EVENT_TYPE_PUBLISHED | SystemEventType.EVENT_TYPE_UNPUBLISHED;
data: {
eventType: {
id: string;
name: string;
description?: string;
duration: number;
price?: number;
currency?: string;
category: string;
isPublic: boolean;
settings: {
bufferTime?: number;
maxBookingsPerDay?: number;
advanceBookingTime?: number;
cancellationPolicy?: string;
};
previousValues?: Record<string, any>;
};
};
}
export interface IntegrationEventPayload extends SystemEventPayload {
eventType: SystemEventType.INTEGRATION_CONNECTED | SystemEventType.INTEGRATION_DISCONNECTED | SystemEventType.INTEGRATION_ERROR | SystemEventType.INTEGRATION_SYNC_COMPLETED;
data: {
integration: {
id: string;
provider: string;
type: string;
userId: string;
organizationId?: string;
status: 'active' | 'inactive' | 'error';
settings: Record<string, any>;
error?: {
message: string;
code: string;
timestamp: string;
};
syncStats?: {
itemsProcessed: number;
itemsCreated: number;
itemsUpdated: number;
itemsFailed: number;
duration: number;
};
};
};
}
export interface PaymentEventPayload extends SystemEventPayload {
eventType: SystemEventType.PAYMENT_RECEIVED | SystemEventType.PAYMENT_FAILED | SystemEventType.PAYMENT_REFUNDED | SystemEventType.PAYMENT_DISPUTED;
data: {
payment: {
id: string;
bookingId: string;
amount: number;
currency: string;
status: 'pending' | 'completed' | 'failed' | 'refunded' | 'disputed';
paymentMethod: string;
transactionId?: string;
refundId?: string;
disputeId?: string;
failureReason?: string;
};
};
}
export interface CommunicationEventPayload extends SystemEventPayload {
eventType: SystemEventType.EMAIL_SENT | SystemEventType.EMAIL_FAILED | SystemEventType.SMS_SENT | SystemEventType.SMS_FAILED | SystemEventType.NOTIFICATION_SENT;
data: {
communication: {
id: string;
type: 'email' | 'sms' | 'notification';
recipient: string;
subject?: string;
content: string;
status: 'sent' | 'failed' | 'delivered' | 'opened' | 'clicked';
provider?: string;
error?: string;
bookingId?: string;
};
};
}
export interface RuntimePluginEventSubscription {
pluginId: string;
eventTypes: SystemEventType[];
filters?: {
userId?: string;
organizationId?: string;
conditions?: Record<string, any>;
};
actionMethod: string;
enabled: boolean;
priority: number;
}
export interface EventTriggerConfig {
immediate: boolean;
async: boolean;
timeout: number;
retries: number;
backoff: 'linear' | 'exponential';
}
//# sourceMappingURL=system-events.d.ts.map