{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "airtable-query-records", "type": "registry:item", "description": "Query records from Airtable with filtering", "dependencies": [], "files": [ { "path": "steps/airtable-query-records.ts", "content": "/**\n * Query records from Airtable with filtering\n *\n * @param baseId - The Airtable base ID\n * @param tableId - The table name or ID\n * @param filterByFormula - Optional Airtable formula for filtering\n * @param maxRecords - Maximum number of records to return\n * @returns Array of matching records\n *\n * @env AIRTABLE_API_KEY - Airtable personal access token\n */\n\nimport { FatalError } from \"workflow\"\n\ninterface QueryRecordsOptions {\n baseId: string\n tableId: string\n filterByFormula?: string\n maxRecords?: number\n}\n\nexport async function airtableQueryRecords({\n baseId,\n tableId,\n filterByFormula,\n maxRecords = 100,\n}: QueryRecordsOptions) {\n \"use step\"\n\n const apiKey = process.env.AIRTABLE_API_KEY\n if (!apiKey) {\n throw new FatalError(\"AIRTABLE_API_KEY environment variable is required\")\n }\n\n if (!baseId || !tableId) {\n throw new FatalError(\"baseId and tableId are required\")\n }\n\n const params = new URLSearchParams()\n if (filterByFormula) params.append(\"filterByFormula\", filterByFormula)\n params.append(\"maxRecords\", maxRecords.toString())\n\n const url = `https://api.airtable.com/v0/${baseId}/${encodeURIComponent(tableId)}?${params}`\n\n const response = await fetch(url, {\n headers: {\n Authorization: `Bearer ${apiKey}`,\n },\n })\n\n if (!response.ok) {\n const error = await response.text()\n throw new Error(`Failed to query Airtable records: ${error}`)\n }\n\n const data = await response.json()\n return {\n records: data.records.map((record: any) => ({\n id: record.id,\n fields: record.fields,\n createdTime: record.createdTime,\n })),\n }\n}\n", "type": "registry:file", "target": "steps/airtable-query-records.ts" } ] }