MCPcopy Index your code
hub / github.com/simstudioai/sim / normalizeExcelValues

Function normalizeExcelValues

apps/sim/tools/onedrive/utils.ts:12–39  ·  view source on GitHub ↗
(values: unknown)

Source from the content-addressed store, hash-verified

10 * Accepts JSON strings, array-of-arrays, or array-of-objects and normalizes them.
11 */
12export function normalizeExcelValues(values: unknown): NormalizedExcelValues | undefined {
13 if (values === null || values === undefined) {
14 return undefined
15 }
16
17 if (typeof values === 'string') {
18 const trimmed = values.trim()
19 if (!trimmed) {
20 return undefined
21 }
22
23 try {
24 const parsed = JSON.parse(trimmed)
25 if (!Array.isArray(parsed)) {
26 throw new Error('Excel values must be an array of rows or array of objects')
27 }
28 return parsed as NormalizedExcelValues
29 } catch (_error) {
30 throw new Error('Invalid JSON format for values')
31 }
32 }
33
34 if (Array.isArray(values)) {
35 return values as NormalizedExcelValues
36 }
37
38 throw new Error('Excel values must be an array of rows or array of objects')
39}
40
41/**
42 * Convenience helper for contexts that expect the narrower ToolParams typing.

Callers 2

route.tsFile · 0.90

Calls 1

parseMethod · 0.80

Tested by

no test coverage detected