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

Function normalizeAnswers

apps/sim/tools/google_forms/get_responses.ts:116–135  ·  view source on GitHub ↗
(answers: unknown)

Source from the content-addressed store, hash-verified

114 }
115
116 const normalizeAnswers = (answers: unknown): Record<string, unknown> => {
117 if (!answers || typeof answers !== 'object') return {}
118 const src = answers as Record<string, unknown>
119 const out: Record<string, unknown> = {}
120 for (const [questionId, answerObj] of Object.entries(src)) {
121 if (answerObj && typeof answerObj === 'object') {
122 const aRec = answerObj as Record<string, unknown>
123 // Find first *Answers property that contains an answers array
124 const key = Object.keys(aRec).find(
125 (k) => k.toLowerCase().endsWith('answers') && Array.isArray((aRec[k] as any)?.answers)
126 )
127 if (key) {
128 out[questionId] = normalizeAnswerContainer(aRec[key])
129 continue
130 }
131 }
132 out[questionId] = answerObj as unknown
133 }
134 return out
135 }
136
137 const normalizeResponse = (r: GoogleFormsResponse): Record<string, unknown> => ({
138 responseId: r.responseId,

Callers 1

normalizeResponseFunction · 0.70

Calls 1

normalizeAnswerContainerFunction · 0.85

Tested by

no test coverage detected