// Session-communication scheduler constants (Welcome / Program completion auto-triggers).
export const SESSION_COMMUNICATION_SCHEDULER = {
  /** Deterministic name prefixes → idempotent create/update/delete per program. */
  WELCOME_SCHEDULE_NAME_PREFIX: 'session-comm-welcome-',
  COMPLETION_SCHEDULE_NAME_PREFIX: 'session-comm-completion-',
  /** Welcome fires this many minutes before the program's first session starts. */
  WELCOME_LEAD_MINUTES: 60,
  // Delivery retry (reuses the same policy as join-link; no DLQ).
  MAX_RETRY_ATTEMPTS: 5,
  MAX_EVENT_AGE_SECONDS: 86400, // 24h max
} as const;

export const buildWelcomeScheduleName = (programId: number): string =>
  `${SESSION_COMMUNICATION_SCHEDULER.WELCOME_SCHEDULE_NAME_PREFIX}${programId}`;

export const buildCompletionScheduleName = (programId: number): string =>
  `${SESSION_COMMUNICATION_SCHEDULER.COMPLETION_SCHEDULE_NAME_PREFIX}${programId}`;

export const SESSION_COMMUNICATION_SCHEDULER_LOG = {
  DISABLED:
    'Session-communication scheduler disabled (ENABLE_SESSION_COMMUNICATION_SCHEDULER!=true); skipping',
  MISSING_CONFIG:
    'Session-communication scheduler is enabled but AWS_SCHEDULER_TARGET_QUEUE_ARN / EXECUTION_ROLE_ARN is not configured; skipping',
  CREATED: (name: string, at: string): string =>
    `Session-communication schedule upserted: ${name} at ${at}`,
  DELETED: (name: string): string => `Session-communication schedule deleted: ${name}`,
  UPSERT_FAILED: 'Failed to upsert session-communication schedule',
  DELETE_FAILED: 'Failed to delete session-communication schedule',
  NO_ONLINE_SESSIONS: (programId: number): string =>
    `No online sessions for program ${programId}; skipping session-communication schedules`,
} as const;
