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

Function recordToPlainText

apps/sim/connectors/airtable/airtable.ts:17–42  ·  view source on GitHub ↗

* Flattens a record's fields into a plain-text representation. * Each field is rendered as "Field Name: value" on its own line.

(
  fields: Record<string, unknown>,
  fieldNames?: Map<string, string>
)

Source from the content-addressed store, hash-verified

15 * Each field is rendered as "Field Name: value" on its own line.
16 */
17function recordToPlainText(
18 fields: Record<string, unknown>,
19 fieldNames?: Map<string, string>
20): string {
21 const lines: string[] = []
22 for (const [key, value] of Object.entries(fields)) {
23 if (value == null) continue
24 const displayName = fieldNames?.get(key) ?? key
25 if (Array.isArray(value)) {
26 // Attachments or linked records
27 const items = value.map((v) => {
28 if (typeof v === 'object' && v !== null) {
29 const obj = v as Record<string, unknown>
30 return (obj.url as string) || (obj.name as string) || JSON.stringify(v)
31 }
32 return String(v)
33 })
34 lines.push(`${displayName}: ${items.join(', ')}`)
35 } else if (typeof value === 'object') {
36 lines.push(`${displayName}: ${JSON.stringify(value)}`)
37 } else {
38 lines.push(`${displayName}: ${String(value)}`)
39 }
40 }
41 return lines.join('\n')
42}
43
44/**
45 * Extracts a human-readable title from a record's fields.

Callers 1

recordToDocumentFunction · 0.85

Calls 3

joinMethod · 0.80
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected