Skip to content

Commit 3fd6e36

Browse files
authored
Merge branch 'master' into issue-12416
2 parents fe95c94 + 8f75260 commit 3fd6e36

File tree

256 files changed

+8799
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+8799
-324
lines changed

.github/ISSUE_TEMPLATE/app---service-integration.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ name: App / Integration Request
33
about: Request for a new API integration
44
title: "[APP]"
55
labels: app, enhancement
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
**Name of app / service**
1110

1211
**Link to developer documentation**
1312

14-
**Is lack of support preventing you from building workflows, or do you have a workaround?**
13+
**Is lack of support preventing you from moving forward, or do you have a workaround?**
1514

16-
**Are there specific actions, or triggers, you'd like to see for this app? Please let us know here or use the Action and Trigger issue templates to open requests for each!**
15+
**Are there specific actions or triggers, you'd like to see for this app? Please let us know here or use the Action and Trigger issue templates to open requests for each!**

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ name: Bug report
33
about: File bugs here
44
title: "[BUG] "
55
labels: bug
6-
assignees: ''
7-
6+
assignees: ""
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is. Note that this issue will be displayed publicly.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -23,16 +23,5 @@ A clear and concise description of what you expected to happen.
2323
**Screenshots**
2424
If applicable, add screenshots to help explain your problem. Note that the screenshots will be displayed publicly.
2525

26-
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
30-
31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
36-
3726
**Additional context**
3827
Add any other context about the problem here.

