* Parse a JSON input string into object payload. * @param {unknown} value * @returns {Record |null}
(value)
| 91 | * @returns {Record<string, any>|null} |
| 92 | */ |
| 93 | function parseJSONPayload(value) { |
| 94 | if (typeof value !== "string" || value.trim() === "") { |
| 95 | return null; |
| 96 | } |
| 97 | |
| 98 | try { |
| 99 | const parsed = JSON.parse(value); |
| 100 | if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) { |
| 101 | return /** @type {Record<string, any>} */ parsed; |
| 102 | } |
| 103 | } catch (_error) { |
| 104 | // Best-effort parsing only. |
| 105 | } |
| 106 | |
| 107 | return null; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Build a minimal event payload from aw_context metadata for centralized slash-command dispatches. |
no test coverage detected