| 1 | import type * as chatbot from "@distilled.cloud/aws/chatbot"; |
| 2 | |
| 3 | /** |
| 4 | * Convert a plain tag map to the Chatbot wire `Tag` list |
| 5 | * (`{ TagKey, TagValue }`). |
| 6 | */ |
| 7 | export const toChatbotTags = (tags: Record<string, string>): chatbot.Tag[] => |
| 8 | Object.entries(tags).map(([TagKey, TagValue]) => ({ TagKey, TagValue })); |
| 9 | |
| 10 | /** |
| 11 | * Convert an observed Chatbot wire `Tag` list to a plain tag map. |
| 12 | */ |
| 13 | export const fromChatbotTags = ( |
| 14 | tags: readonly chatbot.Tag[] | undefined, |
| 15 | ): Record<string, string> => |
| 16 | Object.fromEntries((tags ?? []).map((t) => [t.TagKey, t.TagValue])); |