(text: string, label: string)
| 353 | } |
| 354 | |
| 355 | function parseJsonObject(text: string, label: string): Record<string, unknown> { |
| 356 | let raw: unknown; |
| 357 | try { |
| 358 | raw = JSON.parse(text); |
| 359 | } catch (err) { |
| 360 | throw ErrInvalidStore(`invalid JSON: ${(err as Error).message}`); |
| 361 | } |
| 362 | if (raw === null || typeof raw !== "object" || Array.isArray(raw)) { |
| 363 | throw ErrInvalidStore(`${label} must be a JSON object`); |
| 364 | } |
| 365 | return raw as Record<string, unknown>; |
| 366 | } |
| 367 | |
| 368 | function pickNonEmptyString(obj: Record<string, unknown>, key: string): string | undefined { |
| 369 | const v = obj[key]; |
no test coverage detected