-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Neon PostgreSQL - New Components #16685
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
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
""" WalkthroughA comprehensive Neon PostgreSQL integration is introduced, including a new app module, multiple actions for CRUD operations and custom queries, and sources for detecting new tables, columns, and rows. The implementation leverages and extends existing Pipedream PostgreSQL utilities, providing dynamic schema, table, and column selection, advanced error handling with SSL verification hints, and event-driven polling for database changes. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant NeonAction
participant NeonApp
participant NeonDB
User->>NeonAction: Trigger action (e.g., Insert Row, Find Row)
NeonAction->>NeonApp: Prepare connection/configuration
NeonApp->>NeonDB: Execute SQL or perform operation
NeonDB-->>NeonApp: Return result/error
NeonApp-->>NeonAction: Return result/error
NeonAction-->>User: Output result or error message
sequenceDiagram
participant Source
participant NeonApp
participant NeonDB
participant User
Source->>NeonApp: Poll for changes (e.g., new row, column, table)
NeonApp->>NeonDB: Query for changes
NeonDB-->>NeonApp: Return new/updated data
NeonApp-->>Source: Provide results
Source-->>User: Emit event with metadata
Assessment against linked issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/neon_postgres/actions/insert-row/insert-row.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/neon_postgres/actions/delete-rows/delete-rows.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (10)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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 (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 14
🧹 Nitpick comments (4)
components/neon_postgres/actions/delete-rows/delete-rows.mjs (1)
50-67
: Consider extracting common error handling patternThis error handling pattern appears to be repeated across multiple action components. Consider extracting it to a utility function to improve maintainability.
+ // In a shared utility file + export const handlePostgresError = (error) => { + let errorMsg = "Operation failed due to an error. "; + errorMsg += `${error}`.includes("SSL verification failed") + ? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again." + : `${error}`; + return errorMsg; + } // In this file - try { - const rows = await this.neon.deleteRows( - schema, - table, - column, - value, - ); - $.export("$summary", `Deleted ${rows.length} rows from ${table}`); - return rows; - } catch (error) { - let errorMsg = "Row not deleted due to an error. "; - errorMsg += `${error}`.includes("SSL verification failed") - ? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again." - : `${error}`; - throw new Error(errorMsg); - } + try { + const rows = await this.neon.deleteRows( + schema, + table, + column, + value, + ); + $.export("$summary", `Deleted ${rows.length} rows from ${table}`); + return rows; + } catch (error) { + throw new Error(handlePostgresError(error).replace("Operation", "Row not deleted")); + }components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs (1)
41-43
: Enhance query validation messageThe error message for non-SELECT queries could be more specific about this component's purpose and point users to alternative components for data modification.
if (!query.toLowerCase().includes("select")) { - throw new Error("Need be a `SELECT` statement query. Read more about [SELECT queries here](https://www.w3schools.com/sql/sql_select.asp)"); + throw new Error("This component only supports `SELECT` statement queries. For data modification, please use the 'Execute SQL Query' component instead. Read more about [SELECT queries here](https://www.w3schools.com/sql/sql_select.asp)"); }components/neon_postgres/sources/new-column/new-column.mjs (1)
34-37
: Add logging for clarity on new column detectionAdding a log message would make it clearer in the execution logs when new columns are detected or when no changes are found.
const newColumns = columns.filter((column) => !previousColumns.includes(column)); + console.log(`Found ${newColumns.length} new columns in table ${this.table}`); for (const column of newColumns) { const meta = this.generateMeta(column); this.$emit(column, meta); }
components/neon_postgres/actions/insert-row/insert-row.mjs (1)
48-49
: Enhance the summary message with detailsThe current summary message is generic. Adding details about which table and how many columns were affected would make the message more informative.
- $.export("$summary", "New row inserted"); + $.export("$summary", `New row inserted into ${table} with ${columns.length} column(s)`); return res;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (15)
components/neon_postgres/actions/delete-rows/delete-rows.mjs
(1 hunks)components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjs
(1 hunks)components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs
(1 hunks)components/neon_postgres/actions/find-row/find-row.mjs
(1 hunks)components/neon_postgres/actions/insert-row/insert-row.mjs
(1 hunks)components/neon_postgres/actions/update-row/update-row.mjs
(1 hunks)components/neon_postgres/actions/upsert-row/upsert-row.mjs
(1 hunks)components/neon_postgres/neon_postgres.app.mjs
(1 hunks)components/neon_postgres/package.json
(2 hunks)components/neon_postgres/sources/common/common.mjs
(1 hunks)components/neon_postgres/sources/new-column/new-column.mjs
(1 hunks)components/neon_postgres/sources/new-or-updated-row/new-or-updated-row.mjs
(1 hunks)components/neon_postgres/sources/new-row-custom-query/new-row-custom-query.mjs
(1 hunks)components/neon_postgres/sources/new-row/new-row.mjs
(1 hunks)components/neon_postgres/sources/new-table/new-table.mjs
(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Pull Request Checks
components/neon_postgres/actions/update-row/update-row.mjs
[error] 1-1: Error related to key 'neon_api_keys-update-row' found in this component.
components/neon_postgres/actions/insert-row/insert-row.mjs
[error] 1-1: Error related to key 'neon_api_keys-insert-row' found in this component.
components/neon_postgres/actions/find-row/find-row.mjs
[error] 1-1: Error related to key 'neon_api_keys-find-row' found in this component.
components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjs
[error] 1-1: Error related to key 'neon_api_keys-execute-custom-query' found in this component.
components/neon_postgres/sources/new-row-custom-query/new-row-custom-query.mjs
[error] 1-1: Error related to key 'neon_api_keys-new-row-custom-query' found in this component.
components/neon_postgres/sources/new-column/new-column.mjs
[error] 1-1: Error related to key 'neon_api_keys-new-column' found in this component.
components/neon_postgres/sources/new-table/new-table.mjs
[error] 1-1: Error related to key 'neon_api_keys-new-table' found in this component.
components/neon_postgres/actions/delete-rows/delete-rows.mjs
[error] 1-1: Error related to key 'neon_api_keys-delete-rows' found in this component.
components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs
[error] 1-1: Error related to key 'neon_api_keys-find-row-custom-query' found in this component.
components/neon_postgres/sources/new-or-updated-row/new-or-updated-row.mjs
[error] 1-1: Error related to key 'neon_api_keys-new-or-updated-row' found in this component.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Verify TypeScript components
- GitHub Check: Publish TypeScript components
🔇 Additional comments (19)
components/neon_postgres/package.json (1)
3-3
: LGTM: Version update and dependencies addedThe version update to 0.1.0 and the addition of required dependencies look good. These dependencies align with the Neon PostgreSQL integration needs.
Also applies to: 14-17
components/neon_postgres/sources/common/common.mjs (1)
1-19
: Well-structured common module for sourcesGood implementation of a reusable base configuration for Neon Postgres source components. The approach of extending the common PostgreSQL source with Neon-specific properties follows good software design practices.
components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjs (1)
1-28
: Overall implementation looks goodThe action is well-structured with appropriate props and execution logic. The SQL execution and results handling are implemented correctly.
🧰 Tools
🪛 GitHub Actions: Pull Request Checks
[error] 1-1: Error related to key 'neon_api_keys-execute-custom-query' found in this component.
components/neon_postgres/actions/update-row/update-row.mjs (2)
78-82
: Good error handling for SSL verificationThe error handling implementation is well done, especially the specific message for SSL verification failures which provides clear guidance to users on how to fix the issue.
1-85
: Overall implementation is goodThe action is well-structured with appropriate props for schema, table, column selection and value handling. The dynamic prop definitions that depend on previous selections provide a good user experience.
🧰 Tools
🪛 GitHub Actions: Pull Request Checks
[error] 1-1: Error related to key 'neon_api_keys-update-row' found in this component.
components/neon_postgres/actions/delete-rows/delete-rows.mjs (1)
67-73
: Well-structured error handling with good user guidanceThe error handling logic provides helpful guidance specifically for SSL verification issues, which is a common problem with database connections. This improves user experience by offering a clear solution path.
components/neon_postgres/actions/find-row/find-row.mjs (1)
50-76
: Good error handling for SSL verification failuresThe error handling is robust, especially with the helpful message for SSL verification failures that guides users to resolve the issue.
components/neon_postgres/sources/new-row-custom-query/new-row-custom-query.mjs (2)
70-77
: Good validation for array values and placeholder matchingThe validation logic properly checks that values is an array and that the number of placeholders matches the number of values, which prevents SQL injection and improves error messaging.
79-82
: Good check for column uniquenessVerifying that the selected column contains unique values is important for proper deduplication when emitting events.
components/neon_postgres/neon_postgres.app.mjs (2)
1-8
: Clean integration with PostgreSQL packageEffectively imports and integrates with the
@pipedream/postgresql
package, allowing reuse of common PostgreSQL functionality while adding Neon-specific features.
11-27
: Well-structured client configurationThe
getClientConfiguration()
method cleanly extracts auth parameters and applies SSL configuration, which centralizes connection setup for all Neon Postgres components.components/neon_postgres/actions/upsert-row/upsert-row.mjs (2)
54-56
: Good handling of update columnsExcluding the conflict target column from the update columns list is a best practice for upsert operations.
93-98
: Consistent error handlingThis error handling follows the same pattern as other components in the integration, providing helpful guidance for SSL verification issues.
components/neon_postgres/sources/new-table/new-table.mjs (1)
19-31
: LGTM: Logic for detecting new tables is well implementedThe implementation correctly retrieves the current tables, compares against previously stored values, and emits events for new tables. The state management is properly handled with the _getPreviousValues() and _setPreviousValues() methods.
components/neon_postgres/sources/new-row/new-row.mjs (3)
6-10
: LGTM: Component metadata is correctly definedThe component key "neon_postgres-new-row" follows the expected naming convention, and the component is correctly configured with appropriate metadata and dedupe settings.
42-52
: LGTM: Deploy hook correctly handles column configurationThe deploy hook appropriately sets the column to either the user-specified column or the table's primary key, and initializes the state with existing rows.
69-77
: LGTM: Run method properly validates column and processes new rowsThe implementation correctly checks if the column contains unique values (crucial for proper deduplication) and throws a clear error message if duplicates exist. The method then processes new rows with the newRows helper.
components/neon_postgres/sources/new-or-updated-row/new-or-updated-row.mjs (2)
28-52
: LGTM: Column props are well-defined with clear descriptionsThe implementation correctly defines both an identifier column (for uniquely identifying rows) and a timestamp column (for detecting updates). The descriptions provide clear guidance to users about their purpose and expected values.
65-71
: LGTM: Event metadata generation creates unique identifiersThe generateMeta method properly creates a unique ID by combining the identifier column value and the timestamp, which ensures proper event deduplication even when the same row is updated multiple times.
components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjs
Outdated
Show resolved
Hide resolved
components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs
Outdated
Show resolved
Hide resolved
components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs
Show resolved
Hide resolved
components/neon_postgres/sources/new-row-custom-query/new-row-custom-query.mjs
Outdated
Show resolved
Hide resolved
components/neon_postgres/sources/new-or-updated-row/new-or-updated-row.mjs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left just one comment regarding reusing the error check that is very similar in several components.
} catch (error) { | ||
let errorMsg = "Row not retrieved due to an error. "; | ||
errorMsg += `${error}`.includes("SSL verification failed") | ||
? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have this error message check moved to a shared method or function imported by all these components? Perhaps the initial, unique error message for each component can be passed as a parameter to it.
Resolves #16620
Summary by CodeRabbit
New Features
Chores