diff --git a/components/apify/apify.app.mjs b/components/apify/apify.app.mjs index 8f9c2e6c3fbd9..4fe1e06278b29 100644 --- a/components/apify/apify.app.mjs +++ b/components/apify/apify.app.mjs @@ -32,18 +32,10 @@ export default { page, actorSource, }) { actorSource ??= "recently-used"; - const listFn = actorSource === "store" - ? this.listActors - : this.listUserActors; - const { items } = await listFn({ - offset: LIMIT * page, - limit: LIMIT, + return await this.getActorOptions({ + page, + actorSource, }); - - return items.map((actor) => ({ - label: this.formatActorOrTaskLabel(actor), - value: actor.id, - })); }, }, taskId: { @@ -149,6 +141,23 @@ export default { ], }); }, + async getActorOptions({ + page = 0, actorSource = "recently-used", + }) { + const listFn = actorSource === "store" + ? this.listActors + : this.listUserActors; + + const { items } = await listFn({ + offset: LIMIT * page, + limit: LIMIT, + }); + + return items.map((actor) => ({ + label: this.formatActorOrTaskLabel(actor), + value: actor.id, + })); + }, getAuthToken() { return this.$auth.api_token; }, @@ -217,7 +226,6 @@ export default { listUserActors(opts = {}) { return this._client().actors() .list({ - my: true, sortBy: "stats.lastRunStartedAt", desc: true, ...opts, diff --git a/components/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs b/components/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs index 14611eda57639..8e195953fe796 100644 --- a/components/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs +++ b/components/apify/sources/new-finished-actor-run-instant/new-finished-actor-run-instant.mjs @@ -1,24 +1,54 @@ import common from "../common/base.mjs"; import sampleEmit from "./test-event.mjs"; +import apify from "../../apify.app.mjs"; export default { ...common, key: "apify-new-finished-actor-run-instant", name: "New Finished Actor Run (Instant)", description: "Emit new event when a selected Actor is run and finishes.", - version: "0.0.5", + version: "0.0.6", type: "source", dedupe: "unique", props: { ...common.props, db: "$.service.db", - actorId: { - propDefinition: [ - common.props.apify, - "actorId", + apify, + actorSource: { + type: "string", + label: "Search Actors from", + description: "Where to search for Actors. Valid options are Store and Recently used Actors.", + options: [ + { + label: "Apify Store Actors", + value: "store", + }, + { + label: "Recently used Actors", + value: "recently-used", + }, ], + default: "recently-used", + reloadProps: true, }, }, + additionalProps() { + const props = {}; + + if (this.actorSource) { + props.actorId = { + ...apify.propDefinitions.actorId, // it doesn't contain options() method + options: async ({ page }) => { + return await this.apify.getActorOptions({ + page, + actorSource: this.actorSource, + }); + }, + }; + } + + return props; + }, methods: { ...common.methods, getCondition() {