forked from GitHubMirrors/silverbullet-icalendar
1.9 KiB
1.9 KiB
Specification: Generic RRULE Object Formatter
Overview
The current implementation for converting RRULE objects (from ts-ics) back to strings is brittle and fails when encountering nested objects or arrays for properties like BYDAY. This results in [object Object] being injected into the RRULE string, causing syntax errors in the rrule library. This track replaces the specific property handling with a robust, recursive generic formatter.
Functional Requirements
- Recursive Value Formatting: The
formatRRuleValuefunction must handle nested structures:- Arrays: Join elements with commas (e.g.,
['MO', 'TU']->MO,TU). - Date Objects: Format as
YYYYMMDDTHHMMSSZ. - Nested Property Objects: If an object has a
date,day, orvalueproperty, extract and format that value (e.g.,{ day: 'MO' }->MO). - Recursion: If an array contains objects, or an object contains an array, the logic must recurse until primitives are reached.
- Arrays: Join elements with commas (e.g.,
- iCalendar Compliance: Ensure the resulting string for every property matches the iCalendar spec format expected by
rrule.js.
Implementation Steps
- Reproduce: Create a test case in
icalendar_test.tswhereBYDAYis an object or an array of objects. Verify it fails withInvalid weekday string: [object Object]. - Fix: Re-implement
formatRRuleValueinicalendar.tsas a recursive function that handles Arrays, Dates, and standardts-icsnested value objects. - Verify:
- Confirm the
BYDAYreproduction test passes. - Add a composite test with
UNTIL(Date) andBYDAY(Array) together. - Run regression tests to ensure standard string RRULEs still work.
- Confirm the
Acceptance Criteria
expandRecurrencescorrectly handlesBYDAYwhen provided as an array of objects.expandRecurrencescorrectly handlesUNTILwhen provided as a nested date object.- All 12+ existing tests pass, including regression checks for string-based RRULEs.