forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Components - neuronwriter (PipedreamHQ#12155)
* neuronwriter init * [Components] neuronwriter PipedreamHQ#12067 Webhooks - New Query Processed - New Done Query Actions - Create New Query - Get Query Details - Get Content Saved * pnpm update * Update components/neuronwriter/package.json Co-authored-by: Jorge Cortes <[email protected]> * some adjusts --------- Co-authored-by: Jorge Cortes <[email protected]>
- Loading branch information
1 parent
eea62dd
commit 0023fa2
Showing
12 changed files
with
1,256 additions
and
7 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
components/neuronwriter/actions/create-new-query/create-new-query.mjs
This file contains 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,46 @@ | ||
import { | ||
ENGINE_OPTIONS, LANGUAGE_OPTIONS, | ||
} from "../../common/constants.mjs"; | ||
import neuronwriter from "../../neuronwriter.app.mjs"; | ||
|
||
export default { | ||
key: "neuronwriter-create-new-query", | ||
name: "Create New Query", | ||
description: "Launches a new query based on provided keyword, search engine, and language. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-new-query)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neuronwriter, | ||
keyword: { | ||
type: "string", | ||
label: "Keyword", | ||
description: "The keyword to generate a query and recommendations for.", | ||
}, | ||
searchEngine: { | ||
type: "string", | ||
label: "Search Engine", | ||
description: "Preferred search engine.", | ||
options: ENGINE_OPTIONS, | ||
}, | ||
language: { | ||
type: "string", | ||
label: "Language", | ||
description: "Content language.", | ||
options: LANGUAGE_OPTIONS, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.neuronwriter.createNewQuery({ | ||
$, | ||
data: { | ||
project: this.neuronwriter.$auth.project_id, | ||
keyword: this.keyword, | ||
engine: this.searchEngine, | ||
language: this.language, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created new query with Id: ${response.query}`); | ||
return response; | ||
}, | ||
}; |
28 changes: 28 additions & 0 deletions
28
components/neuronwriter/actions/get-content-saved/get-content-saved.mjs
This file contains 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 neuronwriter from "../../neuronwriter.app.mjs"; | ||
|
||
export default { | ||
key: "neuronwriter-get-content-saved", | ||
name: "Get Content Saved", | ||
description: "Pulls the most recent revision of the content saved for a specific query. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-get-content)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neuronwriter, | ||
queryId: { | ||
propDefinition: [ | ||
neuronwriter, | ||
"queryId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.neuronwriter.getContent({ | ||
$, | ||
data: { | ||
query: this.queryId, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully retrieved the content for query ID ${this.queryId}`); | ||
return response; | ||
}, | ||
}; |
33 changes: 33 additions & 0 deletions
33
components/neuronwriter/actions/get-query-details/get-query-details.mjs
This file contains 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,33 @@ | ||
import neuronwriter from "../../neuronwriter.app.mjs"; | ||
|
||
export default { | ||
key: "neuronwriter-get-query-details", | ||
name: "Get Query Details", | ||
description: "Fetches the data related to a pre-defined query. [See the documentation](https://contadu.crisp.help/en/article/neuronwriter-api-how-to-use-2ds6hx/#3-get-query)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
neuronwriter, | ||
queryId: { | ||
propDefinition: [ | ||
neuronwriter, | ||
"queryId", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.neuronwriter.getQueryResults({ | ||
data: { | ||
query: this.queryId, | ||
}, | ||
}); | ||
|
||
let summary = `Successfully fetched query details for Query ID: ${this.queryId}`; | ||
if (response.status != "ready") { | ||
summary = `Query is not ready. Current status: ${response.status}`; | ||
} | ||
|
||
$.export("$summary", summary); | ||
return response; | ||
}, | ||
}; |
Oops, something went wrong.