* Parses the optional `maxNotes` cap from source config. * Returns 0 (unlimited) when unset or invalid.
(sourceConfig: Record<string, unknown>)
| 105 | * Returns 0 (unlimited) when unset or invalid. |
| 106 | */ |
| 107 | function parseMaxNotes(sourceConfig: Record<string, unknown>): number { |
| 108 | const raw = sourceConfig.maxNotes |
| 109 | if (raw == null || raw === '') return 0 |
| 110 | const num = Number(raw) |
| 111 | return Number.isFinite(num) && num > 0 ? Math.floor(num) : 0 |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Parses the optional `folderId` scope from source config. Returns a trimmed |