* Parses the optional `folderId` scope from source config. Returns a trimmed * folder id only when it matches Granola's `fol_…` identifier shape; otherwise * returns undefined so the request is not scoped to an invalid folder.
(sourceConfig: Record<string, unknown>)
| 117 | * returns undefined so the request is not scoped to an invalid folder. |
| 118 | */ |
| 119 | function parseFolderId(sourceConfig: Record<string, unknown>): string | undefined { |
| 120 | const raw = sourceConfig.folderId |
| 121 | if (typeof raw !== 'string') return undefined |
| 122 | const trimmed = raw.trim() |
| 123 | if (!trimmed) return undefined |
| 124 | return FOLDER_ID_PATTERN.test(trimmed) ? trimmed : undefined |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Parses an optional ISO 8601 date filter from a named source-config field. |