Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion plugins/airtable/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const PLUGIN_KEYS = {
} as const

const IMAGE_FILE_MIME_TYPES = ["image/jpeg", "image/png", "image/gif", "image/apng", "image/webp", "image/svg+xml"]
const PRESERVE_LOOKUP_ARRAY_TYPES = ["image", "file", "array"]

export interface AirtableBase {
id: string
Expand Down Expand Up @@ -88,7 +89,10 @@ export function getFieldDataEntryForFieldSchema(
value: unknown
): FieldDataEntryInput | null {
// If the field is a lookup field, only use the first value from the array.
if (fieldSchema.originalAirtableType === "multipleLookupValues") {
if (
fieldSchema.originalAirtableType === "multipleLookupValues" &&
!PRESERVE_LOOKUP_ARRAY_TYPES.includes(fieldSchema.type)
) {
if (!Array.isArray(value)) return null
if (value.length === 0) return null
value = value[0]
Expand All @@ -104,6 +108,10 @@ export function getFieldDataEntryForFieldSchema(
case "link":
case "image":
case "file": {
if (Array.isArray(value) && typeof value[0] === "string") {
value = value[0]
}

if (typeof value === "string") {
if (fieldSchema.airtableType === "email" || EMAIL_REGEX.test(value)) {
return {
Expand Down
Loading