UNPKG

scriptable-testlab

Version:

A lightweight, efficient tool designed to manage and update scripts for Scriptable.

271 lines 11.6 kB
import { AbsRecurrenceRule } from "scriptable-abstract"; class MockRecurrenceRule extends AbsRecurrenceRule { constructor(state) { super(state); } get asRecurrenceRule() { return this; } get interval() { return this.state.interval; } get endDate() { return this.state.endDate ?? null; } get occurrenceCount() { return this.state.occurrenceCount ?? null; } get daysOfTheWeek() { return this.state.daysOfTheWeek ?? []; } get daysOfTheMonth() { return this.state.daysOfTheMonth ?? []; } get monthsOfTheYear() { return this.state.monthsOfTheYear ?? []; } get weeksOfTheYear() { return this.state.weeksOfTheYear ?? []; } get daysOfTheYear() { return this.state.daysOfTheYear ?? []; } get setPositions() { return this.state.setPositions ?? []; } /** * Constructs a daily recurrence rule * @param interval - Interval at which to repeat the rule */ static daily(interval) { return new MockRecurrenceRule({ interval }).asRecurrenceRule; } /** * Constructs a daily recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param endDate - Date at which the recurrence rule should end */ static dailyEndDate(interval, endDate) { return new MockRecurrenceRule({ interval, endDate }).asRecurrenceRule; } /** * Constructs a daily recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param occurrenceCount - Number of times the rule should repeat before it ends */ static dailyOccurrenceCount(interval, occurrenceCount) { return new MockRecurrenceRule({ interval, occurrenceCount }).asRecurrenceRule; } /** * Constructs a weekly recurrence rule * @param interval - Interval at which to repeat the rule */ static weekly(interval) { return new MockRecurrenceRule({ interval }).asRecurrenceRule; } /** * Constructs a weekly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param endDate - Date at which the recurrence rule should end */ static weeklyEndDate(interval, endDate) { return new MockRecurrenceRule({ interval, endDate }).asRecurrenceRule; } /** * Constructs a weekly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param occurrenceCount - Number of times the rule should repeat before it ends */ static weeklyOccurrenceCount(interval, occurrenceCount) { return new MockRecurrenceRule({ interval, occurrenceCount }).asRecurrenceRule; } /** * Constructs a monthly recurrence rule * @param interval - Interval at which to repeat the rule */ static monthly(interval) { return new MockRecurrenceRule({ interval }).asRecurrenceRule; } /** * Constructs a monthly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param endDate - Date at which the recurrence rule should end */ static monthlyEndDate(interval, endDate) { return new MockRecurrenceRule({ interval, endDate }).asRecurrenceRule; } /** * Constructs a monthly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param occurrenceCount - Number of times the rule should repeat before it ends */ static monthlyOccurrenceCount(interval, occurrenceCount) { return new MockRecurrenceRule({ interval, occurrenceCount }).asRecurrenceRule; } /** * Constructs a yearly recurrence rule * @param interval - Interval at which to repeat the rule */ static yearly(interval) { return new MockRecurrenceRule({ interval }).asRecurrenceRule; } /** * Constructs a yearly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param endDate - Date at which the recurrence rule should end */ static yearlyEndDate(interval, endDate) { return new MockRecurrenceRule({ interval, endDate }).asRecurrenceRule; } /** * Constructs a yearly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param occurrenceCount - Number of times the rule should repeat before it ends */ static yearlyOccurrenceCount(interval, occurrenceCount) { return new MockRecurrenceRule({ interval, occurrenceCount }).asRecurrenceRule; } /** * Constructs a complex weekly recurrence rule * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param setPositions - Filters which recurrences to include in the rule's frequency */ static complexWeekly(interval, daysOfTheWeek, setPositions) { return new MockRecurrenceRule({ interval, daysOfTheWeek, setPositions }).asRecurrenceRule; } /** * Constructs a complex weekly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param endDate - Date at which the recurrence rule should end */ static complexWeeklyEndDate(interval, daysOfTheWeek, setPositions, endDate) { return new MockRecurrenceRule({ interval, daysOfTheWeek, setPositions, endDate }).asRecurrenceRule; } /** * Constructs a complex weekly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param occurrenceCount - Number of times the rule should repeat before it ends */ static complexWeeklyOccurrenceCount(interval, daysOfTheWeek, setPositions, occurrenceCount) { return new MockRecurrenceRule({ interval, daysOfTheWeek, setPositions, occurrenceCount }).asRecurrenceRule; } /** * Constructs a complex monthly recurrence rule * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param daysOfTheMonth - Days of the month to repeat the rule. Values range from 1 to 31 and from -1 to -31 * @param setPositions - Filters which recurrences to include in the rule's frequency */ static complexMonthly(interval, daysOfTheWeek, daysOfTheMonth, setPositions) { return new MockRecurrenceRule({ interval, daysOfTheWeek, daysOfTheMonth, setPositions }).asRecurrenceRule; } /** * Constructs a complex monthly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param daysOfTheMonth - Days of the month to repeat the rule. Values range from 1 to 31 and from -1 to -31 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param endDate - Date at which the recurrence rule should end */ static complexMonthlyEndDate(interval, daysOfTheWeek, daysOfTheMonth, setPositions, endDate) { return new MockRecurrenceRule({ interval, daysOfTheWeek, daysOfTheMonth, setPositions, endDate }).asRecurrenceRule; } /** * Constructs a complex monthly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param daysOfTheMonth - Days of the month to repeat the rule. Values range from 1 to 31 and from -1 to -31 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param occurrenceCount - Number of times the rule should repeat before it ends */ static complexMonthlyOccurrenceCount(interval, daysOfTheWeek, daysOfTheMonth, setPositions, occurrenceCount) { return new MockRecurrenceRule({ interval, daysOfTheWeek, daysOfTheMonth, setPositions, occurrenceCount }).asRecurrenceRule; } /** * Constructs a complex yearly recurrence rule * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param monthsOfTheYear - Months of the year to repeat the rule. Values range from 1 to 12 * @param weeksOfTheYear - Weeks of the year to repeat the rule. Values range from 1 to 53 and from -1 to -53 * @param daysOfTheYear - Days of the year to repeat the rule. Values range from 1 to 366 and from -1 to -366 * @param setPositions - Filters which recurrences to include in the rule's frequency */ static complexYearly(interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions) { return new MockRecurrenceRule({ interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions }).asRecurrenceRule; } /** * Constructs a complex yearly recurrence rule with an end date * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param monthsOfTheYear - Months of the year to repeat the rule. Values range from 1 to 12 * @param weeksOfTheYear - Weeks of the year to repeat the rule. Values range from 1 to 53 and from -1 to -53 * @param daysOfTheYear - Days of the year to repeat the rule. Values range from 1 to 366 and from -1 to -366 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param endDate - Date at which the recurrence rule should end */ static complexYearlyEndDate(interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions, endDate) { return new MockRecurrenceRule({ interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions, endDate }).asRecurrenceRule; } /** * Constructs a complex yearly recurrence rule with an occurrence count * @param interval - Interval at which to repeat the rule * @param daysOfTheWeek - Days of the week to repeat the rule. Values range from 1 to 7, with Sunday being 1 * @param monthsOfTheYear - Months of the year to repeat the rule. Values range from 1 to 12 * @param weeksOfTheYear - Weeks of the year to repeat the rule. Values range from 1 to 53 and from -1 to -53 * @param daysOfTheYear - Days of the year to repeat the rule. Values range from 1 to 366 and from -1 to -366 * @param setPositions - Filters which recurrences to include in the rule's frequency * @param occurrenceCount - Number of times the rule should repeat before it ends */ static complexYearlyOccurrenceCount(interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions, occurrenceCount) { return new MockRecurrenceRule({ interval, daysOfTheWeek, monthsOfTheYear, weeksOfTheYear, daysOfTheYear, setPositions, occurrenceCount }).asRecurrenceRule; } } export { MockRecurrenceRule }; //# sourceMappingURL=recurrence-rule.js.map