* Parses an optional ISO 8601 date filter from a named source-config field. * Returns a normalized ISO 8601 string when the value is a valid date; otherwise * returns undefined so the request is not scoped to an invalid date.
(sourceConfig: Record<string, unknown>, key: string)
| 130 | * returns undefined so the request is not scoped to an invalid date. |
| 131 | */ |
| 132 | function parseDateFilter(sourceConfig: Record<string, unknown>, key: string): string | undefined { |
| 133 | const raw = sourceConfig[key] |
| 134 | if (typeof raw !== 'string') return undefined |
| 135 | const trimmed = raw.trim() |
| 136 | if (!trimmed) return undefined |
| 137 | const parsed = new Date(trimmed) |
| 138 | return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString() |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Detects whether a string contains HTML markup. Granola returns markdown for |