Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add runs() and builds() top level endpoints #468

Merged
merged 4 commits into from
Feb 16, 2024
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
33 changes: 17 additions & 16 deletions src/apify_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RequestInterceptorFunction } from './interceptors';
import { ActorClient } from './resource_clients/actor';
import { ActorCollectionClient } from './resource_clients/actor_collection';
import { BuildClient } from './resource_clients/build';
// import { BuildCollectionClient } from './resource_clients/build_collection';
import { BuildCollectionClient } from './resource_clients/build_collection';
import { DatasetClient } from './resource_clients/dataset';
import { DatasetCollectionClient } from './resource_clients/dataset_collection';
import { KeyValueStoreClient } from './resource_clients/key_value_store';
Expand All @@ -17,7 +17,7 @@ import { LogClient } from './resource_clients/log';
import { RequestQueueClient, RequestQueueUserOptions } from './resource_clients/request_queue';
import { RequestQueueCollectionClient } from './resource_clients/request_queue_collection';
import { RunClient } from './resource_clients/run';
// import { RunCollectionClient } from './resource_clients/run_collection';
import { RunCollectionClient } from './resource_clients/run_collection';
import { ScheduleClient } from './resource_clients/schedule';
import { ScheduleCollectionClient } from './resource_clients/schedule_collection';
import { StoreCollectionClient } from './resource_clients/store_collection';
Expand Down Expand Up @@ -107,13 +107,12 @@ export class ApifyClient {
});
}

// TODO we don't have this endpoint yet
// /**
// * @return {BuildCollectionClient}
// */
// builds() {
// return new BuildCollectionClient(this._options());
// }
/**
* https://docs.apify.com/api/v2#/reference/actor-builds/build-collection
*/
builds(): BuildCollectionClient {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a reference to API docs into comments, the same as we had in the rest of the endpoints.

return new BuildCollectionClient(this._options());
}

/**
* https://docs.apify.com/api/v2#/reference/actor-builds/build-object
Expand Down Expand Up @@ -203,13 +202,15 @@ export class ApifyClient {
return new RequestQueueClient(apiClientOptions, options);
}

// TODO we don't have this endpoint yet
// /**
// * @return {RunCollectionClient}
// */
// runs() {
// return new RunCollectionClient(this._options());
// }
/**
* https://docs.apify.com/api/v2#/reference/actor-runs/run-collection
*/
runs(): RunCollectionClient {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the build list, please add a reference to docs.

return new RunCollectionClient({
...this._options(),
resourcePath: 'actor-runs',
});
}

/**
* https://docs.apify.com/api/v2#/reference/actor-runs/run-object-and-its-storages
Expand Down
4 changes: 2 additions & 2 deletions src/resource_clients/build_collection.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import ow from 'ow';

import { Build } from './build';
import { ApiClientOptions } from '../base/api_client';
import { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
import { ResourceCollectionClient } from '../base/resource_collection_client';
import { PaginatedList } from '../utils';

export class BuildCollectionClient extends ResourceCollectionClient {
/**
* @hidden
*/
constructor(options: ApiClientOptions) {
constructor(options: ApiClientOptionsWithOptionalResourcePath) {
super({
...options,
resourcePath: options.resourcePath || 'actor-builds',
Expand Down
4 changes: 2 additions & 2 deletions src/resource_clients/run_collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { ACT_JOB_STATUSES } from '@apify/consts';
import ow from 'ow';

import { ActorRunListItem } from './actor';
import { ApiClientSubResourceOptions } from '../base/api_client';
import { ApiClientOptionsWithOptionalResourcePath } from '../base/api_client';
import { ResourceCollectionClient } from '../base/resource_collection_client';
import { PaginatedList } from '../utils';

export class RunCollectionClient extends ResourceCollectionClient {
/**
* @hidden
*/
constructor(options: ApiClientSubResourceOptions) {
constructor(options: ApiClientOptionsWithOptionalResourcePath) {
super({
resourcePath: 'runs',
...options,
Expand Down
2 changes: 1 addition & 1 deletion test/builds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Build methods', () => {
});

describe('builds()', () => {
test.skip('list() works', async () => {
test('list() works', async () => {
const query = {
limit: 5,
offset: 3,
Expand Down
1 change: 1 addition & 0 deletions test/mock_server/routes/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { addRoutes } = require('./add_routes');
const builds = express.Router();

const ROUTES = [
{ id: 'list-builds', method: 'GET', path: '/' },
{ id: 'get-build', method: 'GET', path: '/:buildId', type: 'responseJsonMock' },
{ id: 'abort-build', method: 'POST', path: '/:buildId/abort' },
{ id: 'build-log', method: 'GET', path: '/:buildId/log', type: 'text' },
Expand Down
1 change: 1 addition & 0 deletions test/mock_server/routes/runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { addRoutes } = require('./add_routes');
const runs = express.Router();

const ROUTES = [
{ id: 'list-runs', method: 'GET', path: '/' },
{ id: 'get-run', method: 'GET', path: '/:runId', type: 'responseJsonMock' },
{ id: 'abort-run', method: 'POST', path: '/:runId/abort' },
{ id: 'metamorph-run', method: 'POST', path: '/:runId/metamorph' },
Expand Down
Loading
Loading