Skip to content

Commit c494b3b

Browse files
authored
feat: add defaultBuild method (#668)
This PR adds `defaultBuild()` method to Actor client
1 parent ed169e3 commit c494b3b

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/resource_clients/actor.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
77
import type { ActorVersion} from './actor_version';
88
import { ActorVersionClient } from './actor_version';
99
import { ActorVersionCollectionClient } from './actor_version_collection';
10-
import type { Build } from './build';
10+
import type { Build, BuildClientGetOptions } from './build';
1111
import { BuildCollectionClient } from './build_collection';
1212
import { RunClient } from './run';
1313
import { RunCollectionClient } from './run_collection';
@@ -161,6 +161,19 @@ export class ActorClient extends ResourceClient {
161161
return cast(parseDateFields(pluckData(response.data)));
162162
}
163163

164+
/**
165+
* https://docs.apify.com/api/v2/act-build-default-get
166+
*/
167+
async defaultBuild(options: BuildClientGetOptions = {}): Promise<Build> {
168+
const response = await this.httpClient.call({
169+
url: this._url('builds/default'),
170+
method: 'GET',
171+
params: this._params(options),
172+
});
173+
174+
return cast(parseDateFields(pluckData(response.data)));
175+
}
176+
164177
/**
165178
* https://docs.apify.com/api/v2#/reference/actors/last-run-object-and-its-storages
166179
*/

test/actors.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ describe('Actor methods', () => {
103103
validateRequest({}, { actorId });
104104
});
105105

106+
test('defaultBuild() works', async () => {
107+
const actorId = 'some-id';
108+
109+
const res = await client.actor(actorId).defaultBuild();
110+
expect(res.id).toEqual('get-default-build');
111+
validateRequest({}, { actorId });
112+
113+
const browserRes = await page.evaluate((id) => client.actor(id).defaultBuild(), actorId);
114+
expect(browserRes).toEqual(res);
115+
validateRequest({}, { actorId });
116+
});
117+
106118
test('delete() works', async () => {
107119
const actorId = '204';
108120
const res = await client.actor(actorId).delete();

test/mock_server/routes/actors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const ROUTES = [
2323
{ id: 'resurrect-run', method: 'POST', path: '/:actorId/runs/:runId/resurrect' },
2424
{ id: 'list-builds', method: 'GET', path: '/:actorId/builds' },
2525
{ id: 'build-actor', method: 'POST', path: '/:actorId/builds' },
26+
{ id: 'get-default-build', method: 'GET', path: '/:actorId/builds/default', type: 'responseJsonMock' },
2627
{ id: 'get-build', method: 'GET', path: '/:actorId/builds/:buildId', type: 'responseJsonMock' },
2728
{ id: 'abort-build', method: 'POST', path: '/:actorId/builds/:buildId/abort' },
2829
{ id: 'list-actor-versions', method: 'GET', path: '/:actorId/versions' },

0 commit comments

Comments
 (0)