import { type Maybe } from '@dereekb/util'; import { RRule } from './rrule.interop'; /** * Internal iteration arguments used by the RRule iteration engine. * * Mirrors the shape expected by RRule's `_iter` method for custom iteration control. */ export interface IterArgs { inc: boolean; before: Date; after: Date; dt: Date; _value: Date | Date[] | null; } /** * Safety limit to prevent infinite iteration over unbounded recurrence rules. */ export declare const DEFAULT_LAST_ITER_RESULT_MAX_ITERATIONS_ALLOWED = 10000; /** * Extended RRule that adds convenience methods for querying recurrence dates * using custom iteration strategies (`last`, `next`, `any`). * * Works around missing typings in the upstream RRule library. * * @example * ```ts * const rule = new DateRRule({ freq: RRule.DAILY, dtstart: new Date() }); * const lastDate = rule.last(); * const nextDate = rule.next(new Date()); * const hasAny = rule.any({ minDate: startDate, maxDate: endDate }); * ``` */ export declare class DateRRule extends RRule { /** * Returns the last occurrence in the rule chain, up to the configured max iteration limit. * * @returns The last occurrence date, or `undefined` if there are none. * * @example * ```ts * const rule = new DateRRule({ freq: RRule.DAILY, count: 5, dtstart: startDate }); * const lastDate = rule.last(); // fifth occurrence * ``` */ last(): Maybe; /** * Returns the first recurrence that occurs on or after the given date. * * @param minDate - The earliest date to consider. * @returns The first occurrence on or after `minDate`, or `undefined` if none. * * @example * ```ts * const rule = new DateRRule({ freq: RRule.WEEKLY, dtstart: startDate }); * const nextDate = rule.next(new Date()); * ``` */ next(minDate: Date): Maybe; /** * Checks whether any recurrence falls within the optional date bounds. * * @param filter - Optional date bounds with `minDate` and `maxDate`. * @param filter.minDate - Optional minimum date bound. * @param filter.maxDate - Optional maximum date bound. * @returns `true` if at least one recurrence falls within the bounds. * * @example * ```ts * const rule = new DateRRule({ freq: RRule.DAILY, dtstart: startDate }); * const exists = rule.any({ minDate: rangeStart, maxDate: rangeEnd }); * ``` */ any(filter?: { minDate?: Maybe; maxDate?: Maybe; }): boolean; } /** * Used for typing information. Unused otherwise. */ declare abstract class BaseRRuleIter { readonly method = "before"; readonly minDate: Date | null; readonly maxDate: Date | null; readonly _result: Date[]; readonly args: Partial; total: number; protected _value: Date | null; getValue(): Date | null; } /** * Iterator result that captures the last date encountered before reaching the max future date * or the iteration limit. Used by {@link DateRRule.last}. */ export declare class LastIterResult extends BaseRRuleIter { private readonly _maxIterationsAllowed; readonly maxDate: Date; constructor(maxIterationsAllowed?: number); get maxIterationsAllowed(): number; accept(date: Date): boolean; add(date: Date): boolean; clone(): LastIterResult; } /** * Iterator result that finds the first recurrence on or after a minimum date. * Stops iteration as soon as a qualifying date is found. Used by {@link DateRRule.next}. */ export declare class NextIterResult extends BaseRRuleIter { readonly minDate: Date; readonly maxIterationsAllowed: number; readonly maxDate: Date; constructor(minDate: Date, maxIterationsAllowed?: number); accept(date: Date): boolean; add(date: Date): boolean; clone(): NextIterResult; } /** * Iterator result that checks whether any recurrence falls within an optional date range. * Stops as soon as one qualifying date is found. Used by {@link DateRRule.any}. */ export declare class AnyIterResult extends BaseRRuleIter { readonly maxIterationsAllowed: number; readonly minDate: Date | null; readonly maxDate: Date | null; constructor(filter?: { minDate?: Maybe; maxDate?: Maybe; }, maxIterationsAllowed?: number); accept(date: Date): boolean; add(date: Date): boolean; clone(): AnyIterResult; } export {};