(row: Record<string, unknown>, key: string, index: number)
| 121 | } |
| 122 | |
| 123 | function placeholderValue(row: Record<string, unknown>, key: string, index: number): string { |
| 124 | if (key === "index") return String(index); |
| 125 | if (!Object.hasOwn(row, key)) { |
| 126 | throw new BatchRenderInputError( |
| 127 | "Invalid output template", |
| 128 | `Missing value for placeholder {${key}} in row ${index}.`, |
| 129 | ); |
| 130 | } |
| 131 | |
| 132 | const value = row[key]; |
| 133 | if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { |
| 134 | return String(value); |
| 135 | } |
| 136 | |
| 137 | throw new BatchRenderInputError( |
| 138 | "Invalid output template", |
| 139 | `Placeholder {${key}} in row ${index} must resolve to a string, number, or boolean.`, |
| 140 | ); |
| 141 | } |
| 142 | |
| 143 | export function resolveOutputTemplate( |
| 144 | template: string, |
no outgoing calls
no test coverage detected