UNPKG

@wuwei-labs/srsly

Version:
74 lines 2.42 kB
/** * @purpose Payment schedule parameter conversion utilities * * Converts user-friendly schedule formats to strings for use with Solana programs. * Supports common shortcuts and cron expressions. */ /** * Schedule parameter type * * Accepts either: * - Schedule shortcuts (e.g., '@daily', 'daily', '@hourly', 'hourly') * - Cron expressions for custom schedules */ export type ScheduleParam = string; /** * Common schedule shortcuts */ export declare const SCHEDULE_SHORTCUTS: readonly ["@hourly", "@daily", "@weekly", "@monthly", "@yearly", "@annually", "@decasecond", "@minute", "hourly", "daily", "weekly", "monthly", "yearly", "annually", "decasecond", "minute"]; /** * Normalize payment schedule input to program-compatible format * * @param schedule - Payment schedule string * @returns Normalized schedule string for Solana program * @throws Error if schedule format is invalid * * @example * ```typescript * normalizeSchedule('daily') // '@daily' * normalizeSchedule('@hourly') // '@hourly' * normalizeSchedule('0 * * * *') // '0 * * * *' * normalizeSchedule('0 0 * * * *') // '0 0 * * * *' (with seconds) * ``` */ export declare function normalizeSchedule(schedule: ScheduleParam): string; /** * Validate schedule format * * Checks if a schedule string is either: * - A valid @shortcut * - A valid cron expression (5 or 6 fields) * * @param schedule - Schedule string to validate * @returns True if valid, false otherwise * * @example * ```typescript * validateScheduleFormat('@daily') // true * validateScheduleFormat('0 * * * *') // true * validateScheduleFormat('invalid') // false * ``` */ export declare function validateScheduleFormat(schedule: string): boolean; /** * Convert schedule string to human-readable description * * @param schedule - Normalized schedule string * @returns Human-readable description * * @example * ```typescript * formatSchedule('@daily') // "Daily" * formatSchedule('@hourly') // "Hourly" * formatSchedule('0 * * * *') // "Custom: 0 * * * *" * ``` */ export declare function formatSchedule(schedule: string): string; /** * Check if a schedule is a known shortcut * * @param schedule - Schedule string to check * @returns True if it's a shortcut (with or without @) */ export declare function isScheduleShortcut(schedule: string): boolean; //# sourceMappingURL=schedule.d.ts.map