components/apify/actions/get-dataset-items/get-dataset-items.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "apify-get-dataset-items",
66
name: "Get Dataset Items",
77
description: "Returns data stored in a dataset. [See the documentation](https://docs.apify.com/api/v2/dataset-items-get)",
8-
version: "0.0.1",
8+
version: "0.0.2",
99
type: "action",
1010
props: {
1111
apify,

components/apify/actions/run-actor/run-actor.mjs

Lines changed: 143 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/* eslint-disable no-unused-vars */
22
import apify from "../../apify.app.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
4+
import { EVENT_TYPES } from "../../common/constants.mjs";
35

46
export default {
57
key: "apify-run-actor",
68
name: "Run Actor",
79
description: "Performs an execution of a selected actor in Apify. [See the documentation](https://docs.apify.com/api/v2#/reference/actors/run-collection/run-actor)",
8-
version: "0.0.2",
10+
version: "0.0.3",
911
type: "action",
1012
props: {
1113
apify,
@@ -14,6 +16,52 @@ export default {
1416
apify,
1517
"actorId",
1618
],
19+
},
20+
buildId: {
21+
propDefinition: [
22+
apify,
23+
"buildId",
24+
(c) => ({
25+
actorId: c.actorId,
26+
}),
27+
],
28+
reloadProps: true,
29+
},
30+
runAsynchronously: {
31+
type: "boolean",
32+
label: "Run Asynchronously",
33+
description: "Set to `true` to run the actor asynchronously",
34+
reloadProps: true,
35+
},
36+
timeout: {
37+
type: "string",
38+
label: "Timeout",
39+
description: "Optional timeout for the run, in seconds. By default, the run uses a timeout specified in the default run configuration for the Actor.",
40+
optional: true,
41+
},
42+
memory: {
43+
type: "string",
44+
label: "Memory",
45+
description: "Memory limit for the run, in megabytes. The amount of memory can be set to a power of 2 with a minimum of 128. By default, the run uses a memory limit specified in the default run configuration for the Actor.",
46+
optional: true,
47+
},
48+
maxItems: {
49+
type: "string",
50+
label: "Max Items",
51+
description: "The maximum number of items that the Actor run should return. This is useful for pay-per-result Actors, as it allows you to limit the number of results that will be charged to your subscription. You can access the maximum number of items in your Actor by using the ACTOR_MAX_PAID_DATASET_ITEMS environment variable.",
52+
optional: true,
53+
},
54+
maxTotalChargeUsd: {
55+
type: "string",
56+
label: "Max Total Charge USD",
57+
description: "Specifies the maximum cost of the Actor run. This parameter is useful for pay-per-event Actors, as it allows you to limit the amount charged to your subscription. You can access the maximum cost in your Actor by using the ACTOR_MAX_TOTAL_CHARGE_USD environment variable.",
58+
optional: true,
59+
},
60+
webhook: {
61+
type: "string",
62+
label: "Webhook",
63+
description: "Specifies optional webhook associated with the Actor run, which can be used to receive a notification e.g. when the Actor finished or failed.",
64+
optional: true,
1765
reloadProps: true,
1866
},
1967
},
@@ -28,16 +76,14 @@ export default {
2876
? type
2977
: "string[]";
3078
},
31-
async getSchema() {
32-
const { data: { items: builds } } = await this.apify.listBuilds(this.actorId);
33-
const buildId = builds.at(-1).id;
79+
async getSchema(buildId) {
3480
const { data: { inputSchema } } = await this.apify.getBuild(buildId);
3581
return JSON.parse(inputSchema);
3682
},
3783
async prepareData(data) {
3884
const newData = {};
3985

40-
const { properties } = await this.getSchema();
86+
const { properties } = await this.getSchema(this.buildId);
4187
for (const [
4288
key,
4389
value,
@@ -85,27 +131,64 @@ export default {
85131
},
86132
async additionalProps() {
87133
const props = {};
88-
if (this.actorId) {
89-
const {
90-
properties, required: requiredProps = [],
91-
} = await this.getSchema();
134+
if (this.buildId) {
135+
try {
136+
const {
137+
properties, required: requiredProps = [],
138+
} = await this.getSchema(this.buildId);
92139

93-
for (const [
94-
key,
95-
value,
96-
] of Object.entries(properties)) {
97-
if (value.editor === "hidden") continue;
140+
for (const [
141+
key,
142+
value,
143+
] of Object.entries(properties)) {
144+
if (value.editor === "hidden") continue;
98145

99-
props[key] = {
100-
type: this.getType(value.type),
101-
label: value.title,
102-
description: value.description,
103-
optional: !requiredProps.includes(key),
146+
props[key] = {
147+
type: this.getType(value.type),
148+
label: value.title,
149+
description: value.description,
150+
optional: !requiredProps.includes(key),
151+
};
152+
const options = this.prepareOptions(value);
153+
if (options) props[key].options = options;
154+
if (value.default) {
155+
props[key].description += ` Default: \`${JSON.stringify(value.default)}\``;
156+
if (props[key].type !== "object") { // default values don't work properly for object props
157+
props[key].default = value.default;
158+
}
159+
}
160+
}
161+
} catch {
162+
props.properties = {
163+
type: "object",
164+
label: "Properties",
165+
description: "Properties to set for this actor",
166+
};
167+
}
168+
if (this.runAsynchronously) {
169+
props.outputRecordKey = {
170+
type: "string",
171+
label: "Output Record Key",
172+
description: "Key of the record from run's default key-value store to be returned in the response. By default, it is OUTPUT.",
173+
optional: true,
174+
};
175+
} else {
176+
props.waitForFinish = {
177+
type: "string",
178+
label: "Wait For Finish",
179+
description: "The maximum number of seconds the server waits for the run to finish. By default, it is 0, the maximum value is 60. If the build finishes in time then the returned run object will have a terminal status (e.g. SUCCEEDED), otherwise it will have a transitional status (e.g. RUNNING).",
180+
optional: true,
104181
};
105-
const options = this.prepareOptions(value);
106-
if (options) props[key].options = options;
107182
}
108183
}
184+
if (this.webhook) {
185+
props.eventTypes = {
186+
type: "string[]",
187+
label: "Event Types",
188+
description: "The types of events to send to the webhook",
189+
options: EVENT_TYPES,
190+
};
191+
}
109192
return props;
110193
},
111194
async run({ $ }) {
@@ -117,14 +200,50 @@ export default {
117200
prepareData,
118201
apify,
119202
actorId,
203+
buildId,
204+
properties,
205+
runAsynchronously,
206+
outputRecordKey,
207+
timeout,
208+
memory,
209+
maxItems,
210+
maxTotalChargeUsd,
211+
waitForFinish,
212+
webhook,
213+
eventTypes,
120214
...data
121215
} = this;
122216

123-
const response = await apify.runActor({
217+
const fn = runAsynchronously
218+
? apify.runActorAsynchronously
219+
: apify.runActor;
220+
221+
const response = await fn({
124222
actorId,
125-
data: await prepareData(data),
223+
data: properties
224+
? parseObject(properties)
225+
: await prepareData(data),
226+
params: {
227+
outputRecordKey,
228+
timeout,
229+
memory,
230+
maxItems,
231+
maxTotalChargeUsd,
232+
waitForFinish,
233+
webhooks: webhook
234+
? btoa(JSON.stringify([
235+
{
236+
eventTypes,
237+
requestUrl: webhook,
238+
},
239+
]))
240+
: undefined,
241+
},
126242
});
127-
$.export("$summary", `Successfully started actor run with ID: ${response.data.id}`);
243+
const summary = this.runAsynchronously
244+
? `Successfully started actor run with ID: ${response.data.id}`
245+
: `Successfully ran actor with ID: ${this.actorId}`;
246+
$.export("$summary", `${summary}`);
128247
return response;
129248
},
130249
};

components/apify/actions/run-task-synchronously/run-task-synchronously.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "apify-run-task-synchronously",
55
name: "Run Task Synchronously",
66
description: "Run a specific task and return its dataset items. [See the documentation](https://docs.apify.com/api/v2/actor-task-run-sync-get-dataset-items-get)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
apify,

components/apify/actions/scrape-single-url/scrape-single-url.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "apify-scrape-single-url",
66
name: "Scrape Single URL",
77
description: "Executes a scraper on a specific website and returns its content as text. This action is perfect for extracting content from a single page.",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
apify,

components/apify/actions/set-key-value-store-record/set-key-value-store-record.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "apify-set-key-value-store-record",
66
name: "Set Key-Value Store Record",
77
description: "Create or update a record in the key-value store of Apify. [See the documentation](https://docs.apify.com/api/v2#/reference/key-value-stores/record-collection/put-record)",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
apify,

components/apify/apify.app.mjs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default {
2929
actorId: {
3030
type: "string",
3131
label: "Actor ID",
32-
description: "The ID of the actor to run.",
32+
description: "Actor ID or a tilde-separated owner's username and Actor name",
3333
async options({ page }) {
3434
const { data: { items } } = await this.listActors({
3535
params: {
@@ -105,6 +105,23 @@ export default {
105105
})) || [];
106106
},
107107
},
108+
buildId: {
109+
type: "string",
110+
label: "Build",
111+
description: "Specifies the Actor build to run. It can be either a build tag or build number.",
112+
async options({
113+
page, actorId,
114+
}) {
115+
const { data: { items } } = await this.listBuilds({
116+
actorId,
117+
params: {
118+
offset: LIMIT * page,
119+
limit: LIMIT,
120+
},
121+
});
122+
return items?.map(({ id }) => id) || [];
123+
},
124+
},
108125
clean: {
109126
type: "boolean",
110127
label: "Clean",
@@ -171,6 +188,15 @@ export default {
171188
},
172189
runActor({
173190
actorId, ...opts
191+
}) {
192+
return this._makeRequest({
193+
method: "POST",
194+
path: `/acts/${actorId}/run-sync`,
195+
...opts,
196+
});
197+
},
198+
runActorAsynchronously({
199+
actorId, ...opts
174200
}) {
175201
return this._makeRequest({
176202
method: "POST",
@@ -207,7 +233,7 @@ export default {
207233
...opts,
208234
});
209235
},
210-
listBuilds(actorId) {
236+
listBuilds({ actorId }) {
211237
return this._makeRequest({
212238
path: `/acts/${actorId}/builds`,
213239
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
export const ACTOR_ID = "aYG0l9s7dbB7j3gbS";
22
export const LIMIT = 100;
3+
4+
export const EVENT_TYPES = [
5+
"ACTOR.RUN.CREATED",
6+
"ACTOR.RUN.SUCCEEDED",
7+
"ACTOR.RUN.FAILED",
8+
"ACTOR.RUN.ABORTED",
9+
"ACTOR.RUN.TIMED_OUT",
10+
"ACTOR.RUN.RESURRECTED",
11+
];

components/apify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/apify",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "Pipedream Apify Components",
55
"main": "apify.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)