Skip to content

Commit f813f3c

Browse files
committed
new components
1 parent 26413b6 commit f813f3c

File tree

18 files changed

+861
-8
lines changed

18 files changed

+861
-8
lines changed

components/neon_api_keys/actions/create-branch/create-branch.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import app from "../../neon_api_keys.app.mjs";
22

33
export default {
44
name: "Create Branch",
5-
version: "0.0.1",
5+
version: "0.0.2",
66
key: "neon_api_keys-create-branch",
7-
description: "Creates a branch in the project. [See docs here](https://api-docs.neon.tech/reference/createprojectbranch)",
7+
description: "Creates a branch in the project. [See the documentation](https://api-docs.neon.tech/reference/createprojectbranch)",
88
type: "action",
99
props: {
1010
app,

components/neon_api_keys/actions/create-database/create-database.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import app from "../../neon_api_keys.app.mjs";
22

33
export default {
44
name: "Create Database",
5-
version: "0.0.1",
5+
version: "0.0.2",
66
key: "neon_api_keys-create-database",
7-
description: "Creates a database in the project. [See docs here](https://api-docs.neon.tech/reference/createprojectbranchdatabase)",
7+
description: "Creates a database in the project. [See the documentation](https://api-docs.neon.tech/reference/createprojectbranchdatabase)",
88
type: "action",
99
props: {
1010
app,

components/neon_api_keys/actions/create-project/create-project.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import constants from "../common/constants.mjs";
33

44
export default {
55
name: "Create Project",
6-
version: "0.0.1",
6+
version: "0.0.2",
77
key: "neon_api_keys-create-project",
8-
description: "Creates a project. [See docs here](https://api-docs.neon.tech/reference/createproject)",
8+
description: "Creates a project. [See the documentation](https://api-docs.neon.tech/reference/createproject)",
99
type: "action",
1010
props: {
1111
app,
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import neon from "../../neon_api_keys.app.mjs";
2+
3+
export default {
4+
name: "Delete Row(s)",
5+
key: "neon_api_keys-delete-rows",
6+
description: "Deletes a row or rows from a table. [See the documentation](https://node-postgres.com/features/queries)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
neon,
11+
schema: {
12+
propDefinition: [
13+
neon,
14+
"schema",
15+
],
16+
},
17+
table: {
18+
propDefinition: [
19+
neon,
20+
"table",
21+
(c) => ({
22+
schema: c.schema,
23+
}),
24+
],
25+
},
26+
column: {
27+
propDefinition: [
28+
neon,
29+
"column",
30+
(c) => ({
31+
table: c.table,
32+
schema: c.schema,
33+
}),
34+
],
35+
label: "Lookup Column",
36+
description: "Find row(s) by searching for a value in this column",
37+
},
38+
value: {
39+
propDefinition: [
40+
neon,
41+
"value",
42+
(c) => ({
43+
table: c.table,
44+
column: c.column,
45+
schema: c.schema,
46+
}),
47+
],
48+
},
49+
},
50+
async run({ $ }) {
51+
const {
52+
table,
53+
schema,
54+
column,
55+
value,
56+
} = this;
57+
58+
try {
59+
const rows = await this.neon.deleteRows(
60+
schema,
61+
table,
62+
column,
63+
value,
64+
);
65+
$.export("$summary", `Deleted ${rows.length} rows from ${table}`);
66+
return rows;
67+
} catch (error) {
68+
let errorMsg = "Row not deleted due to an error. ";
69+
errorMsg += `${error}`.includes("SSL verification failed")
70+
? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again."
71+
: `${error}`;
72+
throw new Error(errorMsg);
73+
}
74+
},
75+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import neon from "../../neon_api_keys.app.mjs";
2+
3+
export default {
4+
key: "neon_api_keys-execute-custom-query",
5+
name: "Execute SQL Query",
6+
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.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
neon,
11+
// eslint-disable-next-line pipedream/props-description
12+
sql: {
13+
type: "sql",
14+
auth: {
15+
app: "neon",
16+
},
17+
label: "PostgreSQL Query",
18+
},
19+
},
20+
async run({ $ }) {
21+
const args = this.neon.executeQueryAdapter(this.sql);
22+
const data = await this.neon.executeQuery(args);
23+
$.export("$summary", `Returned ${data.length} ${data.length === 1
24+
? "row"
25+
: "rows"}`);
26+
return data;
27+
},
28+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import neon from "../../neon_api_keys.app.mjs";
2+
3+
export default {
4+
name: "Find Row With Custom Query",
5+
key: "neon_api_keys-find-row-custom-query",
6+
description: "Finds a row in a table via a custom query. [See the documentation](https://node-postgres.com/features/queries)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
neon,
11+
query: {
12+
propDefinition: [
13+
neon,
14+
"query",
15+
],
16+
},
17+
values: {
18+
propDefinition: [
19+
neon,
20+
"values",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const {
26+
query,
27+
values = [],
28+
} = this;
29+
30+
if (!Array.isArray(values)) {
31+
throw new Error("No valid values provided. The values property must be an array.");
32+
}
33+
34+
if (this.values) {
35+
const numberOfValues = query?.match(/\$/g)?.length || 0;
36+
if (values.length !== numberOfValues) {
37+
throw new Error("The number of values provided does not match the number of values in the query.");
38+
}
39+
}
40+
41+
if (!query.toLowerCase().includes("select")) {
42+
throw new Error("Need be a `SELECT` statement query. Read more about [SELECT queries here](https://www.w3schools.com/sql/sql_select.asp)");
43+
}
44+
45+
try {
46+
const res = await this.neon.executeQuery({
47+
text: query,
48+
values,
49+
});
50+
$.export("$summary", "Successfully executed query");
51+
return res;
52+
} catch (error) {
53+
let errorMsg = "Query not executed due to an error. ";
54+
errorMsg += `${error}`.includes("SSL verification failed")
55+
? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again."
56+
: `${error}`;
57+
throw new Error(errorMsg);
58+
}
59+
},
60+
};
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import neon from "../../neon_api_keys.app.mjs";
2+
3+
export default {
4+
name: "Find Row",
5+
key: "neon_api_keys-find-row",
6+
description: "Finds a row in a table via a lookup column. [See the documentation](https://node-postgres.com/features/queries)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
neon,
11+
schema: {
12+
propDefinition: [
13+
neon,
14+
"schema",
15+
(c) => ({
16+
connectionUriArgs: {
17+
projectId: c.projectId,
18+
params: {
19+
branchId: c.branchId,
20+
databaseName: c.databaseName,
21+
roleName: c.roleName,
22+
},
23+
},
24+
}),
25+
],
26+
},
27+
table: {
28+
propDefinition: [
29+
neon,
30+
"table",
31+
(c) => ({
32+
schema: c.schema,
33+
connectionUriArgs: {
34+
projectId: c.projectId,
35+
params: {
36+
branchId: c.branchId,
37+
databaseName: c.databaseName,
38+
roleName: c.roleName,
39+
},
40+
},
41+
}),
42+
],
43+
},
44+
column: {
45+
propDefinition: [
46+
neon,
47+
"column",
48+
(c) => ({
49+
table: c.table,
50+
schema: c.schema,
51+
connectionUriArgs: {
52+
projectId: c.projectId,
53+
params: {
54+
branchId: c.branchId,
55+
databaseName: c.databaseName,
56+
roleName: c.roleName,
57+
},
58+
},
59+
}),
60+
],
61+
label: "Lookup Column",
62+
description: "Find row by searching for a value in this column. Returns first row found",
63+
},
64+
value: {
65+
propDefinition: [
66+
neon,
67+
"value",
68+
(c) => ({
69+
table: c.table,
70+
column: c.column,
71+
schema: c.schema,
72+
}),
73+
],
74+
},
75+
},
76+
async run({ $ }) {
77+
const {
78+
schema,
79+
table,
80+
column,
81+
value,
82+
} = this;
83+
try {
84+
const res = await this.neon.findRowByValue(
85+
schema,
86+
table,
87+
column,
88+
value,
89+
);
90+
const summary = res
91+
? "Row found"
92+
: "Row not found";
93+
$.export("$summary", summary);
94+
return res;
95+
} catch (error) {
96+
let errorMsg = "Row not retrieved due to an error. ";
97+
errorMsg += `${error}`.includes("SSL verification failed")
98+
? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again."
99+
: `${error}`;
100+
throw new Error(errorMsg);
101+
}
102+
},
103+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import neon from "../../neon_api_keys.app.mjs";
2+
3+
export default {
4+
name: "Insert Row",
5+
key: "neon_api_keys-insert-row",
6+
description: "Adds a new row. [See the documentation](https://node-postgres.com/features/queries)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
neon,
11+
schema: {
12+
propDefinition: [
13+
neon,
14+
"schema",
15+
],
16+
},
17+
table: {
18+
propDefinition: [
19+
neon,
20+
"table",
21+
(c) => ({
22+
schema: c.schema,
23+
}),
24+
],
25+
},
26+
rowValues: {
27+
propDefinition: [
28+
neon,
29+
"rowValues",
30+
],
31+
},
32+
},
33+
async run({ $ }) {
34+
const {
35+
schema,
36+
table,
37+
rowValues,
38+
} = this;
39+
const columns = Object.keys(rowValues);
40+
const values = Object.values(rowValues);
41+
try {
42+
const res = await this.neon.insertRow(
43+
schema,
44+
table,
45+
columns,
46+
values,
47+
);
48+
$.export("$summary", "New row inserted");
49+
return res;
50+
} catch (error) {
51+
let errorMsg = "New row not inserted due to an error. ";
52+
errorMsg += `${error}`.includes("SSL verification failed")
53+
? "This could be because SSL verification failed. To resolve this, reconnect your account and set SSL Verification Mode: Skip Verification, and try again."
54+
: `${error}`;
55+
throw new Error(errorMsg);
56+
}
57+
},
58+
};

0 commit comments

Comments
 (0)