Skip to content

Commit 84b1ce8

Browse files
authored
fix: Fix type used for options argument of Actor.start (#524)
- Use the correct type for `options` argument of `Actor.start` method. Previously used similar type `CallOptions` had a field `waitSecs`, which is not valid in `Actor.start` method.
1 parent 6bb337b commit 84b1ce8

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

packages/apify/src/actor.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import type {
2626
import { sleep, snakeCaseToCamelCase } from '@crawlee/utils';
2727
import type {
2828
ActorCallOptions,
29+
ActorStartOptions,
2930
ApifyClientOptions,
3031
RunAbortOptions,
3132
TaskCallOptions,
@@ -227,40 +228,37 @@ export interface ApifyEnv {
227228

228229
export type UserFunc<T = unknown> = () => Awaitable<T>;
229230

230-
export interface CallOptions extends Omit<ActorCallOptions, 'timeout'> {
231+
export interface Token {
231232
/**
232-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
233+
* User Apify API token that is used for API calls. By default, it is taken from the `APIFY_TOKEN` environment variable.
233234
*/
234235
token?: string;
235-
/**
236-
* Timeout for the Actor run in seconds, or `'inherit'`.
237-
*
238-
* Using `inherit` will set timeout of the newly started Actor run to the time
239-
* remaining until this Actor run times out so that the new run does not outlive this one.
240-
*/
241-
timeout?: number | 'inherit';
242236
}
243237

244-
export interface CallTaskOptions extends Omit<TaskCallOptions, 'timeout'> {
245-
/**
246-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
247-
*/
248-
token?: string;
238+
export interface Timeout {
249239
/**
250-
* Timeout for the Actor task in seconds, or `'inherit'`.
240+
* Timeout for the Actor run in seconds, or `'inherit'`.
251241
*
252-
* Using `inherit` will set timeout of the newly started Actor task to the time
242+
* Using `inherit` will set timeout of the newly started Actor run to the time
253243
* remaining until this Actor run times out so that the new run does not outlive this one.
254244
*/
255245
timeout?: number | 'inherit';
256246
}
257247

258-
export interface AbortOptions extends RunAbortOptions {
259-
/**
260-
* User API token that is used to run the Actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
261-
*/
262-
token?: string;
263-
248+
export interface CallOptions
249+
extends Omit<ActorCallOptions, 'timeout'>,
250+
Token,
251+
Timeout {}
252+
export interface StartOptions
253+
extends Omit<ActorStartOptions, 'waitForFinish' | 'timeout'>,
254+
Token,
255+
Timeout {}
256+
export interface CallTaskOptions
257+
extends Omit<TaskCallOptions, 'timeout'>,
258+
Token,
259+
Timeout {}
260+
261+
export interface AbortOptions extends RunAbortOptions, Token {
264262
/** Exit with given status message */
265263
statusMessage?: string;
266264
}
@@ -718,7 +716,7 @@ export class Actor<Data extends Dictionary = Dictionary> {
718716
async start(
719717
actorId: string,
720718
input?: unknown,
721-
options: CallOptions = {},
719+
options: StartOptions = {},
722720
): Promise<ClientActorRun> {
723721
const timeout =
724722
options.timeout === 'inherit'
@@ -1835,7 +1833,7 @@ export class Actor<Data extends Dictionary = Dictionary> {
18351833
static async start(
18361834
actorId: string,
18371835
input?: Dictionary,
1838-
options: CallOptions = {},
1836+
options: StartOptions = {},
18391837
): Promise<ClientActorRun> {
18401838
return Actor.getDefaultInstance().start(actorId, input, options);
18411839
}

0 commit comments

Comments
 (0)