Skip to content

Commit 8b89b6a

Browse files
feat(apify): Improve generating props from input schema
1 parent 76a38be commit 8b89b6a

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,34 @@ export default {
191191
optional: !requiredProps.includes(key),
192192
};
193193

194+
if (props[key].type === "string" && value.isSecret) {
195+
props[key].secret = value.isSecret;
196+
} else if (props[key].type === "integer") {
197+
props[key].min = value.minimum;
198+
props[key].max = value.maximum;
199+
if (value.unit) {
200+
props[key].description += ` Unit: ${value.unit}.`;
201+
}
202+
} else if (props[key].type === "boolean") {
203+
// Default all boolean properties to false
204+
props[key].default = false;
205+
}
206+
194207
const options = this.prepareOptions(value);
195208
if (options) props[key].options = options;
196209

197-
if (value.default) {
198-
props[key].description += ` Default: \`${JSON.stringify(value.default)}\``;
210+
const defaultValue = value.default ?? value.prefill;
211+
212+
if (defaultValue) {
199213
if (props[key].type !== "object") {
200-
props[key].default = value.default;
214+
props[key].default = defaultValue;
215+
216+
if (props[key].type === "string[]" && value.editor === "requestListSources") {
217+
props[key].default = defaultValue.map((request) => request.url);
218+
}
201219
}
220+
221+
props[key].description += ` Default: \`${JSON.stringify(defaultValue)}\``;
202222
}
203223
}
204224
} catch (e) {

components/apify/apify.app.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,16 @@ export default {
188188
throw new Error(`Actor ${actorId} not found.`);
189189
}
190190

191-
// Ensure "latest" build tag exists
192-
const latestBuild = actor.taggedBuilds?.latest;
193-
if (!latestBuild) {
191+
// Get the default build
192+
const { build: defaultBuildTag } = actor.defaultRunOptions;
193+
const build = actor.taggedBuilds[defaultBuildTag];
194+
if (!build) {
194195
throw new Error(
195-
`Actor ${actorId} has no build tagged "latest". Please build the actor first.`,
196+
`Actor ${actorId} has no build tagged "${defaultBuildTag}". Please build the actor first.`,
196197
);
197198
}
198199

199-
buildId = latestBuild.buildId;
200+
buildId = build.buildId;
200201
}
201202

202203
// Fetch the build by ID

0 commit comments

Comments
 (0)