Skip to content

Commit 693808c

Browse files
authored
feat: add forcePermissionLevel run option (#743)
We want Actor developers to be able to easily test their full permission Actors with limited permissions without changing the Actor configuration for everybody or redeploying the Actor under a different name. For that reason, we have introduced a new `forcePermissionLevel` run option. This PR adds the option to the client. Full context here: apify/apify-core#22681
1 parent 756ba82 commit 693808c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"build:browser": "rsbuild build"
6363
},
6464
"dependencies": {
65-
"@apify/consts": "^2.25.0",
65+
"@apify/consts": "^2.42.0",
6666
"@apify/log": "^2.2.6",
6767
"@apify/utilities": "^2.18.0",
6868
"@crawlee/types": "^3.3.0",

src/resource_clients/actor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { AxiosRequestConfig } from 'axios';
22
import ow from 'ow';
33

44
import type { RUN_GENERAL_ACCESS } from '@apify/consts';
5-
import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
5+
import { ACT_JOB_STATUSES, ACTOR_PERMISSION_LEVEL, META_ORIGINS } from '@apify/consts';
66

77
import type { ApiClientSubResourceOptions } from '../base/api_client';
88
import { ResourceClient } from '../base/resource_client';
@@ -70,10 +70,11 @@ export class ActorClient extends ResourceClient {
7070
webhooks: ow.optional.array.ofType(ow.object),
7171
maxItems: ow.optional.number.not.negative,
7272
maxTotalChargeUsd: ow.optional.number.not.negative,
73+
forcePermissionLevel: ow.optional.string.oneOf(Object.values(ACTOR_PERMISSION_LEVEL)),
7374
}),
7475
);
7576

76-
const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd } = options;
77+
const { waitForFinish, timeout, memory, build, maxItems, maxTotalChargeUsd, forcePermissionLevel } = options;
7778

7879
const params = {
7980
waitForFinish,
@@ -83,6 +84,7 @@ export class ActorClient extends ResourceClient {
8384
webhooks: stringifyWebhooksToBase64(options.webhooks),
8485
maxItems,
8586
maxTotalChargeUsd,
87+
forcePermissionLevel,
8688
};
8789

8890
const request: AxiosRequestConfig = {
@@ -126,6 +128,7 @@ export class ActorClient extends ResourceClient {
126128
webhooks: ow.optional.array.ofType(ow.object),
127129
maxItems: ow.optional.number.not.negative,
128130
maxTotalChargeUsd: ow.optional.number.not.negative,
131+
forcePermissionLevel: ow.optional.string.oneOf(Object.values(ACTOR_PERMISSION_LEVEL)),
129132
}),
130133
);
131134

@@ -394,6 +397,12 @@ export interface ActorStartOptions {
394397
maxItems?: number;
395398

396399
// TODO(PPE): add maxTotalChargeUsd after finished
400+
401+
/**
402+
* Override the Actor's permissions for this run. If not set, the Actor will run with permissions configured in the
403+
* Actor settings.
404+
*/
405+
forcePermissionLevel?: ACTOR_PERMISSION_LEVEL;
397406
}
398407

399408
export interface ActorCallOptions extends Omit<ActorStartOptions, 'waitForFinish'> {

src/resource_clients/task.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export interface TaskLastRunOptions {
232232
status?: keyof typeof ACT_JOB_STATUSES;
233233
}
234234

235-
export type TaskStartOptions = Omit<ActorStartOptions, 'contentType'>;
235+
export type TaskStartOptions = Omit<ActorStartOptions, 'contentType' | 'forcePermissionLevel'>;
236236

237237
export interface TaskCallOptions extends Omit<TaskStartOptions, 'waitForFinish'> {
238238
waitSecs?: number;

0 commit comments

Comments
 (0)