Skip to content

Commit e738112

Browse files
committed
[Components] neo4j_auradb #15828
Sources - New Node - New Relationship - New Query Result Actions - Create Node - Create Relationship - Run Query
1 parent c07e308 commit e738112

File tree

14 files changed

+419
-518
lines changed

14 files changed

+419
-518
lines changed

components/neo4j_auradb/actions/create-node/create-node.mjs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
1-
import neo4jAuradb from "../../neo4j_auradb.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { parseObject } from "../../common/utils.mjs";
2+
import app from "../../neo4j_auradb.app.mjs";
33

44
export default {
55
key: "neo4j_auradb-create-node",
66
name: "Create Node",
7-
description: "Creates a new node in the Neo4j AuraDB instance. [See the documentation]()",
8-
version: "0.0.{{ts}}",
7+
description: "Creates a new node in the Neo4j AuraDB instance. [See the documentation](https://neo4j.com/docs/query-api/current/query/)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
neo4jAuradb,
12-
createNodeLabel: {
13-
propDefinition: [
14-
neo4jAuradb,
15-
"createNodeLabel",
16-
],
11+
app,
12+
nodeLabel: {
13+
type: "string",
14+
label: "Node Label",
15+
description: "The label of the node to filter events for new node creation.",
1716
},
18-
createNodeProperties: {
19-
propDefinition: [
20-
neo4jAuradb,
21-
"createNodeProperties",
22-
],
17+
nodeProperties: {
18+
type: "object",
19+
label: "Create Node Properties",
20+
description: "Anobject representing the properties of the node to create.",
2321
},
2422
},
2523
async run({ $ }) {
26-
const response = await this.neo4jAuradb.createNode({
27-
createNodeLabel: this.createNodeLabel,
28-
createNodeProperties: this.createNodeProperties,
24+
const response = await this.app.createNode({
25+
$,
26+
label: this.nodeLabel,
27+
properties: parseObject(this.nodeProperties),
2928
});
3029

31-
const node = response.results?.[0]?.data?.[0]?.row?.[0];
32-
$.export("$summary", node
33-
? `Created node with id ${node.id}`
30+
const elementId = response.data?.values?.[0]?.[0]?.elementId;
31+
$.export("$summary", elementId
32+
? `Created node with id ${elementId}`
3433
: "Node created successfully");
3534
return response;
3635
},

components/neo4j_auradb/actions/create-relationship/create-relationship.mjs

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
1-
import neo4jAuradb from "../../neo4j_auradb.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { parseObject } from "../../common/utils.mjs";
2+
import app from "../../neo4j_auradb.app.mjs";
33

44
export default {
55
key: "neo4j_auradb-create-relationship",
66
name: "Create Relationship",
7-
description: "Creates a relationship between two existing nodes. [See the documentation]()",
8-
version: "0.0.{{ts}}",
7+
description: "Creates a relationship between two existing nodes. [See the documentation](https://neo4j.com/docs/query-api/current/query/)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
11-
neo4jAuradb: {
12-
type: "app",
13-
app: "neo4j_auradb",
11+
app,
12+
relationshipType: {
13+
type: "string",
14+
label: "Create Relationship Type",
15+
description: "The name of the relationship to create.",
1416
},
15-
createRelationshipType: {
16-
propDefinition: [
17-
"neo4j_auradb",
18-
"createRelationshipType",
19-
],
17+
startNode: {
18+
type: "object",
19+
label: "Start Node Identifier",
20+
description: "An object containing any fields used to identify the start node.",
2021
},
21-
createStartNode: {
22-
propDefinition: [
23-
"neo4j_auradb",
24-
"createStartNode",
25-
],
22+
endNode: {
23+
type: "object",
24+
label: "End Node Identifier",
25+
description: "An object containing any fields used to identify the end node.",
2626
},
27-
createEndNode: {
28-
propDefinition: [
29-
"neo4j_auradb",
30-
"createEndNode",
31-
],
32-
},
33-
createRelationshipProperties: {
34-
propDefinition: [
35-
"neo4j_auradb",
36-
"createRelationshipProperties",
37-
],
27+
relationshipProperties: {
28+
type: "object",
29+
label: "Create Relationship Properties",
30+
description: "An object representing the properties of the relationship to create.",
31+
optional: true,
3832
},
3933
},
4034
async run({ $ }) {
41-
const response = await this.neo4jAuradb.createRelationship({
42-
createRelationshipType: this.createRelationshipType,
43-
createStartNode: this.createStartNode,
44-
createEndNode: this.createEndNode,
45-
createRelationshipProperties: this.createRelationshipProperties,
35+
const response = await this.app.createRelationship({
36+
$,
37+
relationshipType: this.relationshipType,
38+
startNode: parseObject(this.startNode),
39+
endNode: parseObject(this.endNode),
40+
relationshipProperties: parseObject(this.relationshipProperties),
4641
});
4742
$.export(
4843
"$summary",
49-
`Created relationship '${this.createRelationshipType}' between nodes '${this.createStartNode}' and '${this.createEndNode}'`,
44+
`Created relationship '${this.relationshipType}' between nodes`,
5045
);
5146
return response;
5247
},

components/neo4j_auradb/actions/run-query/run-query.mjs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import neo4jAuradb from "../../neo4j_auradb.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import app from "../../neo4j_auradb.app.mjs";
32

43
export default {
54
key: "neo4j_auradb-run-query",
65
name: "Run Cypher Query",
7-
description: "Executes a Cypher query against the Neo4j AuraDB instance. [See the documentation]()",
8-
version: "0.0.{{ts}}",
6+
description: "Executes a Cypher query against the Neo4j AuraDB instance. [See the documentation](https://neo4j.com/docs/query-api/current/query/)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
11-
neo4jAuradb,
12-
executeCypherQuery: {
13-
propDefinition: [
14-
neo4jAuradb,
15-
"executeCypherQuery",
16-
],
10+
app,
11+
cypherQuery: {
12+
type: "string",
13+
label: "Execute Cypher Query",
14+
description: "A valid Cypher query to execute against the Neo4j AuraDB instance.",
1715
},
1816
},
1917
async run({ $ }) {
20-
const response = await this.neo4jAuradb.executeCypherQuery({
21-
executeCypherQuery: this.executeCypherQuery,
18+
const response = await this.app.executeCypherQuery({
19+
$,
20+
cypherQuery: this.cypherQuery,
2221
});
2322
$.export("$summary", "Executed Cypher query successfully");
2423
return response;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const LIMIT = 100;
2+
3+
export const ORDER_TYPE_OPTIONS = [
4+
{
5+
label: "DateTime",
6+
value: "datetime",
7+
},
8+
{
9+
label: "Sequencial (integer)",
10+
value: "sequencial",
11+
},
12+
{
13+
label: "Other",
14+
value: "other",
15+
},
16+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

0 commit comments

Comments
 (0)