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

Function processRows

apps/sim/lib/webhooks/polling/google-sheets.ts:391–473  ·  view source on GitHub ↗
(
  rows: string[][],
  headers: string[],
  startRowIndex: number,
  spreadsheetId: string,
  sheetName: string,
  webhookData: PollWebhookContext['webhookData'],
  workflowData: PollWebhookContext['workflowData'],
  requestId: string,
  logger: Logger
)

Source from the content-addressed store, hash-verified

389}
390
391async function processRows(
392 rows: string[][],
393 headers: string[],
394 startRowIndex: number,
395 spreadsheetId: string,
396 sheetName: string,
397 webhookData: PollWebhookContext['webhookData'],
398 workflowData: PollWebhookContext['workflowData'],
399 requestId: string,
400 logger: Logger
401): Promise<{ processedCount: number; failedCount: number }> {
402 let processedCount = 0
403 let failedCount = 0
404
405 for (let i = 0; i < rows.length; i++) {
406 const row = rows[i]
407 const rowNumber = startRowIndex + i
408
409 // Skip empty rows — don't fire a workflow run with no data.
410 if (!row || row.length === 0) {
411 logger.info(`[${requestId}] Skipping empty row ${rowNumber} for webhook ${webhookData.id}`)
412 continue
413 }
414
415 try {
416 await pollingIdempotency.executeWithIdempotency(
417 'google-sheets',
418 `${webhookData.id}:${spreadsheetId}:${sheetName}:row${rowNumber}`,
419 async () => {
420 let mappedRow: Record<string, string> | null = null
421 if (headers.length > 0) {
422 mappedRow = {}
423 for (let j = 0; j < headers.length; j++) {
424 mappedRow[headers[j] || `Column ${j + 1}`] = row[j] ?? ''
425 }
426 for (let j = headers.length; j < row.length; j++) {
427 mappedRow[`Column ${j + 1}`] = row[j] ?? ''
428 }
429 }
430
431 const payload: GoogleSheetsWebhookPayload = {
432 row: mappedRow,
433 rawRow: row,
434 headers,
435 rowNumber,
436 spreadsheetId,
437 sheetName,
438 timestamp: new Date().toISOString(),
439 }
440
441 const result = await processPolledWebhookEvent(
442 webhookData,
443 workflowData,
444 payload,
445 requestId
446 )
447
448 if (!result.success) {

Callers 1

pollWebhookFunction · 0.85

Calls 5

getErrorMessageFunction · 0.90
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected