diff --git a/components/parsehub/actions/cancel-run/cancel-run.mjs b/components/parsehub/actions/cancel-run/cancel-run.mjs new file mode 100644 index 0000000000000..7de5c90887059 --- /dev/null +++ b/components/parsehub/actions/cancel-run/cancel-run.mjs @@ -0,0 +1,26 @@ +import app from "../../parsehub.app.mjs"; + +export default { + key: "parsehub-cancel-run", + name: "Cancel Run", + description: "Cancels a run and changes its status to cancelled. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#cancel-a-run)", + version: "0.0.1", + type: "action", + props: { + app, + runToken: { + propDefinition: [ + app, + "runToken", + ], + }, + }, + async run({ $ }) { + const response = await this.app.cancelRun({ + $, + runToken: this.runToken, + }); + $.export("$summary", "Successfully cancelled the run with token: " + this.runToken); + return response; + }, +}; diff --git a/components/parsehub/actions/delete-run/delete-run.mjs b/components/parsehub/actions/delete-run/delete-run.mjs new file mode 100644 index 0000000000000..08b51eb080e60 --- /dev/null +++ b/components/parsehub/actions/delete-run/delete-run.mjs @@ -0,0 +1,26 @@ +import app from "../../parsehub.app.mjs"; + +export default { + key: "parsehub-delete-run", + name: "Delete Run", + description: "Cancels a run if running, and deletes the run and its data. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#delete-a-run)", + version: "0.0.1", + type: "action", + props: { + app, + runToken: { + propDefinition: [ + app, + "runToken", + ], + }, + }, + async run({ $ }) { + const response = await this.app.deleteRun({ + $, + runToken: this.runToken, + }); + $.export("$summary", "Successfully deleted the run with token: " + this.runToken); + return response; + }, +}; diff --git a/components/parsehub/actions/get-data-run/get-data-run.mjs b/components/parsehub/actions/get-data-run/get-data-run.mjs index f5c924242e770..e2ecd3e181b76 100644 --- a/components/parsehub/actions/get-data-run/get-data-run.mjs +++ b/components/parsehub/actions/get-data-run/get-data-run.mjs @@ -4,7 +4,7 @@ export default { key: "parsehub-get-data-run", name: "Get Data for a Run", description: "Returns the data extracted by a specified run. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#get-data-for-a-run)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { app, diff --git a/components/parsehub/actions/get-project/get-project.mjs b/components/parsehub/actions/get-project/get-project.mjs index 71d9a0c0b301b..1784252af1c1c 100644 --- a/components/parsehub/actions/get-project/get-project.mjs +++ b/components/parsehub/actions/get-project/get-project.mjs @@ -4,7 +4,7 @@ export default { key: "parsehub-get-project", name: "Get Project Details", description: "Retrieves the details of a specified project within the user's account. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#get-a-project)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { app, diff --git a/components/parsehub/actions/get-projects/get-projects.mjs b/components/parsehub/actions/get-projects/get-projects.mjs new file mode 100644 index 0000000000000..cadea9f5b9732 --- /dev/null +++ b/components/parsehub/actions/get-projects/get-projects.mjs @@ -0,0 +1,35 @@ +import app from "../../parsehub.app.mjs"; + +export default { + key: "parsehub-get-projects", + name: "Get Projects", + description: "Lists all projects in your account [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#list-all-projects)", + version: "0.0.1", + type: "action", + props: { + app, + offset: { + propDefinition: [ + app, + "offset", + ], + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + }, + async run({ $ }) { + const response = await this.app.listProjects({ + $, + params: { + offset: this.offset, + limit: this.limit, + }, + }); + $.export("$summary", "Successfully listed your projects"); + return response; + }, +}; diff --git a/components/parsehub/actions/run-project/run-project.mjs b/components/parsehub/actions/run-project/run-project.mjs index a2cf015dda28e..6e78be68f88cc 100644 --- a/components/parsehub/actions/run-project/run-project.mjs +++ b/components/parsehub/actions/run-project/run-project.mjs @@ -4,7 +4,7 @@ export default { key: "parsehub-run-project", name: "Run Parsehub Project", description: "Initiates an instance of a specified project on the Parsehub cloud. [See the documentation](https://www.parsehub.com/docs/ref/api/v2/#run-a-project)", - version: "0.0.2", + version: "0.0.3", type: "action", props: { app, diff --git a/components/parsehub/package.json b/components/parsehub/package.json index c83d188417880..7604eda15c2ae 100644 --- a/components/parsehub/package.json +++ b/components/parsehub/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/parsehub", - "version": "0.1.1", + "version": "0.2.0", "description": "Pipedream ParseHub Components", "main": "parsehub.app.mjs", "keywords": [ diff --git a/components/parsehub/parsehub.app.mjs b/components/parsehub/parsehub.app.mjs index f3de672b6b67e..49af7acb46a9c 100644 --- a/components/parsehub/parsehub.app.mjs +++ b/components/parsehub/parsehub.app.mjs @@ -29,6 +29,18 @@ export default { label: "Start URL", description: "The url to start running on", }, + offset: { + type: "string", + label: "Offset", + description: "Specifies the offset from which to start listing the projects", + optional: true, + }, + limit: { + type: "string", + label: "Limit", + description: "Specifies how many entries will be returned in the list", + optional: true, + }, }, methods: { _baseUrl() { @@ -81,5 +93,23 @@ export default { ...args, }); }, + async cancelRun({ + runToken, ...args + }) { + return this._makeRequest({ + path: `/runs/${runToken}/cancel`, + method: "post", + ...args, + }); + }, + async deleteRun({ + runToken, ...args + }) { + return this._makeRequest({ + path: `/runs/${runToken}`, + method: "delete", + ...args, + }); + }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e11efdcd7858..b960ec306dec4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -35984,6 +35984,8 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) + transitivePeerDependencies: + - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: