Conversation
WalkthroughThe changes introduce the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
41be670 to
ddb4044
Compare
There was a problem hiding this comment.
Caution
Inline review comments failed to post
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (12)
convert/what3words/rollup.config.mjs (1)
1-5: Overall, the Rollup configuration looks good.The file structure is correct and follows best practices for Rollup configuration files. It uses a custom configuration builder from '@flatfile/rollup-config', which suggests consistency with other Flatfile plugins.
To improve maintainability:
Consider adding a comment explaining the purpose of this configuration file and any specific requirements for the what3words plugin. This will help future developers understand the rationale behind using the default configuration or add custom options if needed.
Example:
// Rollup configuration for the what3words plugin // Uses default configuration from @flatfile/rollup-config // Add custom options here if specific build requirements arise for the what3words pluginconvert/what3words/CHANGELOG.md (1)
3-3: Consider adding version numbers in parentheses for consistency.For better readability and consistency, consider adding the version number in parentheses for version 0.2.0, similar to how it's done for the initial release.
Here's a suggested change for line 3:
-## 0.2.0 +## 0.2.0 (Latest Release)This change would make the format consistent with the initial release entry and provide additional clarity about the latest version.
Also applies to: 10-10
convert/what3words/README.md (3)
10-28: Adjust heading levels for consistency.The parameters section provides clear and detailed information about each configuration option. However, the heading levels are inconsistent. Consider changing the parameter headings from h4 (####) to h3 (###) for better document structure.
Example fix for the first parameter:
-#### `config.what3wordsField` - `string` +### `config.what3wordsField` - `string`Apply this change to all parameter headings in this section.
🧰 Tools
🪛 Markdownlint
12-12: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
30-46: Replace emphasis with proper headings for subsections.The usage section provides valuable information about environment variables, installation, and import. To improve the document structure and readability, consider replacing the emphasized text with proper headings for each subsection.
Example fix:
-**Environment Variables** +### Environment Variables -**Install** +### Install -**Import** +### ImportThis change will create a clearer hierarchy in the document and improve navigation.
🧰 Tools
🪛 Markdownlint
32-32: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
38-38: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
43-43: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
48-60: Replace emphasis with a proper heading for the Listener.js section.The Listener.js example effectively demonstrates how to configure and use the plugin. To improve the document structure, consider replacing the emphasized text with a proper heading.
Example fix:
-**Listener.js** +### Listener.jsThis change will maintain consistency with the document structure and improve navigation.
🧰 Tools
🪛 Markdownlint
48-48: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
convert/what3words/src/what3words.plugin.spec.ts (5)
17-24: LGTM: Well-structured configuration objectThe configuration object is well-defined and includes all necessary fields for the what3words converter. This approach allows for easy customization of field names.
Consider extracting the
'test-api-key'into a constant at the top of the file for better maintainability:const TEST_API_KEY = 'test-api-key'; // Then in the config object: apiKey: TEST_API_KEY,
26-51: LGTM: Comprehensive test for valid What3Words address conversionThis test case thoroughly covers the happy path scenario for converting a valid What3Words address. It correctly mocks the API response and verifies that the record is updated with all expected fields.
Consider adding assertions to verify that the
What3WordsApiconstructor is called with the correct API key:expect(mockWhat3WordsApi).toHaveBeenCalledWith({ apiKey: 'test-api-key' });This ensures that the API is initialized correctly with the provided configuration.
53-68: LGTM: Good error handling test for invalid What3Words addressThis test case effectively verifies the behavior when an invalid What3Words address is provided. It correctly mocks the API error and checks that the record fields remain undefined while an error message is added to the record.
To make the error checking more robust, consider asserting the exact number of errors:
expect(record.getErrors('w3w')).toHaveLength(1);This ensures that only one error is added for the invalid address and prevents potential issues with multiple errors being added unintentionally.
70-81: LGTM: Good edge case handling for empty What3Words fieldThis test case effectively verifies the behavior when the What3Words field is empty. It correctly checks that the API is not called and that all fields remain undefined.
Consider adding an assertion to verify that no errors are added to the record in this case:
expect(record.getErrors()).toHaveLength(0);This ensures that the converter doesn't add any unnecessary errors when the input field is empty.
1-81: Overall: Excellent test coverage with minor improvement suggestionsThe test suite for the what3words converter is well-structured and comprehensive. It covers the main scenarios (valid conversion, invalid input, and empty input) and uses proper mocking and assertions. The tests follow good practices and provide solid coverage of the converter's functionality.
To further enhance the test suite, consider adding the following test cases:
- Test with partial configuration (e.g., missing some optional fields) to ensure the converter handles different configuration scenarios correctly.
- Test with multiple records to verify that the converter can handle batch processing if applicable.
- Test edge cases for the What3Words format (e.g., mixed case, leading/trailing spaces) to ensure robust input handling.
Example for testing with partial configuration:
it('should work with partial configuration', async () => { const partialConfig = { apiKey: 'test-api-key', what3wordsField: 'w3w', latField: 'lat', longField: 'long' }; const record = new FlatfileRecord({ w3w: 'filled.count.soap' }); const converter = what3wordsConverter(partialConfig); await converter(record); expect(record.get('lat')).toBeDefined(); expect(record.get('long')).toBeDefined(); expect(record.get('country')).toBeUndefined(); expect(record.get('nearestPlace')).toBeUndefined(); });These additional test cases will help ensure the robustness and flexibility of the what3words converter.
convert/what3words/src/index.ts (2)
38-38: Replace console logging with a structured logging approachUsing
console.errorandconsole.logfor error handling and debugging is not recommended in production code as it can lead to unstructured logs and potential performance issues. Consider using a structured logging library or framework that integrates with your application's logging strategy.Apply this diff to remove or replace console statements:
// In getSecret function } catch (e) { - console.error(e, `Error fetching secret ${name}`) + // Handle the error appropriately, e.g., log using a logging library return undefined } // Inside the records loop try { const result = await w3wService.convertToCoordinates({ words }) - console.log({ result }) record.set(config.countryField, result.country) // ... } catch (error) { - console.log({ error }) record.addError( config.what3wordsField, 'Invalid What3Words address' ) }Also applies to: 67-67, 73-73
86-86: Ensure consistent export styleCurrently, the
convertWhat3wordsfunction is exported both as a named export and as the default export. This could lead to confusion when importing the module. Consider choosing one export style to maintain consistency.Apply this diff to export only the default or named export:
Option 1: Export only the default export
-export function convertWhat3words(config: What3WordsConfig) { +function convertWhat3words(config: What3WordsConfig) { // function implementation } -export default convertWhat3words +export default convertWhat3wordsOption 2: Export only the named export
export function convertWhat3words(config: What3WordsConfig) { // function implementation } -export default convertWhat3words
🛑 Comments failed to post (4)
convert/what3words/src/index.ts (4)
66-71:
⚠️ Potential issueAdd null checks for API response fields to prevent runtime errors
When setting the fields from the
resultofw3wService.convertToCoordinates, there is an implicit assumption thatresult.country,result.nearestPlace, andresult.coordinatesare defined. If the API response is missing any of these fields, it could result in runtime errors. Consider adding null or undefined checks before setting these fields.Apply this diff to add checks:
-record.set(config.countryField, result.country) -record.set(config.nearestPlaceField, result.nearestPlace) -record.set(config.latField, result.coordinates.lat) -record.set(config.longField, result.coordinates.lng) +if (result.country) { + record.set(config.countryField, result.country) +} +if (result.nearestPlace) { + record.set(config.nearestPlaceField, result.nearestPlace) +} +if (result.coordinates) { + record.set(config.latField, result.coordinates.lat) + record.set(config.longField, result.coordinates.lng) +} else { + record.addError(config.what3wordsField, 'Unable to retrieve coordinates from What3Words') +}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.const result = await w3wService.convertToCoordinates({ words }) console.log({ result }) if (result.country) { record.set(config.countryField, result.country) } if (result.nearestPlace) { record.set(config.nearestPlaceField, result.nearestPlace) } if (result.coordinates) { record.set(config.latField, result.coordinates.lat) record.set(config.longField, result.coordinates.lng) } else { record.addError(config.what3wordsField, 'Unable to retrieve coordinates from What3Words') }
56-61:
⚠️ Potential issueHandle missing What3Words API key to prevent runtime errors
The
apiKeyfetched bygetSecretmight beundefinedif the secret is not found or an error occurs. Initializing the What3Words service with an undefinedapiKeycould lead to runtime errors when making API calls. Please add a check to ensureapiKeyis defined before proceeding. If it is undefined, consider adding an error to all records or handling the error appropriately.Apply this diff to add the check:
const apiKey = await getSecret('W3W_API_KEY', environmentId, spaceId) +if (!apiKey) { + // Handle the missing API key, e.g., add an error to records or throw an exception + const errorMessage = 'What3Words API key is missing. Please set the W3W_API_KEY secret.' + console.error(errorMessage) + records.forEach(record => record.addError(config.what3wordsField, errorMessage)) + return +} const transport: Transport = fetchTransport()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.const apiKey = await getSecret('W3W_API_KEY', environmentId, spaceId) if (!apiKey) { // Handle the missing API key, e.g., add an error to records or throw an exception const errorMessage = 'What3Words API key is missing. Please set the W3W_API_KEY secret.' console.error(errorMessage) records.forEach(record => record.addError(config.what3wordsField, errorMessage)) return } const transport: Transport = fetchTransport() const w3wService: What3wordsService = what3words(apiKey, w3wConfig, { transport, })
62-81:
⚠️ Potential issueRemove the premature return statement inside the record processing loop
The
return recordstatement at line 80 is inside the loop iterating overrecords. This causes the function to exit after processing the first record, preventing the remaining records from being processed. To ensure all records are processed, remove thereturnstatement from inside the loop.Apply this diff to fix the issue:
} } - return record } + return records📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.for (const record of records) { const words = record.get(config.what3wordsField) as string if (words) { try { const result = await w3wService.convertToCoordinates({ words }) console.log({ result }) record.set(config.countryField, result.country) record.set(config.nearestPlaceField, result.nearestPlace) record.set(config.latField, result.coordinates.lat) record.set(config.longField, result.coordinates.lng) } catch (error) { console.log({ error }) record.addError( config.what3wordsField, 'Invalid What3Words address' ) } } } return records
25-41: 🛠️ Refactor suggestion
Improve error handling in
getSecretfunctionCurrently, if there's an error fetching the secret, the function logs the error and returns
undefined. It might be more appropriate to throw an error or propagate it to the caller to handle it accordingly, especially if the secret is critical for the plugin's operation.Consider modifying the function to throw an error:
async function getSecret( name: string, environmentId?: string, spaceId?: string ): Promise<string> { try { const secrets = await api.secrets.list({ spaceId, environmentId }) const secret = secrets.data.find((secret) => secret.name === name) if (!secret) { - return undefined + throw new Error(`Secret ${name} not found.`) } return secret.value } catch (e) { - console.error(e, `Error fetching secret ${name}`) - return undefined + throw new Error(`Error fetching secret ${name}: ${e.message}`) } }And update the caller to handle the error:
const apiKey = await getSecret('W3W_API_KEY', environmentId, spaceId) +// No need to check for undefined apiKey here since getSecret will throw an error if not found📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.async function getSecret( name: string, environmentId?: string, spaceId?: string ): Promise<string> { try { const secrets = await api.secrets.list({ spaceId, environmentId }) const secret = secrets.data.find((secret) => secret.name === name) if (!secret) { throw new Error(`Secret ${name} not found.`) } return secret.value } catch (e) { throw new Error(`Error fetching secret ${name}: ${e.message}`) } }
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (4)
convert/what3words/README.md (4)
1-8: Improve formatting for better readabilityThe infocard section provides valuable information about the plugin. To enhance readability, consider the following suggestions:
- Add a heading for the plugin name.
- Use Markdown formatting instead of HTML comments for the infocard section.
- Use bold text for "Event Type:" instead of wrapping it in double asterisks.
Here's an example of how it could look:
# @flatfile/plugin-convert-what3words ## Overview The `@flatfile/plugin-convert-what3words` plugin provides functionality to convert What3Words addresses to standard addresses and coordinates within Flatfile. It integrates with the official What3Words JavaScript API to perform the conversion and populate the user-specified fields with the results. **Event Type:** `listener.on('commit:created')`
10-28: Adjust heading levels for consistencyThe Parameters section provides clear explanations for each configuration option. However, the heading levels need adjustment to maintain proper hierarchy and address the Markdownlint warning (MD001). Here are the suggested changes:
- Change the "Parameters" heading to an h2 (##).
- Use h3 (###) for each parameter name instead of h4 (####).
- Consider adding a brief introduction to the Parameters section.
Example:
## Parameters The following parameters can be used to configure the plugin: ### `config.what3wordsField` - `string` The name of the field containing the What3Words address. ### `config.countryField` - `string` The name of the field where the country code will be stored. ... ### `config.sheetSlug` - `string` - `default: **` - (optional) The slug of the sheet to apply the converter to. If not provided, it will apply to all sheets with a `what3wordsField`.🧰 Tools
🪛 Markdownlint
12-12: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
30-60: Improve formatting in the Usage sectionThe Usage section provides valuable information on how to set up and use the plugin. To enhance readability and address the Markdownlint warnings (MD036), consider the following suggestions:
- Use proper heading levels instead of bold text for subsections.
- Add a brief introduction to the Usage section.
- Use consistent formatting for code blocks.
Here's an example of how it could look:
## Usage Follow these steps to set up and use the @flatfile/plugin-convert-what3words plugin: ### Environment Variables Add the following environment variable to your space: - `W3W_API_KEY` - Your What3Words API key ### Installation ```bash npm install @flatfile/plugin-convert-what3wordsImporting the Plugin
import { convertWhat3words } from '@flatfile/plugin-convert-what3words'Basic Configuration
Add the following to your Flatfile listener configuration:
listener.use( convertWhat3words({ sheetSlug: 'locations', what3wordsField: 'what3words', countryField: 'country', nearestPlaceField: 'nearestPlace', latField: 'latitude', longField: 'longitude' }) )<details> <summary>🧰 Tools</summary> <details> <summary>🪛 Markdownlint</summary><blockquote> 32-32: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 38-38: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 43-43: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 48-48: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) </blockquote></details> </details> --- `62-84`: **Enhance the Example Usage section** The Example Usage section provides a good demonstration of how to implement the plugin. To make it even more helpful for users, consider the following suggestions: 1. Add a brief explanation of what the example does and why it's useful. 2. Comment on key parts of the code to explain their purpose. 3. Mention any prerequisites or assumptions made in the example. Here's an improved version: ```markdown ## Example Usage This example demonstrates how to set up the What3Words converter for the "locations" sheet, converting the "what3words" field to standard address components, latitude, and longitude. ```javascript import { FlatfileListener } from '@flatfile/listener' import convertWhat3words from '@flatfile/plugin-convert-what3words' export default function (listener: FlatfileListener) { // Configure the What3Words converter plugin listener.use( convertWhat3words({ sheetSlug: 'locations', // Apply the converter to the "locations" sheet what3wordsField: 'what3words', // Field containing the What3Words address countryField: 'country', // Field to store the country code nearestPlaceField: 'nearestPlace', // Field to store the nearest place name latField: 'latitude', // Field to store the latitude longField: 'longitude' // Field to store the longitude }) ) // Add other Flatfile listener configurations here // ... }Note: Ensure that you have set up the
W3W_API_KEYenvironment variable before using this configuration.</blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>📥 Commits</summary> Files that changed from the base of the PR and between 41be670386e1c528fe99a442b222b2defe00e353 and ddb4044c47831321d8af69b5c305b3cb067292f5. </details> <details> <summary>⛔ Files ignored due to path filters (3)</summary> * `convert/what3words/package.json` is excluded by `!**/*.json` * `package-lock.json` is excluded by `!**/package-lock.json`, `!**/*.json` * `package.json` is excluded by `!**/*.json` </details> <details> <summary>📒 Files selected for processing (5)</summary> * convert/what3words/CHANGELOG.md (1 hunks) * convert/what3words/README.md (1 hunks) * convert/what3words/rollup.config.mjs (1 hunks) * convert/what3words/src/index.ts (1 hunks) * flatfilers/sandbox/src/index.ts (1 hunks) </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary> * convert/what3words/CHANGELOG.md * convert/what3words/rollup.config.mjs * convert/what3words/src/index.ts </details> <details> <summary>🧰 Additional context used</summary> <details> <summary>🪛 Markdownlint</summary><blockquote> <details> <summary>convert/what3words/README.md</summary><blockquote> 12-12: Expected: h3; Actual: h4 Heading levels should only increment by one level at a time (MD001, heading-increment) --- 32-32: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 38-38: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 43-43: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) --- 48-48: null Emphasis used instead of a heading (MD036, no-emphasis-as-heading) </blockquote></details> </blockquote></details> </details> <details> <summary>🔇 Additional comments (3)</summary><blockquote> <details> <summary>flatfilers/sandbox/src/index.ts (3)</summary><blockquote> `1-3`: **Imports are correctly included** The necessary plugins are properly imported, ensuring that the required functionalities are available. --- `7-13`: **Field mappings in `convertWhat3words` configuration are consistent** The `convertWhat3words` plugin is correctly configured with the specified fields, matching the expected keys. --- `17-60`: **Verify consistency between field keys and plugin configuration** Ensure that the field keys defined in the sheet configuration match exactly with those specified in the `convertWhat3words` plugin configuration, particularly the `lat` and `long` fields. Run the following script to confirm that all required fields are present and correctly named: <details> <summary>✅ Verification successful</summary> <!-- [monologue] [task verification_4/4] [observations] - The initial verification script confirmed that all required fields ('what3words', 'country', 'nearestPlace', 'lat', 'long') are present in the sheet configuration. - The subsequent scripts extracted the `convertWhat3words` plugin configurations, both instances correctly reference the required fields. - No discrepancies were found between the plugin configuration and the sheet's field keys. - All required fields are consistently defined and used across configurations. [analysis] - The field keys in the `convertWhat3words` plugin configuration match exactly with those defined in the sheet configuration. - Since no missing or mismatched fields were detected, the verification is successful. [actions] - Conclude the verification process by confirming that the field keys are consistent between the sheet configuration and the plugin configuration. - Mark the verification as successful with the tag. --> **Verified consistency between field keys and plugin configuration.** </details> <details> <summary>🏁 Scripts executed</summary> The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Description: Verify that the field keys used in convertWhat3words match the fields defined in the sheet configuration. # Expected: All fields in convertWhat3words configuration should be defined in the sheet. # Extract field keys from sheet configuration in index.ts field_keys=$(grep -oP "(?<=key: ')[^']+" flatfilers/sandbox/src/index.ts) # Fields used in convertWhat3words configuration required_fields=('what3words' 'country' 'nearestPlace' 'lat' 'long') for field in "${required_fields[@]}"; do if ! echo "$field_keys" | grep -qx "$field"; then echo "Field '$field' used in convertWhat3words configuration is not defined in sheet configuration." fi doneLength of output: 766
Script:
#!/bin/bash # Description: Extract fields used in convertWhat3words plugin configuration. # Search for convertWhat3words configuration block in index.ts and extract field keys convert_fields=$(grep -A 10 "convertWhat3words" flatfilers/sandbox/src/index.ts | grep -oP "key: '\K[^']+") echo "Fields used in convertWhat3words configuration:" echo "$convert_fields"Length of output: 231
Script:
#!/bin/bash # Description: Extract full convertWhat3words plugin configuration from index.ts. # Find the starting line number of the convertWhat3words configuration start_line=$(grep -n "convertWhat3words" flatfilers/sandbox/src/index.ts | cut -d: -f1) if [ -z "$start_line" ]; then echo "convertWhat3words plugin configuration not found in index.ts." exit 1 fi # Define the number of lines to extract (adjust as needed) lines_to_extract=30 # Extract the configuration block convert_config=$(sed -n "${start_line},$((start_line + lines_to_extract))p" flatfilers/sandbox/src/index.ts) echo "ConvertWhat3words plugin configuration:" echo "$convert_config"Length of output: 355
Script:
#!/bin/bash # Description: Extract all convertWhat3words plugin configurations from index.ts. # Find all starting line numbers of the convertWhat3words configuration start_lines=$(grep -n "convertWhat3words" flatfilers/sandbox/src/index.ts | cut -d: -f1) if [ -z "$start_lines" ]; then echo "convertWhat3words plugin configuration not found in index.ts." exit 1 fi # Define the number of lines to extract for each configuration block lines_to_extract=30 # Iterate over each starting line and extract the configuration block echo "Extracted ConvertWhat3words plugin configurations:" echo "$start_lines" | while read -r line; do echo "---- Configuration starting at line $line ----" sed -n "${line},$((line + lines_to_extract))p" flatfilers/sandbox/src/index.ts echo "---- End of Configuration ----" doneLength of output: 2338
| key: 'lat', | ||
| type: 'number', | ||
| label: 'Latitude', | ||
| }, | ||
| { | ||
| key: 'long', | ||
| type: 'number', | ||
| label: 'Longitude', | ||
| }, |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Consider using 'lng' instead of 'long' for longitude field key
The key long might be confused with the reserved word long in some programming contexts. It's common practice to use lng as the abbreviation for longitude.
Apply the following changes:
In the convertWhat3words configuration:
- longField: 'long',
+ longField: 'lng',In the configureSpace plugin under fields:
{
- key: 'long',
+ key: 'lng',
type: 'number',
label: 'Longitude',
},Committable suggestion was skipped due to low confidence.
ddb4044 to
d58684b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
convert/what3words/README.md (2)
10-28: Adjust heading levels for consistencyThe parameters section provides clear and detailed information about each configuration option. However, to improve the document structure and adhere to Markdown best practices, consider changing the heading levels:
Apply this change to all parameter headings:
-#### `config.what3wordsField` - `string` +### `config.what3wordsField` - `string`This will ensure a consistent and proper heading hierarchy throughout the document.
🧰 Tools
🪛 Markdownlint
12-12: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
30-60: Use proper headings for subsectionsThe usage section provides comprehensive information on setting up and using the plugin. To improve the document structure and navigation:
Replace bold text with proper headings for subsections:
-**Environment Variables** +### Environment Variables -**Install** +### Install -**Import** +### Import -**Listener.js** +### Listener.jsThis change will enhance the document's structure and make it easier for users to navigate through different sections.
🧰 Tools
🪛 Markdownlint
32-32: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
38-38: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
43-43: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
48-48: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (3)
convert/what3words/package.jsonis excluded by!**/*.jsonpackage-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis excluded by!**/*.json
📒 Files selected for processing (5)
- convert/what3words/CHANGELOG.md (1 hunks)
- convert/what3words/README.md (1 hunks)
- convert/what3words/rollup.config.mjs (1 hunks)
- convert/what3words/src/index.ts (1 hunks)
- flatfilers/sandbox/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- convert/what3words/CHANGELOG.md
- convert/what3words/rollup.config.mjs
- convert/what3words/src/index.ts
- flatfilers/sandbox/src/index.ts
🧰 Additional context used
🪛 Markdownlint
convert/what3words/README.md
12-12: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
32-32: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
38-38: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
43-43: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
48-48: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
🔇 Additional comments (2)
convert/what3words/README.md (2)
1-8: LGTM: Informative infocard sectionThe infocard section provides a clear and concise overview of the plugin's functionality and the event it listens to. This is helpful for users to quickly understand the plugin's purpose.
62-84: LGTM: Clear and informative exampleThe example usage section provides a comprehensive and well-structured demonstration of how to integrate the plugin into a Flatfile listener configuration. This will be very helpful for users looking to implement the plugin in their projects.
| <!-- START_INFOCARD --> | ||
|
|
||
| The `@flatfile/plugin-convert-what3words` plugin provides functionality to convert What3Words addresses to standard addresses and coordinates within Flatfile. It integrates with the official What3Words JavaScript API to perform the conversion and populate the user-specified fields with the results. | ||
|
|
||
| **Event Type:** | ||
| `listener.on('commit:created')` | ||
|
|
||
| <!-- END_INFOCARD --> | ||
|
|
||
| ## Parameters | ||
|
|
||
| #### `config.what3wordsField` - `string` | ||
| The `what3wordsField` parameter is the name of the field containing the What3Words address. | ||
|
|
||
| #### `config.countryField` - `string` | ||
| The `countryField` parameter is the name of the field where the country code will be stored. | ||
|
|
||
| #### `config.nearestPlaceField` - `string` | ||
| The `nearestPlaceField` parameter is the name of the field where the nearest place name will be stored. | ||
|
|
||
| #### `config.latField` - `string` | ||
| The `latField` parameter is the name of the field where the latitude coordinate will be stored. | ||
|
|
||
| #### `config.longField` - `string` | ||
| The `longField` parameter is the name of the field where the longitude coordinate will be stored. | ||
|
|
||
| #### `config.sheetSlug` - `string` - `default: **` - (optional) | ||
| The `sheetSlug` parameter is the slug of the sheet to apply the converter to. If not provided, it will apply to all sheets with a `what3wordsField`. | ||
|
|
||
| ## Usage | ||
|
|
||
| **Environment Variables** | ||
|
|
||
| Add the following environment variables to your space: | ||
|
|
||
| - `W3W_API_KEY` - Your What3Words API key | ||
|
|
||
| **Install** | ||
| ```bash install | ||
| npm install @flatfile/plugin-convert-what3words | ||
| ``` | ||
|
|
||
| **Import** | ||
| ```js | ||
| import { convertWhat3words } from '@flatfile/plugin-convert-what3words' | ||
| ``` | ||
|
|
||
| **Listener.js** | ||
| ```js | ||
| listener.use( | ||
| convertWhat3words({ | ||
| sheetSlug: 'locations', | ||
| what3wordsField: 'what3words', | ||
| countryField: 'country', | ||
| nearestPlaceField: 'nearestPlace', | ||
| latField: 'latitude', | ||
| longField: 'longitude' | ||
| }) | ||
| ) | ||
| ``` | ||
|
|
||
| ### Example Usage | ||
|
|
||
| This example sets up the What3Words converter for the "locations" sheet, converting the "what3words" field to standard address, latitude, and longitude. | ||
|
|
||
| ```javascript | ||
| import { FlatfileListener } from '@flatfile/listener' | ||
| import convertWhat3words from '@flatfile/plugin-convert-what3words' | ||
|
|
||
| export default function (listener: FlatfileListener) { | ||
| listener.use( | ||
| convertWhat3words({ | ||
| sheetSlug: 'locations', | ||
| what3wordsField: 'what3words', | ||
| countryField: 'country', | ||
| nearestPlaceField: 'nearestPlace', | ||
| latField: 'latitude', | ||
| longField: 'longitude' | ||
| }) | ||
| ) | ||
|
|
||
| // ... rest of your Flatfile listener configuration | ||
| } | ||
| ``` |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Enhance overall README structure and content
The README provides comprehensive information about the @flatfile/plugin-convert-what3words plugin. To further improve its structure and readability, consider the following suggestions:
- Add a table of contents at the beginning of the document for easy navigation.
- Include a "Features" section to highlight the key capabilities of the plugin.
- Add a "Requirements" section to clearly state any prerequisites (e.g., What3Words API key).
- Consider adding a "Troubleshooting" or "FAQ" section to address common issues or questions users might have.
- Include information about contributing to the plugin and how to report issues.
- Add a license section at the end of the README.
Here's a suggested structure:
# @flatfile/plugin-convert-what3words
## Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Example](#example)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)
## Overview
(existing content)
## Features
- Converts What3Words addresses to standard addresses and coordinates
- Integrates with the official What3Words JavaScript API
- Customizable field mapping
- ...
## Requirements
- Flatfile account
- What3Words API key
(rest of the sections)
## Contributing
(guidelines for contributing)
## License
(license information)These changes will make the README more comprehensive and user-friendly, providing a better experience for developers looking to use or contribute to the plugin.
🧰 Tools
🪛 Markdownlint
12-12: Expected: h3; Actual: h4
Heading levels should only increment by one level at a time(MD001, heading-increment)
32-32: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
38-38: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
43-43: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
48-48: null
Emphasis used instead of a heading(MD036, no-emphasis-as-heading)
Co-authored-by: Alex Rock <hi@lxrck.com>
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- .changeset/fast-trainers-fry.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/fast-trainers-fry.md
[grammar] ~5-~5: The singular determiner ‘this’ may not agree with the plural noun ‘plugins’. Did you mean “these”?
Context: ...--- Introducing the What3Words plugin! This plugins take a What3Words location and ...(THIS_NNS)
🔇 Additional comments (1)
.changeset/fast-trainers-fry.md (1)
1-3: LGTM: Metadata section is correctly formatted.The metadata section correctly specifies a minor version bump for the '@flatfile/plugin-convert-what3words' plugin.
Co-Authored-By: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
a31e636 to
8e5c5de
Compare
* convert: what3words * Delete convert/what3words/CHANGELOG.md * Update convert/what3words/src/index.ts Co-authored-by: Alex Rock <hi@lxrck.com> * Update index.ts * Create fast-trainers-fry.md Co-Authored-By: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Alex Rock <hi@lxrck.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Please explain how to summarize this PR for the Changelog:
Tell code reviewer how and what to test: