// Join-link scheduler constants.
export const JOIN_LINK_SCHEDULER = {
  /** Deterministic name → idempotent create/update/delete. */
  SCHEDULE_NAME_PREFIX: 'join-link-',
  // Delivery retry (no DLQ — the 4-hourly fallback cron is the safety net).
  MAX_RETRY_ATTEMPTS: 5,
  MAX_EVENT_AGE_SECONDS: 86400, // 24h max
} as const;

/** Builds the deterministic schedule name for a program session. */
export const buildScheduleName = (programSessionId: number): string =>
  `${JOIN_LINK_SCHEDULER.SCHEDULE_NAME_PREFIX}${programSessionId}`;

export const JOIN_LINK_SCHEDULER_LOG = {
  DISABLED: 'Join-link scheduler disabled (ENABLE_JOIN_LINK_SCHEDULER!=true); skipping schedule',
  MISSING_CONFIG:
    'Join-link scheduler is enabled but target queue ARN / execution role ARN is not configured; skipping schedule',
  CREATED: (name: string, at: string): string => `Join-link schedule created: ${name} at ${at}`,
  UPDATED: (name: string, at: string): string => `Join-link schedule updated: ${name} at ${at}`,
  DELETED: (name: string): string => `Join-link schedule deleted: ${name}`,
  CREATE_FAILED: 'Failed to create session link schedule',
  UPDATE_FAILED: 'Failed to update session link schedule',
  DELETE_FAILED: 'Failed to delete session link schedule',
} as const;
