Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for all airtable field types #234

Merged
merged 9 commits into from
Dec 10, 2024

Conversation

shekharnwagh
Copy link
Contributor

@shekharnwagh shekharnwagh commented Dec 6, 2024

Description

Note

JIRA: CAFE-1068

  • Support for string arrays: Added handling when array values are received for string type where it concatenates them with comma delimiter and thus returning string values.

  • Renaming price to currency: The price field has been renamed to currency and adds support for a new field in mapping options prefix which allows for displaying the currency symbol or prefix.

  • Currency Prefix/Symbol Support: Added support for currency prefixes or symbols, enhancing the display options for monetary values.

  • Comprehensive Airtable Type Support: Added support for all the Airtable fields documented here: https://airtable.com/developers/web/api/field-model. The Airtables types are mapped to plugin's output mapping types using the following mapping:

    Airtable Field Type Mapped Type Special Handling Notes
    singleLineText string Direct string conversion
    multilineText string Direct string conversion
    email string Direct string conversion
    phoneNumber string Direct string conversion
    richText string Direct string conversion
    barcode string Direct string conversion
    singleSelect string Direct string conversion
    date string Direct string conversion
    dateTime string Direct string conversion
    lastModifiedTime string Direct string conversion
    createdTime string Direct string conversion
    multipleSelects string_array Array of strings joined with commas
    multipleRecordLinks string_array Array of record IDs using [*].id
    rollup string Direct string conversion
    externalSyncSource string Direct string conversion
    number number Cast to float
    autoNumber number Cast to float
    rating number Cast to float
    duration number Cast to float
    count number Cast to float
    percent number Cast to float
    createdBy string Extracts user's name using .name
    lastModifiedBy string Extracts user's name using .name
    singleCollaborator string Extracts user's name using .name
    multipleCollaborator string_array Array of user names using [*].name
    url button_url Direct string conversion
    button button_url Direct string conversion
    currency currency Uses field's currency symbol as prefix
    checkbox boolean Cast to boolean
    multipleAttachments image_url Takes first attachment's URL using [0].url
    formula string Uses result type if available, else string
    lookup string Uses result type if available, else string

Testing

To test these changes:

  1. Start the local development server using instructions given here
  2. Open the WP-Admin and go to Settings > Remote Data Blocks and add new Airtable data source
  3. Verify that all the fields are supported and the output is as expected.
  4. Try testing by adding various types of fields and verify that Airtable fields are mapped to the correct types.

…ndling

- Updated the path generation for output query mappings to use bracket notation for keys, ensuring compatibility with keys that may contain special characters.
- Introduced a variable for the mapping key to enhance code readability.
- Automatically assign output mapping types to airtable fields
- Improved field mapping logic to filter unsupported fields and handle selected table fields more effectively.
@shekharnwagh shekharnwagh self-assigned this Dec 6, 2024
- Implemented handling for 'string_array' field type, allowing for the conversion of array values into a comma-separated string format.
…ice' and add 'string_array' support

- Changed field type from 'price' to 'currency' in multiple queries and configurations to standardize currency handling.
- Updated the QueryRunner to accept a mapping array for field values, enhancing flexibility in field type management.
- Added 'string_array' to the list of supported text field types, allowing for better data handling in queries.
- Adjusted documentation to reflect these changes.
@shekharnwagh shekharnwagh requested review from maxschmeling, brookewp, chriszarate and alecgeatches and removed request for maxschmeling December 6, 2024 21:36
@shekharnwagh shekharnwagh marked this pull request as ready for review December 6, 2024 21:36
Comment on lines 261 to 262
case 'string_array':
return implode( ', ', $field_value );
Copy link
Contributor Author

@shekharnwagh shekharnwagh Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if this should be a separate type - string_array or would it be better if we keep the type as string and if it finds an array, it should just join them using comma. The only reason I can think against keeping the type as string is if for some reason we want to expose the raw array to the block. However, I can't think of why we'd want to do that top of my mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the latter is preferred. The value is a string. It's just our way of automatically mapping the array from the source. But once we join them, it's just a string and that's what it should be on our side. If you write your own config, you can use a different type and conversion.

@maxschmeling
Copy link
Contributor

Other than the small string array change you mentioned, this looks really good.

@shekharnwagh shekharnwagh merged commit 78e3755 into trunk Dec 10, 2024
11 checks passed
@shekharnwagh shekharnwagh deleted the update/airtable-field-selection branch December 10, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants