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

Function recordToDocument

apps/sim/connectors/airtable/airtable.ts:262–287  ·  view source on GitHub ↗

* Converts an Airtable record to an ExternalDocument.

(
  record: AirtableRecord,
  baseId: string,
  tableIdOrName: string,
  titleField: string | undefined,
  fieldNames: Map<string, string>
)

Source from the content-addressed store, hash-verified

260 * Converts an Airtable record to an ExternalDocument.
261 */
262async function recordToDocument(
263 record: AirtableRecord,
264 baseId: string,
265 tableIdOrName: string,
266 titleField: string | undefined,
267 fieldNames: Map<string, string>
268): Promise<ExternalDocument> {
269 const plainText = recordToPlainText(record.fields, fieldNames)
270 const contentHash = await computeContentHash(plainText)
271 const title = extractTitle(record.fields, titleField)
272
273 const encodedTable = encodeURIComponent(tableIdOrName)
274 const sourceUrl = `https://airtable.com/${baseId}/${encodedTable}/${record.id}`
275
276 return {
277 externalId: record.id,
278 title,
279 content: plainText,
280 mimeType: 'text/plain',
281 sourceUrl,
282 contentHash,
283 metadata: {
284 createdTime: record.createdTime,
285 },
286 }
287}
288
289/**
290 * Fetches the table schema to build a field ID → field name mapping.

Callers 1

airtable.tsFile · 0.70

Calls 3

computeContentHashFunction · 0.90
recordToPlainTextFunction · 0.85
extractTitleFunction · 0.70

Tested by

no test coverage detected