forked from activepieces/activepieces
-
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.
Merge pull request activepieces#6059 from buttonsbond/main
feat(apify): get actors ,get database items and get last run actions
- Loading branch information
Showing
11 changed files
with
263 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
{ | ||
"extends": [ | ||
"../../../../.eslintrc.base.json" | ||
], | ||
"ignorePatterns": [ | ||
"!**/*" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx", | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.ts", | ||
"*.tsx" | ||
], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": [ | ||
"*.js", | ||
"*.jsx" | ||
], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,7 @@ | ||
# pieces-apify | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build pieces-apify` to build the library. |
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,4 @@ | ||
{ | ||
"name": "@activepieces/piece-apify", | ||
"version": "0.0.1" | ||
} |
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,45 @@ | ||
{ | ||
"name": "pieces-apify", | ||
"$schema": "../../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/pieces/community/apify/src", | ||
"projectType": "library", | ||
"release": { | ||
"version": { | ||
"generatorOptions": { | ||
"packageRoot": "dist/{projectRoot}", | ||
"currentVersionResolver": "git-tag" | ||
} | ||
} | ||
}, | ||
"tags": [], | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": [ | ||
"{options.outputPath}" | ||
], | ||
"options": { | ||
"outputPath": "dist/packages/pieces/community/apify", | ||
"tsConfig": "packages/pieces/community/apify/tsconfig.lib.json", | ||
"packageJson": "packages/pieces/community/apify/package.json", | ||
"main": "packages/pieces/community/apify/src/index.ts", | ||
"assets": [ | ||
"packages/pieces/community/apify/*.md" | ||
], | ||
"buildableProjectDepsInPackageJsonType": "dependencies", | ||
"updateBuildableProjectDepsInPackageJson": true | ||
} | ||
}, | ||
"nx-release-publish": { | ||
"options": { | ||
"packageRoot": "dist/{projectRoot}" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint", | ||
"outputs": [ | ||
"{options.outputFile}" | ||
] | ||
} | ||
} | ||
} |
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,35 @@ | ||
import { createPiece, PieceAuth } from '@activepieces/pieces-framework'; | ||
import { PieceCategory } from '@activepieces/shared'; | ||
import { getDatasetItems } from './lib/actions/get-dataset-items'; | ||
import { getActors } from './lib/actions/get-actors'; | ||
import { getLastRun } from './lib/actions/get-last-run'; | ||
|
||
export const apifyAuth = PieceAuth.SecretText({ | ||
displayName: 'API Key', | ||
required: true, | ||
description: | ||
'Find your API key on Apify in the settings, API & Integrations section.', | ||
validate: async ({ auth }) => { | ||
if (auth) { | ||
return { | ||
valid: true, | ||
}; | ||
} | ||
return { | ||
valid: false, | ||
error: 'Invalid API Key', | ||
}; | ||
}, | ||
}); | ||
|
||
export const apify = createPiece({ | ||
displayName: 'Apify', | ||
description: 'Your full‑stack platform for web scraping', | ||
auth: apifyAuth, | ||
minimumSupportedRelease: '0.20.0', | ||
logoUrl: 'https://cdn.activepieces.com/pieces/apify.svg', | ||
categories: [PieceCategory.BUSINESS_INTELLIGENCE], | ||
authors: ['buttonsbond'], | ||
actions: [getDatasetItems, getActors, getLastRun], | ||
triggers: [], | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/pieces/community/apify/src/lib/actions/get-actors.ts
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,29 @@ | ||
import { createAction } from '@activepieces/pieces-framework'; | ||
import { apifyAuth } from '../..'; | ||
import { httpClient, HttpMethod } from '@activepieces/pieces-common'; | ||
|
||
export const getActors = createAction({ | ||
name: 'getActors', | ||
auth: apifyAuth, | ||
displayName: "Get user's Actors", | ||
description: 'Gets the list of Actors available to the user.', | ||
props: {}, | ||
async run(context) { | ||
const apifyToken = context.auth; | ||
const headers = { | ||
Authorization: 'Bearer ' + apifyToken, | ||
'Content-Type': 'application/json', | ||
}; | ||
|
||
const url = 'https://api.apify.com/v2/acts/'; | ||
|
||
const httprequestdata = { | ||
method: HttpMethod.GET, | ||
url, | ||
headers, | ||
}; | ||
|
||
const response = await httpClient.sendRequest(httprequestdata); | ||
return response.body; | ||
}, | ||
}); |
38 changes: 38 additions & 0 deletions
38
packages/pieces/community/apify/src/lib/actions/get-dataset-items.ts
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,38 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { apifyAuth } from '../..'; | ||
import { httpClient, HttpMethod } from '@activepieces/pieces-common'; | ||
|
||
export const getDatasetItems = createAction({ | ||
name: 'getDatasetItems', | ||
auth: apifyAuth, | ||
displayName: 'Get Dataset Items', | ||
description: 'Gets the data from an Actors run.', | ||
props: { | ||
runid: Property.ShortText({ | ||
displayName: 'The runid of the Actor (alphanumeric)', | ||
description: 'The runid of the completed Actors run (compulsory).', | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
const apifyToken = context.auth; | ||
const headers = { | ||
Authorization: 'Bearer ' + apifyToken, | ||
'Content-Type': 'application/json', | ||
}; | ||
|
||
const url = | ||
'https://api.apify.com/v2/datasets/' + | ||
context.propsValue.runid + | ||
'/items/'; | ||
|
||
const httprequestdata = { | ||
method: HttpMethod.GET, | ||
url, | ||
headers, | ||
}; | ||
|
||
const response = await httpClient.sendRequest(httprequestdata); | ||
return response.body; | ||
}, | ||
}); |
39 changes: 39 additions & 0 deletions
39
packages/pieces/community/apify/src/lib/actions/get-last-run.ts
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,39 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { apifyAuth } from '../..'; | ||
import { httpClient, HttpMethod } from '@activepieces/pieces-common'; | ||
|
||
export const getLastRun = createAction({ | ||
name: 'getLastRun', | ||
auth: apifyAuth, | ||
displayName: 'Get last run details', | ||
description: 'Gets last run details for a given Actor.', | ||
props: { | ||
actorid: Property.ShortText({ | ||
displayName: 'The id of the Actor (alphanumeric)', | ||
description: | ||
'The id of the Actor to get run information [item of interest:defaultDatasetId] (compulsory)', | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
const apifyToken = context.auth; | ||
const headers = { | ||
Authorization: 'Bearer ' + apifyToken, | ||
'Content-Type': 'application/json', | ||
}; | ||
|
||
const url = | ||
'https://api.apify.com/v2/acts/' + | ||
context.propsValue.actorid + | ||
'/runs/last?status=SUCCEEDED'; | ||
|
||
const httprequestdata = { | ||
method: HttpMethod.GET, | ||
url, | ||
headers, | ||
}; | ||
|
||
const response = await httpClient.sendRequest(httprequestdata); | ||
return response.body; | ||
}, | ||
}); |
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,19 @@ | ||
{ | ||
"extends": "../../../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"], | ||
"include": ["src/**/*.ts"] | ||
} |
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