-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f813f3c
new components
michelle0927 b5404dd
add error
michelle0927 9abb005
pnpm-lock.yaml
michelle0927 d174288
Merge remote-tracking branch 'origin/master' into issue-16620
michelle0927 81abc12
move sql related components to neon_postgres
michelle0927 110e30c
pnpm-lock.yaml
michelle0927 b51cb96
pnpm-lock.yaml
michelle0927 d792a55
remove sql related components from neon_api_keys
michelle0927 ea358df
fix keys
michelle0927 af92d5a
updates
michelle0927 f3c395a
postgresql package version
michelle0927 120113a
updates
michelle0927 e72e36f
pnpm-lock.yaml
michelle0927 eb49c5a
Merge remote-tracking branch 'origin/master' into issue-16620
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
components/neon_postgres/actions/delete-rows/delete-rows.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
name: "Delete Row(s)", | ||
key: "neon_api_keys-delete-rows", | ||
description: "Deletes a row or rows from a table. [See the documentation](https://node-postgres.com/features/queries)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
schema: { | ||
propDefinition: [ | ||
neon, | ||
"schema", | ||
], | ||
}, | ||
table: { | ||
propDefinition: [ | ||
neon, | ||
"table", | ||
(c) => ({ | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
column: { | ||
propDefinition: [ | ||
neon, | ||
"column", | ||
(c) => ({ | ||
table: c.table, | ||
schema: c.schema, | ||
}), | ||
], | ||
label: "Lookup Column", | ||
description: "Find row(s) by searching for a value in this column", | ||
}, | ||
value: { | ||
propDefinition: [ | ||
neon, | ||
"value", | ||
(c) => ({ | ||
table: c.table, | ||
column: c.column, | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
table, | ||
schema, | ||
column, | ||
value, | ||
} = this; | ||
|
||
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); | ||
} | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
components/neon_postgres/actions/execute-custom-query/execute-custom-query.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
key: "neon_api_keys-execute-custom-query", | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: "Execute SQL Query", | ||
description: "Execute a custom PostgreSQL query. See [our docs](https://pipedream.com/docs/databases/working-with-sql) to learn more about working with SQL in Pipedream.", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
// eslint-disable-next-line pipedream/props-description | ||
sql: { | ||
type: "sql", | ||
auth: { | ||
app: "neon", | ||
}, | ||
label: "PostgreSQL Query", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const args = this.neon.executeQueryAdapter(this.sql); | ||
const data = await this.neon.executeQuery(args); | ||
$.export("$summary", `Returned ${data.length} ${data.length === 1 | ||
? "row" | ||
: "rows"}`); | ||
return data; | ||
}, | ||
}; |
60 changes: 60 additions & 0 deletions
60
components/neon_postgres/actions/find-row-custom-query/find-row-custom-query.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
name: "Find Row With Custom Query", | ||
key: "neon_api_keys-find-row-custom-query", | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: "Finds a row in a table via a custom query. [See the documentation](https://node-postgres.com/features/queries)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
query: { | ||
propDefinition: [ | ||
neon, | ||
"query", | ||
], | ||
}, | ||
values: { | ||
propDefinition: [ | ||
neon, | ||
"values", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
query, | ||
values = [], | ||
} = this; | ||
|
||
if (!Array.isArray(values)) { | ||
throw new Error("No valid values provided. The values property must be an array."); | ||
} | ||
|
||
if (this.values) { | ||
const numberOfValues = query?.match(/\$/g)?.length || 0; | ||
if (values.length !== numberOfValues) { | ||
throw new Error("The number of values provided does not match the number of values in the query."); | ||
} | ||
} | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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)"); | ||
} | ||
|
||
try { | ||
const res = await this.neon.executeQuery({ | ||
text: query, | ||
values, | ||
}); | ||
$.export("$summary", "Successfully executed query"); | ||
return res; | ||
} catch (error) { | ||
let errorMsg = "Query not executed 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); | ||
} | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
name: "Find Row", | ||
key: "neon_api_keys-find-row", | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: "Finds a row in a table via a lookup column. [See the documentation](https://node-postgres.com/features/queries)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
schema: { | ||
propDefinition: [ | ||
neon, | ||
"schema", | ||
], | ||
}, | ||
table: { | ||
propDefinition: [ | ||
neon, | ||
"table", | ||
(c) => ({ | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
column: { | ||
propDefinition: [ | ||
neon, | ||
"column", | ||
(c) => ({ | ||
table: c.table, | ||
schema: c.schema, | ||
}), | ||
], | ||
label: "Lookup Column", | ||
description: "Find row by searching for a value in this column. Returns first row found", | ||
}, | ||
value: { | ||
propDefinition: [ | ||
neon, | ||
"value", | ||
(c) => ({ | ||
table: c.table, | ||
column: c.column, | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
schema, | ||
table, | ||
column, | ||
value, | ||
} = this; | ||
try { | ||
const res = await this.neon.findRowByValue( | ||
schema, | ||
table, | ||
column, | ||
value, | ||
); | ||
const summary = res | ||
? "Row found" | ||
: "Row not found"; | ||
$.export("$summary", summary); | ||
return res; | ||
} 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." | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
: `${error}`; | ||
throw new Error(errorMsg); | ||
} | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
components/neon_postgres/actions/insert-row/insert-row.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
name: "Insert Row", | ||
key: "neon_api_keys-insert-row", | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: "Adds a new row. [See the documentation](https://node-postgres.com/features/queries)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
schema: { | ||
propDefinition: [ | ||
neon, | ||
"schema", | ||
], | ||
}, | ||
table: { | ||
propDefinition: [ | ||
neon, | ||
"table", | ||
(c) => ({ | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
rowValues: { | ||
propDefinition: [ | ||
neon, | ||
"rowValues", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
schema, | ||
table, | ||
rowValues, | ||
} = this; | ||
const columns = Object.keys(rowValues); | ||
const values = Object.values(rowValues); | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
try { | ||
const res = await this.neon.insertRow( | ||
schema, | ||
table, | ||
columns, | ||
values, | ||
); | ||
$.export("$summary", "New row inserted"); | ||
return res; | ||
} catch (error) { | ||
let errorMsg = "New row not inserted 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); | ||
} | ||
}, | ||
}; |
85 changes: 85 additions & 0 deletions
85
components/neon_postgres/actions/update-row/update-row.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import neon from "../../neon_postgres.app.mjs"; | ||
|
||
export default { | ||
name: "Update Row", | ||
key: "neon_api_keys-update-row", | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description: "Updates an existing row. [See the documentation](https://node-postgres.com/features/queries)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neon, | ||
schema: { | ||
propDefinition: [ | ||
neon, | ||
"schema", | ||
], | ||
}, | ||
table: { | ||
propDefinition: [ | ||
neon, | ||
"table", | ||
(c) => ({ | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
column: { | ||
propDefinition: [ | ||
neon, | ||
"column", | ||
(c) => ({ | ||
table: c.table, | ||
schema: c.schema, | ||
}), | ||
], | ||
label: "Lookup Column", | ||
description: "Find row to update by searching for a value in this column. Returns first row found", | ||
}, | ||
value: { | ||
propDefinition: [ | ||
neon, | ||
"value", | ||
(c) => ({ | ||
table: c.table, | ||
column: c.column, | ||
schema: c.schema, | ||
}), | ||
], | ||
}, | ||
rowValues: { | ||
propDefinition: [ | ||
neon, | ||
"rowValues", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
schema, | ||
table, | ||
column, | ||
value, | ||
rowValues, | ||
} = this; | ||
try { | ||
const res = await this.neon.updateRow( | ||
schema, | ||
table, | ||
column, | ||
value, | ||
rowValues, | ||
); | ||
const summary = res | ||
? "Row updated" | ||
: "Row not found"; | ||
$.export("$summary", summary); | ||
return res; | ||
} catch (error) { | ||
let errorMsg = "Row not updated 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); | ||
} | ||
}, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.