Skip to content

Commit 7deba52

Browse files
authored
feat: add support for general resource access (#669)
We plan to allow users to configure through API & clients how their storages and runs can be accessed — whether just the ID / name is sufficient to access the storage. This is controlled through the `generalAccess` resource property, which overrides account setting for the resource. Full context in apify/apify-core#19012. This PR updates the client so that it can be used to get and update general access on datasets, key-value stores, request queues, and runs. ```typescript const run = client.run(runId); // Set general access to ANYONE_WITH_ID_CAN_READ which overrides the account setting. await run.update({ generalAccess: RUN_GENERAL_ACCESS.ANYONE_WITH_ID_CAN_READ }); // Reset the general access so that it follows the account setting. await run.update({ generalAccess: null }); ```
1 parent 13934f1 commit 7deba52

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"build:browser": "webpack"
6060
},
6161
"dependencies": {
62-
"@apify/consts": "^2.25.0",
62+
"@apify/consts": "^2.40.0",
6363
"@apify/log": "^2.2.6",
6464
"@crawlee/types": "^3.3.0",
6565
"agentkeepalive": "^4.2.1",

src/resource_clients/actor.ts

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

4+
import type { RUN_GENERAL_ACCESS } from '@apify/consts';
45
import { ACT_JOB_STATUSES, META_ORIGINS } from '@apify/consts';
56

67
import type { ActorVersion} from './actor_version';
@@ -386,6 +387,7 @@ export interface ActorRun extends ActorRunListItem {
386387
usageUsd?: ActorRunUsage;
387388
pricingInfo?: ActorRunPricingInfo;
388389
chargedEventCounts?: Record<string, number>;
390+
generalAccess?: RUN_GENERAL_ACCESS | null,
389391
}
390392

391393
export interface ActorRunUsage {

src/resource_clients/dataset.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import ow from 'ow';
22

3+
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
4+
35
import type { ApifyApiError } from '../apify_api_error';
46
import type { ApiClientSubResourceOptions } from '../base/api_client';
57
import { ResourceClient } from '../base/resource_client';
@@ -177,6 +179,7 @@ export interface Dataset {
177179
actRunId?: string;
178180
stats: DatasetStats;
179181
fields: string[];
182+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
180183
}
181184

182185
export interface DatasetStats {
@@ -189,6 +192,7 @@ export interface DatasetStats {
189192
export interface DatasetClientUpdateOptions {
190193
name?: string | null;
191194
title?: string;
195+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
192196
}
193197

194198
export interface DatasetClientListItemOptions {

src/resource_clients/key_value_store.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Readable } from 'node:stream';
33
import ow from 'ow';
44
import type { JsonValue } from 'type-fest';
55

6+
import type { STORAGE_GENERAL_ACCESS } from '@apify/consts';
67
import log from '@apify/log';
78

89
import type { ApifyApiError } from '../apify_api_error';
@@ -226,6 +227,7 @@ export interface KeyValueStore {
226227
actId?: string;
227228
actRunId?: string;
228229
stats?: KeyValueStoreStats;
230+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
229231
}
230232

231233
export interface KeyValueStoreStats {
@@ -239,6 +241,7 @@ export interface KeyValueStoreStats {
239241
export interface KeyValueClientUpdateOptions {
240242
name?: string | null;
241243
title?: string;
244+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
242245
}
243246

244247
export interface KeyValueClientListKeysOptions {

src/resource_clients/request_queue.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import ow from 'ow';
22
import type { JsonObject } from 'type-fest';
33

4-
import { MAX_PAYLOAD_SIZE_BYTES, REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION } from '@apify/consts';
4+
import type {
5+
STORAGE_GENERAL_ACCESS
6+
} from '@apify/consts';
7+
import {
8+
MAX_PAYLOAD_SIZE_BYTES,
9+
REQUEST_QUEUE_MAX_REQUESTS_PER_BATCH_OPERATION
10+
} from '@apify/consts';
511
import log from '@apify/log';
612

713
import type { ApifyApiError } from '../apify_api_error';
@@ -487,6 +493,7 @@ export interface RequestQueue {
487493
actRunId?: string;
488494
hadMultipleClients: boolean;
489495
stats: RequestQueueStats;
496+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
490497
}
491498

492499
export interface RequestQueueStats {
@@ -500,6 +507,7 @@ export interface RequestQueueStats {
500507
export interface RequestQueueClientUpdateOptions {
501508
name?: string | null;
502509
title?: string;
510+
generalAccess?: STORAGE_GENERAL_ACCESS | null,
503511
}
504512

505513
export interface RequestQueueClientListHeadOptions {

src/resource_clients/run.ts

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

4+
import type { RUN_GENERAL_ACCESS } from '@apify/consts';
5+
46
import type { ActorRun } from './actor';
57
import { DatasetClient } from './dataset';
68
import { KeyValueStoreClient } from './key_value_store';
@@ -257,6 +259,7 @@ export interface RunMetamorphOptions {
257259
export interface RunUpdateOptions {
258260
statusMessage?: string;
259261
isStatusMessageTerminal?: boolean;
262+
generalAccess?: RUN_GENERAL_ACCESS | null,
260263
}
261264

262265
export interface RunResurrectOptions {

0 commit comments

Comments
 (0)