| 1 | /** |
| 2 | * Coerce a distilled Location `TagMap` (`{ [key]: string | undefined }`) into a |
| 3 | * plain `Record<string, string>`, dropping any undefined values. Amazon |
| 4 | * Location returns tags directly on every `Describe*` response, so this is the |
| 5 | * single normalization used to feed `diffTags`/`hasAlchemyTags`. |
| 6 | */ |
| 7 | export const toTagRecord = ( |
| 8 | tags: { [key: string]: string | undefined } | undefined, |
| 9 | ): Record<string, string> => |
| 10 | Object.fromEntries( |
| 11 | Object.entries(tags ?? {}).filter( |
| 12 | (entry): entry is [string, string] => typeof entry[1] === "string", |
| 13 | ), |
| 14 | ); |