Skip to content

Commit 562a193

Browse files
authored
feat: allow sorting of Actors collection (#708)
Added new sorting param sortBy for the new feature described in this [Issue](https://app.zenhub.com/workspaces/platform-team-5f6454160d9f82000fa6733f/issues/gh/apify/apify-core/20997) I will wait until [Apify-Core PR](apify/apify-core#21566) is deployed and then will merge this.
1 parent 97de8f1 commit 562a193

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/resource_clients/actor_collection.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class ActorCollectionClient extends ResourceCollectionClient {
2828
limit: ow.optional.number,
2929
offset: ow.optional.number,
3030
desc: ow.optional.boolean,
31+
sortBy: ow.optional.string.oneOf(Object.values(ActorListSortBy)),
3132
}),
3233
);
3334

@@ -44,11 +45,17 @@ export class ActorCollectionClient extends ResourceCollectionClient {
4445
}
4546
}
4647

48+
export enum ActorListSortBy {
49+
CREATED_AT = 'createdAt',
50+
LAST_RUN_STARTED_AT = 'lastRunStartedAt',
51+
}
52+
4753
export interface ActorCollectionListOptions {
4854
my?: boolean;
4955
limit?: number;
5056
offset?: number;
5157
desc?: boolean;
58+
sortBy?: ActorListSortBy;
5259
}
5360

5461
export interface ActorCollectionListItem {

test/actors.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const { Browser, validateRequest, DEFAULT_OPTIONS } = require('./_helper');
2-
const { ApifyClient } = require('apify-client');
2+
const { ActorListSortBy, ApifyClient } = require('apify-client');
33
const { stringifyWebhooksToBase64 } = require('../src/utils');
44
const mockServer = require('./mock_server/server');
55

@@ -39,6 +39,7 @@ describe('Actor methods', () => {
3939
offset: 3,
4040
desc: true,
4141
my: true,
42+
sortBy: ActorListSortBy.CREATED_AT,
4243
};
4344

4445
const res = await client.actors().list(opts);

0 commit comments

Comments
 (0)