-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - neo4j_auradb #15848
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c07e308
neo4j_auradb init
luancazarine e738112
[Components] neo4j_auradb #15828
luancazarine fe20d21
pnpm update
luancazarine db334c4
remove unnecessary fields on source base file
luancazarine b2d0f83
Update components/neo4j_auradb/actions/create-node/create-node.mjs
luancazarine 809d933
some adjusts
luancazarine 6a52804
[ACTION] Calendly - List User Availability Schedules #15214
luancazarine 5a9d509
some adjusts
luancazarine 4c6dc82
remove console.log
luancazarine 7851e4e
some adjusts
luancazarine 7f799e8
some adjusts
luancazarine a5727de
Merge branch 'master' into issue-15828
luancazarine 86a432e
error validation added
luancazarine a42e850
Merge branch 'issue-15828' of https://github.com/PipedreamHQ/pipedrea…
luancazarine 5d1867f
pnpm update
luancazarine e66ff59
remove wrong file
luancazarine 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
41 changes: 41 additions & 0 deletions
41
components/neo4j_auradb/actions/create-node/create-node.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,41 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import app from "../../neo4j_auradb.app.mjs"; | ||
|
||
export default { | ||
key: "neo4j_auradb-create-node", | ||
name: "Create Node", | ||
description: "Creates a new node in the Neo4j AuraDB instance. [See the documentation](https://neo4j.com/docs/query-api/current/query/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
nodeLabel: { | ||
type: "string", | ||
label: "Node Label", | ||
description: "The label of the node to filter events for new node creation.", | ||
}, | ||
nodeProperties: { | ||
type: "object", | ||
label: "Create Node Properties", | ||
description: "An object representing the properties of the node to create.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createNode({ | ||
$, | ||
label: this.nodeLabel, | ||
properties: parseObject(this.nodeProperties), | ||
}); | ||
|
||
if (response.errors) { | ||
throw new ConfigurationError(response.errors[0].message); | ||
} | ||
|
||
const elementId = response.data?.values?.[0]?.[0]?.elementId; | ||
$.export("$summary", elementId | ||
? `Created node with id ${elementId}` | ||
: "Node created successfully"); | ||
return response; | ||
}, | ||
}; |
48 changes: 48 additions & 0 deletions
48
components/neo4j_auradb/actions/create-relationship/create-relationship.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,48 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import app from "../../neo4j_auradb.app.mjs"; | ||
|
||
export default { | ||
key: "neo4j_auradb-create-relationship", | ||
name: "Create Relationship", | ||
description: "Creates a relationship between two existing nodes. [See the documentation](https://neo4j.com/docs/query-api/current/query/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
relationshipType: { | ||
type: "string", | ||
label: "Create Relationship Type", | ||
description: "The name of the relationship to create.", | ||
}, | ||
startNode: { | ||
type: "object", | ||
label: "Start Node Identifier", | ||
description: "An object containing any fields used to identify the start node.", | ||
}, | ||
endNode: { | ||
type: "object", | ||
label: "End Node Identifier", | ||
description: "An object containing any fields used to identify the end node.", | ||
}, | ||
relationshipProperties: { | ||
type: "object", | ||
label: "Create Relationship Properties", | ||
description: "An object representing the properties of the relationship to create.", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.createRelationship({ | ||
$, | ||
relationshipType: this.relationshipType, | ||
startNode: parseObject(this.startNode), | ||
endNode: parseObject(this.endNode), | ||
relationshipProperties: parseObject(this.relationshipProperties), | ||
}); | ||
$.export( | ||
"$summary", | ||
`Created relationship '${this.relationshipType}' between nodes`, | ||
); | ||
return response; | ||
}, | ||
}; |
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,25 @@ | ||
import app from "../../neo4j_auradb.app.mjs"; | ||
|
||
export default { | ||
key: "neo4j_auradb-run-query", | ||
name: "Run Cypher Query", | ||
description: "Executes a Cypher query against the Neo4j AuraDB instance. [See the documentation](https://neo4j.com/docs/query-api/current/query/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
cypherQuery: { | ||
type: "string", | ||
label: "Execute Cypher Query", | ||
description: "A valid Cypher query to execute against the Neo4j AuraDB instance.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.app.executeCypherQuery({ | ||
$, | ||
cypherQuery: this.cypherQuery, | ||
}); | ||
$.export("$summary", "Executed Cypher query successfully"); | ||
return response; | ||
}, | ||
}; |
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,16 @@ | ||
export const LIMIT = 100; | ||
|
||
export const ORDER_TYPE_OPTIONS = [ | ||
{ | ||
label: "DateTime", | ||
value: "datetime", | ||
}, | ||
{ | ||
label: "Sequential (Integer)", | ||
value: "sequential", | ||
}, | ||
{ | ||
label: "Other", | ||
value: "other", | ||
}, | ||
]; |
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,24 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; |
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 |
---|---|---|
@@ -1,11 +1,109 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import { LIMIT } from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "neo4j_auradb", | ||
propDefinitions: {}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return `${this.$auth.api_url}`; | ||
}, | ||
_auth() { | ||
return { | ||
username: `${this.$auth.username}`, | ||
password: `${this.$auth.password}`, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path = "", ...opts | ||
}) { | ||
return axios($, { | ||
url: this._baseUrl() + path, | ||
auth: this._auth(), | ||
...opts, | ||
}); | ||
}, | ||
createNode({ | ||
label, properties, ...opts | ||
}) { | ||
const cypher = `CREATE (n:${label} $properties) RETURN n AS Node`; | ||
return this._makeRequest({ | ||
method: "POST", | ||
data: { | ||
statement: cypher, | ||
parameters: { | ||
properties, | ||
}, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
createRelationship({ | ||
relationshipType, | ||
startNode, | ||
endNode, | ||
relationshipProperties = {}, | ||
...opts | ||
}) { | ||
const stringStartNode = JSON.stringify(startNode).replace(/"[^"]*":/g, (match) => match.replace(/"/g, "")); | ||
const stringEndNode = JSON.stringify(endNode).replace(/"[^"]*":/g, (match) => match.replace(/"/g, "")); | ||
const cypher = ` | ||
MATCH (a ${stringStartNode}) | ||
MATCH (b ${stringEndNode}) | ||
CREATE (a)-[r:${relationshipType} $properties]->(b) | ||
RETURN r | ||
`; | ||
return this._makeRequest({ | ||
method: "POST", | ||
data: { | ||
statement: cypher, | ||
parameters: { | ||
startNode, | ||
endNode, | ||
properties: relationshipProperties, | ||
}, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
executeCypherQuery({ | ||
cypherQuery, ...opts | ||
}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
data: { | ||
statement: cypherQuery, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
async *paginate({ | ||
query, maxResults = null, | ||
}) { | ||
let hasMore = false; | ||
let count = 0; | ||
let page = 0; | ||
let cypherQuery = ""; | ||
|
||
do { | ||
cypherQuery = `${query} SKIP ${LIMIT * page} LIMIT ${LIMIT}`; | ||
page++; | ||
|
||
const { data: { values } } = await this.executeCypherQuery({ | ||
cypherQuery, | ||
}); | ||
for (const d of values) { | ||
yield d[0]; | ||
|
||
if (maxResults && ++count === maxResults) { | ||
return count; | ||
} | ||
} | ||
|
||
hasMore = values.length; | ||
|
||
} while (hasMore); | ||
}, | ||
}, | ||
}; |
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
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.