(structured: unknown)
| 257 | } |
| 258 | |
| 259 | export const extractPausedInteraction = (structured: unknown): PausedInteraction | undefined => { |
| 260 | if (!isRecord(structured) || !isRecord(structured.interaction)) { |
| 261 | return undefined; |
| 262 | } |
| 263 | |
| 264 | const interaction = structured.interaction; |
| 265 | if ( |
| 266 | (interaction.kind !== "url" && interaction.kind !== "form") || |
| 267 | typeof interaction.message !== "string" |
| 268 | ) { |
| 269 | return undefined; |
| 270 | } |
| 271 | |
| 272 | const base: PausedInteraction = { |
| 273 | kind: interaction.kind, |
| 274 | message: interaction.message, |
| 275 | }; |
| 276 | |
| 277 | if (interaction.kind === "url" && typeof interaction.url === "string") { |
| 278 | return { ...base, url: interaction.url }; |
| 279 | } |
| 280 | |
| 281 | if (interaction.kind === "form" && isRecord(interaction.requestedSchema)) { |
| 282 | return { ...base, requestedSchema: interaction.requestedSchema }; |
| 283 | } |
| 284 | |
| 285 | return base; |
| 286 | }; |
| 287 | |
| 288 | const schemaExample = (schema: unknown, depth = 0): unknown => { |
| 289 | if (!isRecord(schema) || depth > 4) return {}; |
no test coverage detected