Skip to content

Commit afd30c1

Browse files
authored
chore: Mark unused options as deprecated (#800)
- Mark unused options as deprecated - Remove validation of unused options - Do not pass unused options to the API Deprecated options should be removed in #799
1 parent ac8b74c commit afd30c1

File tree

3 files changed

+36
-39
lines changed

3 files changed

+36
-39
lines changed

src/resource_clients/actor_env_var_collection.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,23 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
4848
* Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
4949
* items in a single API call is limited.
5050
* ```javascript
51-
* const paginatedList = await client.list(options);
52-
* ```
51+
* const paginatedList = await client.list();
52+
*```
5353
*
5454
* Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
5555
* retrieved.
5656
*
5757
* ```javascript
58-
* for await (const singleItem of client.list(options)) {...}
58+
* for await (const singleItem of client.list()) {...}
5959
* ```
6060
*
61-
* @param options - Pagination options.
6261
* @returns A paginated iterator of environment variables.
6362
* @see https://docs.apify.com/api/v2/act-version-env-vars-get
6463
*/
6564
list(
66-
options: ActorEnvVarCollectionListOptions = {},
65+
_options: ActorEnvVarCollectionListOptions = {},
6766
): Promise<ActorEnvVarListResult> & AsyncIterable<ActorEnvironmentVariable> {
68-
ow(
69-
options,
70-
ow.object.exactShape({
71-
limit: ow.optional.number.not.negative,
72-
offset: ow.optional.number.not.negative,
73-
desc: ow.optional.boolean,
74-
}),
75-
);
76-
return this._listPaginated(options);
67+
return this._listPaginated();
7768
}
7869

7970
/**
@@ -89,6 +80,10 @@ export class ActorEnvVarCollectionClient extends ResourceCollectionClient {
8980
}
9081
}
9182

83+
/**
84+
* @deprecated No options are used in the current API implementation.
85+
* https://github.com/apify/apify-client-js/issues/799
86+
*/
9287
export interface ActorEnvVarCollectionListOptions extends PaginationOptions {
9388
desc?: boolean;
9489
}

src/resource_clients/actor_version_collection.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,23 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
4646
* Awaiting the return value (as you would with a Promise) will result in a single API call. The amount of fetched
4747
* items in a single API call is limited.
4848
* ```javascript
49-
* const paginatedList = await client.list(options);
50-
* ```
49+
* const paginatedList = await client.list();
50+
*```
5151
*
5252
* Asynchronous iteration is also supported. This will fetch additional pages if needed until all items are
5353
* retrieved.
5454
*
5555
* ```javascript
56-
* for await (const singleItem of client.list(options)) {...}
56+
* for await (const singleItem of client.list()) {...}
5757
* ```
5858
*
59-
* @param options - Pagination options.
6059
* @returns A paginated iterator of Actor versions.
6160
* @see https://docs.apify.com/api/v2/act-versions-get
6261
*/
6362
list(
64-
options: ActorVersionCollectionListOptions = {},
63+
_options: ActorVersionCollectionListOptions = {},
6564
): Promise<ActorVersionListResult> & AsyncIterable<FinalActorVersion> {
66-
ow(
67-
options,
68-
ow.object.exactShape({
69-
limit: ow.optional.number.not.negative,
70-
offset: ow.optional.number.not.negative,
71-
desc: ow.optional.boolean,
72-
}),
73-
);
74-
75-
return this._listPaginated(options);
65+
return this._listPaginated();
7666
}
7767

7868
/**
@@ -89,6 +79,10 @@ export class ActorVersionCollectionClient extends ResourceCollectionClient {
8979
}
9080
}
9181

82+
/**
83+
* @deprecated No options are used in the current API implementation.
84+
* https://github.com/apify/apify-client-js/issues/799
85+
*/
9286
export interface ActorVersionCollectionListOptions extends PaginationOptions {
9387
desc?: boolean;
9488
}

test/pagination.test.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ const range = (start, end, step = 1) => {
1313
);
1414
};
1515

16-
const limitPaginationOptions = [
16+
const noOptions = [
1717
{
1818
testName: 'No options',
1919
userDefinedOptions: {},
2020
expectedItems: range(0, 2500),
2121
},
22+
];
23+
24+
const limitPaginationOptions = [
2225
{
2326
testName: 'User limit',
2427
userDefinedOptions: { limit: 1100 },
@@ -72,11 +75,11 @@ describe('Collection clients list method as async iterable', () => {
7275
const maxItemsPerPage = 1000;
7376

7477
const allCollectionClients = [
78+
client.actor('some-id').version('some-version').envVars(), // Does not support options
79+
client.actor('some-id').versions(), // Does not support options
7580
client.store(), // Does not support desc
76-
client.actors(),
77-
client.actor('some-id').version('some-version').envVars(),
78-
client.actor('some-id').versions(),
7981
client.actor('some-id').builds(),
82+
client.actors(),
8083
client.datasets(), // Supports unnamed
8184
client.keyValueStores(), // Supports unnamed
8285
client.requestQueues(), // Supports unnamed
@@ -95,17 +98,22 @@ describe('Collection clients list method as async iterable', () => {
9598
];
9699

97100
// Create valid tests cases for each client based on the pagination options it is supporting.
98-
const commonTestCases = generateTestCases(allCollectionClients, [
99-
...limitPaginationOptions,
100-
...offsetPaginationOptions,
101-
]);
101+
const noOptionsTestCases = generateTestCases(allCollectionClients, noOptions);
102+
103+
const commonTestCases = generateTestCases(
104+
allCollectionClients.slice(2), // without envVars and versions
105+
[...limitPaginationOptions, ...offsetPaginationOptions],
106+
);
102107
const unnamedTestCases = generateTestCases(
103108
[client.datasets(), client.keyValueStores(), client.requestQueues()],
104109
unnamedPaginationOptions,
105110
);
106-
const descTestCases = generateTestCases(allCollectionClients.slice(1), descPaginationOptions);
111+
const descTestCases = generateTestCases(
112+
allCollectionClients.slice(3), // without envVars, versions and store
113+
descPaginationOptions,
114+
);
107115

108-
test.each([...commonTestCases, ...unnamedTestCases, ...descTestCases])(
116+
test.each([...noOptionsTestCases, ...commonTestCases, ...unnamedTestCases, ...descTestCases])(
109117
'$clientName: $testName',
110118
async ({ resourceClient, userDefinedOptions, expectedItems }) => {
111119
const mockedPlatformLogic = async (request) => {

0 commit comments

Comments
 (0)