Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/resource_clients/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { AxiosRequestConfig } from 'axios';
import ow from 'ow';

import type { RUN_GENERAL_ACCESS } from '@apify/consts';
import { ACT_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
import { ACTOR_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
import { Log } from '@apify/log';

import type { ApiClientSubResourceOptions } from '../base/api_client';
Expand All @@ -18,6 +18,7 @@ import { RunClient } from './run';
import { RunCollectionClient } from './run_collection';
import type { WebhookUpdateData } from './webhook';
import { WebhookCollectionClient } from './webhook_collection';
import type { ValueOf } from 'type-fest';

/**
* Client for managing a specific Actor.
Expand Down Expand Up @@ -371,7 +372,7 @@ export class ActorClient extends ResourceClient {
ow(
options,
ow.object.exactShape({
status: ow.optional.string.oneOf(Object.values(ACT_JOB_STATUSES)),
status: ow.optional.string.oneOf(Object.values(ACTOR_JOB_STATUSES)),
origin: ow.optional.string.oneOf(Object.values(META_ORIGINS)),
}),
);
Expand Down Expand Up @@ -708,7 +709,7 @@ export interface ActorRunListItem {
actorTaskId?: string;
startedAt: Date;
finishedAt: Date;
status: (typeof ACT_JOB_STATUSES)[keyof typeof ACT_JOB_STATUSES];
status: (typeof ACTOR_JOB_STATUSES)[keyof typeof ACTOR_JOB_STATUSES];
meta: ActorRunMeta;
buildId: string;
buildNumber: string;
Expand Down Expand Up @@ -843,7 +844,8 @@ export interface ActorBuildOptions {
* Options for filtering the last run of an Actor.
*/
export interface ActorLastRunOptions {
status?: keyof typeof ACT_JOB_STATUSES;
status?: ValueOf<typeof ACTOR_JOB_STATUSES>;
origin?: ValueOf<typeof META_ORIGINS>;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/resource_clients/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ResourceClient } from '../base/resource_client';
import type { ApifyRequestConfig } from '../http_client';
import type { Dictionary } from '../utils';
import { cast, catchNotFoundOrThrow, parseDateFields, pluckData, stringifyWebhooksToBase64 } from '../utils';
import type { ActorRun, ActorStandby, ActorStartOptions } from './actor';
import type { ActorLastRunOptions, ActorRun, ActorStandby, ActorStartOptions } from './actor';
import { RunClient } from './run';
import { RunCollectionClient } from './run_collection';
import { WebhookCollectionClient } from './webhook_collection';
Expand Down Expand Up @@ -322,9 +322,7 @@ export type TaskUpdateData = Partial<
/**
* Options for filtering the last run of a Task.
*/
export interface TaskLastRunOptions {
status?: keyof typeof ACT_JOB_STATUSES;
}
export interface TaskLastRunOptions extends ActorLastRunOptions {}

/**
* Options for starting a Task.
Expand Down
10 changes: 6 additions & 4 deletions test/actors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import express from 'express';
import type { Page } from 'puppeteer';
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';

import { WEBHOOK_EVENT_TYPES } from '@apify/consts';
import { META_ORIGINS, WEBHOOK_EVENT_TYPES } from '@apify/consts';
import { LEVELS, Log } from '@apify/log';

import { stringifyWebhooksToBase64 } from '../src/utils';
Expand Down Expand Up @@ -385,9 +385,11 @@ describe('Actor methods', () => {
'%s() works',
async (method) => {
const actorId = 'some-actor-id';
const requestedStatus = 'SUCCEEDED';
const requestedStatus = 'TIMING-OUT';

const lastRunClient = client.actor(actorId).lastRun({ status: requestedStatus });
const lastRunClient = client
.actor(actorId)
.lastRun({ status: requestedStatus, origin: META_ORIGINS.API });
const res = method === 'get' ? await lastRunClient.get() : await lastRunClient[method]().get();

const endpointIdMap = {
Expand All @@ -398,7 +400,7 @@ describe('Actor methods', () => {
log: 'last-run-log',
} as const;
validateRequest({
query: { status: requestedStatus },
query: { status: requestedStatus, origin: META_ORIGINS.API },
params: { actorId },
endpointId: endpointIdMap[method],
});
Expand Down
Loading